babylon.module.d.ts 5.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684
  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 current color in rgb space to HSV values
  466. * @returns a new color3 representing the HSV values
  467. */
  468. toHSV(): Color3;
  469. /**
  470. * Converts current color in rgb space to HSV values
  471. * @param result defines the Color3 where to store the HSV values
  472. */
  473. toHSVToRef(result: Color3): void;
  474. /**
  475. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the linear space version
  477. * @returns the unmodified Color3
  478. */
  479. toLinearSpaceToRef(convertedColor: Color3): Color3;
  480. /**
  481. * Computes a new Color3 converted from the current one to gamma space
  482. * @returns a new Color3 object
  483. */
  484. toGammaSpace(): Color3;
  485. /**
  486. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  487. * @param convertedColor defines the Color3 object where to store the gamma space version
  488. * @returns the unmodified Color3
  489. */
  490. toGammaSpaceToRef(convertedColor: Color3): Color3;
  491. private static _BlackReadOnly;
  492. /**
  493. * Convert Hue, saturation and value to a Color3 (RGB)
  494. * @param hue defines the hue
  495. * @param saturation defines the saturation
  496. * @param value defines the value
  497. * @param result defines the Color3 where to store the RGB values
  498. */
  499. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  500. /**
  501. * Creates a new Color3 from the string containing valid hexadecimal values
  502. * @param hex defines a string containing valid hexadecimal values
  503. * @returns a new Color3 object
  504. */
  505. static FromHexString(hex: string): Color3;
  506. /**
  507. * Creates a new Color3 from the starting index of the given array
  508. * @param array defines the source array
  509. * @param offset defines an offset in the source array
  510. * @returns a new Color3 object
  511. */
  512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  513. /**
  514. * Creates a new Color3 from integer values (< 256)
  515. * @param r defines the red component to read from (value between 0 and 255)
  516. * @param g defines the green component to read from (value between 0 and 255)
  517. * @param b defines the blue component to read from (value between 0 and 255)
  518. * @returns a new Color3 object
  519. */
  520. static FromInts(r: number, g: number, b: number): Color3;
  521. /**
  522. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  523. * @param start defines the start Color3 value
  524. * @param end defines the end Color3 value
  525. * @param amount defines the gradient value between start and end
  526. * @returns a new Color3 object
  527. */
  528. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  529. /**
  530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  531. * @param left defines the start value
  532. * @param right defines the end value
  533. * @param amount defines the gradient factor
  534. * @param result defines the Color3 object where to store the result
  535. */
  536. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  537. /**
  538. * Returns a Color3 value containing a red color
  539. * @returns a new Color3 object
  540. */
  541. static Red(): Color3;
  542. /**
  543. * Returns a Color3 value containing a green color
  544. * @returns a new Color3 object
  545. */
  546. static Green(): Color3;
  547. /**
  548. * Returns a Color3 value containing a blue color
  549. * @returns a new Color3 object
  550. */
  551. static Blue(): Color3;
  552. /**
  553. * Returns a Color3 value containing a black color
  554. * @returns a new Color3 object
  555. */
  556. static Black(): Color3;
  557. /**
  558. * Gets a Color3 value containing a black color that must not be updated
  559. */
  560. static readonly BlackReadOnly: DeepImmutable<Color3>;
  561. /**
  562. * Returns a Color3 value containing a white color
  563. * @returns a new Color3 object
  564. */
  565. static White(): Color3;
  566. /**
  567. * Returns a Color3 value containing a purple color
  568. * @returns a new Color3 object
  569. */
  570. static Purple(): Color3;
  571. /**
  572. * Returns a Color3 value containing a magenta color
  573. * @returns a new Color3 object
  574. */
  575. static Magenta(): Color3;
  576. /**
  577. * Returns a Color3 value containing a yellow color
  578. * @returns a new Color3 object
  579. */
  580. static Yellow(): Color3;
  581. /**
  582. * Returns a Color3 value containing a gray color
  583. * @returns a new Color3 object
  584. */
  585. static Gray(): Color3;
  586. /**
  587. * Returns a Color3 value containing a teal color
  588. * @returns a new Color3 object
  589. */
  590. static Teal(): Color3;
  591. /**
  592. * Returns a Color3 value containing a random color
  593. * @returns a new Color3 object
  594. */
  595. static Random(): Color3;
  596. }
  597. /**
  598. * Class used to hold a RBGA color
  599. */
  600. export class Color4 {
  601. /**
  602. * Defines the red component (between 0 and 1, default is 0)
  603. */
  604. r: number;
  605. /**
  606. * Defines the green component (between 0 and 1, default is 0)
  607. */
  608. g: number;
  609. /**
  610. * Defines the blue component (between 0 and 1, default is 0)
  611. */
  612. b: number;
  613. /**
  614. * Defines the alpha component (between 0 and 1, default is 1)
  615. */
  616. a: number;
  617. /**
  618. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  619. * @param r defines the red component (between 0 and 1, default is 0)
  620. * @param g defines the green component (between 0 and 1, default is 0)
  621. * @param b defines the blue component (between 0 and 1, default is 0)
  622. * @param a defines the alpha component (between 0 and 1, default is 1)
  623. */
  624. constructor(
  625. /**
  626. * Defines the red component (between 0 and 1, default is 0)
  627. */
  628. r?: number,
  629. /**
  630. * Defines the green component (between 0 and 1, default is 0)
  631. */
  632. g?: number,
  633. /**
  634. * Defines the blue component (between 0 and 1, default is 0)
  635. */
  636. b?: number,
  637. /**
  638. * Defines the alpha component (between 0 and 1, default is 1)
  639. */
  640. a?: number);
  641. /**
  642. * Adds in place the given Color4 values to the current Color4 object
  643. * @param right defines the second operand
  644. * @returns the current updated Color4 object
  645. */
  646. addInPlace(right: DeepImmutable<Color4>): Color4;
  647. /**
  648. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  649. * @returns the new array
  650. */
  651. asArray(): number[];
  652. /**
  653. * Stores from the starting index in the given array the Color4 successive values
  654. * @param array defines the array where to store the r,g,b components
  655. * @param index defines an optional index in the target array to define where to start storing values
  656. * @returns the current Color4 object
  657. */
  658. toArray(array: number[], index?: number): Color4;
  659. /**
  660. * Determines equality between Color4 objects
  661. * @param otherColor defines the second operand
  662. * @returns true if the rgba values are equal to the given ones
  663. */
  664. equals(otherColor: DeepImmutable<Color4>): boolean;
  665. /**
  666. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  667. * @param right defines the second operand
  668. * @returns a new Color4 object
  669. */
  670. add(right: DeepImmutable<Color4>): Color4;
  671. /**
  672. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  673. * @param right defines the second operand
  674. * @returns a new Color4 object
  675. */
  676. subtract(right: DeepImmutable<Color4>): Color4;
  677. /**
  678. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  679. * @param right defines the second operand
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the current Color4 object
  682. */
  683. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  684. /**
  685. * Creates a new Color4 with the current Color4 values multiplied by scale
  686. * @param scale defines the scaling factor to apply
  687. * @returns a new Color4 object
  688. */
  689. scale(scale: number): Color4;
  690. /**
  691. * Multiplies the current Color4 values by scale and stores the result in "result"
  692. * @param scale defines the scaling factor to apply
  693. * @param result defines the Color4 object where to store the result
  694. * @returns the current unmodified Color4
  695. */
  696. scaleToRef(scale: number, result: Color4): Color4;
  697. /**
  698. * Scale the current Color4 values by a factor and add the result to a given Color4
  699. * @param scale defines the scale factor
  700. * @param result defines the Color4 object where to store the result
  701. * @returns the unmodified current Color4
  702. */
  703. scaleAndAddToRef(scale: number, result: Color4): Color4;
  704. /**
  705. * Clamps the rgb values by the min and max values and stores the result into "result"
  706. * @param min defines minimum clamping value (default is 0)
  707. * @param max defines maximum clamping value (default is 1)
  708. * @param result defines color to store the result into.
  709. * @returns the cuurent Color4
  710. */
  711. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  712. /**
  713. * Multipy an Color4 value by another and return a new Color4 object
  714. * @param color defines the Color4 value to multiply by
  715. * @returns a new Color4 object
  716. */
  717. multiply(color: Color4): Color4;
  718. /**
  719. * Multipy a Color4 value by another and push the result in a reference value
  720. * @param color defines the Color4 value to multiply by
  721. * @param result defines the Color4 to fill the result in
  722. * @returns the result Color4
  723. */
  724. multiplyToRef(color: Color4, result: Color4): Color4;
  725. /**
  726. * Creates a string with the Color4 current values
  727. * @returns the string representation of the Color4 object
  728. */
  729. toString(): string;
  730. /**
  731. * Returns the string "Color4"
  732. * @returns "Color4"
  733. */
  734. getClassName(): string;
  735. /**
  736. * Compute the Color4 hash code
  737. * @returns an unique number that can be used to hash Color4 objects
  738. */
  739. getHashCode(): number;
  740. /**
  741. * Creates a new Color4 copied from the current one
  742. * @returns a new Color4 object
  743. */
  744. clone(): Color4;
  745. /**
  746. * Copies the given Color4 values into the current one
  747. * @param source defines the source Color4 object
  748. * @returns the current updated Color4 object
  749. */
  750. copyFrom(source: Color4): Color4;
  751. /**
  752. * Copies the given float values into the current one
  753. * @param r defines the red component to read from
  754. * @param g defines the green component to read from
  755. * @param b defines the blue component to read from
  756. * @param a defines the alpha component to read from
  757. * @returns the current updated Color4 object
  758. */
  759. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  760. /**
  761. * Copies the given float values into the current one
  762. * @param r defines the red component to read from
  763. * @param g defines the green component to read from
  764. * @param b defines the blue component to read from
  765. * @param a defines the alpha component to read from
  766. * @returns the current updated Color4 object
  767. */
  768. set(r: number, g: number, b: number, a: number): Color4;
  769. /**
  770. * Compute the Color4 hexadecimal code as a string
  771. * @returns a string containing the hexadecimal representation of the Color4 object
  772. */
  773. toHexString(): string;
  774. /**
  775. * Computes a new Color4 converted from the current one to linear space
  776. * @returns a new Color4 object
  777. */
  778. toLinearSpace(): Color4;
  779. /**
  780. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  781. * @param convertedColor defines the Color4 object where to store the linear space version
  782. * @returns the unmodified Color4
  783. */
  784. toLinearSpaceToRef(convertedColor: Color4): Color4;
  785. /**
  786. * Computes a new Color4 converted from the current one to gamma space
  787. * @returns a new Color4 object
  788. */
  789. toGammaSpace(): Color4;
  790. /**
  791. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  792. * @param convertedColor defines the Color4 object where to store the gamma space version
  793. * @returns the unmodified Color4
  794. */
  795. toGammaSpaceToRef(convertedColor: Color4): Color4;
  796. /**
  797. * Creates a new Color4 from the string containing valid hexadecimal values
  798. * @param hex defines a string containing valid hexadecimal values
  799. * @returns a new Color4 object
  800. */
  801. static FromHexString(hex: string): Color4;
  802. /**
  803. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  804. * @param left defines the start value
  805. * @param right defines the end value
  806. * @param amount defines the gradient factor
  807. * @returns a new Color4 object
  808. */
  809. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  810. /**
  811. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  812. * @param left defines the start value
  813. * @param right defines the end value
  814. * @param amount defines the gradient factor
  815. * @param result defines the Color4 object where to store data
  816. */
  817. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  818. /**
  819. * Creates a new Color4 from a Color3 and an alpha value
  820. * @param color3 defines the source Color3 to read from
  821. * @param alpha defines the alpha component (1.0 by default)
  822. * @returns a new Color4 object
  823. */
  824. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  825. /**
  826. * Creates a new Color4 from the starting index element of the given array
  827. * @param array defines the source array to read from
  828. * @param offset defines the offset in the source array
  829. * @returns a new Color4 object
  830. */
  831. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  832. /**
  833. * Creates a new Color3 from integer values (< 256)
  834. * @param r defines the red component to read from (value between 0 and 255)
  835. * @param g defines the green component to read from (value between 0 and 255)
  836. * @param b defines the blue component to read from (value between 0 and 255)
  837. * @param a defines the alpha component to read from (value between 0 and 255)
  838. * @returns a new Color3 object
  839. */
  840. static FromInts(r: number, g: number, b: number, a: number): Color4;
  841. /**
  842. * Check the content of a given array and convert it to an array containing RGBA data
  843. * If the original array was already containing count * 4 values then it is returned directly
  844. * @param colors defines the array to check
  845. * @param count defines the number of RGBA data to expect
  846. * @returns an array containing count * 4 values (RGBA)
  847. */
  848. static CheckColors4(colors: number[], count: number): number[];
  849. }
  850. /**
  851. * Class representing a vector containing 2 coordinates
  852. */
  853. export class Vector2 {
  854. /** defines the first coordinate */
  855. x: number;
  856. /** defines the second coordinate */
  857. y: number;
  858. /**
  859. * Creates a new Vector2 from the given x and y coordinates
  860. * @param x defines the first coordinate
  861. * @param y defines the second coordinate
  862. */
  863. constructor(
  864. /** defines the first coordinate */
  865. x?: number,
  866. /** defines the second coordinate */
  867. y?: number);
  868. /**
  869. * Gets a string with the Vector2 coordinates
  870. * @returns a string with the Vector2 coordinates
  871. */
  872. toString(): string;
  873. /**
  874. * Gets class name
  875. * @returns the string "Vector2"
  876. */
  877. getClassName(): string;
  878. /**
  879. * Gets current vector hash code
  880. * @returns the Vector2 hash code as a number
  881. */
  882. getHashCode(): number;
  883. /**
  884. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  885. * @param array defines the source array
  886. * @param index defines the offset in source array
  887. * @returns the current Vector2
  888. */
  889. toArray(array: FloatArray, index?: number): Vector2;
  890. /**
  891. * Copy the current vector to an array
  892. * @returns a new array with 2 elements: the Vector2 coordinates.
  893. */
  894. asArray(): number[];
  895. /**
  896. * Sets the Vector2 coordinates with the given Vector2 coordinates
  897. * @param source defines the source Vector2
  898. * @returns the current updated Vector2
  899. */
  900. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the Vector2 coordinates with the given floats
  903. * @param x defines the first coordinate
  904. * @param y defines the second coordinate
  905. * @returns the current updated Vector2
  906. */
  907. copyFromFloats(x: number, y: number): Vector2;
  908. /**
  909. * Sets the Vector2 coordinates with the given floats
  910. * @param x defines the first coordinate
  911. * @param y defines the second coordinate
  912. * @returns the current updated Vector2
  913. */
  914. set(x: number, y: number): Vector2;
  915. /**
  916. * Add another vector with the current one
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  919. */
  920. add(otherVector: DeepImmutable<Vector2>): Vector2;
  921. /**
  922. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  923. * @param otherVector defines the other vector
  924. * @param result defines the target vector
  925. * @returns the unmodified current Vector2
  926. */
  927. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  928. /**
  929. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  930. * @param otherVector defines the other vector
  931. * @returns the current updated Vector2
  932. */
  933. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  934. /**
  935. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  936. * @param otherVector defines the other vector
  937. * @returns a new Vector2
  938. */
  939. addVector3(otherVector: Vector3): Vector2;
  940. /**
  941. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  942. * @param otherVector defines the other vector
  943. * @returns a new Vector2
  944. */
  945. subtract(otherVector: Vector2): Vector2;
  946. /**
  947. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  948. * @param otherVector defines the other vector
  949. * @param result defines the target vector
  950. * @returns the unmodified current Vector2
  951. */
  952. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  953. /**
  954. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @returns the current updated Vector2
  957. */
  958. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  959. /**
  960. * Multiplies in place the current Vector2 coordinates by the given ones
  961. * @param otherVector defines the other vector
  962. * @returns the current updated Vector2
  963. */
  964. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  971. /**
  972. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  980. * @param x defines the first coordinate
  981. * @param y defines the second coordinate
  982. * @returns a new Vector2
  983. */
  984. multiplyByFloats(x: number, y: number): Vector2;
  985. /**
  986. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  987. * @param otherVector defines the other vector
  988. * @returns a new Vector2
  989. */
  990. divide(otherVector: Vector2): Vector2;
  991. /**
  992. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  993. * @param otherVector defines the other vector
  994. * @param result defines the target vector
  995. * @returns the unmodified current Vector2
  996. */
  997. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  998. /**
  999. * Divides the current Vector2 coordinates by the given ones
  1000. * @param otherVector defines the other vector
  1001. * @returns the current updated Vector2
  1002. */
  1003. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1004. /**
  1005. * Gets a new Vector2 with current Vector2 negated coordinates
  1006. * @returns a new Vector2
  1007. */
  1008. negate(): Vector2;
  1009. /**
  1010. * Multiply the Vector2 coordinates by scale
  1011. * @param scale defines the scaling factor
  1012. * @returns the current updated Vector2
  1013. */
  1014. scaleInPlace(scale: number): Vector2;
  1015. /**
  1016. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1017. * @param scale defines the scaling factor
  1018. * @returns a new Vector2
  1019. */
  1020. scale(scale: number): Vector2;
  1021. /**
  1022. * Scale the current Vector2 values by a factor to a given Vector2
  1023. * @param scale defines the scale factor
  1024. * @param result defines the Vector2 object where to store the result
  1025. * @returns the unmodified current Vector2
  1026. */
  1027. scaleToRef(scale: number, result: Vector2): Vector2;
  1028. /**
  1029. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1030. * @param scale defines the scale factor
  1031. * @param result defines the Vector2 object where to store the result
  1032. * @returns the unmodified current Vector2
  1033. */
  1034. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1035. /**
  1036. * Gets a boolean if two vectors are equals
  1037. * @param otherVector defines the other vector
  1038. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1039. */
  1040. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1041. /**
  1042. * Gets a boolean if two vectors are equals (using an epsilon value)
  1043. * @param otherVector defines the other vector
  1044. * @param epsilon defines the minimal distance to consider equality
  1045. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1046. */
  1047. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1048. /**
  1049. * Gets a new Vector2 from current Vector2 floored values
  1050. * @returns a new Vector2
  1051. */
  1052. floor(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 from current Vector2 floored values
  1055. * @returns a new Vector2
  1056. */
  1057. fract(): Vector2;
  1058. /**
  1059. * Gets the length of the vector
  1060. * @returns the vector length (float)
  1061. */
  1062. length(): number;
  1063. /**
  1064. * Gets the vector squared length
  1065. * @returns the vector squared length (float)
  1066. */
  1067. lengthSquared(): number;
  1068. /**
  1069. * Normalize the vector
  1070. * @returns the current updated Vector2
  1071. */
  1072. normalize(): Vector2;
  1073. /**
  1074. * Gets a new Vector2 copied from the Vector2
  1075. * @returns a new Vector2
  1076. */
  1077. clone(): Vector2;
  1078. /**
  1079. * Gets a new Vector2(0, 0)
  1080. * @returns a new Vector2
  1081. */
  1082. static Zero(): Vector2;
  1083. /**
  1084. * Gets a new Vector2(1, 1)
  1085. * @returns a new Vector2
  1086. */
  1087. static One(): Vector2;
  1088. /**
  1089. * Gets a new Vector2 set from the given index element of the given array
  1090. * @param array defines the data source
  1091. * @param offset defines the offset in the data source
  1092. * @returns a new Vector2
  1093. */
  1094. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1095. /**
  1096. * Sets "result" from the given index element of the given array
  1097. * @param array defines the data source
  1098. * @param offset defines the offset in the data source
  1099. * @param result defines the target vector
  1100. */
  1101. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1102. /**
  1103. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1104. * @param value1 defines 1st point of control
  1105. * @param value2 defines 2nd point of control
  1106. * @param value3 defines 3rd point of control
  1107. * @param value4 defines 4th point of control
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * 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".
  1114. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1115. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1116. * @param value defines the value to clamp
  1117. * @param min defines the lower limit
  1118. * @param max defines the upper limit
  1119. * @returns a new Vector2
  1120. */
  1121. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1122. /**
  1123. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1124. * @param value1 defines the 1st control point
  1125. * @param tangent1 defines the outgoing tangent
  1126. * @param value2 defines the 2nd control point
  1127. * @param tangent2 defines the incoming tangent
  1128. * @param amount defines the interpolation factor
  1129. * @returns a new Vector2
  1130. */
  1131. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1132. /**
  1133. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1134. * @param start defines the start vector
  1135. * @param end defines the end vector
  1136. * @param amount defines the interpolation factor
  1137. * @returns a new Vector2
  1138. */
  1139. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1140. /**
  1141. * Gets the dot product of the vector "left" and the vector "right"
  1142. * @param left defines first vector
  1143. * @param right defines second vector
  1144. * @returns the dot product (float)
  1145. */
  1146. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1147. /**
  1148. * Returns a new Vector2 equal to the normalized given vector
  1149. * @param vector defines the vector to normalize
  1150. * @returns a new Vector2
  1151. */
  1152. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1155. * @param left defines 1st vector
  1156. * @param right defines 2nd vector
  1157. * @returns a new Vector2
  1158. */
  1159. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1160. /**
  1161. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1162. * @param left defines 1st vector
  1163. * @param right defines 2nd vector
  1164. * @returns a new Vector2
  1165. */
  1166. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1167. /**
  1168. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1169. * @param vector defines the vector to transform
  1170. * @param transformation defines the matrix to apply
  1171. * @returns a new Vector2
  1172. */
  1173. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1174. /**
  1175. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1176. * @param vector defines the vector to transform
  1177. * @param transformation defines the matrix to apply
  1178. * @param result defines the target vector
  1179. */
  1180. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1181. /**
  1182. * Determines if a given vector is included in a triangle
  1183. * @param p defines the vector to test
  1184. * @param p0 defines 1st triangle point
  1185. * @param p1 defines 2nd triangle point
  1186. * @param p2 defines 3rd triangle point
  1187. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1188. */
  1189. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1190. /**
  1191. * Gets the distance between the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns the distance between vectors
  1195. */
  1196. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1197. /**
  1198. * Returns the squared distance between the vectors "value1" and "value2"
  1199. * @param value1 defines first vector
  1200. * @param value2 defines second vector
  1201. * @returns the squared distance between vectors
  1202. */
  1203. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1204. /**
  1205. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1206. * @param value1 defines first vector
  1207. * @param value2 defines second vector
  1208. * @returns a new Vector2
  1209. */
  1210. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1211. /**
  1212. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1213. * @param p defines the middle point
  1214. * @param segA defines one point of the segment
  1215. * @param segB defines the other point of the segment
  1216. * @returns the shortest distance
  1217. */
  1218. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1219. }
  1220. /**
  1221. * Classed used to store (x,y,z) vector representation
  1222. * A Vector3 is the main object used in 3D geometry
  1223. * It can represent etiher the coordinates of a point the space, either a direction
  1224. * Reminder: js uses a left handed forward facing system
  1225. */
  1226. export class Vector3 {
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x: number;
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y: number;
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z: number;
  1239. private static _UpReadOnly;
  1240. private static _ZeroReadOnly;
  1241. /**
  1242. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1243. * @param x defines the first coordinates (on X axis)
  1244. * @param y defines the second coordinates (on Y axis)
  1245. * @param z defines the third coordinates (on Z axis)
  1246. */
  1247. constructor(
  1248. /**
  1249. * Defines the first coordinates (on X axis)
  1250. */
  1251. x?: number,
  1252. /**
  1253. * Defines the second coordinates (on Y axis)
  1254. */
  1255. y?: number,
  1256. /**
  1257. * Defines the third coordinates (on Z axis)
  1258. */
  1259. z?: number);
  1260. /**
  1261. * Creates a string representation of the Vector3
  1262. * @returns a string with the Vector3 coordinates.
  1263. */
  1264. toString(): string;
  1265. /**
  1266. * Gets the class name
  1267. * @returns the string "Vector3"
  1268. */
  1269. getClassName(): string;
  1270. /**
  1271. * Creates the Vector3 hash code
  1272. * @returns a number which tends to be unique between Vector3 instances
  1273. */
  1274. getHashCode(): number;
  1275. /**
  1276. * Creates an array containing three elements : the coordinates of the Vector3
  1277. * @returns a new array of numbers
  1278. */
  1279. asArray(): number[];
  1280. /**
  1281. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1282. * @param array defines the destination array
  1283. * @param index defines the offset in the destination array
  1284. * @returns the current Vector3
  1285. */
  1286. toArray(array: FloatArray, index?: number): Vector3;
  1287. /**
  1288. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1289. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1290. */
  1291. toQuaternion(): Quaternion;
  1292. /**
  1293. * Adds the given vector to the current Vector3
  1294. * @param otherVector defines the second operand
  1295. * @returns the current updated Vector3
  1296. */
  1297. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1298. /**
  1299. * Adds the given coordinates to the current Vector3
  1300. * @param x defines the x coordinate of the operand
  1301. * @param y defines the y coordinate of the operand
  1302. * @param z defines the z coordinate of the operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1306. /**
  1307. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Adds the current Vector3 to the given one 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. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Subtract the given vector from the current Vector3
  1321. * @param otherVector defines the second operand
  1322. * @returns the current updated Vector3
  1323. */
  1324. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1325. /**
  1326. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1327. * @param otherVector defines the second operand
  1328. * @returns the resulting Vector3
  1329. */
  1330. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1331. /**
  1332. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1333. * @param otherVector defines the second operand
  1334. * @param result defines the Vector3 object where to store the result
  1335. * @returns the current Vector3
  1336. */
  1337. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1338. /**
  1339. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1340. * @param x defines the x coordinate of the operand
  1341. * @param y defines the y coordinate of the operand
  1342. * @param z defines the z coordinate of the operand
  1343. * @returns the resulting Vector3
  1344. */
  1345. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1346. /**
  1347. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1348. * @param x defines the x coordinate of the operand
  1349. * @param y defines the y coordinate of the operand
  1350. * @param z defines the z coordinate of the operand
  1351. * @param result defines the Vector3 object where to store the result
  1352. * @returns the current Vector3
  1353. */
  1354. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1355. /**
  1356. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1357. * @returns a new Vector3
  1358. */
  1359. negate(): Vector3;
  1360. /**
  1361. * Multiplies the Vector3 coordinates by the float "scale"
  1362. * @param scale defines the multiplier factor
  1363. * @returns the current updated Vector3
  1364. */
  1365. scaleInPlace(scale: number): Vector3;
  1366. /**
  1367. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1368. * @param scale defines the multiplier factor
  1369. * @returns a new Vector3
  1370. */
  1371. scale(scale: number): Vector3;
  1372. /**
  1373. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1374. * @param scale defines the multiplier factor
  1375. * @param result defines the Vector3 object where to store the result
  1376. * @returns the current Vector3
  1377. */
  1378. scaleToRef(scale: number, result: Vector3): Vector3;
  1379. /**
  1380. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1381. * @param scale defines the scale factor
  1382. * @param result defines the Vector3 object where to store the result
  1383. * @returns the unmodified current Vector3
  1384. */
  1385. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1386. /**
  1387. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1388. * @param otherVector defines the second operand
  1389. * @returns true if both vectors are equals
  1390. */
  1391. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1392. /**
  1393. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1394. * @param otherVector defines the second operand
  1395. * @param epsilon defines the minimal distance to define values as equals
  1396. * @returns true if both vectors are distant less than epsilon
  1397. */
  1398. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1399. /**
  1400. * Returns true if the current Vector3 coordinates equals the given floats
  1401. * @param x defines the x coordinate of the operand
  1402. * @param y defines the y coordinate of the operand
  1403. * @param z defines the z coordinate of the operand
  1404. * @returns true if both vectors are equals
  1405. */
  1406. equalsToFloats(x: number, y: number, z: number): boolean;
  1407. /**
  1408. * Multiplies the current Vector3 coordinates by the given ones
  1409. * @param otherVector defines the second operand
  1410. * @returns the current updated Vector3
  1411. */
  1412. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1413. /**
  1414. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1428. * @param x defines the x coordinate of the operand
  1429. * @param y defines the y coordinate of the operand
  1430. * @param z defines the z coordinate of the operand
  1431. * @returns the new Vector3
  1432. */
  1433. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1434. /**
  1435. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1436. * @param otherVector defines the second operand
  1437. * @returns the new Vector3
  1438. */
  1439. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1442. * @param otherVector defines the second operand
  1443. * @param result defines the Vector3 object where to store the result
  1444. * @returns the current Vector3
  1445. */
  1446. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1447. /**
  1448. * Divides the current Vector3 coordinates by the given ones.
  1449. * @param otherVector defines the second operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. divideInPlace(otherVector: Vector3): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1455. * @param other defines the second operand
  1456. * @returns the current updated Vector3
  1457. */
  1458. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1459. /**
  1460. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1461. * @param other defines the second operand
  1462. * @returns the current updated Vector3
  1463. */
  1464. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1465. /**
  1466. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1467. * @param x defines the x coordinate of the operand
  1468. * @param y defines the y coordinate of the operand
  1469. * @param z defines the z coordinate of the operand
  1470. * @returns the current updated Vector3
  1471. */
  1472. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1473. /**
  1474. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1475. * @param x defines the x coordinate of the operand
  1476. * @param y defines the y coordinate of the operand
  1477. * @param z defines the z coordinate of the operand
  1478. * @returns the current updated Vector3
  1479. */
  1480. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1481. /**
  1482. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1483. * Check if is non uniform within a certain amount of decimal places to account for this
  1484. * @param epsilon the amount the values can differ
  1485. * @returns if the the vector is non uniform to a certain number of decimal places
  1486. */
  1487. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1488. /**
  1489. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1490. */
  1491. readonly isNonUniform: boolean;
  1492. /**
  1493. * Gets a new Vector3 from current Vector3 floored values
  1494. * @returns a new Vector3
  1495. */
  1496. floor(): Vector3;
  1497. /**
  1498. * Gets a new Vector3 from current Vector3 floored values
  1499. * @returns a new Vector3
  1500. */
  1501. fract(): Vector3;
  1502. /**
  1503. * Gets the length of the Vector3
  1504. * @returns the length of the Vecto3
  1505. */
  1506. length(): number;
  1507. /**
  1508. * Gets the squared length of the Vector3
  1509. * @returns squared length of the Vector3
  1510. */
  1511. lengthSquared(): number;
  1512. /**
  1513. * Normalize the current Vector3.
  1514. * Please note that this is an in place operation.
  1515. * @returns the current updated Vector3
  1516. */
  1517. normalize(): Vector3;
  1518. /**
  1519. * Reorders the x y z properties of the vector in place
  1520. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1521. * @returns the current updated vector
  1522. */
  1523. reorderInPlace(order: string): this;
  1524. /**
  1525. * Rotates the vector around 0,0,0 by a quaternion
  1526. * @param quaternion the rotation quaternion
  1527. * @param result vector to store the result
  1528. * @returns the resulting vector
  1529. */
  1530. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1531. /**
  1532. * Rotates a vector around a given point
  1533. * @param quaternion the rotation quaternion
  1534. * @param point the point to rotate around
  1535. * @param result vector to store the result
  1536. * @returns the resulting vector
  1537. */
  1538. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * 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"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * 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"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Interface for the size containing width and height
  2363. */
  2364. export interface ISize {
  2365. /**
  2366. * Width
  2367. */
  2368. width: number;
  2369. /**
  2370. * Heighht
  2371. */
  2372. height: number;
  2373. }
  2374. /**
  2375. * Size containing widht and height
  2376. */
  2377. export class Size implements ISize {
  2378. /**
  2379. * Width
  2380. */
  2381. width: number;
  2382. /**
  2383. * Height
  2384. */
  2385. height: number;
  2386. /**
  2387. * Creates a Size object from the given width and height (floats).
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. */
  2391. constructor(width: number, height: number);
  2392. /**
  2393. * Returns a string with the Size width and height
  2394. * @returns a string with the Size width and height
  2395. */
  2396. toString(): string;
  2397. /**
  2398. * "Size"
  2399. * @returns the string "Size"
  2400. */
  2401. getClassName(): string;
  2402. /**
  2403. * Returns the Size hash code.
  2404. * @returns a hash code for a unique width and height
  2405. */
  2406. getHashCode(): number;
  2407. /**
  2408. * Updates the current size from the given one.
  2409. * @param src the given size
  2410. */
  2411. copyFrom(src: Size): void;
  2412. /**
  2413. * Updates in place the current Size from the given floats.
  2414. * @param width width of the new size
  2415. * @param height height of the new size
  2416. * @returns the updated Size.
  2417. */
  2418. copyFromFloats(width: number, height: number): Size;
  2419. /**
  2420. * Updates in place the current Size from the given floats.
  2421. * @param width width to set
  2422. * @param height height to set
  2423. * @returns the updated Size.
  2424. */
  2425. set(width: number, height: number): Size;
  2426. /**
  2427. * Multiplies the width and height by numbers
  2428. * @param w factor to multiple the width by
  2429. * @param h factor to multiple the height by
  2430. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2431. */
  2432. multiplyByFloats(w: number, h: number): Size;
  2433. /**
  2434. * Clones the size
  2435. * @returns a new Size copied from the given one.
  2436. */
  2437. clone(): Size;
  2438. /**
  2439. * True if the current Size and the given one width and height are strictly equal.
  2440. * @param other the other size to compare against
  2441. * @returns True if the current Size and the given one width and height are strictly equal.
  2442. */
  2443. equals(other: Size): boolean;
  2444. /**
  2445. * The surface of the Size : width * height (float).
  2446. */
  2447. readonly surface: number;
  2448. /**
  2449. * Create a new size of zero
  2450. * @returns a new Size set to (0.0, 0.0)
  2451. */
  2452. static Zero(): Size;
  2453. /**
  2454. * Sums the width and height of two sizes
  2455. * @param otherSize size to add to this size
  2456. * @returns a new Size set as the addition result of the current Size and the given one.
  2457. */
  2458. add(otherSize: Size): Size;
  2459. /**
  2460. * Subtracts the width and height of two
  2461. * @param otherSize size to subtract to this size
  2462. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2463. */
  2464. subtract(otherSize: Size): Size;
  2465. /**
  2466. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2467. * @param start starting size to lerp between
  2468. * @param end end size to lerp between
  2469. * @param amount amount to lerp between the start and end values
  2470. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2471. */
  2472. static Lerp(start: Size, end: Size, amount: number): Size;
  2473. }
  2474. /**
  2475. * Class used to store quaternion data
  2476. * @see https://en.wikipedia.org/wiki/Quaternion
  2477. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2478. */
  2479. export class Quaternion {
  2480. /** defines the first component (0 by default) */
  2481. x: number;
  2482. /** defines the second component (0 by default) */
  2483. y: number;
  2484. /** defines the third component (0 by default) */
  2485. z: number;
  2486. /** defines the fourth component (1.0 by default) */
  2487. w: number;
  2488. /**
  2489. * Creates a new Quaternion from the given floats
  2490. * @param x defines the first component (0 by default)
  2491. * @param y defines the second component (0 by default)
  2492. * @param z defines the third component (0 by default)
  2493. * @param w defines the fourth component (1.0 by default)
  2494. */
  2495. constructor(
  2496. /** defines the first component (0 by default) */
  2497. x?: number,
  2498. /** defines the second component (0 by default) */
  2499. y?: number,
  2500. /** defines the third component (0 by default) */
  2501. z?: number,
  2502. /** defines the fourth component (1.0 by default) */
  2503. w?: number);
  2504. /**
  2505. * Gets a string representation for the current quaternion
  2506. * @returns a string with the Quaternion coordinates
  2507. */
  2508. toString(): string;
  2509. /**
  2510. * Gets the class name of the quaternion
  2511. * @returns the string "Quaternion"
  2512. */
  2513. getClassName(): string;
  2514. /**
  2515. * Gets a hash code for this quaternion
  2516. * @returns the quaternion hash code
  2517. */
  2518. getHashCode(): number;
  2519. /**
  2520. * Copy the quaternion to an array
  2521. * @returns a new array populated with 4 elements from the quaternion coordinates
  2522. */
  2523. asArray(): number[];
  2524. /**
  2525. * Check if two quaternions are equals
  2526. * @param otherQuaternion defines the second operand
  2527. * @return true if the current quaternion and the given one coordinates are strictly equals
  2528. */
  2529. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2530. /**
  2531. * Clone the current quaternion
  2532. * @returns a new quaternion copied from the current one
  2533. */
  2534. clone(): Quaternion;
  2535. /**
  2536. * Copy a quaternion to the current one
  2537. * @param other defines the other quaternion
  2538. * @returns the updated current quaternion
  2539. */
  2540. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Updates the current quaternion with the given float coordinates
  2543. * @param x defines the x coordinate
  2544. * @param y defines the y coordinate
  2545. * @param z defines the z coordinate
  2546. * @param w defines the w coordinate
  2547. * @returns the updated current quaternion
  2548. */
  2549. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2550. /**
  2551. * Updates the current quaternion from the given float coordinates
  2552. * @param x defines the x coordinate
  2553. * @param y defines the y coordinate
  2554. * @param z defines the z coordinate
  2555. * @param w defines the w coordinate
  2556. * @returns the updated current quaternion
  2557. */
  2558. set(x: number, y: number, z: number, w: number): Quaternion;
  2559. /**
  2560. * Adds two quaternions
  2561. * @param other defines the second operand
  2562. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2563. */
  2564. add(other: DeepImmutable<Quaternion>): Quaternion;
  2565. /**
  2566. * Add a quaternion to the current one
  2567. * @param other defines the quaternion to add
  2568. * @returns the current quaternion
  2569. */
  2570. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2571. /**
  2572. * Subtract two quaternions
  2573. * @param other defines the second operand
  2574. * @returns a new quaternion as the subtraction result of the given one from the current one
  2575. */
  2576. subtract(other: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies the current quaternion by a scale factor
  2579. * @param value defines the scale factor
  2580. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2581. */
  2582. scale(value: number): Quaternion;
  2583. /**
  2584. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2585. * @param scale defines the scale factor
  2586. * @param result defines the Quaternion object where to store the result
  2587. * @returns the unmodified current quaternion
  2588. */
  2589. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2590. /**
  2591. * Multiplies in place the current quaternion by a scale factor
  2592. * @param value defines the scale factor
  2593. * @returns the current modified quaternion
  2594. */
  2595. scaleInPlace(value: number): Quaternion;
  2596. /**
  2597. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2598. * @param scale defines the scale factor
  2599. * @param result defines the Quaternion object where to store the result
  2600. * @returns the unmodified current quaternion
  2601. */
  2602. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2603. /**
  2604. * Multiplies two quaternions
  2605. * @param q1 defines the second operand
  2606. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2607. */
  2608. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2609. /**
  2610. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2611. * @param q1 defines the second operand
  2612. * @param result defines the target quaternion
  2613. * @returns the current quaternion
  2614. */
  2615. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2616. /**
  2617. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2618. * @param q1 defines the second operand
  2619. * @returns the currentupdated quaternion
  2620. */
  2621. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2622. /**
  2623. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2624. * @param ref defines the target quaternion
  2625. * @returns the current quaternion
  2626. */
  2627. conjugateToRef(ref: Quaternion): Quaternion;
  2628. /**
  2629. * Conjugates in place (1-q) the current quaternion
  2630. * @returns the current updated quaternion
  2631. */
  2632. conjugateInPlace(): Quaternion;
  2633. /**
  2634. * Conjugates in place (1-q) the current quaternion
  2635. * @returns a new quaternion
  2636. */
  2637. conjugate(): Quaternion;
  2638. /**
  2639. * Gets length of current quaternion
  2640. * @returns the quaternion length (float)
  2641. */
  2642. length(): number;
  2643. /**
  2644. * Normalize in place the current quaternion
  2645. * @returns the current updated quaternion
  2646. */
  2647. normalize(): Quaternion;
  2648. /**
  2649. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2650. * @param order is a reserved parameter and is ignore for now
  2651. * @returns a new Vector3 containing the Euler angles
  2652. */
  2653. toEulerAngles(order?: string): Vector3;
  2654. /**
  2655. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2656. * @param result defines the vector which will be filled with the Euler angles
  2657. * @param order is a reserved parameter and is ignore for now
  2658. * @returns the current unchanged quaternion
  2659. */
  2660. toEulerAnglesToRef(result: Vector3): Quaternion;
  2661. /**
  2662. * Updates the given rotation matrix with the current quaternion values
  2663. * @param result defines the target matrix
  2664. * @returns the current unchanged quaternion
  2665. */
  2666. toRotationMatrix(result: Matrix): Quaternion;
  2667. /**
  2668. * Updates the current quaternion from the given rotation matrix values
  2669. * @param matrix defines the source matrix
  2670. * @returns the current updated quaternion
  2671. */
  2672. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2673. /**
  2674. * Creates a new quaternion from a rotation matrix
  2675. * @param matrix defines the source matrix
  2676. * @returns a new quaternion created from the given rotation matrix values
  2677. */
  2678. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2679. /**
  2680. * Updates the given quaternion with the given rotation matrix values
  2681. * @param matrix defines the source matrix
  2682. * @param result defines the target quaternion
  2683. */
  2684. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2685. /**
  2686. * Returns the dot product (float) between the quaternions "left" and "right"
  2687. * @param left defines the left operand
  2688. * @param right defines the right operand
  2689. * @returns the dot product
  2690. */
  2691. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2692. /**
  2693. * Checks if the two quaternions are close to each other
  2694. * @param quat0 defines the first quaternion to check
  2695. * @param quat1 defines the second quaternion to check
  2696. * @returns true if the two quaternions are close to each other
  2697. */
  2698. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2699. /**
  2700. * Creates an empty quaternion
  2701. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2702. */
  2703. static Zero(): Quaternion;
  2704. /**
  2705. * Inverse a given quaternion
  2706. * @param q defines the source quaternion
  2707. * @returns a new quaternion as the inverted current quaternion
  2708. */
  2709. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2710. /**
  2711. * Inverse a given quaternion
  2712. * @param q defines the source quaternion
  2713. * @param result the quaternion the result will be stored in
  2714. * @returns the result quaternion
  2715. */
  2716. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates an identity quaternion
  2719. * @returns the identity quaternion
  2720. */
  2721. static Identity(): Quaternion;
  2722. /**
  2723. * Gets a boolean indicating if the given quaternion is identity
  2724. * @param quaternion defines the quaternion to check
  2725. * @returns true if the quaternion is identity
  2726. */
  2727. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2728. /**
  2729. * Creates a quaternion from a rotation around an axis
  2730. * @param axis defines the axis to use
  2731. * @param angle defines the angle to use
  2732. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2733. */
  2734. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2735. /**
  2736. * Creates a rotation around an axis and stores it into the given quaternion
  2737. * @param axis defines the axis to use
  2738. * @param angle defines the angle to use
  2739. * @param result defines the target quaternion
  2740. * @returns the target quaternion
  2741. */
  2742. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Creates a new quaternion from data stored into an array
  2745. * @param array defines the data source
  2746. * @param offset defines the offset in the source array where the data starts
  2747. * @returns a new quaternion
  2748. */
  2749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2750. /**
  2751. * Create a quaternion from Euler rotation angles
  2752. * @param x Pitch
  2753. * @param y Yaw
  2754. * @param z Roll
  2755. * @returns the new Quaternion
  2756. */
  2757. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2758. /**
  2759. * Updates a quaternion from Euler rotation angles
  2760. * @param x Pitch
  2761. * @param y Yaw
  2762. * @param z Roll
  2763. * @param result the quaternion to store the result
  2764. * @returns the updated quaternion
  2765. */
  2766. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2767. /**
  2768. * Create a quaternion from Euler rotation vector
  2769. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2770. * @returns the new Quaternion
  2771. */
  2772. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2773. /**
  2774. * Updates a quaternion from Euler rotation vector
  2775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2776. * @param result the quaternion to store the result
  2777. * @returns the updated quaternion
  2778. */
  2779. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2782. * @param yaw defines the rotation around Y axis
  2783. * @param pitch defines the rotation around X axis
  2784. * @param roll defines the rotation around Z axis
  2785. * @returns the new quaternion
  2786. */
  2787. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2788. /**
  2789. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2790. * @param yaw defines the rotation around Y axis
  2791. * @param pitch defines the rotation around X axis
  2792. * @param roll defines the rotation around Z axis
  2793. * @param result defines the target quaternion
  2794. */
  2795. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2796. /**
  2797. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2798. * @param alpha defines the rotation around first axis
  2799. * @param beta defines the rotation around second axis
  2800. * @param gamma defines the rotation around third axis
  2801. * @returns the new quaternion
  2802. */
  2803. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2804. /**
  2805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2806. * @param alpha defines the rotation around first axis
  2807. * @param beta defines the rotation around second axis
  2808. * @param gamma defines the rotation around third axis
  2809. * @param result defines the target quaternion
  2810. */
  2811. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2812. /**
  2813. * 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)
  2814. * @param axis1 defines the first axis
  2815. * @param axis2 defines the second axis
  2816. * @param axis3 defines the third axis
  2817. * @returns the new quaternion
  2818. */
  2819. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2820. /**
  2821. * 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
  2822. * @param axis1 defines the first axis
  2823. * @param axis2 defines the second axis
  2824. * @param axis3 defines the third axis
  2825. * @param ref defines the target quaternion
  2826. */
  2827. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2828. /**
  2829. * Interpolates between two quaternions
  2830. * @param left defines first quaternion
  2831. * @param right defines second quaternion
  2832. * @param amount defines the gradient to use
  2833. * @returns the new interpolated quaternion
  2834. */
  2835. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2836. /**
  2837. * Interpolates between two quaternions and stores it into a target quaternion
  2838. * @param left defines first quaternion
  2839. * @param right defines second quaternion
  2840. * @param amount defines the gradient to use
  2841. * @param result defines the target quaternion
  2842. */
  2843. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2844. /**
  2845. * Interpolate between two quaternions using Hermite interpolation
  2846. * @param value1 defines first quaternion
  2847. * @param tangent1 defines the incoming tangent
  2848. * @param value2 defines second quaternion
  2849. * @param tangent2 defines the outgoing tangent
  2850. * @param amount defines the target quaternion
  2851. * @returns the new interpolated quaternion
  2852. */
  2853. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2854. }
  2855. /**
  2856. * Class used to store matrix data (4x4)
  2857. */
  2858. export class Matrix {
  2859. private static _updateFlagSeed;
  2860. private static _identityReadOnly;
  2861. private _isIdentity;
  2862. private _isIdentityDirty;
  2863. private _isIdentity3x2;
  2864. private _isIdentity3x2Dirty;
  2865. /**
  2866. * Gets the update flag of the matrix which is an unique number for the matrix.
  2867. * It will be incremented every time the matrix data change.
  2868. * You can use it to speed the comparison between two versions of the same matrix.
  2869. */
  2870. updateFlag: number;
  2871. private readonly _m;
  2872. /**
  2873. * Gets the internal data of the matrix
  2874. */
  2875. readonly m: DeepImmutable<Float32Array>;
  2876. /** @hidden */
  2877. _markAsUpdated(): void;
  2878. /** @hidden */
  2879. private _updateIdentityStatus;
  2880. /**
  2881. * Creates an empty matrix (filled with zeros)
  2882. */
  2883. constructor();
  2884. /**
  2885. * Check if the current matrix is identity
  2886. * @returns true is the matrix is the identity matrix
  2887. */
  2888. isIdentity(): boolean;
  2889. /**
  2890. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2891. * @returns true is the matrix is the identity matrix
  2892. */
  2893. isIdentityAs3x2(): boolean;
  2894. /**
  2895. * Gets the determinant of the matrix
  2896. * @returns the matrix determinant
  2897. */
  2898. determinant(): number;
  2899. /**
  2900. * Returns the matrix as a Float32Array
  2901. * @returns the matrix underlying array
  2902. */
  2903. toArray(): DeepImmutable<Float32Array>;
  2904. /**
  2905. * Returns the matrix as a Float32Array
  2906. * @returns the matrix underlying array.
  2907. */
  2908. asArray(): DeepImmutable<Float32Array>;
  2909. /**
  2910. * Inverts the current matrix in place
  2911. * @returns the current inverted matrix
  2912. */
  2913. invert(): Matrix;
  2914. /**
  2915. * Sets all the matrix elements to zero
  2916. * @returns the current matrix
  2917. */
  2918. reset(): Matrix;
  2919. /**
  2920. * Adds the current matrix with a second one
  2921. * @param other defines the matrix to add
  2922. * @returns a new matrix as the addition of the current matrix and the given one
  2923. */
  2924. add(other: DeepImmutable<Matrix>): Matrix;
  2925. /**
  2926. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2927. * @param other defines the matrix to add
  2928. * @param result defines the target matrix
  2929. * @returns the current matrix
  2930. */
  2931. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2932. /**
  2933. * Adds in place the given matrix to the current matrix
  2934. * @param other defines the second operand
  2935. * @returns the current updated matrix
  2936. */
  2937. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2938. /**
  2939. * Sets the given matrix to the current inverted Matrix
  2940. * @param other defines the target matrix
  2941. * @returns the unmodified current matrix
  2942. */
  2943. invertToRef(other: Matrix): Matrix;
  2944. /**
  2945. * add a value at the specified position in the current Matrix
  2946. * @param index the index of the value within the matrix. between 0 and 15.
  2947. * @param value the value to be added
  2948. * @returns the current updated matrix
  2949. */
  2950. addAtIndex(index: number, value: number): Matrix;
  2951. /**
  2952. * mutiply the specified position in the current Matrix by a value
  2953. * @param index the index of the value within the matrix. between 0 and 15.
  2954. * @param value the value to be added
  2955. * @returns the current updated matrix
  2956. */
  2957. multiplyAtIndex(index: number, value: number): Matrix;
  2958. /**
  2959. * Inserts the translation vector (using 3 floats) in the current matrix
  2960. * @param x defines the 1st component of the translation
  2961. * @param y defines the 2nd component of the translation
  2962. * @param z defines the 3rd component of the translation
  2963. * @returns the current updated matrix
  2964. */
  2965. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2966. /**
  2967. * Adds the translation vector (using 3 floats) in the current matrix
  2968. * @param x defines the 1st component of the translation
  2969. * @param y defines the 2nd component of the translation
  2970. * @param z defines the 3rd component of the translation
  2971. * @returns the current updated matrix
  2972. */
  2973. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2974. /**
  2975. * Inserts the translation vector in the current matrix
  2976. * @param vector3 defines the translation to insert
  2977. * @returns the current updated matrix
  2978. */
  2979. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2980. /**
  2981. * Gets the translation value of the current matrix
  2982. * @returns a new Vector3 as the extracted translation from the matrix
  2983. */
  2984. getTranslation(): Vector3;
  2985. /**
  2986. * Fill a Vector3 with the extracted translation from the matrix
  2987. * @param result defines the Vector3 where to store the translation
  2988. * @returns the current matrix
  2989. */
  2990. getTranslationToRef(result: Vector3): Matrix;
  2991. /**
  2992. * Remove rotation and scaling part from the matrix
  2993. * @returns the updated matrix
  2994. */
  2995. removeRotationAndScaling(): Matrix;
  2996. /**
  2997. * Multiply two matrices
  2998. * @param other defines the second operand
  2999. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3000. */
  3001. multiply(other: DeepImmutable<Matrix>): Matrix;
  3002. /**
  3003. * Copy the current matrix from the given one
  3004. * @param other defines the source matrix
  3005. * @returns the current updated matrix
  3006. */
  3007. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3008. /**
  3009. * Populates the given array from the starting index with the current matrix values
  3010. * @param array defines the target array
  3011. * @param offset defines the offset in the target array where to start storing values
  3012. * @returns the current matrix
  3013. */
  3014. copyToArray(array: Float32Array, offset?: number): Matrix;
  3015. /**
  3016. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3017. * @param other defines the second operand
  3018. * @param result defines the matrix where to store the multiplication
  3019. * @returns the current matrix
  3020. */
  3021. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3022. /**
  3023. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3024. * @param other defines the second operand
  3025. * @param result defines the array where to store the multiplication
  3026. * @param offset defines the offset in the target array where to start storing values
  3027. * @returns the current matrix
  3028. */
  3029. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3030. /**
  3031. * Check equality between this matrix and a second one
  3032. * @param value defines the second matrix to compare
  3033. * @returns true is the current matrix and the given one values are strictly equal
  3034. */
  3035. equals(value: DeepImmutable<Matrix>): boolean;
  3036. /**
  3037. * Clone the current matrix
  3038. * @returns a new matrix from the current matrix
  3039. */
  3040. clone(): Matrix;
  3041. /**
  3042. * Returns the name of the current matrix class
  3043. * @returns the string "Matrix"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Gets the hash code of the current matrix
  3048. * @returns the hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Decomposes the current Matrix into a translation, rotation and scaling components
  3053. * @param scale defines the scale vector3 given as a reference to update
  3054. * @param rotation defines the rotation quaternion given as a reference to update
  3055. * @param translation defines the translation vector3 given as a reference to update
  3056. * @returns true if operation was successful
  3057. */
  3058. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3059. /**
  3060. * Gets specific row of the matrix
  3061. * @param index defines the number of the row to get
  3062. * @returns the index-th row of the current matrix as a new Vector4
  3063. */
  3064. getRow(index: number): Nullable<Vector4>;
  3065. /**
  3066. * Sets the index-th row of the current matrix to the vector4 values
  3067. * @param index defines the number of the row to set
  3068. * @param row defines the target vector4
  3069. * @returns the updated current matrix
  3070. */
  3071. setRow(index: number, row: Vector4): Matrix;
  3072. /**
  3073. * Compute the transpose of the matrix
  3074. * @returns the new transposed matrix
  3075. */
  3076. transpose(): Matrix;
  3077. /**
  3078. * Compute the transpose of the matrix and store it in a given matrix
  3079. * @param result defines the target matrix
  3080. * @returns the current matrix
  3081. */
  3082. transposeToRef(result: Matrix): Matrix;
  3083. /**
  3084. * Sets the index-th row of the current matrix with the given 4 x float values
  3085. * @param index defines the row index
  3086. * @param x defines the x component to set
  3087. * @param y defines the y component to set
  3088. * @param z defines the z component to set
  3089. * @param w defines the w component to set
  3090. * @returns the updated current matrix
  3091. */
  3092. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3093. /**
  3094. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3095. * @param scale defines the scale factor
  3096. * @returns a new matrix
  3097. */
  3098. scale(scale: number): Matrix;
  3099. /**
  3100. * Scale the current matrix values by a factor to a given result matrix
  3101. * @param scale defines the scale factor
  3102. * @param result defines the matrix to store the result
  3103. * @returns the current matrix
  3104. */
  3105. scaleToRef(scale: number, result: Matrix): Matrix;
  3106. /**
  3107. * Scale the current matrix values by a factor and add the result to a given matrix
  3108. * @param scale defines the scale factor
  3109. * @param result defines the Matrix to store the result
  3110. * @returns the current matrix
  3111. */
  3112. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3113. /**
  3114. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3115. * @param ref matrix to store the result
  3116. */
  3117. toNormalMatrix(ref: Matrix): void;
  3118. /**
  3119. * Gets only rotation part of the current matrix
  3120. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3121. */
  3122. getRotationMatrix(): Matrix;
  3123. /**
  3124. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3125. * @param result defines the target matrix to store data to
  3126. * @returns the current matrix
  3127. */
  3128. getRotationMatrixToRef(result: Matrix): Matrix;
  3129. /**
  3130. * Toggles model matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleModelMatrixHandInPlace(): void;
  3133. /**
  3134. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3135. */
  3136. toggleProjectionMatrixHandInPlace(): void;
  3137. /**
  3138. * Creates a matrix from an array
  3139. * @param array defines the source array
  3140. * @param offset defines an offset in the source array
  3141. * @returns a new Matrix set from the starting index of the given array
  3142. */
  3143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3144. /**
  3145. * Copy the content of an array into a given matrix
  3146. * @param array defines the source array
  3147. * @param offset defines an offset in the source array
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3151. /**
  3152. * Stores an array into a matrix after having multiplied each component by a given factor
  3153. * @param array defines the source array
  3154. * @param offset defines the offset in the source array
  3155. * @param scale defines the scaling factor
  3156. * @param result defines the target matrix
  3157. */
  3158. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3159. /**
  3160. * Gets an identity matrix that must not be updated
  3161. */
  3162. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3163. /**
  3164. * Stores a list of values (16) inside a given matrix
  3165. * @param initialM11 defines 1st value of 1st row
  3166. * @param initialM12 defines 2nd value of 1st row
  3167. * @param initialM13 defines 3rd value of 1st row
  3168. * @param initialM14 defines 4th value of 1st row
  3169. * @param initialM21 defines 1st value of 2nd row
  3170. * @param initialM22 defines 2nd value of 2nd row
  3171. * @param initialM23 defines 3rd value of 2nd row
  3172. * @param initialM24 defines 4th value of 2nd row
  3173. * @param initialM31 defines 1st value of 3rd row
  3174. * @param initialM32 defines 2nd value of 3rd row
  3175. * @param initialM33 defines 3rd value of 3rd row
  3176. * @param initialM34 defines 4th value of 3rd row
  3177. * @param initialM41 defines 1st value of 4th row
  3178. * @param initialM42 defines 2nd value of 4th row
  3179. * @param initialM43 defines 3rd value of 4th row
  3180. * @param initialM44 defines 4th value of 4th row
  3181. * @param result defines the target matrix
  3182. */
  3183. 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;
  3184. /**
  3185. * Creates new matrix from a list of values (16)
  3186. * @param initialM11 defines 1st value of 1st row
  3187. * @param initialM12 defines 2nd value of 1st row
  3188. * @param initialM13 defines 3rd value of 1st row
  3189. * @param initialM14 defines 4th value of 1st row
  3190. * @param initialM21 defines 1st value of 2nd row
  3191. * @param initialM22 defines 2nd value of 2nd row
  3192. * @param initialM23 defines 3rd value of 2nd row
  3193. * @param initialM24 defines 4th value of 2nd row
  3194. * @param initialM31 defines 1st value of 3rd row
  3195. * @param initialM32 defines 2nd value of 3rd row
  3196. * @param initialM33 defines 3rd value of 3rd row
  3197. * @param initialM34 defines 4th value of 3rd row
  3198. * @param initialM41 defines 1st value of 4th row
  3199. * @param initialM42 defines 2nd value of 4th row
  3200. * @param initialM43 defines 3rd value of 4th row
  3201. * @param initialM44 defines 4th value of 4th row
  3202. * @returns the new matrix
  3203. */
  3204. 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;
  3205. /**
  3206. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3207. * @param scale defines the scale vector3
  3208. * @param rotation defines the rotation quaternion
  3209. * @param translation defines the translation vector3
  3210. * @returns a new matrix
  3211. */
  3212. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3213. /**
  3214. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3215. * @param scale defines the scale vector3
  3216. * @param rotation defines the rotation quaternion
  3217. * @param translation defines the translation vector3
  3218. * @param result defines the target matrix
  3219. */
  3220. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3221. /**
  3222. * Creates a new identity matrix
  3223. * @returns a new identity matrix
  3224. */
  3225. static Identity(): Matrix;
  3226. /**
  3227. * Creates a new identity matrix and stores the result in a given matrix
  3228. * @param result defines the target matrix
  3229. */
  3230. static IdentityToRef(result: Matrix): void;
  3231. /**
  3232. * Creates a new zero matrix
  3233. * @returns a new zero matrix
  3234. */
  3235. static Zero(): Matrix;
  3236. /**
  3237. * Creates a new rotation matrix for "angle" radians around the X axis
  3238. * @param angle defines the angle (in radians) to use
  3239. * @return the new matrix
  3240. */
  3241. static RotationX(angle: number): Matrix;
  3242. /**
  3243. * Creates a new matrix as the invert of a given matrix
  3244. * @param source defines the source matrix
  3245. * @returns the new matrix
  3246. */
  3247. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3248. /**
  3249. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3250. * @param angle defines the angle (in radians) to use
  3251. * @param result defines the target matrix
  3252. */
  3253. static RotationXToRef(angle: number, result: Matrix): void;
  3254. /**
  3255. * Creates a new rotation matrix for "angle" radians around the Y axis
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationY(angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3262. * @param angle defines the angle (in radians) to use
  3263. * @param result defines the target matrix
  3264. */
  3265. static RotationYToRef(angle: number, result: Matrix): void;
  3266. /**
  3267. * Creates a new rotation matrix for "angle" radians around the Z axis
  3268. * @param angle defines the angle (in radians) to use
  3269. * @return the new matrix
  3270. */
  3271. static RotationZ(angle: number): Matrix;
  3272. /**
  3273. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3274. * @param angle defines the angle (in radians) to use
  3275. * @param result defines the target matrix
  3276. */
  3277. static RotationZToRef(angle: number, result: Matrix): void;
  3278. /**
  3279. * Creates a new rotation matrix for "angle" radians around the given axis
  3280. * @param axis defines the axis to use
  3281. * @param angle defines the angle (in radians) to use
  3282. * @return the new matrix
  3283. */
  3284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3285. /**
  3286. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3287. * @param axis defines the axis to use
  3288. * @param angle defines the angle (in radians) to use
  3289. * @param result defines the target matrix
  3290. */
  3291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3292. /**
  3293. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3294. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3295. * @param from defines the vector to align
  3296. * @param to defines the vector to align to
  3297. * @param result defines the target matrix
  3298. */
  3299. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3300. /**
  3301. * Creates a rotation matrix
  3302. * @param yaw defines the yaw angle in radians (Y axis)
  3303. * @param pitch defines the pitch angle in radians (X axis)
  3304. * @param roll defines the roll angle in radians (X axis)
  3305. * @returns the new rotation matrix
  3306. */
  3307. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3308. /**
  3309. * Creates a rotation matrix and stores it in a given matrix
  3310. * @param yaw defines the yaw angle in radians (Y axis)
  3311. * @param pitch defines the pitch angle in radians (X axis)
  3312. * @param roll defines the roll angle in radians (X axis)
  3313. * @param result defines the target matrix
  3314. */
  3315. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3316. /**
  3317. * Creates a scaling matrix
  3318. * @param x defines the scale factor on X axis
  3319. * @param y defines the scale factor on Y axis
  3320. * @param z defines the scale factor on Z axis
  3321. * @returns the new matrix
  3322. */
  3323. static Scaling(x: number, y: number, z: number): Matrix;
  3324. /**
  3325. * Creates a scaling matrix and stores it in a given matrix
  3326. * @param x defines the scale factor on X axis
  3327. * @param y defines the scale factor on Y axis
  3328. * @param z defines the scale factor on Z axis
  3329. * @param result defines the target matrix
  3330. */
  3331. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3332. /**
  3333. * Creates a translation matrix
  3334. * @param x defines the translation on X axis
  3335. * @param y defines the translation on Y axis
  3336. * @param z defines the translationon Z axis
  3337. * @returns the new matrix
  3338. */
  3339. static Translation(x: number, y: number, z: number): Matrix;
  3340. /**
  3341. * Creates a translation matrix and stores it in a given matrix
  3342. * @param x defines the translation on X axis
  3343. * @param y defines the translation on Y axis
  3344. * @param z defines the translationon Z axis
  3345. * @param result defines the target matrix
  3346. */
  3347. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3348. /**
  3349. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3350. * @param startValue defines the start value
  3351. * @param endValue defines the end value
  3352. * @param gradient defines the gradient factor
  3353. * @returns the new matrix
  3354. */
  3355. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3356. /**
  3357. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3358. * @param startValue defines the start value
  3359. * @param endValue defines the end value
  3360. * @param gradient defines the gradient factor
  3361. * @param result defines the Matrix object where to store data
  3362. */
  3363. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3364. /**
  3365. * Builds a new matrix whose values are computed by:
  3366. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3367. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3368. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3369. * @param startValue defines the first matrix
  3370. * @param endValue defines the second matrix
  3371. * @param gradient defines the gradient between the two matrices
  3372. * @returns the new matrix
  3373. */
  3374. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3375. /**
  3376. * Update a matrix to values which are computed by:
  3377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3380. * @param startValue defines the first matrix
  3381. * @param endValue defines the second matrix
  3382. * @param gradient defines the gradient between the two matrices
  3383. * @param result defines the target matrix
  3384. */
  3385. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3386. /**
  3387. * 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"
  3388. * This function works in left handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @returns the new matrix
  3393. */
  3394. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3395. /**
  3396. * 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".
  3397. * This function works in left handed mode
  3398. * @param eye defines the final position of the entity
  3399. * @param target defines where the entity should look at
  3400. * @param up defines the up vector for the entity
  3401. * @param result defines the target matrix
  3402. */
  3403. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3404. /**
  3405. * 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"
  3406. * This function works in right handed mode
  3407. * @param eye defines the final position of the entity
  3408. * @param target defines where the entity should look at
  3409. * @param up defines the up vector for the entity
  3410. * @returns the new matrix
  3411. */
  3412. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3413. /**
  3414. * 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".
  3415. * This function works in right handed mode
  3416. * @param eye defines the final position of the entity
  3417. * @param target defines where the entity should look at
  3418. * @param up defines the up vector for the entity
  3419. * @param result defines the target matrix
  3420. */
  3421. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3422. /**
  3423. * Create a left-handed orthographic projection matrix
  3424. * @param width defines the viewport width
  3425. * @param height defines the viewport height
  3426. * @param znear defines the near clip plane
  3427. * @param zfar defines the far clip plane
  3428. * @returns a new matrix as a left-handed orthographic projection matrix
  3429. */
  3430. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3431. /**
  3432. * Store a left-handed orthographic projection to a given matrix
  3433. * @param width defines the viewport width
  3434. * @param height defines the viewport height
  3435. * @param znear defines the near clip plane
  3436. * @param zfar defines the far clip plane
  3437. * @param result defines the target matrix
  3438. */
  3439. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3440. /**
  3441. * Create a left-handed orthographic projection matrix
  3442. * @param left defines the viewport left coordinate
  3443. * @param right defines the viewport right coordinate
  3444. * @param bottom defines the viewport bottom coordinate
  3445. * @param top defines the viewport top coordinate
  3446. * @param znear defines the near clip plane
  3447. * @param zfar defines the far clip plane
  3448. * @returns a new matrix as a left-handed orthographic projection matrix
  3449. */
  3450. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3451. /**
  3452. * Stores a left-handed orthographic projection into a given matrix
  3453. * @param left defines the viewport left coordinate
  3454. * @param right defines the viewport right coordinate
  3455. * @param bottom defines the viewport bottom coordinate
  3456. * @param top defines the viewport top coordinate
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @param result defines the target matrix
  3460. */
  3461. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3462. /**
  3463. * Creates a right-handed orthographic projection matrix
  3464. * @param left defines the viewport left coordinate
  3465. * @param right defines the viewport right coordinate
  3466. * @param bottom defines the viewport bottom coordinate
  3467. * @param top defines the viewport top coordinate
  3468. * @param znear defines the near clip plane
  3469. * @param zfar defines the far clip plane
  3470. * @returns a new matrix as a right-handed orthographic projection matrix
  3471. */
  3472. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3473. /**
  3474. * Stores a right-handed orthographic projection into a given matrix
  3475. * @param left defines the viewport left coordinate
  3476. * @param right defines the viewport right coordinate
  3477. * @param bottom defines the viewport bottom coordinate
  3478. * @param top defines the viewport top coordinate
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. */
  3483. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3484. /**
  3485. * Creates a left-handed perspective projection matrix
  3486. * @param width defines the viewport width
  3487. * @param height defines the viewport height
  3488. * @param znear defines the near clip plane
  3489. * @param zfar defines the far clip plane
  3490. * @returns a new matrix as a left-handed perspective projection matrix
  3491. */
  3492. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3493. /**
  3494. * Creates a left-handed perspective projection matrix
  3495. * @param fov defines the horizontal field of view
  3496. * @param aspect defines the aspect ratio
  3497. * @param znear defines the near clip plane
  3498. * @param zfar defines the far clip plane
  3499. * @returns a new matrix as a left-handed perspective projection matrix
  3500. */
  3501. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3502. /**
  3503. * Stores a left-handed perspective projection into a given matrix
  3504. * @param fov defines the horizontal field of view
  3505. * @param aspect defines the aspect ratio
  3506. * @param znear defines the near clip plane
  3507. * @param zfar defines the far clip plane
  3508. * @param result defines the target matrix
  3509. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3510. */
  3511. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3512. /**
  3513. * Creates a right-handed perspective projection matrix
  3514. * @param fov defines the horizontal field of view
  3515. * @param aspect defines the aspect ratio
  3516. * @param znear defines the near clip plane
  3517. * @param zfar defines the far clip plane
  3518. * @returns a new matrix as a right-handed perspective projection matrix
  3519. */
  3520. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3521. /**
  3522. * Stores a right-handed perspective projection into a given matrix
  3523. * @param fov defines the horizontal field of view
  3524. * @param aspect defines the aspect ratio
  3525. * @param znear defines the near clip plane
  3526. * @param zfar defines the far clip plane
  3527. * @param result defines the target matrix
  3528. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3529. */
  3530. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3531. /**
  3532. * Stores a perspective projection for WebVR info a given matrix
  3533. * @param fov defines the field of view
  3534. * @param znear defines the near clip plane
  3535. * @param zfar defines the far clip plane
  3536. * @param result defines the target matrix
  3537. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3538. */
  3539. static PerspectiveFovWebVRToRef(fov: {
  3540. upDegrees: number;
  3541. downDegrees: number;
  3542. leftDegrees: number;
  3543. rightDegrees: number;
  3544. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3545. /**
  3546. * Computes a complete transformation matrix
  3547. * @param viewport defines the viewport to use
  3548. * @param world defines the world matrix
  3549. * @param view defines the view matrix
  3550. * @param projection defines the projection matrix
  3551. * @param zmin defines the near clip plane
  3552. * @param zmax defines the far clip plane
  3553. * @returns the transformation matrix
  3554. */
  3555. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3556. /**
  3557. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3558. * @param matrix defines the matrix to use
  3559. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3560. */
  3561. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3562. /**
  3563. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3564. * @param matrix defines the matrix to use
  3565. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3566. */
  3567. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3568. /**
  3569. * Compute the transpose of a given matrix
  3570. * @param matrix defines the matrix to transpose
  3571. * @returns the new matrix
  3572. */
  3573. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3574. /**
  3575. * Compute the transpose of a matrix and store it in a target matrix
  3576. * @param matrix defines the matrix to transpose
  3577. * @param result defines the target matrix
  3578. */
  3579. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3580. /**
  3581. * Computes a reflection matrix from a plane
  3582. * @param plane defines the reflection plane
  3583. * @returns a new matrix
  3584. */
  3585. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3586. /**
  3587. * Computes a reflection matrix from a plane
  3588. * @param plane defines the reflection plane
  3589. * @param result defines the target matrix
  3590. */
  3591. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3592. /**
  3593. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3594. * @param xaxis defines the value of the 1st axis
  3595. * @param yaxis defines the value of the 2nd axis
  3596. * @param zaxis defines the value of the 3rd axis
  3597. * @param result defines the target matrix
  3598. */
  3599. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3600. /**
  3601. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3602. * @param quat defines the quaternion to use
  3603. * @param result defines the target matrix
  3604. */
  3605. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3606. }
  3607. /**
  3608. * Represens a plane by the equation ax + by + cz + d = 0
  3609. */
  3610. export class Plane {
  3611. /**
  3612. * Normal of the plane (a,b,c)
  3613. */
  3614. normal: Vector3;
  3615. /**
  3616. * d component of the plane
  3617. */
  3618. d: number;
  3619. /**
  3620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3621. * @param a a component of the plane
  3622. * @param b b component of the plane
  3623. * @param c c component of the plane
  3624. * @param d d component of the plane
  3625. */
  3626. constructor(a: number, b: number, c: number, d: number);
  3627. /**
  3628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3629. */
  3630. asArray(): number[];
  3631. /**
  3632. * @returns a new plane copied from the current Plane.
  3633. */
  3634. clone(): Plane;
  3635. /**
  3636. * @returns the string "Plane".
  3637. */
  3638. getClassName(): string;
  3639. /**
  3640. * @returns the Plane hash code.
  3641. */
  3642. getHashCode(): number;
  3643. /**
  3644. * Normalize the current Plane in place.
  3645. * @returns the updated Plane.
  3646. */
  3647. normalize(): Plane;
  3648. /**
  3649. * Applies a transformation the plane and returns the result
  3650. * @param transformation the transformation matrix to be applied to the plane
  3651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3652. */
  3653. transform(transformation: DeepImmutable<Matrix>): Plane;
  3654. /**
  3655. * Calcualtte the dot product between the point and the plane normal
  3656. * @param point point to calculate the dot product with
  3657. * @returns the dot product (float) of the point coordinates and the plane normal.
  3658. */
  3659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3660. /**
  3661. * Updates the current Plane from the plane defined by the three given points.
  3662. * @param point1 one of the points used to contruct the plane
  3663. * @param point2 one of the points used to contruct the plane
  3664. * @param point3 one of the points used to contruct the plane
  3665. * @returns the updated Plane.
  3666. */
  3667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Checks if the plane is facing a given direction
  3670. * @param direction the direction to check if the plane is facing
  3671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3672. * @returns True is the vector "direction" is the same side than the plane normal.
  3673. */
  3674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3675. /**
  3676. * Calculates the distance to a point
  3677. * @param point point to calculate distance to
  3678. * @returns the signed distance (float) from the given point to the Plane.
  3679. */
  3680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3681. /**
  3682. * Creates a plane from an array
  3683. * @param array the array to create a plane from
  3684. * @returns a new Plane from the given array.
  3685. */
  3686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3687. /**
  3688. * Creates a plane from three points
  3689. * @param point1 point used to create the plane
  3690. * @param point2 point used to create the plane
  3691. * @param point3 point used to create the plane
  3692. * @returns a new Plane defined by the three given points.
  3693. */
  3694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3695. /**
  3696. * Creates a plane from an origin point and a normal
  3697. * @param origin origin of the plane to be constructed
  3698. * @param normal normal of the plane to be constructed
  3699. * @returns a new Plane the normal vector to this plane at the given origin point.
  3700. * Note : the vector "normal" is updated because normalized.
  3701. */
  3702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3703. /**
  3704. * Calculates the distance from a plane and a point
  3705. * @param origin origin of the plane to be constructed
  3706. * @param normal normal of the plane to be constructed
  3707. * @param point point to calculate distance to
  3708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3709. */
  3710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3711. }
  3712. /**
  3713. * Class used to represent a viewport on screen
  3714. */
  3715. export class Viewport {
  3716. /** viewport left coordinate */
  3717. x: number;
  3718. /** viewport top coordinate */
  3719. y: number;
  3720. /**viewport width */
  3721. width: number;
  3722. /** viewport height */
  3723. height: number;
  3724. /**
  3725. * Creates a Viewport object located at (x, y) and sized (width, height)
  3726. * @param x defines viewport left coordinate
  3727. * @param y defines viewport top coordinate
  3728. * @param width defines the viewport width
  3729. * @param height defines the viewport height
  3730. */
  3731. constructor(
  3732. /** viewport left coordinate */
  3733. x: number,
  3734. /** viewport top coordinate */
  3735. y: number,
  3736. /**viewport width */
  3737. width: number,
  3738. /** viewport height */
  3739. height: number);
  3740. /**
  3741. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3742. * @param renderWidth defines the rendering width
  3743. * @param renderHeight defines the rendering height
  3744. * @returns a new Viewport
  3745. */
  3746. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3747. /**
  3748. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3749. * @param renderWidth defines the rendering width
  3750. * @param renderHeight defines the rendering height
  3751. * @param ref defines the target viewport
  3752. * @returns the current viewport
  3753. */
  3754. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3755. /**
  3756. * Returns a new Viewport copied from the current one
  3757. * @returns a new Viewport
  3758. */
  3759. clone(): Viewport;
  3760. }
  3761. /**
  3762. * Reprasents a camera frustum
  3763. */
  3764. export class Frustum {
  3765. /**
  3766. * Gets the planes representing the frustum
  3767. * @param transform matrix to be applied to the returned planes
  3768. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3769. */
  3770. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3771. /**
  3772. * Gets the near frustum plane transformed by the transform matrix
  3773. * @param transform transformation matrix to be applied to the resulting frustum plane
  3774. * @param frustumPlane the resuling frustum plane
  3775. */
  3776. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3777. /**
  3778. * Gets the far frustum plane transformed by the transform matrix
  3779. * @param transform transformation matrix to be applied to the resulting frustum plane
  3780. * @param frustumPlane the resuling frustum plane
  3781. */
  3782. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3783. /**
  3784. * Gets the left frustum plane transformed by the transform matrix
  3785. * @param transform transformation matrix to be applied to the resulting frustum plane
  3786. * @param frustumPlane the resuling frustum plane
  3787. */
  3788. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3789. /**
  3790. * Gets the right frustum plane transformed by the transform matrix
  3791. * @param transform transformation matrix to be applied to the resulting frustum plane
  3792. * @param frustumPlane the resuling frustum plane
  3793. */
  3794. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3795. /**
  3796. * Gets the top frustum plane transformed by the transform matrix
  3797. * @param transform transformation matrix to be applied to the resulting frustum plane
  3798. * @param frustumPlane the resuling frustum plane
  3799. */
  3800. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3801. /**
  3802. * Gets the bottom frustum plane transformed by the transform matrix
  3803. * @param transform transformation matrix to be applied to the resulting frustum plane
  3804. * @param frustumPlane the resuling frustum plane
  3805. */
  3806. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3807. /**
  3808. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3809. * @param transform transformation matrix to be applied to the resulting frustum planes
  3810. * @param frustumPlanes the resuling frustum planes
  3811. */
  3812. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3813. }
  3814. /** Defines supported spaces */
  3815. export enum Space {
  3816. /** Local (object) space */
  3817. LOCAL = 0,
  3818. /** World space */
  3819. WORLD = 1,
  3820. /** Bone space */
  3821. BONE = 2
  3822. }
  3823. /** Defines the 3 main axes */
  3824. export class Axis {
  3825. /** X axis */
  3826. static X: Vector3;
  3827. /** Y axis */
  3828. static Y: Vector3;
  3829. /** Z axis */
  3830. static Z: Vector3;
  3831. }
  3832. /** Class used to represent a Bezier curve */
  3833. export class BezierCurve {
  3834. /**
  3835. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3836. * @param t defines the time
  3837. * @param x1 defines the left coordinate on X axis
  3838. * @param y1 defines the left coordinate on Y axis
  3839. * @param x2 defines the right coordinate on X axis
  3840. * @param y2 defines the right coordinate on Y axis
  3841. * @returns the interpolated value
  3842. */
  3843. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3844. }
  3845. /**
  3846. * Defines potential orientation for back face culling
  3847. */
  3848. export enum Orientation {
  3849. /**
  3850. * Clockwise
  3851. */
  3852. CW = 0,
  3853. /** Counter clockwise */
  3854. CCW = 1
  3855. }
  3856. /**
  3857. * Defines angle representation
  3858. */
  3859. export class Angle {
  3860. private _radians;
  3861. /**
  3862. * Creates an Angle object of "radians" radians (float).
  3863. * @param radians the angle in radians
  3864. */
  3865. constructor(radians: number);
  3866. /**
  3867. * Get value in degrees
  3868. * @returns the Angle value in degrees (float)
  3869. */
  3870. degrees(): number;
  3871. /**
  3872. * Get value in radians
  3873. * @returns the Angle value in radians (float)
  3874. */
  3875. radians(): number;
  3876. /**
  3877. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3878. * @param a defines first vector
  3879. * @param b defines second vector
  3880. * @returns a new Angle
  3881. */
  3882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3883. /**
  3884. * Gets a new Angle object from the given float in radians
  3885. * @param radians defines the angle value in radians
  3886. * @returns a new Angle
  3887. */
  3888. static FromRadians(radians: number): Angle;
  3889. /**
  3890. * Gets a new Angle object from the given float in degrees
  3891. * @param degrees defines the angle value in degrees
  3892. * @returns a new Angle
  3893. */
  3894. static FromDegrees(degrees: number): Angle;
  3895. }
  3896. /**
  3897. * This represents an arc in a 2d space.
  3898. */
  3899. export class Arc2 {
  3900. /** Defines the start point of the arc */
  3901. startPoint: Vector2;
  3902. /** Defines the mid point of the arc */
  3903. midPoint: Vector2;
  3904. /** Defines the end point of the arc */
  3905. endPoint: Vector2;
  3906. /**
  3907. * Defines the center point of the arc.
  3908. */
  3909. centerPoint: Vector2;
  3910. /**
  3911. * Defines the radius of the arc.
  3912. */
  3913. radius: number;
  3914. /**
  3915. * Defines the angle of the arc (from mid point to end point).
  3916. */
  3917. angle: Angle;
  3918. /**
  3919. * Defines the start angle of the arc (from start point to middle point).
  3920. */
  3921. startAngle: Angle;
  3922. /**
  3923. * Defines the orientation of the arc (clock wise/counter clock wise).
  3924. */
  3925. orientation: Orientation;
  3926. /**
  3927. * Creates an Arc object from the three given points : start, middle and end.
  3928. * @param startPoint Defines the start point of the arc
  3929. * @param midPoint Defines the midlle point of the arc
  3930. * @param endPoint Defines the end point of the arc
  3931. */
  3932. constructor(
  3933. /** Defines the start point of the arc */
  3934. startPoint: Vector2,
  3935. /** Defines the mid point of the arc */
  3936. midPoint: Vector2,
  3937. /** Defines the end point of the arc */
  3938. endPoint: Vector2);
  3939. }
  3940. /**
  3941. * Represents a 2D path made up of multiple 2D points
  3942. */
  3943. export class Path2 {
  3944. private _points;
  3945. private _length;
  3946. /**
  3947. * If the path start and end point are the same
  3948. */
  3949. closed: boolean;
  3950. /**
  3951. * Creates a Path2 object from the starting 2D coordinates x and y.
  3952. * @param x the starting points x value
  3953. * @param y the starting points y value
  3954. */
  3955. constructor(x: number, y: number);
  3956. /**
  3957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3958. * @param x the added points x value
  3959. * @param y the added points y value
  3960. * @returns the updated Path2.
  3961. */
  3962. addLineTo(x: number, y: number): Path2;
  3963. /**
  3964. * 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.
  3965. * @param midX middle point x value
  3966. * @param midY middle point y value
  3967. * @param endX end point x value
  3968. * @param endY end point y value
  3969. * @param numberOfSegments (default: 36)
  3970. * @returns the updated Path2.
  3971. */
  3972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3973. /**
  3974. * Closes the Path2.
  3975. * @returns the Path2.
  3976. */
  3977. close(): Path2;
  3978. /**
  3979. * Gets the sum of the distance between each sequential point in the path
  3980. * @returns the Path2 total length (float).
  3981. */
  3982. length(): number;
  3983. /**
  3984. * Gets the points which construct the path
  3985. * @returns the Path2 internal array of points.
  3986. */
  3987. getPoints(): Vector2[];
  3988. /**
  3989. * Retreives the point at the distance aways from the starting point
  3990. * @param normalizedLengthPosition the length along the path to retreive the point from
  3991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3992. */
  3993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3994. /**
  3995. * Creates a new path starting from an x and y position
  3996. * @param x starting x value
  3997. * @param y starting y value
  3998. * @returns a new Path2 starting at the coordinates (x, y).
  3999. */
  4000. static StartingAt(x: number, y: number): Path2;
  4001. }
  4002. /**
  4003. * Represents a 3D path made up of multiple 3D points
  4004. */
  4005. export class Path3D {
  4006. /**
  4007. * an array of Vector3, the curve axis of the Path3D
  4008. */
  4009. path: Vector3[];
  4010. private _curve;
  4011. private _distances;
  4012. private _tangents;
  4013. private _normals;
  4014. private _binormals;
  4015. private _raw;
  4016. /**
  4017. * new Path3D(path, normal, raw)
  4018. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4019. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4020. * @param path an array of Vector3, the curve axis of the Path3D
  4021. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4022. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4023. */
  4024. constructor(
  4025. /**
  4026. * an array of Vector3, the curve axis of the Path3D
  4027. */
  4028. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4029. /**
  4030. * Returns the Path3D array of successive Vector3 designing its curve.
  4031. * @returns the Path3D array of successive Vector3 designing its curve.
  4032. */
  4033. getCurve(): Vector3[];
  4034. /**
  4035. * Returns an array populated with tangent vectors on each Path3D curve point.
  4036. * @returns an array populated with tangent vectors on each Path3D curve point.
  4037. */
  4038. getTangents(): Vector3[];
  4039. /**
  4040. * Returns an array populated with normal vectors on each Path3D curve point.
  4041. * @returns an array populated with normal vectors on each Path3D curve point.
  4042. */
  4043. getNormals(): Vector3[];
  4044. /**
  4045. * Returns an array populated with binormal vectors on each Path3D curve point.
  4046. * @returns an array populated with binormal vectors on each Path3D curve point.
  4047. */
  4048. getBinormals(): Vector3[];
  4049. /**
  4050. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4051. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4052. */
  4053. getDistances(): number[];
  4054. /**
  4055. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4056. * @param path path which all values are copied into the curves points
  4057. * @param firstNormal which should be projected onto the curve
  4058. * @returns the same object updated.
  4059. */
  4060. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4061. private _compute;
  4062. private _getFirstNonNullVector;
  4063. private _getLastNonNullVector;
  4064. private _normalVector;
  4065. }
  4066. /**
  4067. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4068. * A Curve3 is designed from a series of successive Vector3.
  4069. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4070. */
  4071. export class Curve3 {
  4072. private _points;
  4073. private _length;
  4074. /**
  4075. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4076. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4077. * @param v1 (Vector3) the control point
  4078. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4079. * @param nbPoints (integer) the wanted number of points in the curve
  4080. * @returns the created Curve3
  4081. */
  4082. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4083. /**
  4084. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4085. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4086. * @param v1 (Vector3) the first control point
  4087. * @param v2 (Vector3) the second control point
  4088. * @param v3 (Vector3) the end point of the Cubic Bezier
  4089. * @param nbPoints (integer) the wanted number of points in the curve
  4090. * @returns the created Curve3
  4091. */
  4092. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4093. /**
  4094. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4095. * @param p1 (Vector3) the origin point of the Hermite Spline
  4096. * @param t1 (Vector3) the tangent vector at the origin point
  4097. * @param p2 (Vector3) the end point of the Hermite Spline
  4098. * @param t2 (Vector3) the tangent vector at the end point
  4099. * @param nbPoints (integer) the wanted number of points in the curve
  4100. * @returns the created Curve3
  4101. */
  4102. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4103. /**
  4104. * Returns a Curve3 object along a CatmullRom Spline curve :
  4105. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4106. * @param nbPoints (integer) the wanted number of points between each curve control points
  4107. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4108. * @returns the created Curve3
  4109. */
  4110. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4111. /**
  4112. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4113. * A Curve3 is designed from a series of successive Vector3.
  4114. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4115. * @param points points which make up the curve
  4116. */
  4117. constructor(points: Vector3[]);
  4118. /**
  4119. * @returns the Curve3 stored array of successive Vector3
  4120. */
  4121. getPoints(): Vector3[];
  4122. /**
  4123. * @returns the computed length (float) of the curve.
  4124. */
  4125. length(): number;
  4126. /**
  4127. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4128. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4129. * curveA and curveB keep unchanged.
  4130. * @param curve the curve to continue from this curve
  4131. * @returns the newly constructed curve
  4132. */
  4133. continue(curve: DeepImmutable<Curve3>): Curve3;
  4134. private _computeLength;
  4135. }
  4136. /**
  4137. * Contains position and normal vectors for a vertex
  4138. */
  4139. export class PositionNormalVertex {
  4140. /** the position of the vertex (defaut: 0,0,0) */
  4141. position: Vector3;
  4142. /** the normal of the vertex (defaut: 0,1,0) */
  4143. normal: Vector3;
  4144. /**
  4145. * Creates a PositionNormalVertex
  4146. * @param position the position of the vertex (defaut: 0,0,0)
  4147. * @param normal the normal of the vertex (defaut: 0,1,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3);
  4154. /**
  4155. * Clones the PositionNormalVertex
  4156. * @returns the cloned PositionNormalVertex
  4157. */
  4158. clone(): PositionNormalVertex;
  4159. }
  4160. /**
  4161. * Contains position, normal and uv vectors for a vertex
  4162. */
  4163. export class PositionNormalTextureVertex {
  4164. /** the position of the vertex (defaut: 0,0,0) */
  4165. position: Vector3;
  4166. /** the normal of the vertex (defaut: 0,1,0) */
  4167. normal: Vector3;
  4168. /** the uv of the vertex (default: 0,0) */
  4169. uv: Vector2;
  4170. /**
  4171. * Creates a PositionNormalTextureVertex
  4172. * @param position the position of the vertex (defaut: 0,0,0)
  4173. * @param normal the normal of the vertex (defaut: 0,1,0)
  4174. * @param uv the uv of the vertex (default: 0,0)
  4175. */
  4176. constructor(
  4177. /** the position of the vertex (defaut: 0,0,0) */
  4178. position?: Vector3,
  4179. /** the normal of the vertex (defaut: 0,1,0) */
  4180. normal?: Vector3,
  4181. /** the uv of the vertex (default: 0,0) */
  4182. uv?: Vector2);
  4183. /**
  4184. * Clones the PositionNormalTextureVertex
  4185. * @returns the cloned PositionNormalTextureVertex
  4186. */
  4187. clone(): PositionNormalTextureVertex;
  4188. }
  4189. /**
  4190. * @hidden
  4191. */
  4192. export class Tmp {
  4193. static Color3: Color3[];
  4194. static Color4: Color4[];
  4195. static Vector2: Vector2[];
  4196. static Vector3: Vector3[];
  4197. static Vector4: Vector4[];
  4198. static Quaternion: Quaternion[];
  4199. static Matrix: Matrix[];
  4200. }
  4201. }
  4202. declare module "babylonjs/Offline/IOfflineProvider" {
  4203. /**
  4204. * Class used to enable access to offline support
  4205. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4206. */
  4207. export interface IOfflineProvider {
  4208. /**
  4209. * Gets a boolean indicating if scene must be saved in the database
  4210. */
  4211. enableSceneOffline: boolean;
  4212. /**
  4213. * Gets a boolean indicating if textures must be saved in the database
  4214. */
  4215. enableTexturesOffline: boolean;
  4216. /**
  4217. * Open the offline support and make it available
  4218. * @param successCallback defines the callback to call on success
  4219. * @param errorCallback defines the callback to call on error
  4220. */
  4221. open(successCallback: () => void, errorCallback: () => void): void;
  4222. /**
  4223. * Loads an image from the offline support
  4224. * @param url defines the url to load from
  4225. * @param image defines the target DOM image
  4226. */
  4227. loadImage(url: string, image: HTMLImageElement): void;
  4228. /**
  4229. * Loads a file from offline support
  4230. * @param url defines the URL to load from
  4231. * @param sceneLoaded defines a callback to call on success
  4232. * @param progressCallBack defines a callback to call when progress changed
  4233. * @param errorCallback defines a callback to call on error
  4234. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4235. */
  4236. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4237. }
  4238. }
  4239. declare module "babylonjs/Misc/observable" {
  4240. import { Nullable } from "babylonjs/types";
  4241. /**
  4242. * A class serves as a medium between the observable and its observers
  4243. */
  4244. export class EventState {
  4245. /**
  4246. * Create a new EventState
  4247. * @param mask defines the mask associated with this state
  4248. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4249. * @param target defines the original target of the state
  4250. * @param currentTarget defines the current target of the state
  4251. */
  4252. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4253. /**
  4254. * Initialize the current event state
  4255. * @param mask defines the mask associated with this state
  4256. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4257. * @param target defines the original target of the state
  4258. * @param currentTarget defines the current target of the state
  4259. * @returns the current event state
  4260. */
  4261. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4262. /**
  4263. * An Observer can set this property to true to prevent subsequent observers of being notified
  4264. */
  4265. skipNextObservers: boolean;
  4266. /**
  4267. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4268. */
  4269. mask: number;
  4270. /**
  4271. * The object that originally notified the event
  4272. */
  4273. target?: any;
  4274. /**
  4275. * The current object in the bubbling phase
  4276. */
  4277. currentTarget?: any;
  4278. /**
  4279. * This will be populated with the return value of the last function that was executed.
  4280. * If it is the first function in the callback chain it will be the event data.
  4281. */
  4282. lastReturnValue?: any;
  4283. }
  4284. /**
  4285. * Represent an Observer registered to a given Observable object.
  4286. */
  4287. export class Observer<T> {
  4288. /**
  4289. * Defines the callback to call when the observer is notified
  4290. */
  4291. callback: (eventData: T, eventState: EventState) => void;
  4292. /**
  4293. * Defines the mask of the observer (used to filter notifications)
  4294. */
  4295. mask: number;
  4296. /**
  4297. * Defines the current scope used to restore the JS context
  4298. */
  4299. scope: any;
  4300. /** @hidden */
  4301. _willBeUnregistered: boolean;
  4302. /**
  4303. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4304. */
  4305. unregisterOnNextCall: boolean;
  4306. /**
  4307. * Creates a new observer
  4308. * @param callback defines the callback to call when the observer is notified
  4309. * @param mask defines the mask of the observer (used to filter notifications)
  4310. * @param scope defines the current scope used to restore the JS context
  4311. */
  4312. constructor(
  4313. /**
  4314. * Defines the callback to call when the observer is notified
  4315. */
  4316. callback: (eventData: T, eventState: EventState) => void,
  4317. /**
  4318. * Defines the mask of the observer (used to filter notifications)
  4319. */
  4320. mask: number,
  4321. /**
  4322. * Defines the current scope used to restore the JS context
  4323. */
  4324. scope?: any);
  4325. }
  4326. /**
  4327. * Represent a list of observers registered to multiple Observables object.
  4328. */
  4329. export class MultiObserver<T> {
  4330. private _observers;
  4331. private _observables;
  4332. /**
  4333. * Release associated resources
  4334. */
  4335. dispose(): void;
  4336. /**
  4337. * Raise a callback when one of the observable will notify
  4338. * @param observables defines a list of observables to watch
  4339. * @param callback defines the callback to call on notification
  4340. * @param mask defines the mask used to filter notifications
  4341. * @param scope defines the current scope used to restore the JS context
  4342. * @returns the new MultiObserver
  4343. */
  4344. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4345. }
  4346. /**
  4347. * The Observable class is a simple implementation of the Observable pattern.
  4348. *
  4349. * 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.
  4350. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4351. * 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).
  4352. * 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.
  4353. */
  4354. export class Observable<T> {
  4355. private _observers;
  4356. private _eventState;
  4357. private _onObserverAdded;
  4358. /**
  4359. * Creates a new observable
  4360. * @param onObserverAdded defines a callback to call when a new observer is added
  4361. */
  4362. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4363. /**
  4364. * Create a new Observer with the specified callback
  4365. * @param callback the callback that will be executed for that Observer
  4366. * @param mask the mask used to filter observers
  4367. * @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.
  4368. * @param scope optional scope for the callback to be called from
  4369. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4370. * @returns the new observer created for the callback
  4371. */
  4372. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4373. /**
  4374. * Create a new Observer with the specified callback and unregisters after the next notification
  4375. * @param callback the callback that will be executed for that Observer
  4376. * @returns the new observer created for the callback
  4377. */
  4378. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4379. /**
  4380. * Remove an Observer from the Observable object
  4381. * @param observer the instance of the Observer to remove
  4382. * @returns false if it doesn't belong to this Observable
  4383. */
  4384. remove(observer: Nullable<Observer<T>>): boolean;
  4385. /**
  4386. * Remove a callback from the Observable object
  4387. * @param callback the callback to remove
  4388. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4389. * @returns false if it doesn't belong to this Observable
  4390. */
  4391. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4392. private _deferUnregister;
  4393. private _remove;
  4394. /**
  4395. * Moves the observable to the top of the observer list making it get called first when notified
  4396. * @param observer the observer to move
  4397. */
  4398. makeObserverTopPriority(observer: Observer<T>): void;
  4399. /**
  4400. * Moves the observable to the bottom of the observer list making it get called last when notified
  4401. * @param observer the observer to move
  4402. */
  4403. makeObserverBottomPriority(observer: Observer<T>): void;
  4404. /**
  4405. * Notify all Observers by calling their respective callback with the given data
  4406. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4407. * @param eventData defines the data to send to all observers
  4408. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4409. * @param target defines the original target of the state
  4410. * @param currentTarget defines the current target of the state
  4411. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4412. */
  4413. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4414. /**
  4415. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4416. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4417. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4418. * and it is crucial that all callbacks will be executed.
  4419. * The order of the callbacks is kept, callbacks are not executed parallel.
  4420. *
  4421. * @param eventData The data to be sent to each callback
  4422. * @param mask is used to filter observers defaults to -1
  4423. * @param target defines the callback target (see EventState)
  4424. * @param currentTarget defines he current object in the bubbling phase
  4425. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4426. */
  4427. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4428. /**
  4429. * Notify a specific observer
  4430. * @param observer defines the observer to notify
  4431. * @param eventData defines the data to be sent to each callback
  4432. * @param mask is used to filter observers defaults to -1
  4433. */
  4434. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4435. /**
  4436. * Gets a boolean indicating if the observable has at least one observer
  4437. * @returns true is the Observable has at least one Observer registered
  4438. */
  4439. hasObservers(): boolean;
  4440. /**
  4441. * Clear the list of observers
  4442. */
  4443. clear(): void;
  4444. /**
  4445. * Clone the current observable
  4446. * @returns a new observable
  4447. */
  4448. clone(): Observable<T>;
  4449. /**
  4450. * Does this observable handles observer registered with a given mask
  4451. * @param mask defines the mask to be tested
  4452. * @return whether or not one observer registered with the given mask is handeled
  4453. **/
  4454. hasSpecificMask(mask?: number): boolean;
  4455. }
  4456. }
  4457. declare module "babylonjs/Misc/filesInputStore" {
  4458. /**
  4459. * Class used to help managing file picking and drag'n'drop
  4460. * File Storage
  4461. */
  4462. export class FilesInputStore {
  4463. /**
  4464. * List of files ready to be loaded
  4465. */
  4466. static FilesToLoad: {
  4467. [key: string]: File;
  4468. };
  4469. }
  4470. }
  4471. declare module "babylonjs/Engines/constants" {
  4472. /** Defines the cross module used constants to avoid circular dependncies */
  4473. export class Constants {
  4474. /** Defines that alpha blending is disabled */
  4475. static readonly ALPHA_DISABLE: number;
  4476. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4477. static readonly ALPHA_ADD: number;
  4478. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4479. static readonly ALPHA_COMBINE: number;
  4480. /** Defines that alpha blending to DEST - SRC * DEST */
  4481. static readonly ALPHA_SUBTRACT: number;
  4482. /** Defines that alpha blending to SRC * DEST */
  4483. static readonly ALPHA_MULTIPLY: number;
  4484. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4485. static readonly ALPHA_MAXIMIZED: number;
  4486. /** Defines that alpha blending to SRC + DEST */
  4487. static readonly ALPHA_ONEONE: number;
  4488. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4489. static readonly ALPHA_PREMULTIPLIED: number;
  4490. /**
  4491. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4492. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4493. */
  4494. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4495. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4496. static readonly ALPHA_INTERPOLATE: number;
  4497. /**
  4498. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4499. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4500. */
  4501. static readonly ALPHA_SCREENMODE: number;
  4502. /** Defines that the ressource is not delayed*/
  4503. static readonly DELAYLOADSTATE_NONE: number;
  4504. /** Defines that the ressource was successfully delay loaded */
  4505. static readonly DELAYLOADSTATE_LOADED: number;
  4506. /** Defines that the ressource is currently delay loading */
  4507. static readonly DELAYLOADSTATE_LOADING: number;
  4508. /** Defines that the ressource is delayed and has not started loading */
  4509. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4510. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4511. static readonly NEVER: number;
  4512. /** 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 */
  4513. static readonly ALWAYS: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4515. static readonly LESS: number;
  4516. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4517. static readonly EQUAL: number;
  4518. /** 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 */
  4519. static readonly LEQUAL: number;
  4520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4521. static readonly GREATER: number;
  4522. /** 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 */
  4523. static readonly GEQUAL: number;
  4524. /** 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 */
  4525. static readonly NOTEQUAL: number;
  4526. /** Passed to stencilOperation to specify that stencil value must be kept */
  4527. static readonly KEEP: number;
  4528. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4529. static readonly REPLACE: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4531. static readonly INCR: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4533. static readonly DECR: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4535. static readonly INVERT: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4537. static readonly INCR_WRAP: number;
  4538. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4539. static readonly DECR_WRAP: number;
  4540. /** Texture is not repeating outside of 0..1 UVs */
  4541. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4542. /** Texture is repeating outside of 0..1 UVs */
  4543. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4544. /** Texture is repeating and mirrored */
  4545. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4546. /** ALPHA */
  4547. static readonly TEXTUREFORMAT_ALPHA: number;
  4548. /** LUMINANCE */
  4549. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4550. /** LUMINANCE_ALPHA */
  4551. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4552. /** RGB */
  4553. static readonly TEXTUREFORMAT_RGB: number;
  4554. /** RGBA */
  4555. static readonly TEXTUREFORMAT_RGBA: number;
  4556. /** RED */
  4557. static readonly TEXTUREFORMAT_RED: number;
  4558. /** RED (2nd reference) */
  4559. static readonly TEXTUREFORMAT_R: number;
  4560. /** RG */
  4561. static readonly TEXTUREFORMAT_RG: number;
  4562. /** RED_INTEGER */
  4563. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4564. /** RED_INTEGER (2nd reference) */
  4565. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4566. /** RG_INTEGER */
  4567. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4568. /** RGB_INTEGER */
  4569. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4570. /** RGBA_INTEGER */
  4571. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4572. /** UNSIGNED_BYTE */
  4573. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4574. /** UNSIGNED_BYTE (2nd reference) */
  4575. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4576. /** FLOAT */
  4577. static readonly TEXTURETYPE_FLOAT: number;
  4578. /** HALF_FLOAT */
  4579. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4580. /** BYTE */
  4581. static readonly TEXTURETYPE_BYTE: number;
  4582. /** SHORT */
  4583. static readonly TEXTURETYPE_SHORT: number;
  4584. /** UNSIGNED_SHORT */
  4585. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4586. /** INT */
  4587. static readonly TEXTURETYPE_INT: number;
  4588. /** UNSIGNED_INT */
  4589. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4590. /** UNSIGNED_SHORT_4_4_4_4 */
  4591. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4592. /** UNSIGNED_SHORT_5_5_5_1 */
  4593. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4594. /** UNSIGNED_SHORT_5_6_5 */
  4595. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4596. /** UNSIGNED_INT_2_10_10_10_REV */
  4597. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4598. /** UNSIGNED_INT_24_8 */
  4599. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4600. /** UNSIGNED_INT_10F_11F_11F_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4602. /** UNSIGNED_INT_5_9_9_9_REV */
  4603. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4604. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4605. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4606. /** nearest is mag = nearest and min = nearest and mip = linear */
  4607. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4608. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4609. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4610. /** Trilinear is mag = linear and min = linear and mip = linear */
  4611. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4612. /** nearest is mag = nearest and min = nearest and mip = linear */
  4613. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4614. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4615. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4616. /** Trilinear is mag = linear and min = linear and mip = linear */
  4617. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4618. /** mag = nearest and min = nearest and mip = nearest */
  4619. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4620. /** mag = nearest and min = linear and mip = nearest */
  4621. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4622. /** mag = nearest and min = linear and mip = linear */
  4623. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4624. /** mag = nearest and min = linear and mip = none */
  4625. static readonly TEXTURE_NEAREST_LINEAR: number;
  4626. /** mag = nearest and min = nearest and mip = none */
  4627. static readonly TEXTURE_NEAREST_NEAREST: number;
  4628. /** mag = linear and min = nearest and mip = nearest */
  4629. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4630. /** mag = linear and min = nearest and mip = linear */
  4631. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4632. /** mag = linear and min = linear and mip = none */
  4633. static readonly TEXTURE_LINEAR_LINEAR: number;
  4634. /** mag = linear and min = nearest and mip = none */
  4635. static readonly TEXTURE_LINEAR_NEAREST: number;
  4636. /** Explicit coordinates mode */
  4637. static readonly TEXTURE_EXPLICIT_MODE: number;
  4638. /** Spherical coordinates mode */
  4639. static readonly TEXTURE_SPHERICAL_MODE: number;
  4640. /** Planar coordinates mode */
  4641. static readonly TEXTURE_PLANAR_MODE: number;
  4642. /** Cubic coordinates mode */
  4643. static readonly TEXTURE_CUBIC_MODE: number;
  4644. /** Projection coordinates mode */
  4645. static readonly TEXTURE_PROJECTION_MODE: number;
  4646. /** Skybox coordinates mode */
  4647. static readonly TEXTURE_SKYBOX_MODE: number;
  4648. /** Inverse Cubic coordinates mode */
  4649. static readonly TEXTURE_INVCUBIC_MODE: number;
  4650. /** Equirectangular coordinates mode */
  4651. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4652. /** Equirectangular Fixed coordinates mode */
  4653. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4654. /** Equirectangular Fixed Mirrored coordinates mode */
  4655. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4656. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4657. static readonly SCALEMODE_FLOOR: number;
  4658. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4659. static readonly SCALEMODE_NEAREST: number;
  4660. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4661. static readonly SCALEMODE_CEILING: number;
  4662. /**
  4663. * The dirty texture flag value
  4664. */
  4665. static readonly MATERIAL_TextureDirtyFlag: number;
  4666. /**
  4667. * The dirty light flag value
  4668. */
  4669. static readonly MATERIAL_LightDirtyFlag: number;
  4670. /**
  4671. * The dirty fresnel flag value
  4672. */
  4673. static readonly MATERIAL_FresnelDirtyFlag: number;
  4674. /**
  4675. * The dirty attribute flag value
  4676. */
  4677. static readonly MATERIAL_AttributesDirtyFlag: number;
  4678. /**
  4679. * The dirty misc flag value
  4680. */
  4681. static readonly MATERIAL_MiscDirtyFlag: number;
  4682. /**
  4683. * The all dirty flag value
  4684. */
  4685. static readonly MATERIAL_AllDirtyFlag: number;
  4686. /**
  4687. * Returns the triangle fill mode
  4688. */
  4689. static readonly MATERIAL_TriangleFillMode: number;
  4690. /**
  4691. * Returns the wireframe mode
  4692. */
  4693. static readonly MATERIAL_WireFrameFillMode: number;
  4694. /**
  4695. * Returns the point fill mode
  4696. */
  4697. static readonly MATERIAL_PointFillMode: number;
  4698. /**
  4699. * Returns the point list draw mode
  4700. */
  4701. static readonly MATERIAL_PointListDrawMode: number;
  4702. /**
  4703. * Returns the line list draw mode
  4704. */
  4705. static readonly MATERIAL_LineListDrawMode: number;
  4706. /**
  4707. * Returns the line loop draw mode
  4708. */
  4709. static readonly MATERIAL_LineLoopDrawMode: number;
  4710. /**
  4711. * Returns the line strip draw mode
  4712. */
  4713. static readonly MATERIAL_LineStripDrawMode: number;
  4714. /**
  4715. * Returns the triangle strip draw mode
  4716. */
  4717. static readonly MATERIAL_TriangleStripDrawMode: number;
  4718. /**
  4719. * Returns the triangle fan draw mode
  4720. */
  4721. static readonly MATERIAL_TriangleFanDrawMode: number;
  4722. /**
  4723. * Stores the clock-wise side orientation
  4724. */
  4725. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4726. /**
  4727. * Stores the counter clock-wise side orientation
  4728. */
  4729. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4730. /**
  4731. * Nothing
  4732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4733. */
  4734. static readonly ACTION_NothingTrigger: number;
  4735. /**
  4736. * On pick
  4737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4738. */
  4739. static readonly ACTION_OnPickTrigger: number;
  4740. /**
  4741. * On left pick
  4742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4743. */
  4744. static readonly ACTION_OnLeftPickTrigger: number;
  4745. /**
  4746. * On right pick
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnRightPickTrigger: number;
  4750. /**
  4751. * On center pick
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnCenterPickTrigger: number;
  4755. /**
  4756. * On pick down
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnPickDownTrigger: number;
  4760. /**
  4761. * On double pick
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnDoublePickTrigger: number;
  4765. /**
  4766. * On pick up
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnPickUpTrigger: number;
  4770. /**
  4771. * On pick out.
  4772. * This trigger will only be raised if you also declared a OnPickDown
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnPickOutTrigger: number;
  4776. /**
  4777. * On long press
  4778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4779. */
  4780. static readonly ACTION_OnLongPressTrigger: number;
  4781. /**
  4782. * On pointer over
  4783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4784. */
  4785. static readonly ACTION_OnPointerOverTrigger: number;
  4786. /**
  4787. * On pointer out
  4788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4789. */
  4790. static readonly ACTION_OnPointerOutTrigger: number;
  4791. /**
  4792. * On every frame
  4793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4794. */
  4795. static readonly ACTION_OnEveryFrameTrigger: number;
  4796. /**
  4797. * On intersection enter
  4798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4799. */
  4800. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4801. /**
  4802. * On intersection exit
  4803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4804. */
  4805. static readonly ACTION_OnIntersectionExitTrigger: number;
  4806. /**
  4807. * On key down
  4808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4809. */
  4810. static readonly ACTION_OnKeyDownTrigger: number;
  4811. /**
  4812. * On key up
  4813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4814. */
  4815. static readonly ACTION_OnKeyUpTrigger: number;
  4816. /**
  4817. * Billboard mode will only apply to Y axis
  4818. */
  4819. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4820. /**
  4821. * Billboard mode will apply to all axes
  4822. */
  4823. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4824. /**
  4825. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4826. */
  4827. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4828. /**
  4829. * Gets or sets base Assets URL
  4830. */
  4831. static PARTICLES_BaseAssetsUrl: string;
  4832. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4833. * Test order :
  4834. * Is the bounding sphere outside the frustum ?
  4835. * If not, are the bounding box vertices outside the frustum ?
  4836. * It not, then the cullable object is in the frustum.
  4837. */
  4838. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4839. /** Culling strategy : Bounding Sphere Only.
  4840. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4841. * It's also less accurate than the standard because some not visible objects can still be selected.
  4842. * Test : is the bounding sphere outside the frustum ?
  4843. * If not, then the cullable object is in the frustum.
  4844. */
  4845. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4846. /** Culling strategy : Optimistic Inclusion.
  4847. * This in an inclusion test first, then the standard exclusion test.
  4848. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4849. * 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.
  4850. * Anyway, it's as accurate as the standard strategy.
  4851. * Test :
  4852. * Is the cullable object bounding sphere center in the frustum ?
  4853. * If not, apply the default culling strategy.
  4854. */
  4855. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4856. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4857. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4858. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4859. * 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.
  4860. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4861. * Test :
  4862. * Is the cullable object bounding sphere center in the frustum ?
  4863. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4864. */
  4865. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4866. /**
  4867. * No logging while loading
  4868. */
  4869. static readonly SCENELOADER_NO_LOGGING: number;
  4870. /**
  4871. * Minimal logging while loading
  4872. */
  4873. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4874. /**
  4875. * Summary logging while loading
  4876. */
  4877. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4878. /**
  4879. * Detailled logging while loading
  4880. */
  4881. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4882. }
  4883. }
  4884. declare module "babylonjs/Misc/domManagement" {
  4885. /**
  4886. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4887. * Babylon.js
  4888. */
  4889. export class DomManagement {
  4890. /**
  4891. * Checks if the window object exists
  4892. * @returns true if the window object exists
  4893. */
  4894. static IsWindowObjectExist(): boolean;
  4895. /**
  4896. * Extracts text content from a DOM element hierarchy
  4897. * @param element defines the root element
  4898. * @returns a string
  4899. */
  4900. static GetDOMTextContent(element: HTMLElement): string;
  4901. }
  4902. }
  4903. declare module "babylonjs/Misc/logger" {
  4904. /**
  4905. * Logger used througouht the application to allow configuration of
  4906. * the log level required for the messages.
  4907. */
  4908. export class Logger {
  4909. /**
  4910. * No log
  4911. */
  4912. static readonly NoneLogLevel: number;
  4913. /**
  4914. * Only message logs
  4915. */
  4916. static readonly MessageLogLevel: number;
  4917. /**
  4918. * Only warning logs
  4919. */
  4920. static readonly WarningLogLevel: number;
  4921. /**
  4922. * Only error logs
  4923. */
  4924. static readonly ErrorLogLevel: number;
  4925. /**
  4926. * All logs
  4927. */
  4928. static readonly AllLogLevel: number;
  4929. private static _LogCache;
  4930. /**
  4931. * Gets a value indicating the number of loading errors
  4932. * @ignorenaming
  4933. */
  4934. static errorsCount: number;
  4935. /**
  4936. * Callback called when a new log is added
  4937. */
  4938. static OnNewCacheEntry: (entry: string) => void;
  4939. private static _AddLogEntry;
  4940. private static _FormatMessage;
  4941. private static _LogDisabled;
  4942. private static _LogEnabled;
  4943. private static _WarnDisabled;
  4944. private static _WarnEnabled;
  4945. private static _ErrorDisabled;
  4946. private static _ErrorEnabled;
  4947. /**
  4948. * Log a message to the console
  4949. */
  4950. static Log: (message: string) => void;
  4951. /**
  4952. * Write a warning message to the console
  4953. */
  4954. static Warn: (message: string) => void;
  4955. /**
  4956. * Write an error message to the console
  4957. */
  4958. static Error: (message: string) => void;
  4959. /**
  4960. * Gets current log cache (list of logs)
  4961. */
  4962. static readonly LogCache: string;
  4963. /**
  4964. * Clears the log cache
  4965. */
  4966. static ClearLogCache(): void;
  4967. /**
  4968. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4969. */
  4970. static LogLevels: number;
  4971. }
  4972. }
  4973. declare module "babylonjs/Misc/typeStore" {
  4974. /** @hidden */
  4975. export class _TypeStore {
  4976. /** @hidden */
  4977. static RegisteredTypes: {
  4978. [key: string]: Object;
  4979. };
  4980. /** @hidden */
  4981. static GetClass(fqdn: string): any;
  4982. }
  4983. }
  4984. declare module "babylonjs/Misc/deepCopier" {
  4985. /**
  4986. * Class containing a set of static utilities functions for deep copy.
  4987. */
  4988. export class DeepCopier {
  4989. /**
  4990. * Tries to copy an object by duplicating every property
  4991. * @param source defines the source object
  4992. * @param destination defines the target object
  4993. * @param doNotCopyList defines a list of properties to avoid
  4994. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4995. */
  4996. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4997. }
  4998. }
  4999. declare module "babylonjs/Misc/precisionDate" {
  5000. /**
  5001. * Class containing a set of static utilities functions for precision date
  5002. */
  5003. export class PrecisionDate {
  5004. /**
  5005. * Gets either window.performance.now() if supported or Date.now() else
  5006. */
  5007. static readonly Now: number;
  5008. }
  5009. }
  5010. declare module "babylonjs/Misc/devTools" {
  5011. /** @hidden */
  5012. export class _DevTools {
  5013. static WarnImport(name: string): string;
  5014. }
  5015. }
  5016. declare module "babylonjs/Misc/webRequest" {
  5017. /**
  5018. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5019. */
  5020. export class WebRequest {
  5021. private _xhr;
  5022. /**
  5023. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5024. * i.e. when loading files, where the server/service expects an Authorization header
  5025. */
  5026. static CustomRequestHeaders: {
  5027. [key: string]: string;
  5028. };
  5029. /**
  5030. * Add callback functions in this array to update all the requests before they get sent to the network
  5031. */
  5032. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5033. private _injectCustomRequestHeaders;
  5034. /**
  5035. * Gets or sets a function to be called when loading progress changes
  5036. */
  5037. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5038. /**
  5039. * Returns client's state
  5040. */
  5041. readonly readyState: number;
  5042. /**
  5043. * Returns client's status
  5044. */
  5045. readonly status: number;
  5046. /**
  5047. * Returns client's status as a text
  5048. */
  5049. readonly statusText: string;
  5050. /**
  5051. * Returns client's response
  5052. */
  5053. readonly response: any;
  5054. /**
  5055. * Returns client's response url
  5056. */
  5057. readonly responseURL: string;
  5058. /**
  5059. * Returns client's response as text
  5060. */
  5061. readonly responseText: string;
  5062. /**
  5063. * Gets or sets the expected response type
  5064. */
  5065. responseType: XMLHttpRequestResponseType;
  5066. /** @hidden */
  5067. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5068. /** @hidden */
  5069. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5070. /**
  5071. * Cancels any network activity
  5072. */
  5073. abort(): void;
  5074. /**
  5075. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5076. * @param body defines an optional request body
  5077. */
  5078. send(body?: Document | BodyInit | null): void;
  5079. /**
  5080. * Sets the request method, request URL
  5081. * @param method defines the method to use (GET, POST, etc..)
  5082. * @param url defines the url to connect with
  5083. */
  5084. open(method: string, url: string): void;
  5085. }
  5086. }
  5087. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5088. /**
  5089. * Class used to evalaute queries containing `and` and `or` operators
  5090. */
  5091. export class AndOrNotEvaluator {
  5092. /**
  5093. * Evaluate a query
  5094. * @param query defines the query to evaluate
  5095. * @param evaluateCallback defines the callback used to filter result
  5096. * @returns true if the query matches
  5097. */
  5098. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5099. private static _HandleParenthesisContent;
  5100. private static _SimplifyNegation;
  5101. }
  5102. }
  5103. declare module "babylonjs/Misc/tags" {
  5104. /**
  5105. * Class used to store custom tags
  5106. */
  5107. export class Tags {
  5108. /**
  5109. * Adds support for tags on the given object
  5110. * @param obj defines the object to use
  5111. */
  5112. static EnableFor(obj: any): void;
  5113. /**
  5114. * Removes tags support
  5115. * @param obj defines the object to use
  5116. */
  5117. static DisableFor(obj: any): void;
  5118. /**
  5119. * Gets a boolean indicating if the given object has tags
  5120. * @param obj defines the object to use
  5121. * @returns a boolean
  5122. */
  5123. static HasTags(obj: any): boolean;
  5124. /**
  5125. * Gets the tags available on a given object
  5126. * @param obj defines the object to use
  5127. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5128. * @returns the tags
  5129. */
  5130. static GetTags(obj: any, asString?: boolean): any;
  5131. /**
  5132. * Adds tags to an object
  5133. * @param obj defines the object to use
  5134. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5135. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5136. */
  5137. static AddTagsTo(obj: any, tagsString: string): void;
  5138. /**
  5139. * @hidden
  5140. */
  5141. static _AddTagTo(obj: any, tag: string): void;
  5142. /**
  5143. * Removes specific tags from a specific object
  5144. * @param obj defines the object to use
  5145. * @param tagsString defines the tags to remove
  5146. */
  5147. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5148. /**
  5149. * @hidden
  5150. */
  5151. static _RemoveTagFrom(obj: any, tag: string): void;
  5152. /**
  5153. * Defines if tags hosted on an object match a given query
  5154. * @param obj defines the object to use
  5155. * @param tagsQuery defines the tag query
  5156. * @returns a boolean
  5157. */
  5158. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5159. }
  5160. }
  5161. declare module "babylonjs/Materials/materialDefines" {
  5162. /**
  5163. * Manages the defines for the Material
  5164. */
  5165. export class MaterialDefines {
  5166. /** @hidden */
  5167. protected _keys: string[];
  5168. private _isDirty;
  5169. /** @hidden */
  5170. _renderId: number;
  5171. /** @hidden */
  5172. _areLightsDirty: boolean;
  5173. /** @hidden */
  5174. _areAttributesDirty: boolean;
  5175. /** @hidden */
  5176. _areTexturesDirty: boolean;
  5177. /** @hidden */
  5178. _areFresnelDirty: boolean;
  5179. /** @hidden */
  5180. _areMiscDirty: boolean;
  5181. /** @hidden */
  5182. _areImageProcessingDirty: boolean;
  5183. /** @hidden */
  5184. _normals: boolean;
  5185. /** @hidden */
  5186. _uvs: boolean;
  5187. /** @hidden */
  5188. _needNormals: boolean;
  5189. /** @hidden */
  5190. _needUVs: boolean;
  5191. [id: string]: any;
  5192. /**
  5193. * Specifies if the material needs to be re-calculated
  5194. */
  5195. readonly isDirty: boolean;
  5196. /**
  5197. * Marks the material to indicate that it has been re-calculated
  5198. */
  5199. markAsProcessed(): void;
  5200. /**
  5201. * Marks the material to indicate that it needs to be re-calculated
  5202. */
  5203. markAsUnprocessed(): void;
  5204. /**
  5205. * Marks the material to indicate all of its defines need to be re-calculated
  5206. */
  5207. markAllAsDirty(): void;
  5208. /**
  5209. * Marks the material to indicate that image processing needs to be re-calculated
  5210. */
  5211. markAsImageProcessingDirty(): void;
  5212. /**
  5213. * Marks the material to indicate the lights need to be re-calculated
  5214. */
  5215. markAsLightDirty(): void;
  5216. /**
  5217. * Marks the attribute state as changed
  5218. */
  5219. markAsAttributesDirty(): void;
  5220. /**
  5221. * Marks the texture state as changed
  5222. */
  5223. markAsTexturesDirty(): void;
  5224. /**
  5225. * Marks the fresnel state as changed
  5226. */
  5227. markAsFresnelDirty(): void;
  5228. /**
  5229. * Marks the misc state as changed
  5230. */
  5231. markAsMiscDirty(): void;
  5232. /**
  5233. * Rebuilds the material defines
  5234. */
  5235. rebuild(): void;
  5236. /**
  5237. * Specifies if two material defines are equal
  5238. * @param other - A material define instance to compare to
  5239. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5240. */
  5241. isEqual(other: MaterialDefines): boolean;
  5242. /**
  5243. * Clones this instance's defines to another instance
  5244. * @param other - material defines to clone values to
  5245. */
  5246. cloneTo(other: MaterialDefines): void;
  5247. /**
  5248. * Resets the material define values
  5249. */
  5250. reset(): void;
  5251. /**
  5252. * Converts the material define values to a string
  5253. * @returns - String of material define information
  5254. */
  5255. toString(): string;
  5256. }
  5257. }
  5258. declare module "babylonjs/Engines/IPipelineContext" {
  5259. /**
  5260. * Class used to store and describe the pipeline context associated with an effect
  5261. */
  5262. export interface IPipelineContext {
  5263. /**
  5264. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5265. */
  5266. isAsync: boolean;
  5267. /**
  5268. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5269. */
  5270. isReady: boolean;
  5271. /** @hidden */
  5272. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5273. }
  5274. }
  5275. declare module "babylonjs/Meshes/dataBuffer" {
  5276. /**
  5277. * Class used to store gfx data (like WebGLBuffer)
  5278. */
  5279. export class DataBuffer {
  5280. /**
  5281. * Gets or sets the number of objects referencing this buffer
  5282. */
  5283. references: number;
  5284. /** Gets or sets the size of the underlying buffer */
  5285. capacity: number;
  5286. /**
  5287. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5288. */
  5289. is32Bits: boolean;
  5290. /**
  5291. * Gets the underlying buffer
  5292. */
  5293. readonly underlyingResource: any;
  5294. }
  5295. }
  5296. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  5297. /** @hidden */
  5298. export interface IShaderProcessor {
  5299. attributeProcessor?: (attribute: string) => string;
  5300. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5301. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5302. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5303. }
  5304. }
  5305. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  5306. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  5307. /** @hidden */
  5308. export interface ProcessingOptions {
  5309. defines: string[];
  5310. indexParameters: any;
  5311. isFragment: boolean;
  5312. shouldUseHighPrecisionShader: boolean;
  5313. supportsUniformBuffers: boolean;
  5314. shadersRepository: string;
  5315. includesShadersStore: {
  5316. [key: string]: string;
  5317. };
  5318. processor?: IShaderProcessor;
  5319. version: string;
  5320. }
  5321. }
  5322. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  5323. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5324. /** @hidden */
  5325. export class ShaderCodeNode {
  5326. line: string;
  5327. children: ShaderCodeNode[];
  5328. additionalDefineKey?: string;
  5329. additionalDefineValue?: string;
  5330. isValid(preprocessors: {
  5331. [key: string]: string;
  5332. }): boolean;
  5333. process(preprocessors: {
  5334. [key: string]: string;
  5335. }, options: ProcessingOptions): string;
  5336. private _lineStartsWith;
  5337. }
  5338. }
  5339. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  5340. /** @hidden */
  5341. export class ShaderCodeCursor {
  5342. private _lines;
  5343. lineIndex: number;
  5344. readonly currentLine: string;
  5345. readonly canRead: boolean;
  5346. lines: string[];
  5347. }
  5348. }
  5349. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  5350. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5351. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5352. /** @hidden */
  5353. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5354. process(preprocessors: {
  5355. [key: string]: string;
  5356. }, options: ProcessingOptions): string;
  5357. }
  5358. }
  5359. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  5360. /** @hidden */
  5361. export class ShaderDefineExpression {
  5362. isTrue(preprocessors: {
  5363. [key: string]: string;
  5364. }): boolean;
  5365. }
  5366. }
  5367. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  5368. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5369. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5370. /** @hidden */
  5371. export class ShaderCodeTestNode extends ShaderCodeNode {
  5372. testExpression: ShaderDefineExpression;
  5373. isValid(preprocessors: {
  5374. [key: string]: string;
  5375. }): boolean;
  5376. }
  5377. }
  5378. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  5379. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5380. /** @hidden */
  5381. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5382. define: string;
  5383. not: boolean;
  5384. constructor(define: string, not?: boolean);
  5385. isTrue(preprocessors: {
  5386. [key: string]: string;
  5387. }): boolean;
  5388. }
  5389. }
  5390. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  5391. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5392. /** @hidden */
  5393. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5394. leftOperand: ShaderDefineExpression;
  5395. rightOperand: ShaderDefineExpression;
  5396. isTrue(preprocessors: {
  5397. [key: string]: string;
  5398. }): boolean;
  5399. }
  5400. }
  5401. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  5402. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5403. /** @hidden */
  5404. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5405. leftOperand: ShaderDefineExpression;
  5406. rightOperand: ShaderDefineExpression;
  5407. isTrue(preprocessors: {
  5408. [key: string]: string;
  5409. }): boolean;
  5410. }
  5411. }
  5412. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5413. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5414. /** @hidden */
  5415. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5416. define: string;
  5417. operand: string;
  5418. testValue: string;
  5419. constructor(define: string, operand: string, testValue: string);
  5420. isTrue(preprocessors: {
  5421. [key: string]: string;
  5422. }): boolean;
  5423. }
  5424. }
  5425. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5426. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5427. /** @hidden */
  5428. export class ShaderProcessor {
  5429. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5430. private static _ProcessPrecision;
  5431. private static _ExtractOperation;
  5432. private static _BuildSubExpression;
  5433. private static _BuildExpression;
  5434. private static _MoveCursorWithinIf;
  5435. private static _MoveCursor;
  5436. private static _EvaluatePreProcessors;
  5437. private static _PreparePreProcessors;
  5438. private static _ProcessShaderConversion;
  5439. private static _ProcessIncludes;
  5440. }
  5441. }
  5442. declare module "babylonjs/Misc/performanceMonitor" {
  5443. /**
  5444. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5445. */
  5446. export class PerformanceMonitor {
  5447. private _enabled;
  5448. private _rollingFrameTime;
  5449. private _lastFrameTimeMs;
  5450. /**
  5451. * constructor
  5452. * @param frameSampleSize The number of samples required to saturate the sliding window
  5453. */
  5454. constructor(frameSampleSize?: number);
  5455. /**
  5456. * Samples current frame
  5457. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5458. */
  5459. sampleFrame(timeMs?: number): void;
  5460. /**
  5461. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5462. */
  5463. readonly averageFrameTime: number;
  5464. /**
  5465. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5466. */
  5467. readonly averageFrameTimeVariance: number;
  5468. /**
  5469. * Returns the frame time of the most recent frame
  5470. */
  5471. readonly instantaneousFrameTime: number;
  5472. /**
  5473. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5474. */
  5475. readonly averageFPS: number;
  5476. /**
  5477. * Returns the average framerate in frames per second using the most recent frame time
  5478. */
  5479. readonly instantaneousFPS: number;
  5480. /**
  5481. * Returns true if enough samples have been taken to completely fill the sliding window
  5482. */
  5483. readonly isSaturated: boolean;
  5484. /**
  5485. * Enables contributions to the sliding window sample set
  5486. */
  5487. enable(): void;
  5488. /**
  5489. * Disables contributions to the sliding window sample set
  5490. * Samples will not be interpolated over the disabled period
  5491. */
  5492. disable(): void;
  5493. /**
  5494. * Returns true if sampling is enabled
  5495. */
  5496. readonly isEnabled: boolean;
  5497. /**
  5498. * Resets performance monitor
  5499. */
  5500. reset(): void;
  5501. }
  5502. /**
  5503. * RollingAverage
  5504. *
  5505. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5506. */
  5507. export class RollingAverage {
  5508. /**
  5509. * Current average
  5510. */
  5511. average: number;
  5512. /**
  5513. * Current variance
  5514. */
  5515. variance: number;
  5516. protected _samples: Array<number>;
  5517. protected _sampleCount: number;
  5518. protected _pos: number;
  5519. protected _m2: number;
  5520. /**
  5521. * constructor
  5522. * @param length The number of samples required to saturate the sliding window
  5523. */
  5524. constructor(length: number);
  5525. /**
  5526. * Adds a sample to the sample set
  5527. * @param v The sample value
  5528. */
  5529. add(v: number): void;
  5530. /**
  5531. * Returns previously added values or null if outside of history or outside the sliding window domain
  5532. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5533. * @return Value previously recorded with add() or null if outside of range
  5534. */
  5535. history(i: number): number;
  5536. /**
  5537. * Returns true if enough samples have been taken to completely fill the sliding window
  5538. * @return true if sample-set saturated
  5539. */
  5540. isSaturated(): boolean;
  5541. /**
  5542. * Resets the rolling average (equivalent to 0 samples taken so far)
  5543. */
  5544. reset(): void;
  5545. /**
  5546. * Wraps a value around the sample range boundaries
  5547. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5548. * @return Wrapped position in sample range
  5549. */
  5550. protected _wrapPosition(i: number): number;
  5551. }
  5552. }
  5553. declare module "babylonjs/Misc/stringDictionary" {
  5554. import { Nullable } from "babylonjs/types";
  5555. /**
  5556. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5557. * The underlying implementation relies on an associative array to ensure the best performances.
  5558. * The value can be anything including 'null' but except 'undefined'
  5559. */
  5560. export class StringDictionary<T> {
  5561. /**
  5562. * This will clear this dictionary and copy the content from the 'source' one.
  5563. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5564. * @param source the dictionary to take the content from and copy to this dictionary
  5565. */
  5566. copyFrom(source: StringDictionary<T>): void;
  5567. /**
  5568. * Get a value based from its key
  5569. * @param key the given key to get the matching value from
  5570. * @return the value if found, otherwise undefined is returned
  5571. */
  5572. get(key: string): T | undefined;
  5573. /**
  5574. * Get a value from its key or add it if it doesn't exist.
  5575. * This method will ensure you that a given key/data will be present in the dictionary.
  5576. * @param key the given key to get the matching value from
  5577. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5578. * The factory will only be invoked if there's no data for the given key.
  5579. * @return the value corresponding to the key.
  5580. */
  5581. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5582. /**
  5583. * Get a value from its key if present in the dictionary otherwise add it
  5584. * @param key the key to get the value from
  5585. * @param val if there's no such key/value pair in the dictionary add it with this value
  5586. * @return the value corresponding to the key
  5587. */
  5588. getOrAdd(key: string, val: T): T;
  5589. /**
  5590. * Check if there's a given key in the dictionary
  5591. * @param key the key to check for
  5592. * @return true if the key is present, false otherwise
  5593. */
  5594. contains(key: string): boolean;
  5595. /**
  5596. * Add a new key and its corresponding value
  5597. * @param key the key to add
  5598. * @param value the value corresponding to the key
  5599. * @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
  5600. */
  5601. add(key: string, value: T): boolean;
  5602. /**
  5603. * Update a specific value associated to a key
  5604. * @param key defines the key to use
  5605. * @param value defines the value to store
  5606. * @returns true if the value was updated (or false if the key was not found)
  5607. */
  5608. set(key: string, value: T): boolean;
  5609. /**
  5610. * Get the element of the given key and remove it from the dictionary
  5611. * @param key defines the key to search
  5612. * @returns the value associated with the key or null if not found
  5613. */
  5614. getAndRemove(key: string): Nullable<T>;
  5615. /**
  5616. * Remove a key/value from the dictionary.
  5617. * @param key the key to remove
  5618. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5619. */
  5620. remove(key: string): boolean;
  5621. /**
  5622. * Clear the whole content of the dictionary
  5623. */
  5624. clear(): void;
  5625. /**
  5626. * Gets the current count
  5627. */
  5628. readonly count: number;
  5629. /**
  5630. * Execute a callback on each key/val of the dictionary.
  5631. * Note that you can remove any element in this dictionary in the callback implementation
  5632. * @param callback the callback to execute on a given key/value pair
  5633. */
  5634. forEach(callback: (key: string, val: T) => void): void;
  5635. /**
  5636. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5637. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5638. * Note that you can remove any element in this dictionary in the callback implementation
  5639. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5640. * @returns the first item
  5641. */
  5642. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5643. private _count;
  5644. private _data;
  5645. }
  5646. }
  5647. declare module "babylonjs/Misc/promise" {
  5648. /**
  5649. * Helper class that provides a small promise polyfill
  5650. */
  5651. export class PromisePolyfill {
  5652. /**
  5653. * Static function used to check if the polyfill is required
  5654. * If this is the case then the function will inject the polyfill to window.Promise
  5655. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5656. */
  5657. static Apply(force?: boolean): void;
  5658. }
  5659. }
  5660. declare module "babylonjs/Meshes/buffer" {
  5661. import { Nullable, DataArray } from "babylonjs/types";
  5662. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5663. /**
  5664. * Class used to store data that will be store in GPU memory
  5665. */
  5666. export class Buffer {
  5667. private _engine;
  5668. private _buffer;
  5669. /** @hidden */
  5670. _data: Nullable<DataArray>;
  5671. private _updatable;
  5672. private _instanced;
  5673. /**
  5674. * Gets the byte stride.
  5675. */
  5676. readonly byteStride: number;
  5677. /**
  5678. * Constructor
  5679. * @param engine the engine
  5680. * @param data the data to use for this buffer
  5681. * @param updatable whether the data is updatable
  5682. * @param stride the stride (optional)
  5683. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5684. * @param instanced whether the buffer is instanced (optional)
  5685. * @param useBytes set to true if the stride in in bytes (optional)
  5686. */
  5687. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5688. /**
  5689. * Create a new VertexBuffer based on the current buffer
  5690. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5691. * @param offset defines offset in the buffer (0 by default)
  5692. * @param size defines the size in floats of attributes (position is 3 for instance)
  5693. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5694. * @param instanced defines if the vertex buffer contains indexed data
  5695. * @param useBytes defines if the offset and stride are in bytes
  5696. * @returns the new vertex buffer
  5697. */
  5698. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5699. /**
  5700. * Gets a boolean indicating if the Buffer is updatable?
  5701. * @returns true if the buffer is updatable
  5702. */
  5703. isUpdatable(): boolean;
  5704. /**
  5705. * Gets current buffer's data
  5706. * @returns a DataArray or null
  5707. */
  5708. getData(): Nullable<DataArray>;
  5709. /**
  5710. * Gets underlying native buffer
  5711. * @returns underlying native buffer
  5712. */
  5713. getBuffer(): Nullable<DataBuffer>;
  5714. /**
  5715. * Gets the stride in float32 units (i.e. byte stride / 4).
  5716. * May not be an integer if the byte stride is not divisible by 4.
  5717. * DEPRECATED. Use byteStride instead.
  5718. * @returns the stride in float32 units
  5719. */
  5720. getStrideSize(): number;
  5721. /**
  5722. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5723. * @param data defines the data to store
  5724. */
  5725. create(data?: Nullable<DataArray>): void;
  5726. /** @hidden */
  5727. _rebuild(): void;
  5728. /**
  5729. * Update current buffer data
  5730. * @param data defines the data to store
  5731. */
  5732. update(data: DataArray): void;
  5733. /**
  5734. * Updates the data directly.
  5735. * @param data the new data
  5736. * @param offset the new offset
  5737. * @param vertexCount the vertex count (optional)
  5738. * @param useBytes set to true if the offset is in bytes
  5739. */
  5740. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5741. /**
  5742. * Release all resources
  5743. */
  5744. dispose(): void;
  5745. }
  5746. /**
  5747. * Specialized buffer used to store vertex data
  5748. */
  5749. export class VertexBuffer {
  5750. /** @hidden */
  5751. _buffer: Buffer;
  5752. private _kind;
  5753. private _size;
  5754. private _ownsBuffer;
  5755. private _instanced;
  5756. private _instanceDivisor;
  5757. /**
  5758. * The byte type.
  5759. */
  5760. static readonly BYTE: number;
  5761. /**
  5762. * The unsigned byte type.
  5763. */
  5764. static readonly UNSIGNED_BYTE: number;
  5765. /**
  5766. * The short type.
  5767. */
  5768. static readonly SHORT: number;
  5769. /**
  5770. * The unsigned short type.
  5771. */
  5772. static readonly UNSIGNED_SHORT: number;
  5773. /**
  5774. * The integer type.
  5775. */
  5776. static readonly INT: number;
  5777. /**
  5778. * The unsigned integer type.
  5779. */
  5780. static readonly UNSIGNED_INT: number;
  5781. /**
  5782. * The float type.
  5783. */
  5784. static readonly FLOAT: number;
  5785. /**
  5786. * Gets or sets the instance divisor when in instanced mode
  5787. */
  5788. instanceDivisor: number;
  5789. /**
  5790. * Gets the byte stride.
  5791. */
  5792. readonly byteStride: number;
  5793. /**
  5794. * Gets the byte offset.
  5795. */
  5796. readonly byteOffset: number;
  5797. /**
  5798. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5799. */
  5800. readonly normalized: boolean;
  5801. /**
  5802. * Gets the data type of each component in the array.
  5803. */
  5804. readonly type: number;
  5805. /**
  5806. * Constructor
  5807. * @param engine the engine
  5808. * @param data the data to use for this vertex buffer
  5809. * @param kind the vertex buffer kind
  5810. * @param updatable whether the data is updatable
  5811. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5812. * @param stride the stride (optional)
  5813. * @param instanced whether the buffer is instanced (optional)
  5814. * @param offset the offset of the data (optional)
  5815. * @param size the number of components (optional)
  5816. * @param type the type of the component (optional)
  5817. * @param normalized whether the data contains normalized data (optional)
  5818. * @param useBytes set to true if stride and offset are in bytes (optional)
  5819. */
  5820. 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);
  5821. /** @hidden */
  5822. _rebuild(): void;
  5823. /**
  5824. * Returns the kind of the VertexBuffer (string)
  5825. * @returns a string
  5826. */
  5827. getKind(): string;
  5828. /**
  5829. * Gets a boolean indicating if the VertexBuffer is updatable?
  5830. * @returns true if the buffer is updatable
  5831. */
  5832. isUpdatable(): boolean;
  5833. /**
  5834. * Gets current buffer's data
  5835. * @returns a DataArray or null
  5836. */
  5837. getData(): Nullable<DataArray>;
  5838. /**
  5839. * Gets underlying native buffer
  5840. * @returns underlying native buffer
  5841. */
  5842. getBuffer(): Nullable<DataBuffer>;
  5843. /**
  5844. * Gets the stride in float32 units (i.e. byte stride / 4).
  5845. * May not be an integer if the byte stride is not divisible by 4.
  5846. * DEPRECATED. Use byteStride instead.
  5847. * @returns the stride in float32 units
  5848. */
  5849. getStrideSize(): number;
  5850. /**
  5851. * Returns the offset as a multiple of the type byte length.
  5852. * DEPRECATED. Use byteOffset instead.
  5853. * @returns the offset in bytes
  5854. */
  5855. getOffset(): number;
  5856. /**
  5857. * Returns the number of components per vertex attribute (integer)
  5858. * @returns the size in float
  5859. */
  5860. getSize(): number;
  5861. /**
  5862. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5863. * @returns true if this buffer is instanced
  5864. */
  5865. getIsInstanced(): boolean;
  5866. /**
  5867. * Returns the instancing divisor, zero for non-instanced (integer).
  5868. * @returns a number
  5869. */
  5870. getInstanceDivisor(): number;
  5871. /**
  5872. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5873. * @param data defines the data to store
  5874. */
  5875. create(data?: DataArray): void;
  5876. /**
  5877. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5878. * This function will create a new buffer if the current one is not updatable
  5879. * @param data defines the data to store
  5880. */
  5881. update(data: DataArray): void;
  5882. /**
  5883. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5884. * Returns the directly updated WebGLBuffer.
  5885. * @param data the new data
  5886. * @param offset the new offset
  5887. * @param useBytes set to true if the offset is in bytes
  5888. */
  5889. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5890. /**
  5891. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5892. */
  5893. dispose(): void;
  5894. /**
  5895. * Enumerates each value of this vertex buffer as numbers.
  5896. * @param count the number of values to enumerate
  5897. * @param callback the callback function called for each value
  5898. */
  5899. forEach(count: number, callback: (value: number, index: number) => void): void;
  5900. /**
  5901. * Positions
  5902. */
  5903. static readonly PositionKind: string;
  5904. /**
  5905. * Normals
  5906. */
  5907. static readonly NormalKind: string;
  5908. /**
  5909. * Tangents
  5910. */
  5911. static readonly TangentKind: string;
  5912. /**
  5913. * Texture coordinates
  5914. */
  5915. static readonly UVKind: string;
  5916. /**
  5917. * Texture coordinates 2
  5918. */
  5919. static readonly UV2Kind: string;
  5920. /**
  5921. * Texture coordinates 3
  5922. */
  5923. static readonly UV3Kind: string;
  5924. /**
  5925. * Texture coordinates 4
  5926. */
  5927. static readonly UV4Kind: string;
  5928. /**
  5929. * Texture coordinates 5
  5930. */
  5931. static readonly UV5Kind: string;
  5932. /**
  5933. * Texture coordinates 6
  5934. */
  5935. static readonly UV6Kind: string;
  5936. /**
  5937. * Colors
  5938. */
  5939. static readonly ColorKind: string;
  5940. /**
  5941. * Matrix indices (for bones)
  5942. */
  5943. static readonly MatricesIndicesKind: string;
  5944. /**
  5945. * Matrix weights (for bones)
  5946. */
  5947. static readonly MatricesWeightsKind: string;
  5948. /**
  5949. * Additional matrix indices (for bones)
  5950. */
  5951. static readonly MatricesIndicesExtraKind: string;
  5952. /**
  5953. * Additional matrix weights (for bones)
  5954. */
  5955. static readonly MatricesWeightsExtraKind: string;
  5956. /**
  5957. * Deduces the stride given a kind.
  5958. * @param kind The kind string to deduce
  5959. * @returns The deduced stride
  5960. */
  5961. static DeduceStride(kind: string): number;
  5962. /**
  5963. * Gets the byte length of the given type.
  5964. * @param type the type
  5965. * @returns the number of bytes
  5966. */
  5967. static GetTypeByteLength(type: number): number;
  5968. /**
  5969. * Enumerates each value of the given parameters as numbers.
  5970. * @param data the data to enumerate
  5971. * @param byteOffset the byte offset of the data
  5972. * @param byteStride the byte stride of the data
  5973. * @param componentCount the number of components per element
  5974. * @param componentType the type of the component
  5975. * @param count the total number of components
  5976. * @param normalized whether the data is normalized
  5977. * @param callback the callback function called for each value
  5978. */
  5979. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5980. private static _GetFloatValue;
  5981. }
  5982. }
  5983. declare module "babylonjs/Maths/sphericalPolynomial" {
  5984. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5985. /**
  5986. * Class representing spherical harmonics coefficients to the 3rd degree
  5987. */
  5988. export class SphericalHarmonics {
  5989. /**
  5990. * Defines whether or not the harmonics have been prescaled for rendering.
  5991. */
  5992. preScaled: boolean;
  5993. /**
  5994. * The l0,0 coefficients of the spherical harmonics
  5995. */
  5996. l00: Vector3;
  5997. /**
  5998. * The l1,-1 coefficients of the spherical harmonics
  5999. */
  6000. l1_1: Vector3;
  6001. /**
  6002. * The l1,0 coefficients of the spherical harmonics
  6003. */
  6004. l10: Vector3;
  6005. /**
  6006. * The l1,1 coefficients of the spherical harmonics
  6007. */
  6008. l11: Vector3;
  6009. /**
  6010. * The l2,-2 coefficients of the spherical harmonics
  6011. */
  6012. l2_2: Vector3;
  6013. /**
  6014. * The l2,-1 coefficients of the spherical harmonics
  6015. */
  6016. l2_1: Vector3;
  6017. /**
  6018. * The l2,0 coefficients of the spherical harmonics
  6019. */
  6020. l20: Vector3;
  6021. /**
  6022. * The l2,1 coefficients of the spherical harmonics
  6023. */
  6024. l21: Vector3;
  6025. /**
  6026. * The l2,2 coefficients of the spherical harmonics
  6027. */
  6028. l22: Vector3;
  6029. /**
  6030. * Adds a light to the spherical harmonics
  6031. * @param direction the direction of the light
  6032. * @param color the color of the light
  6033. * @param deltaSolidAngle the delta solid angle of the light
  6034. */
  6035. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6036. /**
  6037. * Scales the spherical harmonics by the given amount
  6038. * @param scale the amount to scale
  6039. */
  6040. scaleInPlace(scale: number): void;
  6041. /**
  6042. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6043. *
  6044. * ```
  6045. * E_lm = A_l * L_lm
  6046. * ```
  6047. *
  6048. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6049. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6050. * the scaling factors are given in equation 9.
  6051. */
  6052. convertIncidentRadianceToIrradiance(): void;
  6053. /**
  6054. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6055. *
  6056. * ```
  6057. * L = (1/pi) * E * rho
  6058. * ```
  6059. *
  6060. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6061. */
  6062. convertIrradianceToLambertianRadiance(): void;
  6063. /**
  6064. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6065. * required operations at run time.
  6066. *
  6067. * This is simply done by scaling back the SH with Ylm constants parameter.
  6068. * The trigonometric part being applied by the shader at run time.
  6069. */
  6070. preScaleForRendering(): void;
  6071. /**
  6072. * Constructs a spherical harmonics from an array.
  6073. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6074. * @returns the spherical harmonics
  6075. */
  6076. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6077. /**
  6078. * Gets the spherical harmonics from polynomial
  6079. * @param polynomial the spherical polynomial
  6080. * @returns the spherical harmonics
  6081. */
  6082. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6083. }
  6084. /**
  6085. * Class representing spherical polynomial coefficients to the 3rd degree
  6086. */
  6087. export class SphericalPolynomial {
  6088. private _harmonics;
  6089. /**
  6090. * The spherical harmonics used to create the polynomials.
  6091. */
  6092. readonly preScaledHarmonics: SphericalHarmonics;
  6093. /**
  6094. * The x coefficients of the spherical polynomial
  6095. */
  6096. x: Vector3;
  6097. /**
  6098. * The y coefficients of the spherical polynomial
  6099. */
  6100. y: Vector3;
  6101. /**
  6102. * The z coefficients of the spherical polynomial
  6103. */
  6104. z: Vector3;
  6105. /**
  6106. * The xx coefficients of the spherical polynomial
  6107. */
  6108. xx: Vector3;
  6109. /**
  6110. * The yy coefficients of the spherical polynomial
  6111. */
  6112. yy: Vector3;
  6113. /**
  6114. * The zz coefficients of the spherical polynomial
  6115. */
  6116. zz: Vector3;
  6117. /**
  6118. * The xy coefficients of the spherical polynomial
  6119. */
  6120. xy: Vector3;
  6121. /**
  6122. * The yz coefficients of the spherical polynomial
  6123. */
  6124. yz: Vector3;
  6125. /**
  6126. * The zx coefficients of the spherical polynomial
  6127. */
  6128. zx: Vector3;
  6129. /**
  6130. * Adds an ambient color to the spherical polynomial
  6131. * @param color the color to add
  6132. */
  6133. addAmbient(color: Color3): void;
  6134. /**
  6135. * Scales the spherical polynomial by the given amount
  6136. * @param scale the amount to scale
  6137. */
  6138. scaleInPlace(scale: number): void;
  6139. /**
  6140. * Gets the spherical polynomial from harmonics
  6141. * @param harmonics the spherical harmonics
  6142. * @returns the spherical polynomial
  6143. */
  6144. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6145. /**
  6146. * Constructs a spherical polynomial from an array.
  6147. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6148. * @returns the spherical polynomial
  6149. */
  6150. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6151. }
  6152. }
  6153. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  6154. import { Nullable } from "babylonjs/types";
  6155. /**
  6156. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6157. */
  6158. export interface CubeMapInfo {
  6159. /**
  6160. * The pixel array for the front face.
  6161. * This is stored in format, left to right, up to down format.
  6162. */
  6163. front: Nullable<ArrayBufferView>;
  6164. /**
  6165. * The pixel array for the back face.
  6166. * This is stored in format, left to right, up to down format.
  6167. */
  6168. back: Nullable<ArrayBufferView>;
  6169. /**
  6170. * The pixel array for the left face.
  6171. * This is stored in format, left to right, up to down format.
  6172. */
  6173. left: Nullable<ArrayBufferView>;
  6174. /**
  6175. * The pixel array for the right face.
  6176. * This is stored in format, left to right, up to down format.
  6177. */
  6178. right: Nullable<ArrayBufferView>;
  6179. /**
  6180. * The pixel array for the up face.
  6181. * This is stored in format, left to right, up to down format.
  6182. */
  6183. up: Nullable<ArrayBufferView>;
  6184. /**
  6185. * The pixel array for the down face.
  6186. * This is stored in format, left to right, up to down format.
  6187. */
  6188. down: Nullable<ArrayBufferView>;
  6189. /**
  6190. * The size of the cubemap stored.
  6191. *
  6192. * Each faces will be size * size pixels.
  6193. */
  6194. size: number;
  6195. /**
  6196. * The format of the texture.
  6197. *
  6198. * RGBA, RGB.
  6199. */
  6200. format: number;
  6201. /**
  6202. * The type of the texture data.
  6203. *
  6204. * UNSIGNED_INT, FLOAT.
  6205. */
  6206. type: number;
  6207. /**
  6208. * Specifies whether the texture is in gamma space.
  6209. */
  6210. gammaSpace: boolean;
  6211. }
  6212. /**
  6213. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6214. */
  6215. export class PanoramaToCubeMapTools {
  6216. private static FACE_FRONT;
  6217. private static FACE_BACK;
  6218. private static FACE_RIGHT;
  6219. private static FACE_LEFT;
  6220. private static FACE_DOWN;
  6221. private static FACE_UP;
  6222. /**
  6223. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6224. *
  6225. * @param float32Array The source data.
  6226. * @param inputWidth The width of the input panorama.
  6227. * @param inputHeight The height of the input panorama.
  6228. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6229. * @return The cubemap data
  6230. */
  6231. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6232. private static CreateCubemapTexture;
  6233. private static CalcProjectionSpherical;
  6234. }
  6235. }
  6236. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6237. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6238. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6239. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6240. /**
  6241. * Helper class dealing with the extraction of spherical polynomial dataArray
  6242. * from a cube map.
  6243. */
  6244. export class CubeMapToSphericalPolynomialTools {
  6245. private static FileFaces;
  6246. /**
  6247. * Converts a texture to the according Spherical Polynomial data.
  6248. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6249. *
  6250. * @param texture The texture to extract the information from.
  6251. * @return The Spherical Polynomial data.
  6252. */
  6253. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6254. /**
  6255. * Converts a cubemap to the according Spherical Polynomial data.
  6256. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6257. *
  6258. * @param cubeInfo The Cube map to extract the information from.
  6259. * @return The Spherical Polynomial data.
  6260. */
  6261. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6262. }
  6263. }
  6264. declare module "babylonjs/Engines/engineStore" {
  6265. import { Nullable } from "babylonjs/types";
  6266. import { Engine } from "babylonjs/Engines/engine";
  6267. import { Scene } from "babylonjs/scene";
  6268. /**
  6269. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6270. * during the life time of the application.
  6271. */
  6272. export class EngineStore {
  6273. /** Gets the list of created engines */
  6274. static Instances: import("babylonjs/Engines/engine").Engine[];
  6275. /** @hidden */
  6276. static _LastCreatedScene: Nullable<Scene>;
  6277. /**
  6278. * Gets the latest created engine
  6279. */
  6280. static readonly LastCreatedEngine: Nullable<Engine>;
  6281. /**
  6282. * Gets the latest created scene
  6283. */
  6284. static readonly LastCreatedScene: Nullable<Scene>;
  6285. }
  6286. }
  6287. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6288. /**
  6289. * Define options used to create a render target texture
  6290. */
  6291. export class RenderTargetCreationOptions {
  6292. /**
  6293. * Specifies is mipmaps must be generated
  6294. */
  6295. generateMipMaps?: boolean;
  6296. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6297. generateDepthBuffer?: boolean;
  6298. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6299. generateStencilBuffer?: boolean;
  6300. /** Defines texture type (int by default) */
  6301. type?: number;
  6302. /** Defines sampling mode (trilinear by default) */
  6303. samplingMode?: number;
  6304. /** Defines format (RGBA by default) */
  6305. format?: number;
  6306. }
  6307. }
  6308. declare module "babylonjs/States/alphaCullingState" {
  6309. /**
  6310. * @hidden
  6311. **/
  6312. export class _AlphaState {
  6313. private _isAlphaBlendDirty;
  6314. private _isBlendFunctionParametersDirty;
  6315. private _isBlendEquationParametersDirty;
  6316. private _isBlendConstantsDirty;
  6317. private _alphaBlend;
  6318. private _blendFunctionParameters;
  6319. private _blendEquationParameters;
  6320. private _blendConstants;
  6321. /**
  6322. * Initializes the state.
  6323. */
  6324. constructor();
  6325. readonly isDirty: boolean;
  6326. alphaBlend: boolean;
  6327. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6328. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6329. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6330. reset(): void;
  6331. apply(gl: WebGLRenderingContext): void;
  6332. }
  6333. }
  6334. declare module "babylonjs/States/depthCullingState" {
  6335. import { Nullable } from "babylonjs/types";
  6336. /**
  6337. * @hidden
  6338. **/
  6339. export class _DepthCullingState {
  6340. private _isDepthTestDirty;
  6341. private _isDepthMaskDirty;
  6342. private _isDepthFuncDirty;
  6343. private _isCullFaceDirty;
  6344. private _isCullDirty;
  6345. private _isZOffsetDirty;
  6346. private _isFrontFaceDirty;
  6347. private _depthTest;
  6348. private _depthMask;
  6349. private _depthFunc;
  6350. private _cull;
  6351. private _cullFace;
  6352. private _zOffset;
  6353. private _frontFace;
  6354. /**
  6355. * Initializes the state.
  6356. */
  6357. constructor();
  6358. readonly isDirty: boolean;
  6359. zOffset: number;
  6360. cullFace: Nullable<number>;
  6361. cull: Nullable<boolean>;
  6362. depthFunc: Nullable<number>;
  6363. depthMask: boolean;
  6364. depthTest: boolean;
  6365. frontFace: Nullable<number>;
  6366. reset(): void;
  6367. apply(gl: WebGLRenderingContext): void;
  6368. }
  6369. }
  6370. declare module "babylonjs/States/stencilState" {
  6371. /**
  6372. * @hidden
  6373. **/
  6374. export class _StencilState {
  6375. /** 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 */
  6376. static readonly ALWAYS: number;
  6377. /** Passed to stencilOperation to specify that stencil value must be kept */
  6378. static readonly KEEP: number;
  6379. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6380. static readonly REPLACE: number;
  6381. private _isStencilTestDirty;
  6382. private _isStencilMaskDirty;
  6383. private _isStencilFuncDirty;
  6384. private _isStencilOpDirty;
  6385. private _stencilTest;
  6386. private _stencilMask;
  6387. private _stencilFunc;
  6388. private _stencilFuncRef;
  6389. private _stencilFuncMask;
  6390. private _stencilOpStencilFail;
  6391. private _stencilOpDepthFail;
  6392. private _stencilOpStencilDepthPass;
  6393. readonly isDirty: boolean;
  6394. stencilFunc: number;
  6395. stencilFuncRef: number;
  6396. stencilFuncMask: number;
  6397. stencilOpStencilFail: number;
  6398. stencilOpDepthFail: number;
  6399. stencilOpStencilDepthPass: number;
  6400. stencilMask: number;
  6401. stencilTest: boolean;
  6402. constructor();
  6403. reset(): void;
  6404. apply(gl: WebGLRenderingContext): void;
  6405. }
  6406. }
  6407. declare module "babylonjs/States/index" {
  6408. export * from "babylonjs/States/alphaCullingState";
  6409. export * from "babylonjs/States/depthCullingState";
  6410. export * from "babylonjs/States/stencilState";
  6411. }
  6412. declare module "babylonjs/Instrumentation/timeToken" {
  6413. import { Nullable } from "babylonjs/types";
  6414. /**
  6415. * @hidden
  6416. **/
  6417. export class _TimeToken {
  6418. _startTimeQuery: Nullable<WebGLQuery>;
  6419. _endTimeQuery: Nullable<WebGLQuery>;
  6420. _timeElapsedQuery: Nullable<WebGLQuery>;
  6421. _timeElapsedQueryEnded: boolean;
  6422. }
  6423. }
  6424. declare module "babylonjs/Materials/Textures/internalTexture" {
  6425. import { Observable } from "babylonjs/Misc/observable";
  6426. import { Nullable, int } from "babylonjs/types";
  6427. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6428. import { Engine } from "babylonjs/Engines/engine";
  6429. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6430. /**
  6431. * Class used to store data associated with WebGL texture data for the engine
  6432. * This class should not be used directly
  6433. */
  6434. export class InternalTexture {
  6435. /** @hidden */
  6436. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6437. /**
  6438. * The source of the texture data is unknown
  6439. */
  6440. static DATASOURCE_UNKNOWN: number;
  6441. /**
  6442. * Texture data comes from an URL
  6443. */
  6444. static DATASOURCE_URL: number;
  6445. /**
  6446. * Texture data is only used for temporary storage
  6447. */
  6448. static DATASOURCE_TEMP: number;
  6449. /**
  6450. * Texture data comes from raw data (ArrayBuffer)
  6451. */
  6452. static DATASOURCE_RAW: number;
  6453. /**
  6454. * Texture content is dynamic (video or dynamic texture)
  6455. */
  6456. static DATASOURCE_DYNAMIC: number;
  6457. /**
  6458. * Texture content is generated by rendering to it
  6459. */
  6460. static DATASOURCE_RENDERTARGET: number;
  6461. /**
  6462. * Texture content is part of a multi render target process
  6463. */
  6464. static DATASOURCE_MULTIRENDERTARGET: number;
  6465. /**
  6466. * Texture data comes from a cube data file
  6467. */
  6468. static DATASOURCE_CUBE: number;
  6469. /**
  6470. * Texture data comes from a raw cube data
  6471. */
  6472. static DATASOURCE_CUBERAW: number;
  6473. /**
  6474. * Texture data come from a prefiltered cube data file
  6475. */
  6476. static DATASOURCE_CUBEPREFILTERED: number;
  6477. /**
  6478. * Texture content is raw 3D data
  6479. */
  6480. static DATASOURCE_RAW3D: number;
  6481. /**
  6482. * Texture content is a depth texture
  6483. */
  6484. static DATASOURCE_DEPTHTEXTURE: number;
  6485. /**
  6486. * Texture data comes from a raw cube data encoded with RGBD
  6487. */
  6488. static DATASOURCE_CUBERAW_RGBD: number;
  6489. /**
  6490. * Defines if the texture is ready
  6491. */
  6492. isReady: boolean;
  6493. /**
  6494. * Defines if the texture is a cube texture
  6495. */
  6496. isCube: boolean;
  6497. /**
  6498. * Defines if the texture contains 3D data
  6499. */
  6500. is3D: boolean;
  6501. /**
  6502. * Defines if the texture contains multiview data
  6503. */
  6504. isMultiview: boolean;
  6505. /**
  6506. * Gets the URL used to load this texture
  6507. */
  6508. url: string;
  6509. /**
  6510. * Gets the sampling mode of the texture
  6511. */
  6512. samplingMode: number;
  6513. /**
  6514. * Gets a boolean indicating if the texture needs mipmaps generation
  6515. */
  6516. generateMipMaps: boolean;
  6517. /**
  6518. * Gets the number of samples used by the texture (WebGL2+ only)
  6519. */
  6520. samples: number;
  6521. /**
  6522. * Gets the type of the texture (int, float...)
  6523. */
  6524. type: number;
  6525. /**
  6526. * Gets the format of the texture (RGB, RGBA...)
  6527. */
  6528. format: number;
  6529. /**
  6530. * Observable called when the texture is loaded
  6531. */
  6532. onLoadedObservable: Observable<InternalTexture>;
  6533. /**
  6534. * Gets the width of the texture
  6535. */
  6536. width: number;
  6537. /**
  6538. * Gets the height of the texture
  6539. */
  6540. height: number;
  6541. /**
  6542. * Gets the depth of the texture
  6543. */
  6544. depth: number;
  6545. /**
  6546. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6547. */
  6548. baseWidth: number;
  6549. /**
  6550. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6551. */
  6552. baseHeight: number;
  6553. /**
  6554. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6555. */
  6556. baseDepth: number;
  6557. /**
  6558. * Gets a boolean indicating if the texture is inverted on Y axis
  6559. */
  6560. invertY: boolean;
  6561. /** @hidden */
  6562. _invertVScale: boolean;
  6563. /** @hidden */
  6564. _associatedChannel: number;
  6565. /** @hidden */
  6566. _dataSource: number;
  6567. /** @hidden */
  6568. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6569. /** @hidden */
  6570. _bufferView: Nullable<ArrayBufferView>;
  6571. /** @hidden */
  6572. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6573. /** @hidden */
  6574. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6575. /** @hidden */
  6576. _size: number;
  6577. /** @hidden */
  6578. _extension: string;
  6579. /** @hidden */
  6580. _files: Nullable<string[]>;
  6581. /** @hidden */
  6582. _workingCanvas: Nullable<HTMLCanvasElement>;
  6583. /** @hidden */
  6584. _workingContext: Nullable<CanvasRenderingContext2D>;
  6585. /** @hidden */
  6586. _framebuffer: Nullable<WebGLFramebuffer>;
  6587. /** @hidden */
  6588. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6589. /** @hidden */
  6590. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6591. /** @hidden */
  6592. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6593. /** @hidden */
  6594. _attachments: Nullable<number[]>;
  6595. /** @hidden */
  6596. _cachedCoordinatesMode: Nullable<number>;
  6597. /** @hidden */
  6598. _cachedWrapU: Nullable<number>;
  6599. /** @hidden */
  6600. _cachedWrapV: Nullable<number>;
  6601. /** @hidden */
  6602. _cachedWrapR: Nullable<number>;
  6603. /** @hidden */
  6604. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6605. /** @hidden */
  6606. _isDisabled: boolean;
  6607. /** @hidden */
  6608. _compression: Nullable<string>;
  6609. /** @hidden */
  6610. _generateStencilBuffer: boolean;
  6611. /** @hidden */
  6612. _generateDepthBuffer: boolean;
  6613. /** @hidden */
  6614. _comparisonFunction: number;
  6615. /** @hidden */
  6616. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6617. /** @hidden */
  6618. _lodGenerationScale: number;
  6619. /** @hidden */
  6620. _lodGenerationOffset: number;
  6621. /** @hidden */
  6622. _colorTextureArray: Nullable<WebGLTexture>;
  6623. /** @hidden */
  6624. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6625. /** @hidden */
  6626. _lodTextureHigh: Nullable<BaseTexture>;
  6627. /** @hidden */
  6628. _lodTextureMid: Nullable<BaseTexture>;
  6629. /** @hidden */
  6630. _lodTextureLow: Nullable<BaseTexture>;
  6631. /** @hidden */
  6632. _isRGBD: boolean;
  6633. /** @hidden */
  6634. _linearSpecularLOD: boolean;
  6635. /** @hidden */
  6636. _irradianceTexture: Nullable<BaseTexture>;
  6637. /** @hidden */
  6638. _webGLTexture: Nullable<WebGLTexture>;
  6639. /** @hidden */
  6640. _references: number;
  6641. private _engine;
  6642. /**
  6643. * Gets the Engine the texture belongs to.
  6644. * @returns The babylon engine
  6645. */
  6646. getEngine(): Engine;
  6647. /**
  6648. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6649. */
  6650. readonly dataSource: number;
  6651. /**
  6652. * Creates a new InternalTexture
  6653. * @param engine defines the engine to use
  6654. * @param dataSource defines the type of data that will be used
  6655. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6656. */
  6657. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6658. /**
  6659. * Increments the number of references (ie. the number of Texture that point to it)
  6660. */
  6661. incrementReferences(): void;
  6662. /**
  6663. * Change the size of the texture (not the size of the content)
  6664. * @param width defines the new width
  6665. * @param height defines the new height
  6666. * @param depth defines the new depth (1 by default)
  6667. */
  6668. updateSize(width: int, height: int, depth?: int): void;
  6669. /** @hidden */
  6670. _rebuild(): void;
  6671. /** @hidden */
  6672. _swapAndDie(target: InternalTexture): void;
  6673. /**
  6674. * Dispose the current allocated resources
  6675. */
  6676. dispose(): void;
  6677. }
  6678. }
  6679. declare module "babylonjs/Animations/easing" {
  6680. /**
  6681. * This represents the main contract an easing function should follow.
  6682. * Easing functions are used throughout the animation system.
  6683. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6684. */
  6685. export interface IEasingFunction {
  6686. /**
  6687. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6688. * of the easing function.
  6689. * The link below provides some of the most common examples of easing functions.
  6690. * @see https://easings.net/
  6691. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6692. * @returns the corresponding value on the curve defined by the easing function
  6693. */
  6694. ease(gradient: number): number;
  6695. }
  6696. /**
  6697. * Base class used for every default easing function.
  6698. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6699. */
  6700. export class EasingFunction implements IEasingFunction {
  6701. /**
  6702. * Interpolation follows the mathematical formula associated with the easing function.
  6703. */
  6704. static readonly EASINGMODE_EASEIN: number;
  6705. /**
  6706. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6707. */
  6708. static readonly EASINGMODE_EASEOUT: number;
  6709. /**
  6710. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6711. */
  6712. static readonly EASINGMODE_EASEINOUT: number;
  6713. private _easingMode;
  6714. /**
  6715. * Sets the easing mode of the current function.
  6716. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6717. */
  6718. setEasingMode(easingMode: number): void;
  6719. /**
  6720. * Gets the current easing mode.
  6721. * @returns the easing mode
  6722. */
  6723. getEasingMode(): number;
  6724. /**
  6725. * @hidden
  6726. */
  6727. easeInCore(gradient: number): number;
  6728. /**
  6729. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6730. * of the easing function.
  6731. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6732. * @returns the corresponding value on the curve defined by the easing function
  6733. */
  6734. ease(gradient: number): number;
  6735. }
  6736. /**
  6737. * Easing function with a circle shape (see link below).
  6738. * @see https://easings.net/#easeInCirc
  6739. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6740. */
  6741. export class CircleEase extends EasingFunction implements IEasingFunction {
  6742. /** @hidden */
  6743. easeInCore(gradient: number): number;
  6744. }
  6745. /**
  6746. * Easing function with a ease back shape (see link below).
  6747. * @see https://easings.net/#easeInBack
  6748. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6749. */
  6750. export class BackEase extends EasingFunction implements IEasingFunction {
  6751. /** Defines the amplitude of the function */
  6752. amplitude: number;
  6753. /**
  6754. * Instantiates a back ease easing
  6755. * @see https://easings.net/#easeInBack
  6756. * @param amplitude Defines the amplitude of the function
  6757. */
  6758. constructor(
  6759. /** Defines the amplitude of the function */
  6760. amplitude?: number);
  6761. /** @hidden */
  6762. easeInCore(gradient: number): number;
  6763. }
  6764. /**
  6765. * Easing function with a bouncing shape (see link below).
  6766. * @see https://easings.net/#easeInBounce
  6767. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6768. */
  6769. export class BounceEase extends EasingFunction implements IEasingFunction {
  6770. /** Defines the number of bounces */
  6771. bounces: number;
  6772. /** Defines the amplitude of the bounce */
  6773. bounciness: number;
  6774. /**
  6775. * Instantiates a bounce easing
  6776. * @see https://easings.net/#easeInBounce
  6777. * @param bounces Defines the number of bounces
  6778. * @param bounciness Defines the amplitude of the bounce
  6779. */
  6780. constructor(
  6781. /** Defines the number of bounces */
  6782. bounces?: number,
  6783. /** Defines the amplitude of the bounce */
  6784. bounciness?: number);
  6785. /** @hidden */
  6786. easeInCore(gradient: number): number;
  6787. }
  6788. /**
  6789. * Easing function with a power of 3 shape (see link below).
  6790. * @see https://easings.net/#easeInCubic
  6791. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6792. */
  6793. export class CubicEase extends EasingFunction implements IEasingFunction {
  6794. /** @hidden */
  6795. easeInCore(gradient: number): number;
  6796. }
  6797. /**
  6798. * Easing function with an elastic shape (see link below).
  6799. * @see https://easings.net/#easeInElastic
  6800. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6801. */
  6802. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6803. /** Defines the number of oscillations*/
  6804. oscillations: number;
  6805. /** Defines the amplitude of the oscillations*/
  6806. springiness: number;
  6807. /**
  6808. * Instantiates an elastic easing function
  6809. * @see https://easings.net/#easeInElastic
  6810. * @param oscillations Defines the number of oscillations
  6811. * @param springiness Defines the amplitude of the oscillations
  6812. */
  6813. constructor(
  6814. /** Defines the number of oscillations*/
  6815. oscillations?: number,
  6816. /** Defines the amplitude of the oscillations*/
  6817. springiness?: number);
  6818. /** @hidden */
  6819. easeInCore(gradient: number): number;
  6820. }
  6821. /**
  6822. * Easing function with an exponential shape (see link below).
  6823. * @see https://easings.net/#easeInExpo
  6824. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6825. */
  6826. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6827. /** Defines the exponent of the function */
  6828. exponent: number;
  6829. /**
  6830. * Instantiates an exponential easing function
  6831. * @see https://easings.net/#easeInExpo
  6832. * @param exponent Defines the exponent of the function
  6833. */
  6834. constructor(
  6835. /** Defines the exponent of the function */
  6836. exponent?: number);
  6837. /** @hidden */
  6838. easeInCore(gradient: number): number;
  6839. }
  6840. /**
  6841. * Easing function with a power shape (see link below).
  6842. * @see https://easings.net/#easeInQuad
  6843. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6844. */
  6845. export class PowerEase extends EasingFunction implements IEasingFunction {
  6846. /** Defines the power of the function */
  6847. power: number;
  6848. /**
  6849. * Instantiates an power base easing function
  6850. * @see https://easings.net/#easeInQuad
  6851. * @param power Defines the power of the function
  6852. */
  6853. constructor(
  6854. /** Defines the power of the function */
  6855. power?: number);
  6856. /** @hidden */
  6857. easeInCore(gradient: number): number;
  6858. }
  6859. /**
  6860. * Easing function with a power of 2 shape (see link below).
  6861. * @see https://easings.net/#easeInQuad
  6862. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6863. */
  6864. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6865. /** @hidden */
  6866. easeInCore(gradient: number): number;
  6867. }
  6868. /**
  6869. * Easing function with a power of 4 shape (see link below).
  6870. * @see https://easings.net/#easeInQuart
  6871. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6872. */
  6873. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6874. /** @hidden */
  6875. easeInCore(gradient: number): number;
  6876. }
  6877. /**
  6878. * Easing function with a power of 5 shape (see link below).
  6879. * @see https://easings.net/#easeInQuint
  6880. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6881. */
  6882. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6883. /** @hidden */
  6884. easeInCore(gradient: number): number;
  6885. }
  6886. /**
  6887. * Easing function with a sin shape (see link below).
  6888. * @see https://easings.net/#easeInSine
  6889. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6890. */
  6891. export class SineEase extends EasingFunction implements IEasingFunction {
  6892. /** @hidden */
  6893. easeInCore(gradient: number): number;
  6894. }
  6895. /**
  6896. * Easing function with a bezier shape (see link below).
  6897. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6898. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6899. */
  6900. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6901. /** Defines the x component of the start tangent in the bezier curve */
  6902. x1: number;
  6903. /** Defines the y component of the start tangent in the bezier curve */
  6904. y1: number;
  6905. /** Defines the x component of the end tangent in the bezier curve */
  6906. x2: number;
  6907. /** Defines the y component of the end tangent in the bezier curve */
  6908. y2: number;
  6909. /**
  6910. * Instantiates a bezier function
  6911. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6912. * @param x1 Defines the x component of the start tangent in the bezier curve
  6913. * @param y1 Defines the y component of the start tangent in the bezier curve
  6914. * @param x2 Defines the x component of the end tangent in the bezier curve
  6915. * @param y2 Defines the y component of the end tangent in the bezier curve
  6916. */
  6917. constructor(
  6918. /** Defines the x component of the start tangent in the bezier curve */
  6919. x1?: number,
  6920. /** Defines the y component of the start tangent in the bezier curve */
  6921. y1?: number,
  6922. /** Defines the x component of the end tangent in the bezier curve */
  6923. x2?: number,
  6924. /** Defines the y component of the end tangent in the bezier curve */
  6925. y2?: number);
  6926. /** @hidden */
  6927. easeInCore(gradient: number): number;
  6928. }
  6929. }
  6930. declare module "babylonjs/Animations/animationKey" {
  6931. /**
  6932. * Defines an interface which represents an animation key frame
  6933. */
  6934. export interface IAnimationKey {
  6935. /**
  6936. * Frame of the key frame
  6937. */
  6938. frame: number;
  6939. /**
  6940. * Value at the specifies key frame
  6941. */
  6942. value: any;
  6943. /**
  6944. * The input tangent for the cubic hermite spline
  6945. */
  6946. inTangent?: any;
  6947. /**
  6948. * The output tangent for the cubic hermite spline
  6949. */
  6950. outTangent?: any;
  6951. /**
  6952. * The animation interpolation type
  6953. */
  6954. interpolation?: AnimationKeyInterpolation;
  6955. }
  6956. /**
  6957. * Enum for the animation key frame interpolation type
  6958. */
  6959. export enum AnimationKeyInterpolation {
  6960. /**
  6961. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6962. */
  6963. STEP = 1
  6964. }
  6965. }
  6966. declare module "babylonjs/Animations/animationRange" {
  6967. /**
  6968. * Represents the range of an animation
  6969. */
  6970. export class AnimationRange {
  6971. /**The name of the animation range**/
  6972. name: string;
  6973. /**The starting frame of the animation */
  6974. from: number;
  6975. /**The ending frame of the animation*/
  6976. to: number;
  6977. /**
  6978. * Initializes the range of an animation
  6979. * @param name The name of the animation range
  6980. * @param from The starting frame of the animation
  6981. * @param to The ending frame of the animation
  6982. */
  6983. constructor(
  6984. /**The name of the animation range**/
  6985. name: string,
  6986. /**The starting frame of the animation */
  6987. from: number,
  6988. /**The ending frame of the animation*/
  6989. to: number);
  6990. /**
  6991. * Makes a copy of the animation range
  6992. * @returns A copy of the animation range
  6993. */
  6994. clone(): AnimationRange;
  6995. }
  6996. }
  6997. declare module "babylonjs/Animations/animationEvent" {
  6998. /**
  6999. * Composed of a frame, and an action function
  7000. */
  7001. export class AnimationEvent {
  7002. /** The frame for which the event is triggered **/
  7003. frame: number;
  7004. /** The event to perform when triggered **/
  7005. action: (currentFrame: number) => void;
  7006. /** Specifies if the event should be triggered only once**/
  7007. onlyOnce?: boolean | undefined;
  7008. /**
  7009. * Specifies if the animation event is done
  7010. */
  7011. isDone: boolean;
  7012. /**
  7013. * Initializes the animation event
  7014. * @param frame The frame for which the event is triggered
  7015. * @param action The event to perform when triggered
  7016. * @param onlyOnce Specifies if the event should be triggered only once
  7017. */
  7018. constructor(
  7019. /** The frame for which the event is triggered **/
  7020. frame: number,
  7021. /** The event to perform when triggered **/
  7022. action: (currentFrame: number) => void,
  7023. /** Specifies if the event should be triggered only once**/
  7024. onlyOnce?: boolean | undefined);
  7025. /** @hidden */
  7026. _clone(): AnimationEvent;
  7027. }
  7028. }
  7029. declare module "babylonjs/Behaviors/behavior" {
  7030. import { Nullable } from "babylonjs/types";
  7031. /**
  7032. * Interface used to define a behavior
  7033. */
  7034. export interface Behavior<T> {
  7035. /** gets or sets behavior's name */
  7036. name: string;
  7037. /**
  7038. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7039. */
  7040. init(): void;
  7041. /**
  7042. * Called when the behavior is attached to a target
  7043. * @param target defines the target where the behavior is attached to
  7044. */
  7045. attach(target: T): void;
  7046. /**
  7047. * Called when the behavior is detached from its target
  7048. */
  7049. detach(): void;
  7050. }
  7051. /**
  7052. * Interface implemented by classes supporting behaviors
  7053. */
  7054. export interface IBehaviorAware<T> {
  7055. /**
  7056. * Attach a behavior
  7057. * @param behavior defines the behavior to attach
  7058. * @returns the current host
  7059. */
  7060. addBehavior(behavior: Behavior<T>): T;
  7061. /**
  7062. * Remove a behavior from the current object
  7063. * @param behavior defines the behavior to detach
  7064. * @returns the current host
  7065. */
  7066. removeBehavior(behavior: Behavior<T>): T;
  7067. /**
  7068. * Gets a behavior using its name to search
  7069. * @param name defines the name to search
  7070. * @returns the behavior or null if not found
  7071. */
  7072. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7073. }
  7074. }
  7075. declare module "babylonjs/Collisions/intersectionInfo" {
  7076. import { Nullable } from "babylonjs/types";
  7077. /**
  7078. * @hidden
  7079. */
  7080. export class IntersectionInfo {
  7081. bu: Nullable<number>;
  7082. bv: Nullable<number>;
  7083. distance: number;
  7084. faceId: number;
  7085. subMeshId: number;
  7086. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7087. }
  7088. }
  7089. declare module "babylonjs/Culling/boundingSphere" {
  7090. import { DeepImmutable } from "babylonjs/types";
  7091. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7092. /**
  7093. * Class used to store bounding sphere information
  7094. */
  7095. export class BoundingSphere {
  7096. /**
  7097. * Gets the center of the bounding sphere in local space
  7098. */
  7099. readonly center: Vector3;
  7100. /**
  7101. * Radius of the bounding sphere in local space
  7102. */
  7103. radius: number;
  7104. /**
  7105. * Gets the center of the bounding sphere in world space
  7106. */
  7107. readonly centerWorld: Vector3;
  7108. /**
  7109. * Radius of the bounding sphere in world space
  7110. */
  7111. radiusWorld: number;
  7112. /**
  7113. * Gets the minimum vector in local space
  7114. */
  7115. readonly minimum: Vector3;
  7116. /**
  7117. * Gets the maximum vector in local space
  7118. */
  7119. readonly maximum: Vector3;
  7120. private _worldMatrix;
  7121. private static readonly TmpVector3;
  7122. /**
  7123. * Creates a new bounding sphere
  7124. * @param min defines the minimum vector (in local space)
  7125. * @param max defines the maximum vector (in local space)
  7126. * @param worldMatrix defines the new world matrix
  7127. */
  7128. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7129. /**
  7130. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7131. * @param min defines the new minimum vector (in local space)
  7132. * @param max defines the new maximum vector (in local space)
  7133. * @param worldMatrix defines the new world matrix
  7134. */
  7135. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7136. /**
  7137. * Scale the current bounding sphere by applying a scale factor
  7138. * @param factor defines the scale factor to apply
  7139. * @returns the current bounding box
  7140. */
  7141. scale(factor: number): BoundingSphere;
  7142. /**
  7143. * Gets the world matrix of the bounding box
  7144. * @returns a matrix
  7145. */
  7146. getWorldMatrix(): DeepImmutable<Matrix>;
  7147. /** @hidden */
  7148. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7149. /**
  7150. * Tests if the bounding sphere is intersecting the frustum planes
  7151. * @param frustumPlanes defines the frustum planes to test
  7152. * @returns true if there is an intersection
  7153. */
  7154. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7155. /**
  7156. * Tests if the bounding sphere center is in between the frustum planes.
  7157. * Used for optimistic fast inclusion.
  7158. * @param frustumPlanes defines the frustum planes to test
  7159. * @returns true if the sphere center is in between the frustum planes
  7160. */
  7161. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7162. /**
  7163. * Tests if a point is inside the bounding sphere
  7164. * @param point defines the point to test
  7165. * @returns true if the point is inside the bounding sphere
  7166. */
  7167. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7168. /**
  7169. * Checks if two sphere intersct
  7170. * @param sphere0 sphere 0
  7171. * @param sphere1 sphere 1
  7172. * @returns true if the speres intersect
  7173. */
  7174. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7175. }
  7176. }
  7177. declare module "babylonjs/Culling/boundingBox" {
  7178. import { DeepImmutable } from "babylonjs/types";
  7179. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7180. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7181. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7182. /**
  7183. * Class used to store bounding box information
  7184. */
  7185. export class BoundingBox implements ICullable {
  7186. /**
  7187. * Gets the 8 vectors representing the bounding box in local space
  7188. */
  7189. readonly vectors: Vector3[];
  7190. /**
  7191. * Gets the center of the bounding box in local space
  7192. */
  7193. readonly center: Vector3;
  7194. /**
  7195. * Gets the center of the bounding box in world space
  7196. */
  7197. readonly centerWorld: Vector3;
  7198. /**
  7199. * Gets the extend size in local space
  7200. */
  7201. readonly extendSize: Vector3;
  7202. /**
  7203. * Gets the extend size in world space
  7204. */
  7205. readonly extendSizeWorld: Vector3;
  7206. /**
  7207. * Gets the OBB (object bounding box) directions
  7208. */
  7209. readonly directions: Vector3[];
  7210. /**
  7211. * Gets the 8 vectors representing the bounding box in world space
  7212. */
  7213. readonly vectorsWorld: Vector3[];
  7214. /**
  7215. * Gets the minimum vector in world space
  7216. */
  7217. readonly minimumWorld: Vector3;
  7218. /**
  7219. * Gets the maximum vector in world space
  7220. */
  7221. readonly maximumWorld: Vector3;
  7222. /**
  7223. * Gets the minimum vector in local space
  7224. */
  7225. readonly minimum: Vector3;
  7226. /**
  7227. * Gets the maximum vector in local space
  7228. */
  7229. readonly maximum: Vector3;
  7230. private _worldMatrix;
  7231. private static readonly TmpVector3;
  7232. /**
  7233. * @hidden
  7234. */
  7235. _tag: number;
  7236. /**
  7237. * Creates a new bounding box
  7238. * @param min defines the minimum vector (in local space)
  7239. * @param max defines the maximum vector (in local space)
  7240. * @param worldMatrix defines the new world matrix
  7241. */
  7242. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7243. /**
  7244. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7245. * @param min defines the new minimum vector (in local space)
  7246. * @param max defines the new maximum vector (in local space)
  7247. * @param worldMatrix defines the new world matrix
  7248. */
  7249. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7250. /**
  7251. * Scale the current bounding box by applying a scale factor
  7252. * @param factor defines the scale factor to apply
  7253. * @returns the current bounding box
  7254. */
  7255. scale(factor: number): BoundingBox;
  7256. /**
  7257. * Gets the world matrix of the bounding box
  7258. * @returns a matrix
  7259. */
  7260. getWorldMatrix(): DeepImmutable<Matrix>;
  7261. /** @hidden */
  7262. _update(world: DeepImmutable<Matrix>): void;
  7263. /**
  7264. * Tests if the bounding box is intersecting the frustum planes
  7265. * @param frustumPlanes defines the frustum planes to test
  7266. * @returns true if there is an intersection
  7267. */
  7268. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7269. /**
  7270. * Tests if the bounding box is entirely inside the frustum planes
  7271. * @param frustumPlanes defines the frustum planes to test
  7272. * @returns true if there is an inclusion
  7273. */
  7274. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7275. /**
  7276. * Tests if a point is inside the bounding box
  7277. * @param point defines the point to test
  7278. * @returns true if the point is inside the bounding box
  7279. */
  7280. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7281. /**
  7282. * Tests if the bounding box intersects with a bounding sphere
  7283. * @param sphere defines the sphere to test
  7284. * @returns true if there is an intersection
  7285. */
  7286. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7287. /**
  7288. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7289. * @param min defines the min vector to use
  7290. * @param max defines the max vector to use
  7291. * @returns true if there is an intersection
  7292. */
  7293. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7294. /**
  7295. * Tests if two bounding boxes are intersections
  7296. * @param box0 defines the first box to test
  7297. * @param box1 defines the second box to test
  7298. * @returns true if there is an intersection
  7299. */
  7300. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7301. /**
  7302. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7303. * @param minPoint defines the minimum vector of the bounding box
  7304. * @param maxPoint defines the maximum vector of the bounding box
  7305. * @param sphereCenter defines the sphere center
  7306. * @param sphereRadius defines the sphere radius
  7307. * @returns true if there is an intersection
  7308. */
  7309. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7310. /**
  7311. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7312. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7313. * @param frustumPlanes defines the frustum planes to test
  7314. * @return true if there is an inclusion
  7315. */
  7316. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7317. /**
  7318. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7319. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7320. * @param frustumPlanes defines the frustum planes to test
  7321. * @return true if there is an intersection
  7322. */
  7323. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7324. }
  7325. }
  7326. declare module "babylonjs/Collisions/collider" {
  7327. import { Nullable, IndicesArray } from "babylonjs/types";
  7328. import { Vector3, Plane } from "babylonjs/Maths/math";
  7329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7330. /** @hidden */
  7331. export class Collider {
  7332. /** Define if a collision was found */
  7333. collisionFound: boolean;
  7334. /**
  7335. * Define last intersection point in local space
  7336. */
  7337. intersectionPoint: Vector3;
  7338. /**
  7339. * Define last collided mesh
  7340. */
  7341. collidedMesh: Nullable<AbstractMesh>;
  7342. private _collisionPoint;
  7343. private _planeIntersectionPoint;
  7344. private _tempVector;
  7345. private _tempVector2;
  7346. private _tempVector3;
  7347. private _tempVector4;
  7348. private _edge;
  7349. private _baseToVertex;
  7350. private _destinationPoint;
  7351. private _slidePlaneNormal;
  7352. private _displacementVector;
  7353. /** @hidden */
  7354. _radius: Vector3;
  7355. /** @hidden */
  7356. _retry: number;
  7357. private _velocity;
  7358. private _basePoint;
  7359. private _epsilon;
  7360. /** @hidden */
  7361. _velocityWorldLength: number;
  7362. /** @hidden */
  7363. _basePointWorld: Vector3;
  7364. private _velocityWorld;
  7365. private _normalizedVelocity;
  7366. /** @hidden */
  7367. _initialVelocity: Vector3;
  7368. /** @hidden */
  7369. _initialPosition: Vector3;
  7370. private _nearestDistance;
  7371. private _collisionMask;
  7372. collisionMask: number;
  7373. /**
  7374. * Gets the plane normal used to compute the sliding response (in local space)
  7375. */
  7376. readonly slidePlaneNormal: Vector3;
  7377. /** @hidden */
  7378. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7379. /** @hidden */
  7380. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7381. /** @hidden */
  7382. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7383. /** @hidden */
  7384. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7385. /** @hidden */
  7386. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7387. /** @hidden */
  7388. _getResponse(pos: Vector3, vel: Vector3): void;
  7389. }
  7390. }
  7391. declare module "babylonjs/Culling/boundingInfo" {
  7392. import { DeepImmutable } from "babylonjs/types";
  7393. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7394. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7395. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7396. import { Collider } from "babylonjs/Collisions/collider";
  7397. /**
  7398. * Interface for cullable objects
  7399. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7400. */
  7401. export interface ICullable {
  7402. /**
  7403. * Checks if the object or part of the object is in the frustum
  7404. * @param frustumPlanes Camera near/planes
  7405. * @returns true if the object is in frustum otherwise false
  7406. */
  7407. isInFrustum(frustumPlanes: Plane[]): boolean;
  7408. /**
  7409. * Checks if a cullable object (mesh...) is in the camera frustum
  7410. * Unlike isInFrustum this cheks the full bounding box
  7411. * @param frustumPlanes Camera near/planes
  7412. * @returns true if the object is in frustum otherwise false
  7413. */
  7414. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7415. }
  7416. /**
  7417. * Info for a bounding data of a mesh
  7418. */
  7419. export class BoundingInfo implements ICullable {
  7420. /**
  7421. * Bounding box for the mesh
  7422. */
  7423. readonly boundingBox: BoundingBox;
  7424. /**
  7425. * Bounding sphere for the mesh
  7426. */
  7427. readonly boundingSphere: BoundingSphere;
  7428. private _isLocked;
  7429. private static readonly TmpVector3;
  7430. /**
  7431. * Constructs bounding info
  7432. * @param minimum min vector of the bounding box/sphere
  7433. * @param maximum max vector of the bounding box/sphere
  7434. * @param worldMatrix defines the new world matrix
  7435. */
  7436. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7437. /**
  7438. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7439. * @param min defines the new minimum vector (in local space)
  7440. * @param max defines the new maximum vector (in local space)
  7441. * @param worldMatrix defines the new world matrix
  7442. */
  7443. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7444. /**
  7445. * min vector of the bounding box/sphere
  7446. */
  7447. readonly minimum: Vector3;
  7448. /**
  7449. * max vector of the bounding box/sphere
  7450. */
  7451. readonly maximum: Vector3;
  7452. /**
  7453. * If the info is locked and won't be updated to avoid perf overhead
  7454. */
  7455. isLocked: boolean;
  7456. /**
  7457. * Updates the bounding sphere and box
  7458. * @param world world matrix to be used to update
  7459. */
  7460. update(world: DeepImmutable<Matrix>): void;
  7461. /**
  7462. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7463. * @param center New center of the bounding info
  7464. * @param extend New extend of the bounding info
  7465. * @returns the current bounding info
  7466. */
  7467. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7468. /**
  7469. * Scale the current bounding info by applying a scale factor
  7470. * @param factor defines the scale factor to apply
  7471. * @returns the current bounding info
  7472. */
  7473. scale(factor: number): BoundingInfo;
  7474. /**
  7475. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7476. * @param frustumPlanes defines the frustum to test
  7477. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7478. * @returns true if the bounding info is in the frustum planes
  7479. */
  7480. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7481. /**
  7482. * Gets the world distance between the min and max points of the bounding box
  7483. */
  7484. readonly diagonalLength: number;
  7485. /**
  7486. * Checks if a cullable object (mesh...) is in the camera frustum
  7487. * Unlike isInFrustum this cheks the full bounding box
  7488. * @param frustumPlanes Camera near/planes
  7489. * @returns true if the object is in frustum otherwise false
  7490. */
  7491. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7492. /** @hidden */
  7493. _checkCollision(collider: Collider): boolean;
  7494. /**
  7495. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7496. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7497. * @param point the point to check intersection with
  7498. * @returns if the point intersects
  7499. */
  7500. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7501. /**
  7502. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7503. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7504. * @param boundingInfo the bounding info to check intersection with
  7505. * @param precise if the intersection should be done using OBB
  7506. * @returns if the bounding info intersects
  7507. */
  7508. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7509. }
  7510. }
  7511. declare module "babylonjs/Misc/smartArray" {
  7512. /**
  7513. * Defines an array and its length.
  7514. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7515. */
  7516. export interface ISmartArrayLike<T> {
  7517. /**
  7518. * The data of the array.
  7519. */
  7520. data: Array<T>;
  7521. /**
  7522. * The active length of the array.
  7523. */
  7524. length: number;
  7525. }
  7526. /**
  7527. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7528. */
  7529. export class SmartArray<T> implements ISmartArrayLike<T> {
  7530. /**
  7531. * The full set of data from the array.
  7532. */
  7533. data: Array<T>;
  7534. /**
  7535. * The active length of the array.
  7536. */
  7537. length: number;
  7538. protected _id: number;
  7539. /**
  7540. * Instantiates a Smart Array.
  7541. * @param capacity defines the default capacity of the array.
  7542. */
  7543. constructor(capacity: number);
  7544. /**
  7545. * Pushes a value at the end of the active data.
  7546. * @param value defines the object to push in the array.
  7547. */
  7548. push(value: T): void;
  7549. /**
  7550. * Iterates over the active data and apply the lambda to them.
  7551. * @param func defines the action to apply on each value.
  7552. */
  7553. forEach(func: (content: T) => void): void;
  7554. /**
  7555. * Sorts the full sets of data.
  7556. * @param compareFn defines the comparison function to apply.
  7557. */
  7558. sort(compareFn: (a: T, b: T) => number): void;
  7559. /**
  7560. * Resets the active data to an empty array.
  7561. */
  7562. reset(): void;
  7563. /**
  7564. * Releases all the data from the array as well as the array.
  7565. */
  7566. dispose(): void;
  7567. /**
  7568. * Concats the active data with a given array.
  7569. * @param array defines the data to concatenate with.
  7570. */
  7571. concat(array: any): void;
  7572. /**
  7573. * Returns the position of a value in the active data.
  7574. * @param value defines the value to find the index for
  7575. * @returns the index if found in the active data otherwise -1
  7576. */
  7577. indexOf(value: T): number;
  7578. /**
  7579. * Returns whether an element is part of the active data.
  7580. * @param value defines the value to look for
  7581. * @returns true if found in the active data otherwise false
  7582. */
  7583. contains(value: T): boolean;
  7584. private static _GlobalId;
  7585. }
  7586. /**
  7587. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7588. * The data in this array can only be present once
  7589. */
  7590. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7591. private _duplicateId;
  7592. /**
  7593. * Pushes a value at the end of the active data.
  7594. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7595. * @param value defines the object to push in the array.
  7596. */
  7597. push(value: T): void;
  7598. /**
  7599. * Pushes a value at the end of the active data.
  7600. * If the data is already present, it won t be added again
  7601. * @param value defines the object to push in the array.
  7602. * @returns true if added false if it was already present
  7603. */
  7604. pushNoDuplicate(value: T): boolean;
  7605. /**
  7606. * Resets the active data to an empty array.
  7607. */
  7608. reset(): void;
  7609. /**
  7610. * Concats the active data with a given array.
  7611. * This ensures no dupplicate will be present in the result.
  7612. * @param array defines the data to concatenate with.
  7613. */
  7614. concatWithNoDuplicate(array: any): void;
  7615. }
  7616. }
  7617. declare module "babylonjs/Materials/multiMaterial" {
  7618. import { Nullable } from "babylonjs/types";
  7619. import { Scene } from "babylonjs/scene";
  7620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7621. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7622. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7623. import { Material } from "babylonjs/Materials/material";
  7624. /**
  7625. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7626. * separate meshes. This can be use to improve performances.
  7627. * @see http://doc.babylonjs.com/how_to/multi_materials
  7628. */
  7629. export class MultiMaterial extends Material {
  7630. private _subMaterials;
  7631. /**
  7632. * Gets or Sets the list of Materials used within the multi material.
  7633. * They need to be ordered according to the submeshes order in the associated mesh
  7634. */
  7635. subMaterials: Nullable<Material>[];
  7636. /**
  7637. * Function used to align with Node.getChildren()
  7638. * @returns the list of Materials used within the multi material
  7639. */
  7640. getChildren(): Nullable<Material>[];
  7641. /**
  7642. * Instantiates a new Multi Material
  7643. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7644. * separate meshes. This can be use to improve performances.
  7645. * @see http://doc.babylonjs.com/how_to/multi_materials
  7646. * @param name Define the name in the scene
  7647. * @param scene Define the scene the material belongs to
  7648. */
  7649. constructor(name: string, scene: Scene);
  7650. private _hookArray;
  7651. /**
  7652. * Get one of the submaterial by its index in the submaterials array
  7653. * @param index The index to look the sub material at
  7654. * @returns The Material if the index has been defined
  7655. */
  7656. getSubMaterial(index: number): Nullable<Material>;
  7657. /**
  7658. * Get the list of active textures for the whole sub materials list.
  7659. * @returns All the textures that will be used during the rendering
  7660. */
  7661. getActiveTextures(): BaseTexture[];
  7662. /**
  7663. * Gets the current class name of the material e.g. "MultiMaterial"
  7664. * Mainly use in serialization.
  7665. * @returns the class name
  7666. */
  7667. getClassName(): string;
  7668. /**
  7669. * Checks if the material is ready to render the requested sub mesh
  7670. * @param mesh Define the mesh the submesh belongs to
  7671. * @param subMesh Define the sub mesh to look readyness for
  7672. * @param useInstances Define whether or not the material is used with instances
  7673. * @returns true if ready, otherwise false
  7674. */
  7675. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7676. /**
  7677. * Clones the current material and its related sub materials
  7678. * @param name Define the name of the newly cloned material
  7679. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7680. * @returns the cloned material
  7681. */
  7682. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7683. /**
  7684. * Serializes the materials into a JSON representation.
  7685. * @returns the JSON representation
  7686. */
  7687. serialize(): any;
  7688. /**
  7689. * Dispose the material and release its associated resources
  7690. * @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)
  7691. * @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)
  7692. * @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)
  7693. */
  7694. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7695. /**
  7696. * Creates a MultiMaterial from parsed MultiMaterial data.
  7697. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7698. * @param scene defines the hosting scene
  7699. * @returns a new MultiMaterial
  7700. */
  7701. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7702. }
  7703. }
  7704. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7705. /**
  7706. * Class used to represent data loading progression
  7707. */
  7708. export class SceneLoaderFlags {
  7709. private static _ForceFullSceneLoadingForIncremental;
  7710. private static _ShowLoadingScreen;
  7711. private static _CleanBoneMatrixWeights;
  7712. private static _loggingLevel;
  7713. /**
  7714. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7715. */
  7716. static ForceFullSceneLoadingForIncremental: boolean;
  7717. /**
  7718. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7719. */
  7720. static ShowLoadingScreen: boolean;
  7721. /**
  7722. * Defines the current logging level (while loading the scene)
  7723. * @ignorenaming
  7724. */
  7725. static loggingLevel: number;
  7726. /**
  7727. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7728. */
  7729. static CleanBoneMatrixWeights: boolean;
  7730. }
  7731. }
  7732. declare module "babylonjs/Meshes/transformNode" {
  7733. import { DeepImmutable } from "babylonjs/types";
  7734. import { Observable } from "babylonjs/Misc/observable";
  7735. import { Nullable } from "babylonjs/types";
  7736. import { Camera } from "babylonjs/Cameras/camera";
  7737. import { Scene } from "babylonjs/scene";
  7738. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7739. import { Node } from "babylonjs/node";
  7740. import { Bone } from "babylonjs/Bones/bone";
  7741. /**
  7742. * 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.
  7743. * @see https://doc.babylonjs.com/how_to/transformnode
  7744. */
  7745. export class TransformNode extends Node {
  7746. /**
  7747. * Object will not rotate to face the camera
  7748. */
  7749. static BILLBOARDMODE_NONE: number;
  7750. /**
  7751. * Object will rotate to face the camera but only on the x axis
  7752. */
  7753. static BILLBOARDMODE_X: number;
  7754. /**
  7755. * Object will rotate to face the camera but only on the y axis
  7756. */
  7757. static BILLBOARDMODE_Y: number;
  7758. /**
  7759. * Object will rotate to face the camera but only on the z axis
  7760. */
  7761. static BILLBOARDMODE_Z: number;
  7762. /**
  7763. * Object will rotate to face the camera
  7764. */
  7765. static BILLBOARDMODE_ALL: number;
  7766. private _forward;
  7767. private _forwardInverted;
  7768. private _up;
  7769. private _right;
  7770. private _rightInverted;
  7771. private _position;
  7772. private _rotation;
  7773. private _rotationQuaternion;
  7774. protected _scaling: Vector3;
  7775. protected _isDirty: boolean;
  7776. private _transformToBoneReferal;
  7777. private _billboardMode;
  7778. /**
  7779. * Gets or sets the billboard mode. Default is 0.
  7780. *
  7781. * | Value | Type | Description |
  7782. * | --- | --- | --- |
  7783. * | 0 | BILLBOARDMODE_NONE | |
  7784. * | 1 | BILLBOARDMODE_X | |
  7785. * | 2 | BILLBOARDMODE_Y | |
  7786. * | 4 | BILLBOARDMODE_Z | |
  7787. * | 7 | BILLBOARDMODE_ALL | |
  7788. *
  7789. */
  7790. billboardMode: number;
  7791. private _preserveParentRotationForBillboard;
  7792. /**
  7793. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7794. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7795. */
  7796. preserveParentRotationForBillboard: boolean;
  7797. /**
  7798. * 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
  7799. */
  7800. scalingDeterminant: number;
  7801. private _infiniteDistance;
  7802. /**
  7803. * Gets or sets the distance of the object to max, often used by skybox
  7804. */
  7805. infiniteDistance: boolean;
  7806. /**
  7807. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7808. * By default the system will update normals to compensate
  7809. */
  7810. ignoreNonUniformScaling: boolean;
  7811. /**
  7812. * 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
  7813. */
  7814. reIntegrateRotationIntoRotationQuaternion: boolean;
  7815. /** @hidden */
  7816. _poseMatrix: Nullable<Matrix>;
  7817. /** @hidden */
  7818. _localMatrix: Matrix;
  7819. private _usePivotMatrix;
  7820. private _absolutePosition;
  7821. private _pivotMatrix;
  7822. private _pivotMatrixInverse;
  7823. protected _postMultiplyPivotMatrix: boolean;
  7824. protected _isWorldMatrixFrozen: boolean;
  7825. /** @hidden */
  7826. _indexInSceneTransformNodesArray: number;
  7827. /**
  7828. * An event triggered after the world matrix is updated
  7829. */
  7830. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7831. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7832. /**
  7833. * Gets a string identifying the name of the class
  7834. * @returns "TransformNode" string
  7835. */
  7836. getClassName(): string;
  7837. /**
  7838. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7839. */
  7840. position: Vector3;
  7841. /**
  7842. * 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)).
  7843. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7844. */
  7845. rotation: Vector3;
  7846. /**
  7847. * 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)).
  7848. */
  7849. scaling: Vector3;
  7850. /**
  7851. * 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).
  7852. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7853. */
  7854. rotationQuaternion: Nullable<Quaternion>;
  7855. /**
  7856. * The forward direction of that transform in world space.
  7857. */
  7858. readonly forward: Vector3;
  7859. /**
  7860. * The up direction of that transform in world space.
  7861. */
  7862. readonly up: Vector3;
  7863. /**
  7864. * The right direction of that transform in world space.
  7865. */
  7866. readonly right: Vector3;
  7867. /**
  7868. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7869. * @param matrix the matrix to copy the pose from
  7870. * @returns this TransformNode.
  7871. */
  7872. updatePoseMatrix(matrix: Matrix): TransformNode;
  7873. /**
  7874. * Returns the mesh Pose matrix.
  7875. * @returns the pose matrix
  7876. */
  7877. getPoseMatrix(): Matrix;
  7878. /** @hidden */
  7879. _isSynchronized(): boolean;
  7880. /** @hidden */
  7881. _initCache(): void;
  7882. /**
  7883. * Flag the transform node as dirty (Forcing it to update everything)
  7884. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7885. * @returns this transform node
  7886. */
  7887. markAsDirty(property: string): TransformNode;
  7888. /**
  7889. * Returns the current mesh absolute position.
  7890. * Returns a Vector3.
  7891. */
  7892. readonly absolutePosition: Vector3;
  7893. /**
  7894. * Sets a new matrix to apply before all other transformation
  7895. * @param matrix defines the transform matrix
  7896. * @returns the current TransformNode
  7897. */
  7898. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7899. /**
  7900. * Sets a new pivot matrix to the current node
  7901. * @param matrix defines the new pivot matrix to use
  7902. * @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
  7903. * @returns the current TransformNode
  7904. */
  7905. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7906. /**
  7907. * Returns the mesh pivot matrix.
  7908. * Default : Identity.
  7909. * @returns the matrix
  7910. */
  7911. getPivotMatrix(): Matrix;
  7912. /**
  7913. * Prevents the World matrix to be computed any longer.
  7914. * @returns the TransformNode.
  7915. */
  7916. freezeWorldMatrix(): TransformNode;
  7917. /**
  7918. * Allows back the World matrix computation.
  7919. * @returns the TransformNode.
  7920. */
  7921. unfreezeWorldMatrix(): this;
  7922. /**
  7923. * True if the World matrix has been frozen.
  7924. */
  7925. readonly isWorldMatrixFrozen: boolean;
  7926. /**
  7927. * Retuns the mesh absolute position in the World.
  7928. * @returns a Vector3.
  7929. */
  7930. getAbsolutePosition(): Vector3;
  7931. /**
  7932. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7933. * @param absolutePosition the absolute position to set
  7934. * @returns the TransformNode.
  7935. */
  7936. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7937. /**
  7938. * Sets the mesh position in its local space.
  7939. * @param vector3 the position to set in localspace
  7940. * @returns the TransformNode.
  7941. */
  7942. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7943. /**
  7944. * Returns the mesh position in the local space from the current World matrix values.
  7945. * @returns a new Vector3.
  7946. */
  7947. getPositionExpressedInLocalSpace(): Vector3;
  7948. /**
  7949. * Translates the mesh along the passed Vector3 in its local space.
  7950. * @param vector3 the distance to translate in localspace
  7951. * @returns the TransformNode.
  7952. */
  7953. locallyTranslate(vector3: Vector3): TransformNode;
  7954. private static _lookAtVectorCache;
  7955. /**
  7956. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7957. * @param targetPoint the position (must be in same space as current mesh) to look at
  7958. * @param yawCor optional yaw (y-axis) correction in radians
  7959. * @param pitchCor optional pitch (x-axis) correction in radians
  7960. * @param rollCor optional roll (z-axis) correction in radians
  7961. * @param space the choosen space of the target
  7962. * @returns the TransformNode.
  7963. */
  7964. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7965. /**
  7966. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7967. * This Vector3 is expressed in the World space.
  7968. * @param localAxis axis to rotate
  7969. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7970. */
  7971. getDirection(localAxis: Vector3): Vector3;
  7972. /**
  7973. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7974. * localAxis is expressed in the mesh local space.
  7975. * result is computed in the Wordl space from the mesh World matrix.
  7976. * @param localAxis axis to rotate
  7977. * @param result the resulting transformnode
  7978. * @returns this TransformNode.
  7979. */
  7980. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7981. /**
  7982. * Sets this transform node rotation to the given local axis.
  7983. * @param localAxis the axis in local space
  7984. * @param yawCor optional yaw (y-axis) correction in radians
  7985. * @param pitchCor optional pitch (x-axis) correction in radians
  7986. * @param rollCor optional roll (z-axis) correction in radians
  7987. * @returns this TransformNode
  7988. */
  7989. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7990. /**
  7991. * Sets a new pivot point to the current node
  7992. * @param point defines the new pivot point to use
  7993. * @param space defines if the point is in world or local space (local by default)
  7994. * @returns the current TransformNode
  7995. */
  7996. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7997. /**
  7998. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7999. * @returns the pivot point
  8000. */
  8001. getPivotPoint(): Vector3;
  8002. /**
  8003. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8004. * @param result the vector3 to store the result
  8005. * @returns this TransformNode.
  8006. */
  8007. getPivotPointToRef(result: Vector3): TransformNode;
  8008. /**
  8009. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8010. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8011. */
  8012. getAbsolutePivotPoint(): Vector3;
  8013. /**
  8014. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8015. * @param result vector3 to store the result
  8016. * @returns this TransformNode.
  8017. */
  8018. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8019. /**
  8020. * Defines the passed node as the parent of the current node.
  8021. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8022. * @see https://doc.babylonjs.com/how_to/parenting
  8023. * @param node the node ot set as the parent
  8024. * @returns this TransformNode.
  8025. */
  8026. setParent(node: Nullable<Node>): TransformNode;
  8027. private _nonUniformScaling;
  8028. /**
  8029. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8030. */
  8031. readonly nonUniformScaling: boolean;
  8032. /** @hidden */
  8033. _updateNonUniformScalingState(value: boolean): boolean;
  8034. /**
  8035. * Attach the current TransformNode to another TransformNode associated with a bone
  8036. * @param bone Bone affecting the TransformNode
  8037. * @param affectedTransformNode TransformNode associated with the bone
  8038. * @returns this object
  8039. */
  8040. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8041. /**
  8042. * Detach the transform node if its associated with a bone
  8043. * @returns this object
  8044. */
  8045. detachFromBone(): TransformNode;
  8046. private static _rotationAxisCache;
  8047. /**
  8048. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8049. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8050. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8051. * The passed axis is also normalized.
  8052. * @param axis the axis to rotate around
  8053. * @param amount the amount to rotate in radians
  8054. * @param space Space to rotate in (Default: local)
  8055. * @returns the TransformNode.
  8056. */
  8057. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8058. /**
  8059. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8060. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8061. * The passed axis is also normalized. .
  8062. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8063. * @param point the point to rotate around
  8064. * @param axis the axis to rotate around
  8065. * @param amount the amount to rotate in radians
  8066. * @returns the TransformNode
  8067. */
  8068. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8069. /**
  8070. * Translates the mesh along the axis vector for the passed distance in the given space.
  8071. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8072. * @param axis the axis to translate in
  8073. * @param distance the distance to translate
  8074. * @param space Space to rotate in (Default: local)
  8075. * @returns the TransformNode.
  8076. */
  8077. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8078. /**
  8079. * Adds a rotation step to the mesh current rotation.
  8080. * x, y, z are Euler angles expressed in radians.
  8081. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8082. * This means this rotation is made in the mesh local space only.
  8083. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8084. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8085. * ```javascript
  8086. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8087. * ```
  8088. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8089. * 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.
  8090. * @param x Rotation to add
  8091. * @param y Rotation to add
  8092. * @param z Rotation to add
  8093. * @returns the TransformNode.
  8094. */
  8095. addRotation(x: number, y: number, z: number): TransformNode;
  8096. /**
  8097. * @hidden
  8098. */
  8099. protected _getEffectiveParent(): Nullable<Node>;
  8100. /**
  8101. * Computes the world matrix of the node
  8102. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8103. * @returns the world matrix
  8104. */
  8105. computeWorldMatrix(force?: boolean): Matrix;
  8106. protected _afterComputeWorldMatrix(): void;
  8107. /**
  8108. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8109. * @param func callback function to add
  8110. *
  8111. * @returns the TransformNode.
  8112. */
  8113. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8114. /**
  8115. * Removes a registered callback function.
  8116. * @param func callback function to remove
  8117. * @returns the TransformNode.
  8118. */
  8119. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8120. /**
  8121. * Gets the position of the current mesh in camera space
  8122. * @param camera defines the camera to use
  8123. * @returns a position
  8124. */
  8125. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8126. /**
  8127. * Returns the distance from the mesh to the active camera
  8128. * @param camera defines the camera to use
  8129. * @returns the distance
  8130. */
  8131. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8132. /**
  8133. * Clone the current transform node
  8134. * @param name Name of the new clone
  8135. * @param newParent New parent for the clone
  8136. * @param doNotCloneChildren Do not clone children hierarchy
  8137. * @returns the new transform node
  8138. */
  8139. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8140. /**
  8141. * Serializes the objects information.
  8142. * @param currentSerializationObject defines the object to serialize in
  8143. * @returns the serialized object
  8144. */
  8145. serialize(currentSerializationObject?: any): any;
  8146. /**
  8147. * Returns a new TransformNode object parsed from the source provided.
  8148. * @param parsedTransformNode is the source.
  8149. * @param scene the scne the object belongs to
  8150. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8151. * @returns a new TransformNode object parsed from the source provided.
  8152. */
  8153. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8154. /**
  8155. * Get all child-transformNodes of this node
  8156. * @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
  8157. * @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
  8158. * @returns an array of TransformNode
  8159. */
  8160. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8161. /**
  8162. * Releases resources associated with this transform node.
  8163. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8164. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8165. */
  8166. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8167. }
  8168. }
  8169. declare module "babylonjs/Animations/animationPropertiesOverride" {
  8170. /**
  8171. * Class used to override all child animations of a given target
  8172. */
  8173. export class AnimationPropertiesOverride {
  8174. /**
  8175. * Gets or sets a value indicating if animation blending must be used
  8176. */
  8177. enableBlending: boolean;
  8178. /**
  8179. * Gets or sets the blending speed to use when enableBlending is true
  8180. */
  8181. blendingSpeed: number;
  8182. /**
  8183. * Gets or sets the default loop mode to use
  8184. */
  8185. loopMode: number;
  8186. }
  8187. }
  8188. declare module "babylonjs/Bones/bone" {
  8189. import { Skeleton } from "babylonjs/Bones/skeleton";
  8190. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8191. import { Nullable } from "babylonjs/types";
  8192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8193. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8194. import { Node } from "babylonjs/node";
  8195. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8196. /**
  8197. * Class used to store bone information
  8198. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8199. */
  8200. export class Bone extends Node {
  8201. /**
  8202. * defines the bone name
  8203. */
  8204. name: string;
  8205. private static _tmpVecs;
  8206. private static _tmpQuat;
  8207. private static _tmpMats;
  8208. /**
  8209. * Gets the list of child bones
  8210. */
  8211. children: Bone[];
  8212. /** Gets the animations associated with this bone */
  8213. animations: import("babylonjs/Animations/animation").Animation[];
  8214. /**
  8215. * Gets or sets bone length
  8216. */
  8217. length: number;
  8218. /**
  8219. * @hidden Internal only
  8220. * Set this value to map this bone to a different index in the transform matrices
  8221. * Set this value to -1 to exclude the bone from the transform matrices
  8222. */
  8223. _index: Nullable<number>;
  8224. private _skeleton;
  8225. private _localMatrix;
  8226. private _restPose;
  8227. private _baseMatrix;
  8228. private _absoluteTransform;
  8229. private _invertedAbsoluteTransform;
  8230. private _parent;
  8231. private _scalingDeterminant;
  8232. private _worldTransform;
  8233. private _localScaling;
  8234. private _localRotation;
  8235. private _localPosition;
  8236. private _needToDecompose;
  8237. private _needToCompose;
  8238. /** @hidden */
  8239. _linkedTransformNode: Nullable<TransformNode>;
  8240. /** @hidden */
  8241. _waitingTransformNodeId: Nullable<string>;
  8242. /** @hidden */
  8243. /** @hidden */
  8244. _matrix: Matrix;
  8245. /**
  8246. * Create a new bone
  8247. * @param name defines the bone name
  8248. * @param skeleton defines the parent skeleton
  8249. * @param parentBone defines the parent (can be null if the bone is the root)
  8250. * @param localMatrix defines the local matrix
  8251. * @param restPose defines the rest pose matrix
  8252. * @param baseMatrix defines the base matrix
  8253. * @param index defines index of the bone in the hiearchy
  8254. */
  8255. constructor(
  8256. /**
  8257. * defines the bone name
  8258. */
  8259. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8260. /**
  8261. * Gets the current object class name.
  8262. * @return the class name
  8263. */
  8264. getClassName(): string;
  8265. /**
  8266. * Gets the parent skeleton
  8267. * @returns a skeleton
  8268. */
  8269. getSkeleton(): Skeleton;
  8270. /**
  8271. * Gets parent bone
  8272. * @returns a bone or null if the bone is the root of the bone hierarchy
  8273. */
  8274. getParent(): Nullable<Bone>;
  8275. /**
  8276. * Returns an array containing the root bones
  8277. * @returns an array containing the root bones
  8278. */
  8279. getChildren(): Array<Bone>;
  8280. /**
  8281. * Sets the parent bone
  8282. * @param parent defines the parent (can be null if the bone is the root)
  8283. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8284. */
  8285. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8286. /**
  8287. * Gets the local matrix
  8288. * @returns a matrix
  8289. */
  8290. getLocalMatrix(): Matrix;
  8291. /**
  8292. * Gets the base matrix (initial matrix which remains unchanged)
  8293. * @returns a matrix
  8294. */
  8295. getBaseMatrix(): Matrix;
  8296. /**
  8297. * Gets the rest pose matrix
  8298. * @returns a matrix
  8299. */
  8300. getRestPose(): Matrix;
  8301. /**
  8302. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8303. */
  8304. getWorldMatrix(): Matrix;
  8305. /**
  8306. * Sets the local matrix to rest pose matrix
  8307. */
  8308. returnToRest(): void;
  8309. /**
  8310. * Gets the inverse of the absolute transform matrix.
  8311. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8312. * @returns a matrix
  8313. */
  8314. getInvertedAbsoluteTransform(): Matrix;
  8315. /**
  8316. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8317. * @returns a matrix
  8318. */
  8319. getAbsoluteTransform(): Matrix;
  8320. /**
  8321. * Links with the given transform node.
  8322. * The local matrix of this bone is copied from the transform node every frame.
  8323. * @param transformNode defines the transform node to link to
  8324. */
  8325. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8326. /** Gets or sets current position (in local space) */
  8327. position: Vector3;
  8328. /** Gets or sets current rotation (in local space) */
  8329. rotation: Vector3;
  8330. /** Gets or sets current rotation quaternion (in local space) */
  8331. rotationQuaternion: Quaternion;
  8332. /** Gets or sets current scaling (in local space) */
  8333. scaling: Vector3;
  8334. /**
  8335. * Gets the animation properties override
  8336. */
  8337. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8338. private _decompose;
  8339. private _compose;
  8340. /**
  8341. * Update the base and local matrices
  8342. * @param matrix defines the new base or local matrix
  8343. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8344. * @param updateLocalMatrix defines if the local matrix should be updated
  8345. */
  8346. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8347. /** @hidden */
  8348. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8349. /**
  8350. * Flag the bone as dirty (Forcing it to update everything)
  8351. */
  8352. markAsDirty(): void;
  8353. /** @hidden */
  8354. _markAsDirtyAndCompose(): void;
  8355. private _markAsDirtyAndDecompose;
  8356. /**
  8357. * Translate the bone in local or world space
  8358. * @param vec The amount to translate the bone
  8359. * @param space The space that the translation is in
  8360. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8361. */
  8362. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8363. /**
  8364. * Set the postion of the bone in local or world space
  8365. * @param position The position to set the bone
  8366. * @param space The space that the position is in
  8367. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8368. */
  8369. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8370. /**
  8371. * Set the absolute position of the bone (world space)
  8372. * @param position The position to set the bone
  8373. * @param mesh The mesh that this bone is attached to
  8374. */
  8375. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8376. /**
  8377. * Scale the bone on the x, y and z axes (in local space)
  8378. * @param x The amount to scale the bone on the x axis
  8379. * @param y The amount to scale the bone on the y axis
  8380. * @param z The amount to scale the bone on the z axis
  8381. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8382. */
  8383. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8384. /**
  8385. * Set the bone scaling in local space
  8386. * @param scale defines the scaling vector
  8387. */
  8388. setScale(scale: Vector3): void;
  8389. /**
  8390. * Gets the current scaling in local space
  8391. * @returns the current scaling vector
  8392. */
  8393. getScale(): Vector3;
  8394. /**
  8395. * Gets the current scaling in local space and stores it in a target vector
  8396. * @param result defines the target vector
  8397. */
  8398. getScaleToRef(result: Vector3): void;
  8399. /**
  8400. * Set the yaw, pitch, and roll of the bone in local or world space
  8401. * @param yaw The rotation of the bone on the y axis
  8402. * @param pitch The rotation of the bone on the x axis
  8403. * @param roll The rotation of the bone on the z axis
  8404. * @param space The space that the axes of rotation are in
  8405. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8406. */
  8407. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8408. /**
  8409. * Add a rotation to the bone on an axis in local or world space
  8410. * @param axis The axis to rotate the bone on
  8411. * @param amount The amount to rotate the bone
  8412. * @param space The space that the axis is in
  8413. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8414. */
  8415. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8416. /**
  8417. * Set the rotation of the bone to a particular axis angle in local or world space
  8418. * @param axis The axis to rotate the bone on
  8419. * @param angle The angle that the bone should be rotated to
  8420. * @param space The space that the axis is in
  8421. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8422. */
  8423. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8424. /**
  8425. * Set the euler rotation of the bone in local of world space
  8426. * @param rotation The euler rotation that the bone should be set to
  8427. * @param space The space that the rotation is in
  8428. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8429. */
  8430. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8431. /**
  8432. * Set the quaternion rotation of the bone in local of world space
  8433. * @param quat The quaternion rotation that the bone should be set to
  8434. * @param space The space that the rotation is in
  8435. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8436. */
  8437. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8438. /**
  8439. * Set the rotation matrix of the bone in local of world space
  8440. * @param rotMat The rotation matrix that the bone should be set to
  8441. * @param space The space that the rotation is in
  8442. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8443. */
  8444. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8445. private _rotateWithMatrix;
  8446. private _getNegativeRotationToRef;
  8447. /**
  8448. * Get the position of the bone in local or world space
  8449. * @param space The space that the returned position is in
  8450. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8451. * @returns The position of the bone
  8452. */
  8453. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8454. /**
  8455. * Copy the position of the bone to a vector3 in local or world space
  8456. * @param space The space that the returned position is in
  8457. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8458. * @param result The vector3 to copy the position to
  8459. */
  8460. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8461. /**
  8462. * Get the absolute position of the bone (world space)
  8463. * @param mesh The mesh that this bone is attached to
  8464. * @returns The absolute position of the bone
  8465. */
  8466. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8467. /**
  8468. * Copy the absolute position of the bone (world space) to the result param
  8469. * @param mesh The mesh that this bone is attached to
  8470. * @param result The vector3 to copy the absolute position to
  8471. */
  8472. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8473. /**
  8474. * Compute the absolute transforms of this bone and its children
  8475. */
  8476. computeAbsoluteTransforms(): void;
  8477. /**
  8478. * Get the world direction from an axis that is in the local space of the bone
  8479. * @param localAxis The local direction that is used to compute the world direction
  8480. * @param mesh The mesh that this bone is attached to
  8481. * @returns The world direction
  8482. */
  8483. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8484. /**
  8485. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8486. * @param localAxis The local direction that is used to compute the world direction
  8487. * @param mesh The mesh that this bone is attached to
  8488. * @param result The vector3 that the world direction will be copied to
  8489. */
  8490. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8491. /**
  8492. * Get the euler rotation of the bone in local or world space
  8493. * @param space The space that the rotation should be in
  8494. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8495. * @returns The euler rotation
  8496. */
  8497. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8498. /**
  8499. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8500. * @param space The space that the rotation should be in
  8501. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8502. * @param result The vector3 that the rotation should be copied to
  8503. */
  8504. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8505. /**
  8506. * Get the quaternion rotation of the bone in either local or world space
  8507. * @param space The space that the rotation should be in
  8508. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8509. * @returns The quaternion rotation
  8510. */
  8511. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8512. /**
  8513. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8514. * @param space The space that the rotation should be in
  8515. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8516. * @param result The quaternion that the rotation should be copied to
  8517. */
  8518. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8519. /**
  8520. * Get the rotation matrix of the bone in local or world space
  8521. * @param space The space that the rotation should be in
  8522. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8523. * @returns The rotation matrix
  8524. */
  8525. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8526. /**
  8527. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8528. * @param space The space that the rotation should be in
  8529. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8530. * @param result The quaternion that the rotation should be copied to
  8531. */
  8532. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8533. /**
  8534. * Get the world position of a point that is in the local space of the bone
  8535. * @param position The local position
  8536. * @param mesh The mesh that this bone is attached to
  8537. * @returns The world position
  8538. */
  8539. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8540. /**
  8541. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8542. * @param position The local position
  8543. * @param mesh The mesh that this bone is attached to
  8544. * @param result The vector3 that the world position should be copied to
  8545. */
  8546. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8547. /**
  8548. * Get the local position of a point that is in world space
  8549. * @param position The world position
  8550. * @param mesh The mesh that this bone is attached to
  8551. * @returns The local position
  8552. */
  8553. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8554. /**
  8555. * Get the local position of a point that is in world space and copy it to the result param
  8556. * @param position The world position
  8557. * @param mesh The mesh that this bone is attached to
  8558. * @param result The vector3 that the local position should be copied to
  8559. */
  8560. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8561. }
  8562. }
  8563. declare module "babylonjs/Misc/iInspectable" {
  8564. /**
  8565. * Enum that determines the text-wrapping mode to use.
  8566. */
  8567. export enum InspectableType {
  8568. /**
  8569. * Checkbox for booleans
  8570. */
  8571. Checkbox = 0,
  8572. /**
  8573. * Sliders for numbers
  8574. */
  8575. Slider = 1,
  8576. /**
  8577. * Vector3
  8578. */
  8579. Vector3 = 2,
  8580. /**
  8581. * Quaternions
  8582. */
  8583. Quaternion = 3,
  8584. /**
  8585. * Color3
  8586. */
  8587. Color3 = 4
  8588. }
  8589. /**
  8590. * Interface used to define custom inspectable properties.
  8591. * This interface is used by the inspector to display custom property grids
  8592. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8593. */
  8594. export interface IInspectable {
  8595. /**
  8596. * Gets the label to display
  8597. */
  8598. label: string;
  8599. /**
  8600. * Gets the name of the property to edit
  8601. */
  8602. propertyName: string;
  8603. /**
  8604. * Gets the type of the editor to use
  8605. */
  8606. type: InspectableType;
  8607. /**
  8608. * Gets the minimum value of the property when using in "slider" mode
  8609. */
  8610. min?: number;
  8611. /**
  8612. * Gets the maximum value of the property when using in "slider" mode
  8613. */
  8614. max?: number;
  8615. /**
  8616. * Gets the setp to use when using in "slider" mode
  8617. */
  8618. step?: number;
  8619. }
  8620. }
  8621. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  8622. import { Nullable } from "babylonjs/types";
  8623. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8624. /**
  8625. * This represents the required contract to create a new type of texture loader.
  8626. */
  8627. export interface IInternalTextureLoader {
  8628. /**
  8629. * Defines wether the loader supports cascade loading the different faces.
  8630. */
  8631. supportCascades: boolean;
  8632. /**
  8633. * This returns if the loader support the current file information.
  8634. * @param extension defines the file extension of the file being loaded
  8635. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8636. * @param fallback defines the fallback internal texture if any
  8637. * @param isBase64 defines whether the texture is encoded as a base64
  8638. * @param isBuffer defines whether the texture data are stored as a buffer
  8639. * @returns true if the loader can load the specified file
  8640. */
  8641. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8642. /**
  8643. * Transform the url before loading if required.
  8644. * @param rootUrl the url of the texture
  8645. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8646. * @returns the transformed texture
  8647. */
  8648. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8649. /**
  8650. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8651. * @param rootUrl the url of the texture
  8652. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8653. * @returns the fallback texture
  8654. */
  8655. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8656. /**
  8657. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8658. * @param data contains the texture data
  8659. * @param texture defines the BabylonJS internal texture
  8660. * @param createPolynomials will be true if polynomials have been requested
  8661. * @param onLoad defines the callback to trigger once the texture is ready
  8662. * @param onError defines the callback to trigger in case of error
  8663. */
  8664. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8665. /**
  8666. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8667. * @param data contains the texture data
  8668. * @param texture defines the BabylonJS internal texture
  8669. * @param callback defines the method to call once ready to upload
  8670. */
  8671. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8672. }
  8673. }
  8674. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  8675. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8676. import { Nullable } from "babylonjs/types";
  8677. import { Scene } from "babylonjs/scene";
  8678. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  8679. module "babylonjs/Engines/engine" {
  8680. interface Engine {
  8681. /**
  8682. * Creates a depth stencil cube texture.
  8683. * This is only available in WebGL 2.
  8684. * @param size The size of face edge in the cube texture.
  8685. * @param options The options defining the cube texture.
  8686. * @returns The cube texture
  8687. */
  8688. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8689. /**
  8690. * Creates a cube texture
  8691. * @param rootUrl defines the url where the files to load is located
  8692. * @param scene defines the current scene
  8693. * @param files defines the list of files to load (1 per face)
  8694. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8695. * @param onLoad defines an optional callback raised when the texture is loaded
  8696. * @param onError defines an optional callback raised if there is an issue to load the texture
  8697. * @param format defines the format of the data
  8698. * @param forcedExtension defines the extension to use to pick the right loader
  8699. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8700. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8701. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8702. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8703. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8704. * @returns the cube texture as an InternalTexture
  8705. */
  8706. 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;
  8707. /**
  8708. * Creates a cube texture
  8709. * @param rootUrl defines the url where the files to load is located
  8710. * @param scene defines the current scene
  8711. * @param files defines the list of files to load (1 per face)
  8712. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8713. * @param onLoad defines an optional callback raised when the texture is loaded
  8714. * @param onError defines an optional callback raised if there is an issue to load the texture
  8715. * @param format defines the format of the data
  8716. * @param forcedExtension defines the extension to use to pick the right loader
  8717. * @returns the cube texture as an InternalTexture
  8718. */
  8719. 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;
  8720. /**
  8721. * Creates a cube texture
  8722. * @param rootUrl defines the url where the files to load is located
  8723. * @param scene defines the current scene
  8724. * @param files defines the list of files to load (1 per face)
  8725. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8726. * @param onLoad defines an optional callback raised when the texture is loaded
  8727. * @param onError defines an optional callback raised if there is an issue to load the texture
  8728. * @param format defines the format of the data
  8729. * @param forcedExtension defines the extension to use to pick the right loader
  8730. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8731. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8732. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8733. * @returns the cube texture as an InternalTexture
  8734. */
  8735. 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;
  8736. /** @hidden */
  8737. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8738. /** @hidden */
  8739. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8740. /** @hidden */
  8741. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8742. /** @hidden */
  8743. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8744. }
  8745. }
  8746. }
  8747. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8748. import { Nullable } from "babylonjs/types";
  8749. import { Scene } from "babylonjs/scene";
  8750. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8751. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8752. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  8753. /**
  8754. * Class for creating a cube texture
  8755. */
  8756. export class CubeTexture extends BaseTexture {
  8757. private _delayedOnLoad;
  8758. /**
  8759. * The url of the texture
  8760. */
  8761. url: string;
  8762. /**
  8763. * Gets or sets the center of the bounding box associated with the cube texture.
  8764. * It must define where the camera used to render the texture was set
  8765. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8766. */
  8767. boundingBoxPosition: Vector3;
  8768. private _boundingBoxSize;
  8769. /**
  8770. * Gets or sets the size of the bounding box associated with the cube texture
  8771. * When defined, the cubemap will switch to local mode
  8772. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8773. * @example https://www.babylonjs-playground.com/#RNASML
  8774. */
  8775. /**
  8776. * Returns the bounding box size
  8777. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8778. */
  8779. boundingBoxSize: Vector3;
  8780. protected _rotationY: number;
  8781. /**
  8782. * Sets texture matrix rotation angle around Y axis in radians.
  8783. */
  8784. /**
  8785. * Gets texture matrix rotation angle around Y axis radians.
  8786. */
  8787. rotationY: number;
  8788. /**
  8789. * Are mip maps generated for this texture or not.
  8790. */
  8791. readonly noMipmap: boolean;
  8792. private _noMipmap;
  8793. private _files;
  8794. private _extensions;
  8795. private _textureMatrix;
  8796. private _format;
  8797. private _createPolynomials;
  8798. /** @hidden */
  8799. _prefiltered: boolean;
  8800. /**
  8801. * Creates a cube texture from an array of image urls
  8802. * @param files defines an array of image urls
  8803. * @param scene defines the hosting scene
  8804. * @param noMipmap specifies if mip maps are not used
  8805. * @returns a cube texture
  8806. */
  8807. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8808. /**
  8809. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8810. * @param url defines the url of the prefiltered texture
  8811. * @param scene defines the scene the texture is attached to
  8812. * @param forcedExtension defines the extension of the file if different from the url
  8813. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8814. * @return the prefiltered texture
  8815. */
  8816. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8817. /**
  8818. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8819. * as prefiltered data.
  8820. * @param rootUrl defines the url of the texture or the root name of the six images
  8821. * @param scene defines the scene the texture is attached to
  8822. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8823. * @param noMipmap defines if mipmaps should be created or not
  8824. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8825. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8826. * @param onError defines a callback triggered in case of error during load
  8827. * @param format defines the internal format to use for the texture once loaded
  8828. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8829. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8830. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8831. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8832. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8833. * @return the cube texture
  8834. */
  8835. 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);
  8836. /**
  8837. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8838. */
  8839. readonly isPrefiltered: boolean;
  8840. /**
  8841. * Get the current class name of the texture useful for serialization or dynamic coding.
  8842. * @returns "CubeTexture"
  8843. */
  8844. getClassName(): string;
  8845. /**
  8846. * Update the url (and optional buffer) of this texture if url was null during construction.
  8847. * @param url the url of the texture
  8848. * @param forcedExtension defines the extension to use
  8849. * @param onLoad callback called when the texture is loaded (defaults to null)
  8850. */
  8851. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8852. /**
  8853. * Delays loading of the cube texture
  8854. * @param forcedExtension defines the extension to use
  8855. */
  8856. delayLoad(forcedExtension?: string): void;
  8857. /**
  8858. * Returns the reflection texture matrix
  8859. * @returns the reflection texture matrix
  8860. */
  8861. getReflectionTextureMatrix(): Matrix;
  8862. /**
  8863. * Sets the reflection texture matrix
  8864. * @param value Reflection texture matrix
  8865. */
  8866. setReflectionTextureMatrix(value: Matrix): void;
  8867. /**
  8868. * Parses text to create a cube texture
  8869. * @param parsedTexture define the serialized text to read from
  8870. * @param scene defines the hosting scene
  8871. * @param rootUrl defines the root url of the cube texture
  8872. * @returns a cube texture
  8873. */
  8874. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8875. /**
  8876. * Makes a clone, or deep copy, of the cube texture
  8877. * @returns a new cube texture
  8878. */
  8879. clone(): CubeTexture;
  8880. }
  8881. }
  8882. declare module "babylonjs/Shaders/postprocess.vertex" {
  8883. /** @hidden */
  8884. export var postprocessVertexShader: {
  8885. name: string;
  8886. shader: string;
  8887. };
  8888. }
  8889. declare module "babylonjs/Cameras/targetCamera" {
  8890. import { Nullable } from "babylonjs/types";
  8891. import { Camera } from "babylonjs/Cameras/camera";
  8892. import { Scene } from "babylonjs/scene";
  8893. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8894. /**
  8895. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8896. * This is the base of the follow, arc rotate cameras and Free camera
  8897. * @see http://doc.babylonjs.com/features/cameras
  8898. */
  8899. export class TargetCamera extends Camera {
  8900. private static _RigCamTransformMatrix;
  8901. private static _TargetTransformMatrix;
  8902. private static _TargetFocalPoint;
  8903. /**
  8904. * Define the current direction the camera is moving to
  8905. */
  8906. cameraDirection: Vector3;
  8907. /**
  8908. * Define the current rotation the camera is rotating to
  8909. */
  8910. cameraRotation: Vector2;
  8911. /**
  8912. * When set, the up vector of the camera will be updated by the rotation of the camera
  8913. */
  8914. updateUpVectorFromRotation: boolean;
  8915. private _tmpQuaternion;
  8916. /**
  8917. * Define the current rotation of the camera
  8918. */
  8919. rotation: Vector3;
  8920. /**
  8921. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8922. */
  8923. rotationQuaternion: Quaternion;
  8924. /**
  8925. * Define the current speed of the camera
  8926. */
  8927. speed: number;
  8928. /**
  8929. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8930. * around all axis.
  8931. */
  8932. noRotationConstraint: boolean;
  8933. /**
  8934. * Define the current target of the camera as an object or a position.
  8935. */
  8936. lockedTarget: any;
  8937. /** @hidden */
  8938. _currentTarget: Vector3;
  8939. /** @hidden */
  8940. _initialFocalDistance: number;
  8941. /** @hidden */
  8942. _viewMatrix: Matrix;
  8943. /** @hidden */
  8944. _camMatrix: Matrix;
  8945. /** @hidden */
  8946. _cameraTransformMatrix: Matrix;
  8947. /** @hidden */
  8948. _cameraRotationMatrix: Matrix;
  8949. /** @hidden */
  8950. _referencePoint: Vector3;
  8951. /** @hidden */
  8952. _transformedReferencePoint: Vector3;
  8953. protected _globalCurrentTarget: Vector3;
  8954. protected _globalCurrentUpVector: Vector3;
  8955. /** @hidden */
  8956. _reset: () => void;
  8957. private _defaultUp;
  8958. /**
  8959. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8960. * This is the base of the follow, arc rotate cameras and Free camera
  8961. * @see http://doc.babylonjs.com/features/cameras
  8962. * @param name Defines the name of the camera in the scene
  8963. * @param position Defines the start position of the camera in the scene
  8964. * @param scene Defines the scene the camera belongs to
  8965. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8966. */
  8967. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8968. /**
  8969. * Gets the position in front of the camera at a given distance.
  8970. * @param distance The distance from the camera we want the position to be
  8971. * @returns the position
  8972. */
  8973. getFrontPosition(distance: number): Vector3;
  8974. /** @hidden */
  8975. _getLockedTargetPosition(): Nullable<Vector3>;
  8976. private _storedPosition;
  8977. private _storedRotation;
  8978. private _storedRotationQuaternion;
  8979. /**
  8980. * Store current camera state of the camera (fov, position, rotation, etc..)
  8981. * @returns the camera
  8982. */
  8983. storeState(): Camera;
  8984. /**
  8985. * Restored camera state. You must call storeState() first
  8986. * @returns whether it was successful or not
  8987. * @hidden
  8988. */
  8989. _restoreStateValues(): boolean;
  8990. /** @hidden */
  8991. _initCache(): void;
  8992. /** @hidden */
  8993. _updateCache(ignoreParentClass?: boolean): void;
  8994. /** @hidden */
  8995. _isSynchronizedViewMatrix(): boolean;
  8996. /** @hidden */
  8997. _computeLocalCameraSpeed(): number;
  8998. /**
  8999. * Defines the target the camera should look at.
  9000. * This will automatically adapt alpha beta and radius to fit within the new target.
  9001. * @param target Defines the new target as a Vector or a mesh
  9002. */
  9003. setTarget(target: Vector3): void;
  9004. /**
  9005. * Return the current target position of the camera. This value is expressed in local space.
  9006. * @returns the target position
  9007. */
  9008. getTarget(): Vector3;
  9009. /** @hidden */
  9010. _decideIfNeedsToMove(): boolean;
  9011. /** @hidden */
  9012. _updatePosition(): void;
  9013. /** @hidden */
  9014. _checkInputs(): void;
  9015. protected _updateCameraRotationMatrix(): void;
  9016. /**
  9017. * 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)
  9018. * @returns the current camera
  9019. */
  9020. private _rotateUpVectorWithCameraRotationMatrix;
  9021. private _cachedRotationZ;
  9022. private _cachedQuaternionRotationZ;
  9023. /** @hidden */
  9024. _getViewMatrix(): Matrix;
  9025. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9026. /**
  9027. * @hidden
  9028. */
  9029. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9030. /**
  9031. * @hidden
  9032. */
  9033. _updateRigCameras(): void;
  9034. private _getRigCamPositionAndTarget;
  9035. /**
  9036. * Gets the current object class name.
  9037. * @return the class name
  9038. */
  9039. getClassName(): string;
  9040. }
  9041. }
  9042. declare module "babylonjs/Cameras/cameraInputsManager" {
  9043. import { Nullable } from "babylonjs/types";
  9044. import { Camera } from "babylonjs/Cameras/camera";
  9045. /**
  9046. * @ignore
  9047. * This is a list of all the different input types that are available in the application.
  9048. * Fo instance: ArcRotateCameraGamepadInput...
  9049. */
  9050. export var CameraInputTypes: {};
  9051. /**
  9052. * This is the contract to implement in order to create a new input class.
  9053. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9054. */
  9055. export interface ICameraInput<TCamera extends Camera> {
  9056. /**
  9057. * Defines the camera the input is attached to.
  9058. */
  9059. camera: Nullable<TCamera>;
  9060. /**
  9061. * Gets the class name of the current intput.
  9062. * @returns the class name
  9063. */
  9064. getClassName(): string;
  9065. /**
  9066. * Get the friendly name associated with the input class.
  9067. * @returns the input friendly name
  9068. */
  9069. getSimpleName(): string;
  9070. /**
  9071. * Attach the input controls to a specific dom element to get the input from.
  9072. * @param element Defines the element the controls should be listened from
  9073. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9074. */
  9075. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9076. /**
  9077. * Detach the current controls from the specified dom element.
  9078. * @param element Defines the element to stop listening the inputs from
  9079. */
  9080. detachControl(element: Nullable<HTMLElement>): void;
  9081. /**
  9082. * Update the current camera state depending on the inputs that have been used this frame.
  9083. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9084. */
  9085. checkInputs?: () => void;
  9086. }
  9087. /**
  9088. * Represents a map of input types to input instance or input index to input instance.
  9089. */
  9090. export interface CameraInputsMap<TCamera extends Camera> {
  9091. /**
  9092. * Accessor to the input by input type.
  9093. */
  9094. [name: string]: ICameraInput<TCamera>;
  9095. /**
  9096. * Accessor to the input by input index.
  9097. */
  9098. [idx: number]: ICameraInput<TCamera>;
  9099. }
  9100. /**
  9101. * This represents the input manager used within a camera.
  9102. * It helps dealing with all the different kind of input attached to a camera.
  9103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9104. */
  9105. export class CameraInputsManager<TCamera extends Camera> {
  9106. /**
  9107. * Defines the list of inputs attahed to the camera.
  9108. */
  9109. attached: CameraInputsMap<TCamera>;
  9110. /**
  9111. * Defines the dom element the camera is collecting inputs from.
  9112. * This is null if the controls have not been attached.
  9113. */
  9114. attachedElement: Nullable<HTMLElement>;
  9115. /**
  9116. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9117. */
  9118. noPreventDefault: boolean;
  9119. /**
  9120. * Defined the camera the input manager belongs to.
  9121. */
  9122. camera: TCamera;
  9123. /**
  9124. * Update the current camera state depending on the inputs that have been used this frame.
  9125. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9126. */
  9127. checkInputs: () => void;
  9128. /**
  9129. * Instantiate a new Camera Input Manager.
  9130. * @param camera Defines the camera the input manager blongs to
  9131. */
  9132. constructor(camera: TCamera);
  9133. /**
  9134. * Add an input method to a camera
  9135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9136. * @param input camera input method
  9137. */
  9138. add(input: ICameraInput<TCamera>): void;
  9139. /**
  9140. * Remove a specific input method from a camera
  9141. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9142. * @param inputToRemove camera input method
  9143. */
  9144. remove(inputToRemove: ICameraInput<TCamera>): void;
  9145. /**
  9146. * Remove a specific input type from a camera
  9147. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9148. * @param inputType the type of the input to remove
  9149. */
  9150. removeByType(inputType: string): void;
  9151. private _addCheckInputs;
  9152. /**
  9153. * Attach the input controls to the currently attached dom element to listen the events from.
  9154. * @param input Defines the input to attach
  9155. */
  9156. attachInput(input: ICameraInput<TCamera>): void;
  9157. /**
  9158. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9159. * @param element Defines the dom element to collect the events from
  9160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9161. */
  9162. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  9163. /**
  9164. * Detach the current manager inputs controls from a specific dom element.
  9165. * @param element Defines the dom element to collect the events from
  9166. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9167. */
  9168. detachElement(element: HTMLElement, disconnect?: boolean): void;
  9169. /**
  9170. * Rebuild the dynamic inputCheck function from the current list of
  9171. * defined inputs in the manager.
  9172. */
  9173. rebuildInputCheck(): void;
  9174. /**
  9175. * Remove all attached input methods from a camera
  9176. */
  9177. clear(): void;
  9178. /**
  9179. * Serialize the current input manager attached to a camera.
  9180. * This ensures than once parsed,
  9181. * the input associated to the camera will be identical to the current ones
  9182. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9183. */
  9184. serialize(serializedCamera: any): void;
  9185. /**
  9186. * Parses an input manager serialized JSON to restore the previous list of inputs
  9187. * and states associated to a camera.
  9188. * @param parsedCamera Defines the JSON to parse
  9189. */
  9190. parse(parsedCamera: any): void;
  9191. }
  9192. }
  9193. declare module "babylonjs/Events/keyboardEvents" {
  9194. /**
  9195. * Gather the list of keyboard event types as constants.
  9196. */
  9197. export class KeyboardEventTypes {
  9198. /**
  9199. * The keydown event is fired when a key becomes active (pressed).
  9200. */
  9201. static readonly KEYDOWN: number;
  9202. /**
  9203. * The keyup event is fired when a key has been released.
  9204. */
  9205. static readonly KEYUP: number;
  9206. }
  9207. /**
  9208. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9209. */
  9210. export class KeyboardInfo {
  9211. /**
  9212. * Defines the type of event (KeyboardEventTypes)
  9213. */
  9214. type: number;
  9215. /**
  9216. * Defines the related dom event
  9217. */
  9218. event: KeyboardEvent;
  9219. /**
  9220. * Instantiates a new keyboard info.
  9221. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9222. * @param type Defines the type of event (KeyboardEventTypes)
  9223. * @param event Defines the related dom event
  9224. */
  9225. constructor(
  9226. /**
  9227. * Defines the type of event (KeyboardEventTypes)
  9228. */
  9229. type: number,
  9230. /**
  9231. * Defines the related dom event
  9232. */
  9233. event: KeyboardEvent);
  9234. }
  9235. /**
  9236. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9237. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9238. */
  9239. export class KeyboardInfoPre extends KeyboardInfo {
  9240. /**
  9241. * Defines the type of event (KeyboardEventTypes)
  9242. */
  9243. type: number;
  9244. /**
  9245. * Defines the related dom event
  9246. */
  9247. event: KeyboardEvent;
  9248. /**
  9249. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9250. */
  9251. skipOnPointerObservable: boolean;
  9252. /**
  9253. * Instantiates a new keyboard pre info.
  9254. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9255. * @param type Defines the type of event (KeyboardEventTypes)
  9256. * @param event Defines the related dom event
  9257. */
  9258. constructor(
  9259. /**
  9260. * Defines the type of event (KeyboardEventTypes)
  9261. */
  9262. type: number,
  9263. /**
  9264. * Defines the related dom event
  9265. */
  9266. event: KeyboardEvent);
  9267. }
  9268. }
  9269. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9270. import { Nullable } from "babylonjs/types";
  9271. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9272. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9273. /**
  9274. * Manage the keyboard inputs to control the movement of a free camera.
  9275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9276. */
  9277. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9278. /**
  9279. * Defines the camera the input is attached to.
  9280. */
  9281. camera: FreeCamera;
  9282. /**
  9283. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9284. */
  9285. keysUp: number[];
  9286. /**
  9287. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9288. */
  9289. keysDown: number[];
  9290. /**
  9291. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9292. */
  9293. keysLeft: number[];
  9294. /**
  9295. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9296. */
  9297. keysRight: number[];
  9298. private _keys;
  9299. private _onCanvasBlurObserver;
  9300. private _onKeyboardObserver;
  9301. private _engine;
  9302. private _scene;
  9303. /**
  9304. * Attach the input controls to a specific dom element to get the input from.
  9305. * @param element Defines the element the controls should be listened from
  9306. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9307. */
  9308. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9309. /**
  9310. * Detach the current controls from the specified dom element.
  9311. * @param element Defines the element to stop listening the inputs from
  9312. */
  9313. detachControl(element: Nullable<HTMLElement>): void;
  9314. /**
  9315. * Update the current camera state depending on the inputs that have been used this frame.
  9316. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9317. */
  9318. checkInputs(): void;
  9319. /**
  9320. * Gets the class name of the current intput.
  9321. * @returns the class name
  9322. */
  9323. getClassName(): string;
  9324. /** @hidden */
  9325. _onLostFocus(): void;
  9326. /**
  9327. * Get the friendly name associated with the input class.
  9328. * @returns the input friendly name
  9329. */
  9330. getSimpleName(): string;
  9331. }
  9332. }
  9333. declare module "babylonjs/Lights/shadowLight" {
  9334. import { Camera } from "babylonjs/Cameras/camera";
  9335. import { Scene } from "babylonjs/scene";
  9336. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9338. import { Light } from "babylonjs/Lights/light";
  9339. /**
  9340. * Interface describing all the common properties and methods a shadow light needs to implement.
  9341. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9342. * as well as binding the different shadow properties to the effects.
  9343. */
  9344. export interface IShadowLight extends Light {
  9345. /**
  9346. * The light id in the scene (used in scene.findLighById for instance)
  9347. */
  9348. id: string;
  9349. /**
  9350. * The position the shdow will be casted from.
  9351. */
  9352. position: Vector3;
  9353. /**
  9354. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9355. */
  9356. direction: Vector3;
  9357. /**
  9358. * The transformed position. Position of the light in world space taking parenting in account.
  9359. */
  9360. transformedPosition: Vector3;
  9361. /**
  9362. * The transformed direction. Direction of the light in world space taking parenting in account.
  9363. */
  9364. transformedDirection: Vector3;
  9365. /**
  9366. * The friendly name of the light in the scene.
  9367. */
  9368. name: string;
  9369. /**
  9370. * Defines the shadow projection clipping minimum z value.
  9371. */
  9372. shadowMinZ: number;
  9373. /**
  9374. * Defines the shadow projection clipping maximum z value.
  9375. */
  9376. shadowMaxZ: number;
  9377. /**
  9378. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9379. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9380. */
  9381. computeTransformedInformation(): boolean;
  9382. /**
  9383. * Gets the scene the light belongs to.
  9384. * @returns The scene
  9385. */
  9386. getScene(): Scene;
  9387. /**
  9388. * Callback defining a custom Projection Matrix Builder.
  9389. * This can be used to override the default projection matrix computation.
  9390. */
  9391. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9392. /**
  9393. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9394. * @param matrix The materix to updated with the projection information
  9395. * @param viewMatrix The transform matrix of the light
  9396. * @param renderList The list of mesh to render in the map
  9397. * @returns The current light
  9398. */
  9399. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9400. /**
  9401. * Gets the current depth scale used in ESM.
  9402. * @returns The scale
  9403. */
  9404. getDepthScale(): number;
  9405. /**
  9406. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9407. * @returns true if a cube texture needs to be use
  9408. */
  9409. needCube(): boolean;
  9410. /**
  9411. * Detects if the projection matrix requires to be recomputed this frame.
  9412. * @returns true if it requires to be recomputed otherwise, false.
  9413. */
  9414. needProjectionMatrixCompute(): boolean;
  9415. /**
  9416. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9417. */
  9418. forceProjectionMatrixCompute(): void;
  9419. /**
  9420. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9421. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9422. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9423. */
  9424. getShadowDirection(faceIndex?: number): Vector3;
  9425. /**
  9426. * Gets the minZ used for shadow according to both the scene and the light.
  9427. * @param activeCamera The camera we are returning the min for
  9428. * @returns the depth min z
  9429. */
  9430. getDepthMinZ(activeCamera: Camera): number;
  9431. /**
  9432. * Gets the maxZ used for shadow according to both the scene and the light.
  9433. * @param activeCamera The camera we are returning the max for
  9434. * @returns the depth max z
  9435. */
  9436. getDepthMaxZ(activeCamera: Camera): number;
  9437. }
  9438. /**
  9439. * Base implementation IShadowLight
  9440. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9441. */
  9442. export abstract class ShadowLight extends Light implements IShadowLight {
  9443. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9444. protected _position: Vector3;
  9445. protected _setPosition(value: Vector3): void;
  9446. /**
  9447. * Sets the position the shadow will be casted from. Also use as the light position for both
  9448. * point and spot lights.
  9449. */
  9450. /**
  9451. * Sets the position the shadow will be casted from. Also use as the light position for both
  9452. * point and spot lights.
  9453. */
  9454. position: Vector3;
  9455. protected _direction: Vector3;
  9456. protected _setDirection(value: Vector3): void;
  9457. /**
  9458. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9459. * Also use as the light direction on spot and directional lights.
  9460. */
  9461. /**
  9462. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9463. * Also use as the light direction on spot and directional lights.
  9464. */
  9465. direction: Vector3;
  9466. private _shadowMinZ;
  9467. /**
  9468. * Gets the shadow projection clipping minimum z value.
  9469. */
  9470. /**
  9471. * Sets the shadow projection clipping minimum z value.
  9472. */
  9473. shadowMinZ: number;
  9474. private _shadowMaxZ;
  9475. /**
  9476. * Sets the shadow projection clipping maximum z value.
  9477. */
  9478. /**
  9479. * Gets the shadow projection clipping maximum z value.
  9480. */
  9481. shadowMaxZ: number;
  9482. /**
  9483. * Callback defining a custom Projection Matrix Builder.
  9484. * This can be used to override the default projection matrix computation.
  9485. */
  9486. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9487. /**
  9488. * The transformed position. Position of the light in world space taking parenting in account.
  9489. */
  9490. transformedPosition: Vector3;
  9491. /**
  9492. * The transformed direction. Direction of the light in world space taking parenting in account.
  9493. */
  9494. transformedDirection: Vector3;
  9495. private _needProjectionMatrixCompute;
  9496. /**
  9497. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9498. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9499. */
  9500. computeTransformedInformation(): boolean;
  9501. /**
  9502. * Return the depth scale used for the shadow map.
  9503. * @returns the depth scale.
  9504. */
  9505. getDepthScale(): number;
  9506. /**
  9507. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9508. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9509. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9510. */
  9511. getShadowDirection(faceIndex?: number): Vector3;
  9512. /**
  9513. * Returns the ShadowLight absolute position in the World.
  9514. * @returns the position vector in world space
  9515. */
  9516. getAbsolutePosition(): Vector3;
  9517. /**
  9518. * Sets the ShadowLight direction toward the passed target.
  9519. * @param target The point to target in local space
  9520. * @returns the updated ShadowLight direction
  9521. */
  9522. setDirectionToTarget(target: Vector3): Vector3;
  9523. /**
  9524. * Returns the light rotation in euler definition.
  9525. * @returns the x y z rotation in local space.
  9526. */
  9527. getRotation(): Vector3;
  9528. /**
  9529. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9530. * @returns true if a cube texture needs to be use
  9531. */
  9532. needCube(): boolean;
  9533. /**
  9534. * Detects if the projection matrix requires to be recomputed this frame.
  9535. * @returns true if it requires to be recomputed otherwise, false.
  9536. */
  9537. needProjectionMatrixCompute(): boolean;
  9538. /**
  9539. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9540. */
  9541. forceProjectionMatrixCompute(): void;
  9542. /** @hidden */
  9543. _initCache(): void;
  9544. /** @hidden */
  9545. _isSynchronized(): boolean;
  9546. /**
  9547. * Computes the world matrix of the node
  9548. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9549. * @returns the world matrix
  9550. */
  9551. computeWorldMatrix(force?: boolean): Matrix;
  9552. /**
  9553. * Gets the minZ used for shadow according to both the scene and the light.
  9554. * @param activeCamera The camera we are returning the min for
  9555. * @returns the depth min z
  9556. */
  9557. getDepthMinZ(activeCamera: Camera): number;
  9558. /**
  9559. * Gets the maxZ used for shadow according to both the scene and the light.
  9560. * @param activeCamera The camera we are returning the max for
  9561. * @returns the depth max z
  9562. */
  9563. getDepthMaxZ(activeCamera: Camera): number;
  9564. /**
  9565. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9566. * @param matrix The materix to updated with the projection information
  9567. * @param viewMatrix The transform matrix of the light
  9568. * @param renderList The list of mesh to render in the map
  9569. * @returns The current light
  9570. */
  9571. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9572. }
  9573. }
  9574. declare module "babylonjs/Materials/materialHelper" {
  9575. import { Nullable } from "babylonjs/types";
  9576. import { Scene } from "babylonjs/scene";
  9577. import { Engine } from "babylonjs/Engines/engine";
  9578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9579. import { Light } from "babylonjs/Lights/light";
  9580. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9581. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9582. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9583. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9584. /**
  9585. * "Static Class" containing the most commonly used helper while dealing with material for
  9586. * rendering purpose.
  9587. *
  9588. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9589. *
  9590. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9591. */
  9592. export class MaterialHelper {
  9593. /**
  9594. * Bind the current view position to an effect.
  9595. * @param effect The effect to be bound
  9596. * @param scene The scene the eyes position is used from
  9597. */
  9598. static BindEyePosition(effect: Effect, scene: Scene): void;
  9599. /**
  9600. * Helps preparing the defines values about the UVs in used in the effect.
  9601. * UVs are shared as much as we can accross channels in the shaders.
  9602. * @param texture The texture we are preparing the UVs for
  9603. * @param defines The defines to update
  9604. * @param key The channel key "diffuse", "specular"... used in the shader
  9605. */
  9606. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9607. /**
  9608. * Binds a texture matrix value to its corrsponding uniform
  9609. * @param texture The texture to bind the matrix for
  9610. * @param uniformBuffer The uniform buffer receivin the data
  9611. * @param key The channel key "diffuse", "specular"... used in the shader
  9612. */
  9613. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9614. /**
  9615. * Gets the current status of the fog (should it be enabled?)
  9616. * @param mesh defines the mesh to evaluate for fog support
  9617. * @param scene defines the hosting scene
  9618. * @returns true if fog must be enabled
  9619. */
  9620. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9621. /**
  9622. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9623. * @param mesh defines the current mesh
  9624. * @param scene defines the current scene
  9625. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9626. * @param pointsCloud defines if point cloud rendering has to be turned on
  9627. * @param fogEnabled defines if fog has to be turned on
  9628. * @param alphaTest defines if alpha testing has to be turned on
  9629. * @param defines defines the current list of defines
  9630. */
  9631. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9632. /**
  9633. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9634. * @param scene defines the current scene
  9635. * @param engine defines the current engine
  9636. * @param defines specifies the list of active defines
  9637. * @param useInstances defines if instances have to be turned on
  9638. * @param useClipPlane defines if clip plane have to be turned on
  9639. */
  9640. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9641. /**
  9642. * Prepares the defines for bones
  9643. * @param mesh The mesh containing the geometry data we will draw
  9644. * @param defines The defines to update
  9645. */
  9646. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9647. /**
  9648. * Prepares the defines for morph targets
  9649. * @param mesh The mesh containing the geometry data we will draw
  9650. * @param defines The defines to update
  9651. */
  9652. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9653. /**
  9654. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9655. * @param mesh The mesh containing the geometry data we will draw
  9656. * @param defines The defines to update
  9657. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9658. * @param useBones Precise whether bones should be used or not (override mesh info)
  9659. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9660. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9661. * @returns false if defines are considered not dirty and have not been checked
  9662. */
  9663. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9664. /**
  9665. * Prepares the defines related to multiview
  9666. * @param scene The scene we are intending to draw
  9667. * @param defines The defines to update
  9668. */
  9669. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9670. /**
  9671. * Prepares the defines related to the light information passed in parameter
  9672. * @param scene The scene we are intending to draw
  9673. * @param mesh The mesh the effect is compiling for
  9674. * @param defines The defines to update
  9675. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9676. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9677. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9678. * @returns true if normals will be required for the rest of the effect
  9679. */
  9680. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9681. /**
  9682. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9683. * that won t be acctive due to defines being turned off.
  9684. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9685. * @param samplersList The samplers list
  9686. * @param defines The defines helping in the list generation
  9687. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9688. */
  9689. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9690. /**
  9691. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9692. * @param defines The defines to update while falling back
  9693. * @param fallbacks The authorized effect fallbacks
  9694. * @param maxSimultaneousLights The maximum number of lights allowed
  9695. * @param rank the current rank of the Effect
  9696. * @returns The newly affected rank
  9697. */
  9698. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9699. /**
  9700. * Prepares the list of attributes required for morph targets according to the effect defines.
  9701. * @param attribs The current list of supported attribs
  9702. * @param mesh The mesh to prepare the morph targets attributes for
  9703. * @param defines The current Defines of the effect
  9704. */
  9705. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9706. /**
  9707. * Prepares the list of attributes required for bones according to the effect defines.
  9708. * @param attribs The current list of supported attribs
  9709. * @param mesh The mesh to prepare the bones attributes for
  9710. * @param defines The current Defines of the effect
  9711. * @param fallbacks The current efffect fallback strategy
  9712. */
  9713. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9714. /**
  9715. * Check and prepare the list of attributes required for instances according to the effect defines.
  9716. * @param attribs The current list of supported attribs
  9717. * @param defines The current MaterialDefines of the effect
  9718. */
  9719. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9720. /**
  9721. * Add the list of attributes required for instances to the attribs array.
  9722. * @param attribs The current list of supported attribs
  9723. */
  9724. static PushAttributesForInstances(attribs: string[]): void;
  9725. /**
  9726. * Binds the light shadow information to the effect for the given mesh.
  9727. * @param light The light containing the generator
  9728. * @param scene The scene the lights belongs to
  9729. * @param mesh The mesh we are binding the information to render
  9730. * @param lightIndex The light index in the effect used to render the mesh
  9731. * @param effect The effect we are binding the data to
  9732. */
  9733. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9734. /**
  9735. * Binds the light information to the effect.
  9736. * @param light The light containing the generator
  9737. * @param effect The effect we are binding the data to
  9738. * @param lightIndex The light index in the effect used to render
  9739. */
  9740. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9741. /**
  9742. * Binds the lights information from the scene to the effect for the given mesh.
  9743. * @param scene The scene the lights belongs to
  9744. * @param mesh The mesh we are binding the information to render
  9745. * @param effect The effect we are binding the data to
  9746. * @param defines The generated defines for the effect
  9747. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9748. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9749. */
  9750. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9751. private static _tempFogColor;
  9752. /**
  9753. * Binds the fog information from the scene to the effect for the given mesh.
  9754. * @param scene The scene the lights belongs to
  9755. * @param mesh The mesh we are binding the information to render
  9756. * @param effect The effect we are binding the data to
  9757. * @param linearSpace Defines if the fog effect is applied in linear space
  9758. */
  9759. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9760. /**
  9761. * Binds the bones information from the mesh to the effect.
  9762. * @param mesh The mesh we are binding the information to render
  9763. * @param effect The effect we are binding the data to
  9764. */
  9765. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9766. /**
  9767. * Binds the morph targets information from the mesh to the effect.
  9768. * @param abstractMesh The mesh we are binding the information to render
  9769. * @param effect The effect we are binding the data to
  9770. */
  9771. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9772. /**
  9773. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9774. * @param defines The generated defines used in the effect
  9775. * @param effect The effect we are binding the data to
  9776. * @param scene The scene we are willing to render with logarithmic scale for
  9777. */
  9778. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9779. /**
  9780. * Binds the clip plane information from the scene to the effect.
  9781. * @param scene The scene the clip plane information are extracted from
  9782. * @param effect The effect we are binding the data to
  9783. */
  9784. static BindClipPlane(effect: Effect, scene: Scene): void;
  9785. }
  9786. }
  9787. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9788. /** @hidden */
  9789. export var kernelBlurVaryingDeclaration: {
  9790. name: string;
  9791. shader: string;
  9792. };
  9793. }
  9794. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9795. /** @hidden */
  9796. export var kernelBlurFragment: {
  9797. name: string;
  9798. shader: string;
  9799. };
  9800. }
  9801. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9802. /** @hidden */
  9803. export var kernelBlurFragment2: {
  9804. name: string;
  9805. shader: string;
  9806. };
  9807. }
  9808. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9809. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9810. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9811. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9812. /** @hidden */
  9813. export var kernelBlurPixelShader: {
  9814. name: string;
  9815. shader: string;
  9816. };
  9817. }
  9818. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9819. /** @hidden */
  9820. export var kernelBlurVertex: {
  9821. name: string;
  9822. shader: string;
  9823. };
  9824. }
  9825. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9826. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9827. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9828. /** @hidden */
  9829. export var kernelBlurVertexShader: {
  9830. name: string;
  9831. shader: string;
  9832. };
  9833. }
  9834. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9835. import { Vector2 } from "babylonjs/Maths/math";
  9836. import { Nullable } from "babylonjs/types";
  9837. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9838. import { Camera } from "babylonjs/Cameras/camera";
  9839. import { Effect } from "babylonjs/Materials/effect";
  9840. import { Engine } from "babylonjs/Engines/engine";
  9841. import "babylonjs/Shaders/kernelBlur.fragment";
  9842. import "babylonjs/Shaders/kernelBlur.vertex";
  9843. /**
  9844. * The Blur Post Process which blurs an image based on a kernel and direction.
  9845. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9846. */
  9847. export class BlurPostProcess extends PostProcess {
  9848. /** The direction in which to blur the image. */
  9849. direction: Vector2;
  9850. private blockCompilation;
  9851. protected _kernel: number;
  9852. protected _idealKernel: number;
  9853. protected _packedFloat: boolean;
  9854. private _staticDefines;
  9855. /**
  9856. * Sets the length in pixels of the blur sample region
  9857. */
  9858. /**
  9859. * Gets the length in pixels of the blur sample region
  9860. */
  9861. kernel: number;
  9862. /**
  9863. * Sets wether or not the blur needs to unpack/repack floats
  9864. */
  9865. /**
  9866. * Gets wether or not the blur is unpacking/repacking floats
  9867. */
  9868. packedFloat: boolean;
  9869. /**
  9870. * Creates a new instance BlurPostProcess
  9871. * @param name The name of the effect.
  9872. * @param direction The direction in which to blur the image.
  9873. * @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.
  9874. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9875. * @param camera The camera to apply the render pass to.
  9876. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9877. * @param engine The engine which the post process will be applied. (default: current engine)
  9878. * @param reusable If the post process can be reused on the same frame. (default: false)
  9879. * @param textureType Type of textures used when performing the post process. (default: 0)
  9880. * @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)
  9881. */
  9882. constructor(name: string,
  9883. /** The direction in which to blur the image. */
  9884. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9885. /**
  9886. * Updates the effect with the current post process compile time values and recompiles the shader.
  9887. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9888. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9889. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9890. * @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
  9891. * @param onCompiled Called when the shader has been compiled.
  9892. * @param onError Called if there is an error when compiling a shader.
  9893. */
  9894. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9895. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9896. /**
  9897. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9898. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9899. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9900. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9901. * The gaps between physical kernels are compensated for in the weighting of the samples
  9902. * @param idealKernel Ideal blur kernel.
  9903. * @return Nearest best kernel.
  9904. */
  9905. protected _nearestBestKernel(idealKernel: number): number;
  9906. /**
  9907. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9908. * @param x The point on the Gaussian distribution to sample.
  9909. * @return the value of the Gaussian function at x.
  9910. */
  9911. protected _gaussianWeight(x: number): number;
  9912. /**
  9913. * Generates a string that can be used as a floating point number in GLSL.
  9914. * @param x Value to print.
  9915. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9916. * @return GLSL float string.
  9917. */
  9918. protected _glslFloat(x: number, decimalFigures?: number): string;
  9919. }
  9920. }
  9921. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9922. /** @hidden */
  9923. export var shadowMapPixelShader: {
  9924. name: string;
  9925. shader: string;
  9926. };
  9927. }
  9928. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9929. /** @hidden */
  9930. export var bonesDeclaration: {
  9931. name: string;
  9932. shader: string;
  9933. };
  9934. }
  9935. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9936. /** @hidden */
  9937. export var morphTargetsVertexGlobalDeclaration: {
  9938. name: string;
  9939. shader: string;
  9940. };
  9941. }
  9942. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9943. /** @hidden */
  9944. export var morphTargetsVertexDeclaration: {
  9945. name: string;
  9946. shader: string;
  9947. };
  9948. }
  9949. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9950. /** @hidden */
  9951. export var instancesDeclaration: {
  9952. name: string;
  9953. shader: string;
  9954. };
  9955. }
  9956. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9957. /** @hidden */
  9958. export var helperFunctions: {
  9959. name: string;
  9960. shader: string;
  9961. };
  9962. }
  9963. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9964. /** @hidden */
  9965. export var morphTargetsVertex: {
  9966. name: string;
  9967. shader: string;
  9968. };
  9969. }
  9970. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9971. /** @hidden */
  9972. export var instancesVertex: {
  9973. name: string;
  9974. shader: string;
  9975. };
  9976. }
  9977. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9978. /** @hidden */
  9979. export var bonesVertex: {
  9980. name: string;
  9981. shader: string;
  9982. };
  9983. }
  9984. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9985. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9986. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9987. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9988. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9989. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9990. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9991. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9992. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9993. /** @hidden */
  9994. export var shadowMapVertexShader: {
  9995. name: string;
  9996. shader: string;
  9997. };
  9998. }
  9999. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  10000. /** @hidden */
  10001. export var depthBoxBlurPixelShader: {
  10002. name: string;
  10003. shader: string;
  10004. };
  10005. }
  10006. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  10007. import { Nullable } from "babylonjs/types";
  10008. import { Scene } from "babylonjs/scene";
  10009. import { Matrix } from "babylonjs/Maths/math";
  10010. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10012. import { Mesh } from "babylonjs/Meshes/mesh";
  10013. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  10014. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  10015. import { Effect } from "babylonjs/Materials/effect";
  10016. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10017. import "babylonjs/Shaders/shadowMap.fragment";
  10018. import "babylonjs/Shaders/shadowMap.vertex";
  10019. import "babylonjs/Shaders/depthBoxBlur.fragment";
  10020. import { Observable } from "babylonjs/Misc/observable";
  10021. /**
  10022. * Defines the options associated with the creation of a custom shader for a shadow generator.
  10023. */
  10024. export interface ICustomShaderOptions {
  10025. /**
  10026. * Gets or sets the custom shader name to use
  10027. */
  10028. shaderName: string;
  10029. /**
  10030. * The list of attribute names used in the shader
  10031. */
  10032. attributes?: string[];
  10033. /**
  10034. * The list of unifrom names used in the shader
  10035. */
  10036. uniforms?: string[];
  10037. /**
  10038. * The list of sampler names used in the shader
  10039. */
  10040. samplers?: string[];
  10041. /**
  10042. * The list of defines used in the shader
  10043. */
  10044. defines?: string[];
  10045. }
  10046. /**
  10047. * Interface to implement to create a shadow generator compatible with BJS.
  10048. */
  10049. export interface IShadowGenerator {
  10050. /**
  10051. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10052. * @returns The render target texture if present otherwise, null
  10053. */
  10054. getShadowMap(): Nullable<RenderTargetTexture>;
  10055. /**
  10056. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10057. * @returns The render target texture if the shadow map is present otherwise, null
  10058. */
  10059. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10060. /**
  10061. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10062. * @param subMesh The submesh we want to render in the shadow map
  10063. * @param useInstances Defines wether will draw in the map using instances
  10064. * @returns true if ready otherwise, false
  10065. */
  10066. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10067. /**
  10068. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10069. * @param defines Defines of the material we want to update
  10070. * @param lightIndex Index of the light in the enabled light list of the material
  10071. */
  10072. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  10073. /**
  10074. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10075. * defined in the generator but impacting the effect).
  10076. * It implies the unifroms available on the materials are the standard BJS ones.
  10077. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10078. * @param effect The effect we are binfing the information for
  10079. */
  10080. bindShadowLight(lightIndex: string, effect: Effect): void;
  10081. /**
  10082. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10083. * (eq to shadow prjection matrix * light transform matrix)
  10084. * @returns The transform matrix used to create the shadow map
  10085. */
  10086. getTransformMatrix(): Matrix;
  10087. /**
  10088. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10089. * Cube and 2D textures for instance.
  10090. */
  10091. recreateShadowMap(): void;
  10092. /**
  10093. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10094. * @param onCompiled Callback triggered at the and of the effects compilation
  10095. * @param options Sets of optional options forcing the compilation with different modes
  10096. */
  10097. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10098. useInstances: boolean;
  10099. }>): void;
  10100. /**
  10101. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10102. * @param options Sets of optional options forcing the compilation with different modes
  10103. * @returns A promise that resolves when the compilation completes
  10104. */
  10105. forceCompilationAsync(options?: Partial<{
  10106. useInstances: boolean;
  10107. }>): Promise<void>;
  10108. /**
  10109. * Serializes the shadow generator setup to a json object.
  10110. * @returns The serialized JSON object
  10111. */
  10112. serialize(): any;
  10113. /**
  10114. * Disposes the Shadow map and related Textures and effects.
  10115. */
  10116. dispose(): void;
  10117. }
  10118. /**
  10119. * Default implementation IShadowGenerator.
  10120. * This is the main object responsible of generating shadows in the framework.
  10121. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  10122. */
  10123. export class ShadowGenerator implements IShadowGenerator {
  10124. /**
  10125. * Shadow generator mode None: no filtering applied.
  10126. */
  10127. static readonly FILTER_NONE: number;
  10128. /**
  10129. * Shadow generator mode ESM: Exponential Shadow Mapping.
  10130. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10131. */
  10132. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  10133. /**
  10134. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  10135. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  10136. */
  10137. static readonly FILTER_POISSONSAMPLING: number;
  10138. /**
  10139. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  10140. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10141. */
  10142. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  10143. /**
  10144. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  10145. * edge artifacts on steep falloff.
  10146. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10147. */
  10148. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  10149. /**
  10150. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  10151. * edge artifacts on steep falloff.
  10152. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10153. */
  10154. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  10155. /**
  10156. * Shadow generator mode PCF: Percentage Closer Filtering
  10157. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10158. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  10159. */
  10160. static readonly FILTER_PCF: number;
  10161. /**
  10162. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  10163. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10164. * Contact Hardening
  10165. */
  10166. static readonly FILTER_PCSS: number;
  10167. /**
  10168. * Reserved for PCF and PCSS
  10169. * Highest Quality.
  10170. *
  10171. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  10172. *
  10173. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  10174. */
  10175. static readonly QUALITY_HIGH: number;
  10176. /**
  10177. * Reserved for PCF and PCSS
  10178. * Good tradeoff for quality/perf cross devices
  10179. *
  10180. * Execute PCF on a 3*3 kernel.
  10181. *
  10182. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  10183. */
  10184. static readonly QUALITY_MEDIUM: number;
  10185. /**
  10186. * Reserved for PCF and PCSS
  10187. * The lowest quality but the fastest.
  10188. *
  10189. * Execute PCF on a 1*1 kernel.
  10190. *
  10191. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  10192. */
  10193. static readonly QUALITY_LOW: number;
  10194. /** Gets or sets the custom shader name to use */
  10195. customShaderOptions: ICustomShaderOptions;
  10196. /**
  10197. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  10198. */
  10199. onBeforeShadowMapRenderObservable: Observable<Effect>;
  10200. /**
  10201. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  10202. */
  10203. onAfterShadowMapRenderObservable: Observable<Effect>;
  10204. /**
  10205. * Observable triggered before a mesh is rendered in the shadow map.
  10206. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  10207. */
  10208. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  10209. /**
  10210. * Observable triggered after a mesh is rendered in the shadow map.
  10211. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  10212. */
  10213. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  10214. private _bias;
  10215. /**
  10216. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10217. */
  10218. /**
  10219. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10220. */
  10221. bias: number;
  10222. private _normalBias;
  10223. /**
  10224. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10225. */
  10226. /**
  10227. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10228. */
  10229. normalBias: number;
  10230. private _blurBoxOffset;
  10231. /**
  10232. * Gets the blur box offset: offset applied during the blur pass.
  10233. * Only useful if useKernelBlur = false
  10234. */
  10235. /**
  10236. * Sets the blur box offset: offset applied during the blur pass.
  10237. * Only useful if useKernelBlur = false
  10238. */
  10239. blurBoxOffset: number;
  10240. private _blurScale;
  10241. /**
  10242. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10243. * 2 means half of the size.
  10244. */
  10245. /**
  10246. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10247. * 2 means half of the size.
  10248. */
  10249. blurScale: number;
  10250. private _blurKernel;
  10251. /**
  10252. * Gets the blur kernel: kernel size of the blur pass.
  10253. * Only useful if useKernelBlur = true
  10254. */
  10255. /**
  10256. * Sets the blur kernel: kernel size of the blur pass.
  10257. * Only useful if useKernelBlur = true
  10258. */
  10259. blurKernel: number;
  10260. private _useKernelBlur;
  10261. /**
  10262. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10263. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10264. */
  10265. /**
  10266. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10267. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10268. */
  10269. useKernelBlur: boolean;
  10270. private _depthScale;
  10271. /**
  10272. * Gets the depth scale used in ESM mode.
  10273. */
  10274. /**
  10275. * Sets the depth scale used in ESM mode.
  10276. * This can override the scale stored on the light.
  10277. */
  10278. depthScale: number;
  10279. private _filter;
  10280. /**
  10281. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10282. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10283. */
  10284. /**
  10285. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10286. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10287. */
  10288. filter: number;
  10289. /**
  10290. * Gets if the current filter is set to Poisson Sampling.
  10291. */
  10292. /**
  10293. * Sets the current filter to Poisson Sampling.
  10294. */
  10295. usePoissonSampling: boolean;
  10296. /**
  10297. * Gets if the current filter is set to ESM.
  10298. */
  10299. /**
  10300. * Sets the current filter is to ESM.
  10301. */
  10302. useExponentialShadowMap: boolean;
  10303. /**
  10304. * Gets if the current filter is set to filtered ESM.
  10305. */
  10306. /**
  10307. * Gets if the current filter is set to filtered ESM.
  10308. */
  10309. useBlurExponentialShadowMap: boolean;
  10310. /**
  10311. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10312. * exponential to prevent steep falloff artifacts).
  10313. */
  10314. /**
  10315. * Sets the current filter to "close ESM" (using the inverse of the
  10316. * exponential to prevent steep falloff artifacts).
  10317. */
  10318. useCloseExponentialShadowMap: boolean;
  10319. /**
  10320. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10321. * exponential to prevent steep falloff artifacts).
  10322. */
  10323. /**
  10324. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10325. * exponential to prevent steep falloff artifacts).
  10326. */
  10327. useBlurCloseExponentialShadowMap: boolean;
  10328. /**
  10329. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10330. */
  10331. /**
  10332. * Sets the current filter to "PCF" (percentage closer filtering).
  10333. */
  10334. usePercentageCloserFiltering: boolean;
  10335. private _filteringQuality;
  10336. /**
  10337. * Gets the PCF or PCSS Quality.
  10338. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10339. */
  10340. /**
  10341. * Sets the PCF or PCSS Quality.
  10342. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10343. */
  10344. filteringQuality: number;
  10345. /**
  10346. * Gets if the current filter is set to "PCSS" (contact hardening).
  10347. */
  10348. /**
  10349. * Sets the current filter to "PCSS" (contact hardening).
  10350. */
  10351. useContactHardeningShadow: boolean;
  10352. private _contactHardeningLightSizeUVRatio;
  10353. /**
  10354. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10355. * Using a ratio helps keeping shape stability independently of the map size.
  10356. *
  10357. * It does not account for the light projection as it was having too much
  10358. * instability during the light setup or during light position changes.
  10359. *
  10360. * Only valid if useContactHardeningShadow is true.
  10361. */
  10362. /**
  10363. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10364. * Using a ratio helps keeping shape stability independently of the map size.
  10365. *
  10366. * It does not account for the light projection as it was having too much
  10367. * instability during the light setup or during light position changes.
  10368. *
  10369. * Only valid if useContactHardeningShadow is true.
  10370. */
  10371. contactHardeningLightSizeUVRatio: number;
  10372. private _darkness;
  10373. /** Gets or sets the actual darkness of a shadow */
  10374. darkness: number;
  10375. /**
  10376. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10377. * 0 means strongest and 1 would means no shadow.
  10378. * @returns the darkness.
  10379. */
  10380. getDarkness(): number;
  10381. /**
  10382. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10383. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10384. * @returns the shadow generator allowing fluent coding.
  10385. */
  10386. setDarkness(darkness: number): ShadowGenerator;
  10387. private _transparencyShadow;
  10388. /** Gets or sets the ability to have transparent shadow */
  10389. transparencyShadow: boolean;
  10390. /**
  10391. * Sets the ability to have transparent shadow (boolean).
  10392. * @param transparent True if transparent else False
  10393. * @returns the shadow generator allowing fluent coding
  10394. */
  10395. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10396. private _shadowMap;
  10397. private _shadowMap2;
  10398. /**
  10399. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10400. * @returns The render target texture if present otherwise, null
  10401. */
  10402. getShadowMap(): Nullable<RenderTargetTexture>;
  10403. /**
  10404. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10405. * @returns The render target texture if the shadow map is present otherwise, null
  10406. */
  10407. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10408. /**
  10409. * Gets the class name of that object
  10410. * @returns "ShadowGenerator"
  10411. */
  10412. getClassName(): string;
  10413. /**
  10414. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10415. * @param mesh Mesh to add
  10416. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10417. * @returns the Shadow Generator itself
  10418. */
  10419. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10420. /**
  10421. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10422. * @param mesh Mesh to remove
  10423. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10424. * @returns the Shadow Generator itself
  10425. */
  10426. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10427. /**
  10428. * Controls the extent to which the shadows fade out at the edge of the frustum
  10429. * Used only by directionals and spots
  10430. */
  10431. frustumEdgeFalloff: number;
  10432. private _light;
  10433. /**
  10434. * Returns the associated light object.
  10435. * @returns the light generating the shadow
  10436. */
  10437. getLight(): IShadowLight;
  10438. /**
  10439. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10440. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10441. * It might on the other hand introduce peter panning.
  10442. */
  10443. forceBackFacesOnly: boolean;
  10444. private _scene;
  10445. private _lightDirection;
  10446. private _effect;
  10447. private _viewMatrix;
  10448. private _projectionMatrix;
  10449. private _transformMatrix;
  10450. private _cachedPosition;
  10451. private _cachedDirection;
  10452. private _cachedDefines;
  10453. private _currentRenderID;
  10454. private _boxBlurPostprocess;
  10455. private _kernelBlurXPostprocess;
  10456. private _kernelBlurYPostprocess;
  10457. private _blurPostProcesses;
  10458. private _mapSize;
  10459. private _currentFaceIndex;
  10460. private _currentFaceIndexCache;
  10461. private _textureType;
  10462. private _defaultTextureMatrix;
  10463. /** @hidden */
  10464. static _SceneComponentInitialization: (scene: Scene) => void;
  10465. /**
  10466. * Creates a ShadowGenerator object.
  10467. * A ShadowGenerator is the required tool to use the shadows.
  10468. * Each light casting shadows needs to use its own ShadowGenerator.
  10469. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10470. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10471. * @param light The light object generating the shadows.
  10472. * @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.
  10473. */
  10474. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10475. private _initializeGenerator;
  10476. private _initializeShadowMap;
  10477. private _initializeBlurRTTAndPostProcesses;
  10478. private _renderForShadowMap;
  10479. private _renderSubMeshForShadowMap;
  10480. private _applyFilterValues;
  10481. /**
  10482. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10483. * @param onCompiled Callback triggered at the and of the effects compilation
  10484. * @param options Sets of optional options forcing the compilation with different modes
  10485. */
  10486. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10487. useInstances: boolean;
  10488. }>): void;
  10489. /**
  10490. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10491. * @param options Sets of optional options forcing the compilation with different modes
  10492. * @returns A promise that resolves when the compilation completes
  10493. */
  10494. forceCompilationAsync(options?: Partial<{
  10495. useInstances: boolean;
  10496. }>): Promise<void>;
  10497. /**
  10498. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10499. * @param subMesh The submesh we want to render in the shadow map
  10500. * @param useInstances Defines wether will draw in the map using instances
  10501. * @returns true if ready otherwise, false
  10502. */
  10503. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10504. /**
  10505. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10506. * @param defines Defines of the material we want to update
  10507. * @param lightIndex Index of the light in the enabled light list of the material
  10508. */
  10509. prepareDefines(defines: any, lightIndex: number): void;
  10510. /**
  10511. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10512. * defined in the generator but impacting the effect).
  10513. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10514. * @param effect The effect we are binfing the information for
  10515. */
  10516. bindShadowLight(lightIndex: string, effect: Effect): void;
  10517. /**
  10518. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10519. * (eq to shadow prjection matrix * light transform matrix)
  10520. * @returns The transform matrix used to create the shadow map
  10521. */
  10522. getTransformMatrix(): Matrix;
  10523. /**
  10524. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10525. * Cube and 2D textures for instance.
  10526. */
  10527. recreateShadowMap(): void;
  10528. private _disposeBlurPostProcesses;
  10529. private _disposeRTTandPostProcesses;
  10530. /**
  10531. * Disposes the ShadowGenerator.
  10532. * Returns nothing.
  10533. */
  10534. dispose(): void;
  10535. /**
  10536. * Serializes the shadow generator setup to a json object.
  10537. * @returns The serialized JSON object
  10538. */
  10539. serialize(): any;
  10540. /**
  10541. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10542. * @param parsedShadowGenerator The JSON object to parse
  10543. * @param scene The scene to create the shadow map for
  10544. * @returns The parsed shadow generator
  10545. */
  10546. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10547. }
  10548. }
  10549. declare module "babylonjs/Lights/light" {
  10550. import { Nullable } from "babylonjs/types";
  10551. import { Scene } from "babylonjs/scene";
  10552. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10553. import { Node } from "babylonjs/node";
  10554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10555. import { Effect } from "babylonjs/Materials/effect";
  10556. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10557. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10558. /**
  10559. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10560. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10561. * 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.
  10562. */
  10563. export abstract class Light extends Node {
  10564. /**
  10565. * Falloff Default: light is falling off following the material specification:
  10566. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10567. */
  10568. static readonly FALLOFF_DEFAULT: number;
  10569. /**
  10570. * Falloff Physical: light is falling off following the inverse squared distance law.
  10571. */
  10572. static readonly FALLOFF_PHYSICAL: number;
  10573. /**
  10574. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10575. * to enhance interoperability with other engines.
  10576. */
  10577. static readonly FALLOFF_GLTF: number;
  10578. /**
  10579. * Falloff Standard: light is falling off like in the standard material
  10580. * to enhance interoperability with other materials.
  10581. */
  10582. static readonly FALLOFF_STANDARD: number;
  10583. /**
  10584. * If every light affecting the material is in this lightmapMode,
  10585. * material.lightmapTexture adds or multiplies
  10586. * (depends on material.useLightmapAsShadowmap)
  10587. * after every other light calculations.
  10588. */
  10589. static readonly LIGHTMAP_DEFAULT: number;
  10590. /**
  10591. * material.lightmapTexture as only diffuse lighting from this light
  10592. * adds only specular lighting from this light
  10593. * adds dynamic shadows
  10594. */
  10595. static readonly LIGHTMAP_SPECULAR: number;
  10596. /**
  10597. * material.lightmapTexture as only lighting
  10598. * no light calculation from this light
  10599. * only adds dynamic shadows from this light
  10600. */
  10601. static readonly LIGHTMAP_SHADOWSONLY: number;
  10602. /**
  10603. * Each light type uses the default quantity according to its type:
  10604. * point/spot lights use luminous intensity
  10605. * directional lights use illuminance
  10606. */
  10607. static readonly INTENSITYMODE_AUTOMATIC: number;
  10608. /**
  10609. * lumen (lm)
  10610. */
  10611. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10612. /**
  10613. * candela (lm/sr)
  10614. */
  10615. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10616. /**
  10617. * lux (lm/m^2)
  10618. */
  10619. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10620. /**
  10621. * nit (cd/m^2)
  10622. */
  10623. static readonly INTENSITYMODE_LUMINANCE: number;
  10624. /**
  10625. * Light type const id of the point light.
  10626. */
  10627. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10628. /**
  10629. * Light type const id of the directional light.
  10630. */
  10631. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10632. /**
  10633. * Light type const id of the spot light.
  10634. */
  10635. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10636. /**
  10637. * Light type const id of the hemispheric light.
  10638. */
  10639. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10640. /**
  10641. * Diffuse gives the basic color to an object.
  10642. */
  10643. diffuse: Color3;
  10644. /**
  10645. * Specular produces a highlight color on an object.
  10646. * Note: This is note affecting PBR materials.
  10647. */
  10648. specular: Color3;
  10649. /**
  10650. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10651. * falling off base on range or angle.
  10652. * This can be set to any values in Light.FALLOFF_x.
  10653. *
  10654. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10655. * other types of materials.
  10656. */
  10657. falloffType: number;
  10658. /**
  10659. * Strength of the light.
  10660. * Note: By default it is define in the framework own unit.
  10661. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10662. */
  10663. intensity: number;
  10664. private _range;
  10665. protected _inverseSquaredRange: number;
  10666. /**
  10667. * Defines how far from the source the light is impacting in scene units.
  10668. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10669. */
  10670. /**
  10671. * Defines how far from the source the light is impacting in scene units.
  10672. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10673. */
  10674. range: number;
  10675. /**
  10676. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10677. * of light.
  10678. */
  10679. private _photometricScale;
  10680. private _intensityMode;
  10681. /**
  10682. * Gets the photometric scale used to interpret the intensity.
  10683. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10684. */
  10685. /**
  10686. * Sets the photometric scale used to interpret the intensity.
  10687. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10688. */
  10689. intensityMode: number;
  10690. private _radius;
  10691. /**
  10692. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10693. */
  10694. /**
  10695. * sets the light radius used by PBR Materials to simulate soft area lights.
  10696. */
  10697. radius: number;
  10698. private _renderPriority;
  10699. /**
  10700. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10701. * exceeding the number allowed of the materials.
  10702. */
  10703. renderPriority: number;
  10704. private _shadowEnabled;
  10705. /**
  10706. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10707. * the current shadow generator.
  10708. */
  10709. /**
  10710. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10711. * the current shadow generator.
  10712. */
  10713. shadowEnabled: boolean;
  10714. private _includedOnlyMeshes;
  10715. /**
  10716. * Gets the only meshes impacted by this light.
  10717. */
  10718. /**
  10719. * Sets the only meshes impacted by this light.
  10720. */
  10721. includedOnlyMeshes: AbstractMesh[];
  10722. private _excludedMeshes;
  10723. /**
  10724. * Gets the meshes not impacted by this light.
  10725. */
  10726. /**
  10727. * Sets the meshes not impacted by this light.
  10728. */
  10729. excludedMeshes: AbstractMesh[];
  10730. private _excludeWithLayerMask;
  10731. /**
  10732. * Gets the layer id use to find what meshes are not impacted by the light.
  10733. * Inactive if 0
  10734. */
  10735. /**
  10736. * Sets the layer id use to find what meshes are not impacted by the light.
  10737. * Inactive if 0
  10738. */
  10739. excludeWithLayerMask: number;
  10740. private _includeOnlyWithLayerMask;
  10741. /**
  10742. * Gets the layer id use to find what meshes are impacted by the light.
  10743. * Inactive if 0
  10744. */
  10745. /**
  10746. * Sets the layer id use to find what meshes are impacted by the light.
  10747. * Inactive if 0
  10748. */
  10749. includeOnlyWithLayerMask: number;
  10750. private _lightmapMode;
  10751. /**
  10752. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10753. */
  10754. /**
  10755. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10756. */
  10757. lightmapMode: number;
  10758. /**
  10759. * Shadow generator associted to the light.
  10760. * @hidden Internal use only.
  10761. */
  10762. _shadowGenerator: Nullable<IShadowGenerator>;
  10763. /**
  10764. * @hidden Internal use only.
  10765. */
  10766. _excludedMeshesIds: string[];
  10767. /**
  10768. * @hidden Internal use only.
  10769. */
  10770. _includedOnlyMeshesIds: string[];
  10771. /**
  10772. * The current light unifom buffer.
  10773. * @hidden Internal use only.
  10774. */
  10775. _uniformBuffer: UniformBuffer;
  10776. /**
  10777. * Creates a Light object in the scene.
  10778. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10779. * @param name The firendly name of the light
  10780. * @param scene The scene the light belongs too
  10781. */
  10782. constructor(name: string, scene: Scene);
  10783. protected abstract _buildUniformLayout(): void;
  10784. /**
  10785. * Sets the passed Effect "effect" with the Light information.
  10786. * @param effect The effect to update
  10787. * @param lightIndex The index of the light in the effect to update
  10788. * @returns The light
  10789. */
  10790. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10791. /**
  10792. * Returns the string "Light".
  10793. * @returns the class name
  10794. */
  10795. getClassName(): string;
  10796. /** @hidden */
  10797. readonly _isLight: boolean;
  10798. /**
  10799. * Converts the light information to a readable string for debug purpose.
  10800. * @param fullDetails Supports for multiple levels of logging within scene loading
  10801. * @returns the human readable light info
  10802. */
  10803. toString(fullDetails?: boolean): string;
  10804. /** @hidden */
  10805. protected _syncParentEnabledState(): void;
  10806. /**
  10807. * Set the enabled state of this node.
  10808. * @param value - the new enabled state
  10809. */
  10810. setEnabled(value: boolean): void;
  10811. /**
  10812. * Returns the Light associated shadow generator if any.
  10813. * @return the associated shadow generator.
  10814. */
  10815. getShadowGenerator(): Nullable<IShadowGenerator>;
  10816. /**
  10817. * Returns a Vector3, the absolute light position in the World.
  10818. * @returns the world space position of the light
  10819. */
  10820. getAbsolutePosition(): Vector3;
  10821. /**
  10822. * Specifies if the light will affect the passed mesh.
  10823. * @param mesh The mesh to test against the light
  10824. * @return true the mesh is affected otherwise, false.
  10825. */
  10826. canAffectMesh(mesh: AbstractMesh): boolean;
  10827. /**
  10828. * Sort function to order lights for rendering.
  10829. * @param a First Light object to compare to second.
  10830. * @param b Second Light object to compare first.
  10831. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10832. */
  10833. static CompareLightsPriority(a: Light, b: Light): number;
  10834. /**
  10835. * Releases resources associated with this node.
  10836. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10837. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10838. */
  10839. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10840. /**
  10841. * Returns the light type ID (integer).
  10842. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10843. */
  10844. getTypeID(): number;
  10845. /**
  10846. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10847. * @returns the scaled intensity in intensity mode unit
  10848. */
  10849. getScaledIntensity(): number;
  10850. /**
  10851. * Returns a new Light object, named "name", from the current one.
  10852. * @param name The name of the cloned light
  10853. * @returns the new created light
  10854. */
  10855. clone(name: string): Nullable<Light>;
  10856. /**
  10857. * Serializes the current light into a Serialization object.
  10858. * @returns the serialized object.
  10859. */
  10860. serialize(): any;
  10861. /**
  10862. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10863. * This new light is named "name" and added to the passed scene.
  10864. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10865. * @param name The friendly name of the light
  10866. * @param scene The scene the new light will belong to
  10867. * @returns the constructor function
  10868. */
  10869. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10870. /**
  10871. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10872. * @param parsedLight The JSON representation of the light
  10873. * @param scene The scene to create the parsed light in
  10874. * @returns the created light after parsing
  10875. */
  10876. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10877. private _hookArrayForExcluded;
  10878. private _hookArrayForIncludedOnly;
  10879. private _resyncMeshes;
  10880. /**
  10881. * Forces the meshes to update their light related information in their rendering used effects
  10882. * @hidden Internal Use Only
  10883. */
  10884. _markMeshesAsLightDirty(): void;
  10885. /**
  10886. * Recomputes the cached photometric scale if needed.
  10887. */
  10888. private _computePhotometricScale;
  10889. /**
  10890. * Returns the Photometric Scale according to the light type and intensity mode.
  10891. */
  10892. private _getPhotometricScale;
  10893. /**
  10894. * Reorder the light in the scene according to their defined priority.
  10895. * @hidden Internal Use Only
  10896. */
  10897. _reorderLightsInScene(): void;
  10898. /**
  10899. * Prepares the list of defines specific to the light type.
  10900. * @param defines the list of defines
  10901. * @param lightIndex defines the index of the light for the effect
  10902. */
  10903. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10904. }
  10905. }
  10906. declare module "babylonjs/Actions/action" {
  10907. import { Observable } from "babylonjs/Misc/observable";
  10908. import { Condition } from "babylonjs/Actions/condition";
  10909. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10910. import { ActionManager } from "babylonjs/Actions/actionManager";
  10911. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10912. /**
  10913. * Interface used to define Action
  10914. */
  10915. export interface IAction {
  10916. /**
  10917. * Trigger for the action
  10918. */
  10919. trigger: number;
  10920. /** Options of the trigger */
  10921. triggerOptions: any;
  10922. /**
  10923. * Gets the trigger parameters
  10924. * @returns the trigger parameters
  10925. */
  10926. getTriggerParameter(): any;
  10927. /**
  10928. * Internal only - executes current action event
  10929. * @hidden
  10930. */
  10931. _executeCurrent(evt?: ActionEvent): void;
  10932. /**
  10933. * Serialize placeholder for child classes
  10934. * @param parent of child
  10935. * @returns the serialized object
  10936. */
  10937. serialize(parent: any): any;
  10938. /**
  10939. * Internal only
  10940. * @hidden
  10941. */
  10942. _prepare(): void;
  10943. /**
  10944. * Internal only - manager for action
  10945. * @hidden
  10946. */
  10947. _actionManager: AbstractActionManager;
  10948. /**
  10949. * Adds action to chain of actions, may be a DoNothingAction
  10950. * @param action defines the next action to execute
  10951. * @returns The action passed in
  10952. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10953. */
  10954. then(action: IAction): IAction;
  10955. }
  10956. /**
  10957. * The action to be carried out following a trigger
  10958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10959. */
  10960. export class Action implements IAction {
  10961. /** the trigger, with or without parameters, for the action */
  10962. triggerOptions: any;
  10963. /**
  10964. * Trigger for the action
  10965. */
  10966. trigger: number;
  10967. /**
  10968. * Internal only - manager for action
  10969. * @hidden
  10970. */
  10971. _actionManager: ActionManager;
  10972. private _nextActiveAction;
  10973. private _child;
  10974. private _condition?;
  10975. private _triggerParameter;
  10976. /**
  10977. * An event triggered prior to action being executed.
  10978. */
  10979. onBeforeExecuteObservable: Observable<Action>;
  10980. /**
  10981. * Creates a new Action
  10982. * @param triggerOptions the trigger, with or without parameters, for the action
  10983. * @param condition an optional determinant of action
  10984. */
  10985. constructor(
  10986. /** the trigger, with or without parameters, for the action */
  10987. triggerOptions: any, condition?: Condition);
  10988. /**
  10989. * Internal only
  10990. * @hidden
  10991. */
  10992. _prepare(): void;
  10993. /**
  10994. * Gets the trigger parameters
  10995. * @returns the trigger parameters
  10996. */
  10997. getTriggerParameter(): any;
  10998. /**
  10999. * Internal only - executes current action event
  11000. * @hidden
  11001. */
  11002. _executeCurrent(evt?: ActionEvent): void;
  11003. /**
  11004. * Execute placeholder for child classes
  11005. * @param evt optional action event
  11006. */
  11007. execute(evt?: ActionEvent): void;
  11008. /**
  11009. * Skips to next active action
  11010. */
  11011. skipToNextActiveAction(): void;
  11012. /**
  11013. * Adds action to chain of actions, may be a DoNothingAction
  11014. * @param action defines the next action to execute
  11015. * @returns The action passed in
  11016. * @see https://www.babylonjs-playground.com/#1T30HR#0
  11017. */
  11018. then(action: Action): Action;
  11019. /**
  11020. * Internal only
  11021. * @hidden
  11022. */
  11023. _getProperty(propertyPath: string): string;
  11024. /**
  11025. * Internal only
  11026. * @hidden
  11027. */
  11028. _getEffectiveTarget(target: any, propertyPath: string): any;
  11029. /**
  11030. * Serialize placeholder for child classes
  11031. * @param parent of child
  11032. * @returns the serialized object
  11033. */
  11034. serialize(parent: any): any;
  11035. /**
  11036. * Internal only called by serialize
  11037. * @hidden
  11038. */
  11039. protected _serialize(serializedAction: any, parent?: any): any;
  11040. /**
  11041. * Internal only
  11042. * @hidden
  11043. */
  11044. static _SerializeValueAsString: (value: any) => string;
  11045. /**
  11046. * Internal only
  11047. * @hidden
  11048. */
  11049. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  11050. name: string;
  11051. targetType: string;
  11052. value: string;
  11053. };
  11054. }
  11055. }
  11056. declare module "babylonjs/Actions/condition" {
  11057. import { ActionManager } from "babylonjs/Actions/actionManager";
  11058. /**
  11059. * A Condition applied to an Action
  11060. */
  11061. export class Condition {
  11062. /**
  11063. * Internal only - manager for action
  11064. * @hidden
  11065. */
  11066. _actionManager: ActionManager;
  11067. /**
  11068. * Internal only
  11069. * @hidden
  11070. */
  11071. _evaluationId: number;
  11072. /**
  11073. * Internal only
  11074. * @hidden
  11075. */
  11076. _currentResult: boolean;
  11077. /**
  11078. * Creates a new Condition
  11079. * @param actionManager the manager of the action the condition is applied to
  11080. */
  11081. constructor(actionManager: ActionManager);
  11082. /**
  11083. * Check if the current condition is valid
  11084. * @returns a boolean
  11085. */
  11086. isValid(): boolean;
  11087. /**
  11088. * Internal only
  11089. * @hidden
  11090. */
  11091. _getProperty(propertyPath: string): string;
  11092. /**
  11093. * Internal only
  11094. * @hidden
  11095. */
  11096. _getEffectiveTarget(target: any, propertyPath: string): any;
  11097. /**
  11098. * Serialize placeholder for child classes
  11099. * @returns the serialized object
  11100. */
  11101. serialize(): any;
  11102. /**
  11103. * Internal only
  11104. * @hidden
  11105. */
  11106. protected _serialize(serializedCondition: any): any;
  11107. }
  11108. /**
  11109. * Defines specific conditional operators as extensions of Condition
  11110. */
  11111. export class ValueCondition extends Condition {
  11112. /** path to specify the property of the target the conditional operator uses */
  11113. propertyPath: string;
  11114. /** the value compared by the conditional operator against the current value of the property */
  11115. value: any;
  11116. /** the conditional operator, default ValueCondition.IsEqual */
  11117. operator: number;
  11118. /**
  11119. * Internal only
  11120. * @hidden
  11121. */
  11122. private static _IsEqual;
  11123. /**
  11124. * Internal only
  11125. * @hidden
  11126. */
  11127. private static _IsDifferent;
  11128. /**
  11129. * Internal only
  11130. * @hidden
  11131. */
  11132. private static _IsGreater;
  11133. /**
  11134. * Internal only
  11135. * @hidden
  11136. */
  11137. private static _IsLesser;
  11138. /**
  11139. * returns the number for IsEqual
  11140. */
  11141. static readonly IsEqual: number;
  11142. /**
  11143. * Returns the number for IsDifferent
  11144. */
  11145. static readonly IsDifferent: number;
  11146. /**
  11147. * Returns the number for IsGreater
  11148. */
  11149. static readonly IsGreater: number;
  11150. /**
  11151. * Returns the number for IsLesser
  11152. */
  11153. static readonly IsLesser: number;
  11154. /**
  11155. * Internal only The action manager for the condition
  11156. * @hidden
  11157. */
  11158. _actionManager: ActionManager;
  11159. /**
  11160. * Internal only
  11161. * @hidden
  11162. */
  11163. private _target;
  11164. /**
  11165. * Internal only
  11166. * @hidden
  11167. */
  11168. private _effectiveTarget;
  11169. /**
  11170. * Internal only
  11171. * @hidden
  11172. */
  11173. private _property;
  11174. /**
  11175. * Creates a new ValueCondition
  11176. * @param actionManager manager for the action the condition applies to
  11177. * @param target for the action
  11178. * @param propertyPath path to specify the property of the target the conditional operator uses
  11179. * @param value the value compared by the conditional operator against the current value of the property
  11180. * @param operator the conditional operator, default ValueCondition.IsEqual
  11181. */
  11182. constructor(actionManager: ActionManager, target: any,
  11183. /** path to specify the property of the target the conditional operator uses */
  11184. propertyPath: string,
  11185. /** the value compared by the conditional operator against the current value of the property */
  11186. value: any,
  11187. /** the conditional operator, default ValueCondition.IsEqual */
  11188. operator?: number);
  11189. /**
  11190. * Compares the given value with the property value for the specified conditional operator
  11191. * @returns the result of the comparison
  11192. */
  11193. isValid(): boolean;
  11194. /**
  11195. * Serialize the ValueCondition into a JSON compatible object
  11196. * @returns serialization object
  11197. */
  11198. serialize(): any;
  11199. /**
  11200. * Gets the name of the conditional operator for the ValueCondition
  11201. * @param operator the conditional operator
  11202. * @returns the name
  11203. */
  11204. static GetOperatorName(operator: number): string;
  11205. }
  11206. /**
  11207. * Defines a predicate condition as an extension of Condition
  11208. */
  11209. export class PredicateCondition extends Condition {
  11210. /** defines the predicate function used to validate the condition */
  11211. predicate: () => boolean;
  11212. /**
  11213. * Internal only - manager for action
  11214. * @hidden
  11215. */
  11216. _actionManager: ActionManager;
  11217. /**
  11218. * Creates a new PredicateCondition
  11219. * @param actionManager manager for the action the condition applies to
  11220. * @param predicate defines the predicate function used to validate the condition
  11221. */
  11222. constructor(actionManager: ActionManager,
  11223. /** defines the predicate function used to validate the condition */
  11224. predicate: () => boolean);
  11225. /**
  11226. * @returns the validity of the predicate condition
  11227. */
  11228. isValid(): boolean;
  11229. }
  11230. /**
  11231. * Defines a state condition as an extension of Condition
  11232. */
  11233. export class StateCondition extends Condition {
  11234. /** Value to compare with target state */
  11235. value: string;
  11236. /**
  11237. * Internal only - manager for action
  11238. * @hidden
  11239. */
  11240. _actionManager: ActionManager;
  11241. /**
  11242. * Internal only
  11243. * @hidden
  11244. */
  11245. private _target;
  11246. /**
  11247. * Creates a new StateCondition
  11248. * @param actionManager manager for the action the condition applies to
  11249. * @param target of the condition
  11250. * @param value to compare with target state
  11251. */
  11252. constructor(actionManager: ActionManager, target: any,
  11253. /** Value to compare with target state */
  11254. value: string);
  11255. /**
  11256. * Gets a boolean indicating if the current condition is met
  11257. * @returns the validity of the state
  11258. */
  11259. isValid(): boolean;
  11260. /**
  11261. * Serialize the StateCondition into a JSON compatible object
  11262. * @returns serialization object
  11263. */
  11264. serialize(): any;
  11265. }
  11266. }
  11267. declare module "babylonjs/Actions/directActions" {
  11268. import { Action } from "babylonjs/Actions/action";
  11269. import { Condition } from "babylonjs/Actions/condition";
  11270. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  11271. /**
  11272. * This defines an action responsible to toggle a boolean once triggered.
  11273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11274. */
  11275. export class SwitchBooleanAction extends Action {
  11276. /**
  11277. * The path to the boolean property in the target object
  11278. */
  11279. propertyPath: string;
  11280. private _target;
  11281. private _effectiveTarget;
  11282. private _property;
  11283. /**
  11284. * Instantiate the action
  11285. * @param triggerOptions defines the trigger options
  11286. * @param target defines the object containing the boolean
  11287. * @param propertyPath defines the path to the boolean property in the target object
  11288. * @param condition defines the trigger related conditions
  11289. */
  11290. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11291. /** @hidden */
  11292. _prepare(): void;
  11293. /**
  11294. * Execute the action toggle the boolean value.
  11295. */
  11296. execute(): void;
  11297. /**
  11298. * Serializes the actions and its related information.
  11299. * @param parent defines the object to serialize in
  11300. * @returns the serialized object
  11301. */
  11302. serialize(parent: any): any;
  11303. }
  11304. /**
  11305. * This defines an action responsible to set a the state field of the target
  11306. * to a desired value once triggered.
  11307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11308. */
  11309. export class SetStateAction extends Action {
  11310. /**
  11311. * The value to store in the state field.
  11312. */
  11313. value: string;
  11314. private _target;
  11315. /**
  11316. * Instantiate the action
  11317. * @param triggerOptions defines the trigger options
  11318. * @param target defines the object containing the state property
  11319. * @param value defines the value to store in the state field
  11320. * @param condition defines the trigger related conditions
  11321. */
  11322. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11323. /**
  11324. * Execute the action and store the value on the target state property.
  11325. */
  11326. execute(): void;
  11327. /**
  11328. * Serializes the actions and its related information.
  11329. * @param parent defines the object to serialize in
  11330. * @returns the serialized object
  11331. */
  11332. serialize(parent: any): any;
  11333. }
  11334. /**
  11335. * This defines an action responsible to set a property of the target
  11336. * to a desired value once triggered.
  11337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11338. */
  11339. export class SetValueAction extends Action {
  11340. /**
  11341. * The path of the property to set in the target.
  11342. */
  11343. propertyPath: string;
  11344. /**
  11345. * The value to set in the property
  11346. */
  11347. value: any;
  11348. private _target;
  11349. private _effectiveTarget;
  11350. private _property;
  11351. /**
  11352. * Instantiate the action
  11353. * @param triggerOptions defines the trigger options
  11354. * @param target defines the object containing the property
  11355. * @param propertyPath defines the path of the property to set in the target
  11356. * @param value defines the value to set in the property
  11357. * @param condition defines the trigger related conditions
  11358. */
  11359. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11360. /** @hidden */
  11361. _prepare(): void;
  11362. /**
  11363. * Execute the action and set the targetted property to the desired value.
  11364. */
  11365. execute(): void;
  11366. /**
  11367. * Serializes the actions and its related information.
  11368. * @param parent defines the object to serialize in
  11369. * @returns the serialized object
  11370. */
  11371. serialize(parent: any): any;
  11372. }
  11373. /**
  11374. * This defines an action responsible to increment the target value
  11375. * to a desired value once triggered.
  11376. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11377. */
  11378. export class IncrementValueAction extends Action {
  11379. /**
  11380. * The path of the property to increment in the target.
  11381. */
  11382. propertyPath: string;
  11383. /**
  11384. * The value we should increment the property by.
  11385. */
  11386. value: any;
  11387. private _target;
  11388. private _effectiveTarget;
  11389. private _property;
  11390. /**
  11391. * Instantiate the action
  11392. * @param triggerOptions defines the trigger options
  11393. * @param target defines the object containing the property
  11394. * @param propertyPath defines the path of the property to increment in the target
  11395. * @param value defines the value value we should increment the property by
  11396. * @param condition defines the trigger related conditions
  11397. */
  11398. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11399. /** @hidden */
  11400. _prepare(): void;
  11401. /**
  11402. * Execute the action and increment the target of the value amount.
  11403. */
  11404. execute(): void;
  11405. /**
  11406. * Serializes the actions and its related information.
  11407. * @param parent defines the object to serialize in
  11408. * @returns the serialized object
  11409. */
  11410. serialize(parent: any): any;
  11411. }
  11412. /**
  11413. * This defines an action responsible to start an animation once triggered.
  11414. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11415. */
  11416. export class PlayAnimationAction extends Action {
  11417. /**
  11418. * Where the animation should start (animation frame)
  11419. */
  11420. from: number;
  11421. /**
  11422. * Where the animation should stop (animation frame)
  11423. */
  11424. to: number;
  11425. /**
  11426. * Define if the animation should loop or stop after the first play.
  11427. */
  11428. loop?: boolean;
  11429. private _target;
  11430. /**
  11431. * Instantiate the action
  11432. * @param triggerOptions defines the trigger options
  11433. * @param target defines the target animation or animation name
  11434. * @param from defines from where the animation should start (animation frame)
  11435. * @param end defines where the animation should stop (animation frame)
  11436. * @param loop defines if the animation should loop or stop after the first play
  11437. * @param condition defines the trigger related conditions
  11438. */
  11439. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11440. /** @hidden */
  11441. _prepare(): void;
  11442. /**
  11443. * Execute the action and play the animation.
  11444. */
  11445. execute(): void;
  11446. /**
  11447. * Serializes the actions and its related information.
  11448. * @param parent defines the object to serialize in
  11449. * @returns the serialized object
  11450. */
  11451. serialize(parent: any): any;
  11452. }
  11453. /**
  11454. * This defines an action responsible to stop an animation once triggered.
  11455. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11456. */
  11457. export class StopAnimationAction extends Action {
  11458. private _target;
  11459. /**
  11460. * Instantiate the action
  11461. * @param triggerOptions defines the trigger options
  11462. * @param target defines the target animation or animation name
  11463. * @param condition defines the trigger related conditions
  11464. */
  11465. constructor(triggerOptions: any, target: any, condition?: Condition);
  11466. /** @hidden */
  11467. _prepare(): void;
  11468. /**
  11469. * Execute the action and stop the animation.
  11470. */
  11471. execute(): void;
  11472. /**
  11473. * Serializes the actions and its related information.
  11474. * @param parent defines the object to serialize in
  11475. * @returns the serialized object
  11476. */
  11477. serialize(parent: any): any;
  11478. }
  11479. /**
  11480. * This defines an action responsible that does nothing once triggered.
  11481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11482. */
  11483. export class DoNothingAction extends Action {
  11484. /**
  11485. * Instantiate the action
  11486. * @param triggerOptions defines the trigger options
  11487. * @param condition defines the trigger related conditions
  11488. */
  11489. constructor(triggerOptions?: any, condition?: Condition);
  11490. /**
  11491. * Execute the action and do nothing.
  11492. */
  11493. execute(): void;
  11494. /**
  11495. * Serializes the actions and its related information.
  11496. * @param parent defines the object to serialize in
  11497. * @returns the serialized object
  11498. */
  11499. serialize(parent: any): any;
  11500. }
  11501. /**
  11502. * This defines an action responsible to trigger several actions once triggered.
  11503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11504. */
  11505. export class CombineAction extends Action {
  11506. /**
  11507. * The list of aggregated animations to run.
  11508. */
  11509. children: Action[];
  11510. /**
  11511. * Instantiate the action
  11512. * @param triggerOptions defines the trigger options
  11513. * @param children defines the list of aggregated animations to run
  11514. * @param condition defines the trigger related conditions
  11515. */
  11516. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11517. /** @hidden */
  11518. _prepare(): void;
  11519. /**
  11520. * Execute the action and executes all the aggregated actions.
  11521. */
  11522. execute(evt: ActionEvent): void;
  11523. /**
  11524. * Serializes the actions and its related information.
  11525. * @param parent defines the object to serialize in
  11526. * @returns the serialized object
  11527. */
  11528. serialize(parent: any): any;
  11529. }
  11530. /**
  11531. * This defines an action responsible to run code (external event) once triggered.
  11532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11533. */
  11534. export class ExecuteCodeAction extends Action {
  11535. /**
  11536. * The callback function to run.
  11537. */
  11538. func: (evt: ActionEvent) => void;
  11539. /**
  11540. * Instantiate the action
  11541. * @param triggerOptions defines the trigger options
  11542. * @param func defines the callback function to run
  11543. * @param condition defines the trigger related conditions
  11544. */
  11545. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11546. /**
  11547. * Execute the action and run the attached code.
  11548. */
  11549. execute(evt: ActionEvent): void;
  11550. }
  11551. /**
  11552. * This defines an action responsible to set the parent property of the target once triggered.
  11553. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11554. */
  11555. export class SetParentAction extends Action {
  11556. private _parent;
  11557. private _target;
  11558. /**
  11559. * Instantiate the action
  11560. * @param triggerOptions defines the trigger options
  11561. * @param target defines the target containing the parent property
  11562. * @param parent defines from where the animation should start (animation frame)
  11563. * @param condition defines the trigger related conditions
  11564. */
  11565. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11566. /** @hidden */
  11567. _prepare(): void;
  11568. /**
  11569. * Execute the action and set the parent property.
  11570. */
  11571. execute(): void;
  11572. /**
  11573. * Serializes the actions and its related information.
  11574. * @param parent defines the object to serialize in
  11575. * @returns the serialized object
  11576. */
  11577. serialize(parent: any): any;
  11578. }
  11579. }
  11580. declare module "babylonjs/Actions/actionManager" {
  11581. import { Nullable } from "babylonjs/types";
  11582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11583. import { Scene } from "babylonjs/scene";
  11584. import { IAction } from "babylonjs/Actions/action";
  11585. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11586. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11587. /**
  11588. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11589. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11591. */
  11592. export class ActionManager extends AbstractActionManager {
  11593. /**
  11594. * Nothing
  11595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11596. */
  11597. static readonly NothingTrigger: number;
  11598. /**
  11599. * On pick
  11600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11601. */
  11602. static readonly OnPickTrigger: number;
  11603. /**
  11604. * On left pick
  11605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11606. */
  11607. static readonly OnLeftPickTrigger: number;
  11608. /**
  11609. * On right pick
  11610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11611. */
  11612. static readonly OnRightPickTrigger: number;
  11613. /**
  11614. * On center pick
  11615. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11616. */
  11617. static readonly OnCenterPickTrigger: number;
  11618. /**
  11619. * On pick down
  11620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11621. */
  11622. static readonly OnPickDownTrigger: number;
  11623. /**
  11624. * On double pick
  11625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11626. */
  11627. static readonly OnDoublePickTrigger: number;
  11628. /**
  11629. * On pick up
  11630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11631. */
  11632. static readonly OnPickUpTrigger: number;
  11633. /**
  11634. * On pick out.
  11635. * This trigger will only be raised if you also declared a OnPickDown
  11636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11637. */
  11638. static readonly OnPickOutTrigger: number;
  11639. /**
  11640. * On long press
  11641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11642. */
  11643. static readonly OnLongPressTrigger: number;
  11644. /**
  11645. * On pointer over
  11646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11647. */
  11648. static readonly OnPointerOverTrigger: number;
  11649. /**
  11650. * On pointer out
  11651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11652. */
  11653. static readonly OnPointerOutTrigger: number;
  11654. /**
  11655. * On every frame
  11656. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11657. */
  11658. static readonly OnEveryFrameTrigger: number;
  11659. /**
  11660. * On intersection enter
  11661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11662. */
  11663. static readonly OnIntersectionEnterTrigger: number;
  11664. /**
  11665. * On intersection exit
  11666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11667. */
  11668. static readonly OnIntersectionExitTrigger: number;
  11669. /**
  11670. * On key down
  11671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11672. */
  11673. static readonly OnKeyDownTrigger: number;
  11674. /**
  11675. * On key up
  11676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11677. */
  11678. static readonly OnKeyUpTrigger: number;
  11679. private _scene;
  11680. /**
  11681. * Creates a new action manager
  11682. * @param scene defines the hosting scene
  11683. */
  11684. constructor(scene: Scene);
  11685. /**
  11686. * Releases all associated resources
  11687. */
  11688. dispose(): void;
  11689. /**
  11690. * Gets hosting scene
  11691. * @returns the hosting scene
  11692. */
  11693. getScene(): Scene;
  11694. /**
  11695. * Does this action manager handles actions of any of the given triggers
  11696. * @param triggers defines the triggers to be tested
  11697. * @return a boolean indicating whether one (or more) of the triggers is handled
  11698. */
  11699. hasSpecificTriggers(triggers: number[]): boolean;
  11700. /**
  11701. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11702. * speed.
  11703. * @param triggerA defines the trigger to be tested
  11704. * @param triggerB defines the trigger to be tested
  11705. * @return a boolean indicating whether one (or more) of the triggers is handled
  11706. */
  11707. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11708. /**
  11709. * Does this action manager handles actions of a given trigger
  11710. * @param trigger defines the trigger to be tested
  11711. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11712. * @return whether the trigger is handled
  11713. */
  11714. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11715. /**
  11716. * Does this action manager has pointer triggers
  11717. */
  11718. readonly hasPointerTriggers: boolean;
  11719. /**
  11720. * Does this action manager has pick triggers
  11721. */
  11722. readonly hasPickTriggers: boolean;
  11723. /**
  11724. * Registers an action to this action manager
  11725. * @param action defines the action to be registered
  11726. * @return the action amended (prepared) after registration
  11727. */
  11728. registerAction(action: IAction): Nullable<IAction>;
  11729. /**
  11730. * Unregisters an action to this action manager
  11731. * @param action defines the action to be unregistered
  11732. * @return a boolean indicating whether the action has been unregistered
  11733. */
  11734. unregisterAction(action: IAction): Boolean;
  11735. /**
  11736. * Process a specific trigger
  11737. * @param trigger defines the trigger to process
  11738. * @param evt defines the event details to be processed
  11739. */
  11740. processTrigger(trigger: number, evt?: IActionEvent): void;
  11741. /** @hidden */
  11742. _getEffectiveTarget(target: any, propertyPath: string): any;
  11743. /** @hidden */
  11744. _getProperty(propertyPath: string): string;
  11745. /**
  11746. * Serialize this manager to a JSON object
  11747. * @param name defines the property name to store this manager
  11748. * @returns a JSON representation of this manager
  11749. */
  11750. serialize(name: string): any;
  11751. /**
  11752. * Creates a new ActionManager from a JSON data
  11753. * @param parsedActions defines the JSON data to read from
  11754. * @param object defines the hosting mesh
  11755. * @param scene defines the hosting scene
  11756. */
  11757. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11758. /**
  11759. * Get a trigger name by index
  11760. * @param trigger defines the trigger index
  11761. * @returns a trigger name
  11762. */
  11763. static GetTriggerName(trigger: number): string;
  11764. }
  11765. }
  11766. declare module "babylonjs/Culling/ray" {
  11767. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11768. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11770. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11771. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11772. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11773. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11774. /**
  11775. * Class representing a ray with position and direction
  11776. */
  11777. export class Ray {
  11778. /** origin point */
  11779. origin: Vector3;
  11780. /** direction */
  11781. direction: Vector3;
  11782. /** length of the ray */
  11783. length: number;
  11784. private static readonly TmpVector3;
  11785. private _tmpRay;
  11786. /**
  11787. * Creates a new ray
  11788. * @param origin origin point
  11789. * @param direction direction
  11790. * @param length length of the ray
  11791. */
  11792. constructor(
  11793. /** origin point */
  11794. origin: Vector3,
  11795. /** direction */
  11796. direction: Vector3,
  11797. /** length of the ray */
  11798. length?: number);
  11799. /**
  11800. * Checks if the ray intersects a box
  11801. * @param minimum bound of the box
  11802. * @param maximum bound of the box
  11803. * @param intersectionTreshold extra extend to be added to the box in all direction
  11804. * @returns if the box was hit
  11805. */
  11806. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11807. /**
  11808. * Checks if the ray intersects a box
  11809. * @param box the bounding box to check
  11810. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11811. * @returns if the box was hit
  11812. */
  11813. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11814. /**
  11815. * If the ray hits a sphere
  11816. * @param sphere the bounding sphere to check
  11817. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11818. * @returns true if it hits the sphere
  11819. */
  11820. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11821. /**
  11822. * If the ray hits a triange
  11823. * @param vertex0 triangle vertex
  11824. * @param vertex1 triangle vertex
  11825. * @param vertex2 triangle vertex
  11826. * @returns intersection information if hit
  11827. */
  11828. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11829. /**
  11830. * Checks if ray intersects a plane
  11831. * @param plane the plane to check
  11832. * @returns the distance away it was hit
  11833. */
  11834. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11835. /**
  11836. * Checks if ray intersects a mesh
  11837. * @param mesh the mesh to check
  11838. * @param fastCheck if only the bounding box should checked
  11839. * @returns picking info of the intersecton
  11840. */
  11841. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11842. /**
  11843. * Checks if ray intersects a mesh
  11844. * @param meshes the meshes to check
  11845. * @param fastCheck if only the bounding box should checked
  11846. * @param results array to store result in
  11847. * @returns Array of picking infos
  11848. */
  11849. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11850. private _comparePickingInfo;
  11851. private static smallnum;
  11852. private static rayl;
  11853. /**
  11854. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11855. * @param sega the first point of the segment to test the intersection against
  11856. * @param segb the second point of the segment to test the intersection against
  11857. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11858. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11859. */
  11860. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11861. /**
  11862. * Update the ray from viewport position
  11863. * @param x position
  11864. * @param y y position
  11865. * @param viewportWidth viewport width
  11866. * @param viewportHeight viewport height
  11867. * @param world world matrix
  11868. * @param view view matrix
  11869. * @param projection projection matrix
  11870. * @returns this ray updated
  11871. */
  11872. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11873. /**
  11874. * Creates a ray with origin and direction of 0,0,0
  11875. * @returns the new ray
  11876. */
  11877. static Zero(): Ray;
  11878. /**
  11879. * Creates a new ray from screen space and viewport
  11880. * @param x position
  11881. * @param y y position
  11882. * @param viewportWidth viewport width
  11883. * @param viewportHeight viewport height
  11884. * @param world world matrix
  11885. * @param view view matrix
  11886. * @param projection projection matrix
  11887. * @returns new ray
  11888. */
  11889. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11890. /**
  11891. * 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
  11892. * transformed to the given world matrix.
  11893. * @param origin The origin point
  11894. * @param end The end point
  11895. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11896. * @returns the new ray
  11897. */
  11898. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11899. /**
  11900. * Transforms a ray by a matrix
  11901. * @param ray ray to transform
  11902. * @param matrix matrix to apply
  11903. * @returns the resulting new ray
  11904. */
  11905. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11906. /**
  11907. * Transforms a ray by a matrix
  11908. * @param ray ray to transform
  11909. * @param matrix matrix to apply
  11910. * @param result ray to store result in
  11911. */
  11912. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11913. /**
  11914. * Unproject a ray from screen space to object space
  11915. * @param sourceX defines the screen space x coordinate to use
  11916. * @param sourceY defines the screen space y coordinate to use
  11917. * @param viewportWidth defines the current width of the viewport
  11918. * @param viewportHeight defines the current height of the viewport
  11919. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11920. * @param view defines the view matrix to use
  11921. * @param projection defines the projection matrix to use
  11922. */
  11923. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11924. }
  11925. /**
  11926. * Type used to define predicate used to select faces when a mesh intersection is detected
  11927. */
  11928. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11929. module "babylonjs/scene" {
  11930. interface Scene {
  11931. /** @hidden */
  11932. _tempPickingRay: Nullable<Ray>;
  11933. /** @hidden */
  11934. _cachedRayForTransform: Ray;
  11935. /** @hidden */
  11936. _pickWithRayInverseMatrix: Matrix;
  11937. /** @hidden */
  11938. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11939. /** @hidden */
  11940. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11941. }
  11942. }
  11943. }
  11944. declare module "babylonjs/sceneComponent" {
  11945. import { Scene } from "babylonjs/scene";
  11946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11947. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11948. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11949. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11950. import { Nullable } from "babylonjs/types";
  11951. import { Camera } from "babylonjs/Cameras/camera";
  11952. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11953. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11954. import { AbstractScene } from "babylonjs/abstractScene";
  11955. /**
  11956. * Groups all the scene component constants in one place to ease maintenance.
  11957. * @hidden
  11958. */
  11959. export class SceneComponentConstants {
  11960. static readonly NAME_EFFECTLAYER: string;
  11961. static readonly NAME_LAYER: string;
  11962. static readonly NAME_LENSFLARESYSTEM: string;
  11963. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11964. static readonly NAME_PARTICLESYSTEM: string;
  11965. static readonly NAME_GAMEPAD: string;
  11966. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11967. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11968. static readonly NAME_DEPTHRENDERER: string;
  11969. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11970. static readonly NAME_SPRITE: string;
  11971. static readonly NAME_OUTLINERENDERER: string;
  11972. static readonly NAME_PROCEDURALTEXTURE: string;
  11973. static readonly NAME_SHADOWGENERATOR: string;
  11974. static readonly NAME_OCTREE: string;
  11975. static readonly NAME_PHYSICSENGINE: string;
  11976. static readonly NAME_AUDIO: string;
  11977. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11978. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11979. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11980. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11981. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11982. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11983. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11984. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11985. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11986. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11987. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11988. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11989. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11990. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11991. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11992. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11993. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11994. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11995. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11996. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11997. static readonly STEP_AFTERRENDER_AUDIO: number;
  11998. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11999. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  12000. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  12001. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  12002. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  12003. static readonly STEP_POINTERMOVE_SPRITE: number;
  12004. static readonly STEP_POINTERDOWN_SPRITE: number;
  12005. static readonly STEP_POINTERUP_SPRITE: number;
  12006. }
  12007. /**
  12008. * This represents a scene component.
  12009. *
  12010. * This is used to decouple the dependency the scene is having on the different workloads like
  12011. * layers, post processes...
  12012. */
  12013. export interface ISceneComponent {
  12014. /**
  12015. * The name of the component. Each component must have a unique name.
  12016. */
  12017. name: string;
  12018. /**
  12019. * The scene the component belongs to.
  12020. */
  12021. scene: Scene;
  12022. /**
  12023. * Register the component to one instance of a scene.
  12024. */
  12025. register(): void;
  12026. /**
  12027. * Rebuilds the elements related to this component in case of
  12028. * context lost for instance.
  12029. */
  12030. rebuild(): void;
  12031. /**
  12032. * Disposes the component and the associated ressources.
  12033. */
  12034. dispose(): void;
  12035. }
  12036. /**
  12037. * This represents a SERIALIZABLE scene component.
  12038. *
  12039. * This extends Scene Component to add Serialization methods on top.
  12040. */
  12041. export interface ISceneSerializableComponent extends ISceneComponent {
  12042. /**
  12043. * Adds all the elements from the container to the scene
  12044. * @param container the container holding the elements
  12045. */
  12046. addFromContainer(container: AbstractScene): void;
  12047. /**
  12048. * Removes all the elements in the container from the scene
  12049. * @param container contains the elements to remove
  12050. * @param dispose if the removed element should be disposed (default: false)
  12051. */
  12052. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  12053. /**
  12054. * Serializes the component data to the specified json object
  12055. * @param serializationObject The object to serialize to
  12056. */
  12057. serialize(serializationObject: any): void;
  12058. }
  12059. /**
  12060. * Strong typing of a Mesh related stage step action
  12061. */
  12062. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  12063. /**
  12064. * Strong typing of a Evaluate Sub Mesh related stage step action
  12065. */
  12066. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  12067. /**
  12068. * Strong typing of a Active Mesh related stage step action
  12069. */
  12070. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  12071. /**
  12072. * Strong typing of a Camera related stage step action
  12073. */
  12074. export type CameraStageAction = (camera: Camera) => void;
  12075. /**
  12076. * Strong typing of a Camera Frame buffer related stage step action
  12077. */
  12078. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  12079. /**
  12080. * Strong typing of a Render Target related stage step action
  12081. */
  12082. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  12083. /**
  12084. * Strong typing of a RenderingGroup related stage step action
  12085. */
  12086. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  12087. /**
  12088. * Strong typing of a Mesh Render related stage step action
  12089. */
  12090. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  12091. /**
  12092. * Strong typing of a simple stage step action
  12093. */
  12094. export type SimpleStageAction = () => void;
  12095. /**
  12096. * Strong typing of a render target action.
  12097. */
  12098. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  12099. /**
  12100. * Strong typing of a pointer move action.
  12101. */
  12102. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  12103. /**
  12104. * Strong typing of a pointer up/down action.
  12105. */
  12106. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  12107. /**
  12108. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  12109. * @hidden
  12110. */
  12111. export class Stage<T extends Function> extends Array<{
  12112. index: number;
  12113. component: ISceneComponent;
  12114. action: T;
  12115. }> {
  12116. /**
  12117. * Hide ctor from the rest of the world.
  12118. * @param items The items to add.
  12119. */
  12120. private constructor();
  12121. /**
  12122. * Creates a new Stage.
  12123. * @returns A new instance of a Stage
  12124. */
  12125. static Create<T extends Function>(): Stage<T>;
  12126. /**
  12127. * Registers a step in an ordered way in the targeted stage.
  12128. * @param index Defines the position to register the step in
  12129. * @param component Defines the component attached to the step
  12130. * @param action Defines the action to launch during the step
  12131. */
  12132. registerStep(index: number, component: ISceneComponent, action: T): void;
  12133. /**
  12134. * Clears all the steps from the stage.
  12135. */
  12136. clear(): void;
  12137. }
  12138. }
  12139. declare module "babylonjs/Sprites/spriteSceneComponent" {
  12140. import { Nullable } from "babylonjs/types";
  12141. import { Observable } from "babylonjs/Misc/observable";
  12142. import { Scene } from "babylonjs/scene";
  12143. import { Sprite } from "babylonjs/Sprites/sprite";
  12144. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12145. import { Ray } from "babylonjs/Culling/ray";
  12146. import { Camera } from "babylonjs/Cameras/camera";
  12147. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12148. import { ISceneComponent } from "babylonjs/sceneComponent";
  12149. module "babylonjs/scene" {
  12150. interface Scene {
  12151. /** @hidden */
  12152. _pointerOverSprite: Nullable<Sprite>;
  12153. /** @hidden */
  12154. _pickedDownSprite: Nullable<Sprite>;
  12155. /** @hidden */
  12156. _tempSpritePickingRay: Nullable<Ray>;
  12157. /**
  12158. * All of the sprite managers added to this scene
  12159. * @see http://doc.babylonjs.com/babylon101/sprites
  12160. */
  12161. spriteManagers: Array<ISpriteManager>;
  12162. /**
  12163. * An event triggered when sprites rendering is about to start
  12164. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12165. */
  12166. onBeforeSpritesRenderingObservable: Observable<Scene>;
  12167. /**
  12168. * An event triggered when sprites rendering is done
  12169. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12170. */
  12171. onAfterSpritesRenderingObservable: Observable<Scene>;
  12172. /** @hidden */
  12173. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12174. /** Launch a ray to try to pick a sprite in the scene
  12175. * @param x position on screen
  12176. * @param y position on screen
  12177. * @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
  12178. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12179. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  12180. * @returns a PickingInfo
  12181. */
  12182. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12183. /** Use the given ray to pick a sprite in the scene
  12184. * @param ray The ray (in world space) to use to pick meshes
  12185. * @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
  12186. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12187. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  12188. * @returns a PickingInfo
  12189. */
  12190. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12191. /**
  12192. * Force the sprite under the pointer
  12193. * @param sprite defines the sprite to use
  12194. */
  12195. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  12196. /**
  12197. * Gets the sprite under the pointer
  12198. * @returns a Sprite or null if no sprite is under the pointer
  12199. */
  12200. getPointerOverSprite(): Nullable<Sprite>;
  12201. }
  12202. }
  12203. /**
  12204. * Defines the sprite scene component responsible to manage sprites
  12205. * in a given scene.
  12206. */
  12207. export class SpriteSceneComponent implements ISceneComponent {
  12208. /**
  12209. * The component name helpfull to identify the component in the list of scene components.
  12210. */
  12211. readonly name: string;
  12212. /**
  12213. * The scene the component belongs to.
  12214. */
  12215. scene: Scene;
  12216. /** @hidden */
  12217. private _spritePredicate;
  12218. /**
  12219. * Creates a new instance of the component for the given scene
  12220. * @param scene Defines the scene to register the component in
  12221. */
  12222. constructor(scene: Scene);
  12223. /**
  12224. * Registers the component in a given scene
  12225. */
  12226. register(): void;
  12227. /**
  12228. * Rebuilds the elements related to this component in case of
  12229. * context lost for instance.
  12230. */
  12231. rebuild(): void;
  12232. /**
  12233. * Disposes the component and the associated ressources.
  12234. */
  12235. dispose(): void;
  12236. private _pickSpriteButKeepRay;
  12237. private _pointerMove;
  12238. private _pointerDown;
  12239. private _pointerUp;
  12240. }
  12241. }
  12242. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  12243. /** @hidden */
  12244. export var fogFragmentDeclaration: {
  12245. name: string;
  12246. shader: string;
  12247. };
  12248. }
  12249. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  12250. /** @hidden */
  12251. export var fogFragment: {
  12252. name: string;
  12253. shader: string;
  12254. };
  12255. }
  12256. declare module "babylonjs/Shaders/sprites.fragment" {
  12257. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  12258. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  12259. /** @hidden */
  12260. export var spritesPixelShader: {
  12261. name: string;
  12262. shader: string;
  12263. };
  12264. }
  12265. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  12266. /** @hidden */
  12267. export var fogVertexDeclaration: {
  12268. name: string;
  12269. shader: string;
  12270. };
  12271. }
  12272. declare module "babylonjs/Shaders/sprites.vertex" {
  12273. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  12274. /** @hidden */
  12275. export var spritesVertexShader: {
  12276. name: string;
  12277. shader: string;
  12278. };
  12279. }
  12280. declare module "babylonjs/Sprites/spriteManager" {
  12281. import { IDisposable, Scene } from "babylonjs/scene";
  12282. import { Nullable } from "babylonjs/types";
  12283. import { Observable } from "babylonjs/Misc/observable";
  12284. import { Sprite } from "babylonjs/Sprites/sprite";
  12285. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12286. import { Camera } from "babylonjs/Cameras/camera";
  12287. import { Texture } from "babylonjs/Materials/Textures/texture";
  12288. import "babylonjs/Shaders/sprites.fragment";
  12289. import "babylonjs/Shaders/sprites.vertex";
  12290. import { Ray } from "babylonjs/Culling/ray";
  12291. /**
  12292. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12293. */
  12294. export interface ISpriteManager extends IDisposable {
  12295. /**
  12296. * Restricts the camera to viewing objects with the same layerMask.
  12297. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12298. */
  12299. layerMask: number;
  12300. /**
  12301. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12302. */
  12303. isPickable: boolean;
  12304. /**
  12305. * Specifies the rendering group id for this mesh (0 by default)
  12306. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12307. */
  12308. renderingGroupId: number;
  12309. /**
  12310. * Defines the list of sprites managed by the manager.
  12311. */
  12312. sprites: Array<Sprite>;
  12313. /**
  12314. * Tests the intersection of a sprite with a specific ray.
  12315. * @param ray The ray we are sending to test the collision
  12316. * @param camera The camera space we are sending rays in
  12317. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12318. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12319. * @returns picking info or null.
  12320. */
  12321. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12322. /**
  12323. * Renders the list of sprites on screen.
  12324. */
  12325. render(): void;
  12326. }
  12327. /**
  12328. * Class used to manage multiple sprites on the same spritesheet
  12329. * @see http://doc.babylonjs.com/babylon101/sprites
  12330. */
  12331. export class SpriteManager implements ISpriteManager {
  12332. /** defines the manager's name */
  12333. name: string;
  12334. /** Gets the list of sprites */
  12335. sprites: Sprite[];
  12336. /** Gets or sets the rendering group id (0 by default) */
  12337. renderingGroupId: number;
  12338. /** Gets or sets camera layer mask */
  12339. layerMask: number;
  12340. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12341. fogEnabled: boolean;
  12342. /** Gets or sets a boolean indicating if the sprites are pickable */
  12343. isPickable: boolean;
  12344. /** Defines the default width of a cell in the spritesheet */
  12345. cellWidth: number;
  12346. /** Defines the default height of a cell in the spritesheet */
  12347. cellHeight: number;
  12348. /**
  12349. * An event triggered when the manager is disposed.
  12350. */
  12351. onDisposeObservable: Observable<SpriteManager>;
  12352. private _onDisposeObserver;
  12353. /**
  12354. * Callback called when the manager is disposed
  12355. */
  12356. onDispose: () => void;
  12357. private _capacity;
  12358. private _spriteTexture;
  12359. private _epsilon;
  12360. private _scene;
  12361. private _vertexData;
  12362. private _buffer;
  12363. private _vertexBuffers;
  12364. private _indexBuffer;
  12365. private _effectBase;
  12366. private _effectFog;
  12367. /**
  12368. * Gets or sets the spritesheet texture
  12369. */
  12370. texture: Texture;
  12371. /**
  12372. * Creates a new sprite manager
  12373. * @param name defines the manager's name
  12374. * @param imgUrl defines the sprite sheet url
  12375. * @param capacity defines the maximum allowed number of sprites
  12376. * @param cellSize defines the size of a sprite cell
  12377. * @param scene defines the hosting scene
  12378. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12379. * @param samplingMode defines the smapling mode to use with spritesheet
  12380. */
  12381. constructor(
  12382. /** defines the manager's name */
  12383. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12384. private _appendSpriteVertex;
  12385. /**
  12386. * Intersects the sprites with a ray
  12387. * @param ray defines the ray to intersect with
  12388. * @param camera defines the current active camera
  12389. * @param predicate defines a predicate used to select candidate sprites
  12390. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12391. * @returns null if no hit or a PickingInfo
  12392. */
  12393. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12394. /**
  12395. * Render all child sprites
  12396. */
  12397. render(): void;
  12398. /**
  12399. * Release associated resources
  12400. */
  12401. dispose(): void;
  12402. }
  12403. }
  12404. declare module "babylonjs/Sprites/sprite" {
  12405. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12406. import { Nullable } from "babylonjs/types";
  12407. import { ActionManager } from "babylonjs/Actions/actionManager";
  12408. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12409. /**
  12410. * Class used to represent a sprite
  12411. * @see http://doc.babylonjs.com/babylon101/sprites
  12412. */
  12413. export class Sprite {
  12414. /** defines the name */
  12415. name: string;
  12416. /** Gets or sets the current world position */
  12417. position: Vector3;
  12418. /** Gets or sets the main color */
  12419. color: Color4;
  12420. /** Gets or sets the width */
  12421. width: number;
  12422. /** Gets or sets the height */
  12423. height: number;
  12424. /** Gets or sets rotation angle */
  12425. angle: number;
  12426. /** Gets or sets the cell index in the sprite sheet */
  12427. cellIndex: number;
  12428. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12429. invertU: number;
  12430. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12431. invertV: number;
  12432. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12433. disposeWhenFinishedAnimating: boolean;
  12434. /** Gets the list of attached animations */
  12435. animations: Animation[];
  12436. /** Gets or sets a boolean indicating if the sprite can be picked */
  12437. isPickable: boolean;
  12438. /**
  12439. * Gets or sets the associated action manager
  12440. */
  12441. actionManager: Nullable<ActionManager>;
  12442. private _animationStarted;
  12443. private _loopAnimation;
  12444. private _fromIndex;
  12445. private _toIndex;
  12446. private _delay;
  12447. private _direction;
  12448. private _manager;
  12449. private _time;
  12450. private _onAnimationEnd;
  12451. /**
  12452. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12453. */
  12454. isVisible: boolean;
  12455. /**
  12456. * Gets or sets the sprite size
  12457. */
  12458. size: number;
  12459. /**
  12460. * Creates a new Sprite
  12461. * @param name defines the name
  12462. * @param manager defines the manager
  12463. */
  12464. constructor(
  12465. /** defines the name */
  12466. name: string, manager: ISpriteManager);
  12467. /**
  12468. * Starts an animation
  12469. * @param from defines the initial key
  12470. * @param to defines the end key
  12471. * @param loop defines if the animation must loop
  12472. * @param delay defines the start delay (in ms)
  12473. * @param onAnimationEnd defines a callback to call when animation ends
  12474. */
  12475. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12476. /** Stops current animation (if any) */
  12477. stopAnimation(): void;
  12478. /** @hidden */
  12479. _animate(deltaTime: number): void;
  12480. /** Release associated resources */
  12481. dispose(): void;
  12482. }
  12483. }
  12484. declare module "babylonjs/Collisions/pickingInfo" {
  12485. import { Nullable } from "babylonjs/types";
  12486. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12488. import { Sprite } from "babylonjs/Sprites/sprite";
  12489. import { Ray } from "babylonjs/Culling/ray";
  12490. /**
  12491. * Information about the result of picking within a scene
  12492. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12493. */
  12494. export class PickingInfo {
  12495. /** @hidden */
  12496. _pickingUnavailable: boolean;
  12497. /**
  12498. * If the pick collided with an object
  12499. */
  12500. hit: boolean;
  12501. /**
  12502. * Distance away where the pick collided
  12503. */
  12504. distance: number;
  12505. /**
  12506. * The location of pick collision
  12507. */
  12508. pickedPoint: Nullable<Vector3>;
  12509. /**
  12510. * The mesh corresponding the the pick collision
  12511. */
  12512. pickedMesh: Nullable<AbstractMesh>;
  12513. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12514. bu: number;
  12515. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12516. bv: number;
  12517. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12518. faceId: number;
  12519. /** Id of the the submesh that was picked */
  12520. subMeshId: number;
  12521. /** If a sprite was picked, this will be the sprite the pick collided with */
  12522. pickedSprite: Nullable<Sprite>;
  12523. /**
  12524. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12525. */
  12526. originMesh: Nullable<AbstractMesh>;
  12527. /**
  12528. * The ray that was used to perform the picking.
  12529. */
  12530. ray: Nullable<Ray>;
  12531. /**
  12532. * Gets the normal correspodning to the face the pick collided with
  12533. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12534. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12535. * @returns The normal correspodning to the face the pick collided with
  12536. */
  12537. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12538. /**
  12539. * Gets the texture coordinates of where the pick occured
  12540. * @returns the vector containing the coordnates of the texture
  12541. */
  12542. getTextureCoordinates(): Nullable<Vector2>;
  12543. }
  12544. }
  12545. declare module "babylonjs/Events/pointerEvents" {
  12546. import { Nullable } from "babylonjs/types";
  12547. import { Vector2 } from "babylonjs/Maths/math";
  12548. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12549. import { Ray } from "babylonjs/Culling/ray";
  12550. /**
  12551. * Gather the list of pointer event types as constants.
  12552. */
  12553. export class PointerEventTypes {
  12554. /**
  12555. * 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.
  12556. */
  12557. static readonly POINTERDOWN: number;
  12558. /**
  12559. * The pointerup event is fired when a pointer is no longer active.
  12560. */
  12561. static readonly POINTERUP: number;
  12562. /**
  12563. * The pointermove event is fired when a pointer changes coordinates.
  12564. */
  12565. static readonly POINTERMOVE: number;
  12566. /**
  12567. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12568. */
  12569. static readonly POINTERWHEEL: number;
  12570. /**
  12571. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12572. */
  12573. static readonly POINTERPICK: number;
  12574. /**
  12575. * The pointertap event is fired when a the object has been touched and released without drag.
  12576. */
  12577. static readonly POINTERTAP: number;
  12578. /**
  12579. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12580. */
  12581. static readonly POINTERDOUBLETAP: number;
  12582. }
  12583. /**
  12584. * Base class of pointer info types.
  12585. */
  12586. export class PointerInfoBase {
  12587. /**
  12588. * Defines the type of event (PointerEventTypes)
  12589. */
  12590. type: number;
  12591. /**
  12592. * Defines the related dom event
  12593. */
  12594. event: PointerEvent | MouseWheelEvent;
  12595. /**
  12596. * Instantiates the base class of pointers info.
  12597. * @param type Defines the type of event (PointerEventTypes)
  12598. * @param event Defines the related dom event
  12599. */
  12600. constructor(
  12601. /**
  12602. * Defines the type of event (PointerEventTypes)
  12603. */
  12604. type: number,
  12605. /**
  12606. * Defines the related dom event
  12607. */
  12608. event: PointerEvent | MouseWheelEvent);
  12609. }
  12610. /**
  12611. * This class is used to store pointer related info for the onPrePointerObservable event.
  12612. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12613. */
  12614. export class PointerInfoPre extends PointerInfoBase {
  12615. /**
  12616. * Ray from a pointer if availible (eg. 6dof controller)
  12617. */
  12618. ray: Nullable<Ray>;
  12619. /**
  12620. * Defines the local position of the pointer on the canvas.
  12621. */
  12622. localPosition: Vector2;
  12623. /**
  12624. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12625. */
  12626. skipOnPointerObservable: boolean;
  12627. /**
  12628. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12629. * @param type Defines the type of event (PointerEventTypes)
  12630. * @param event Defines the related dom event
  12631. * @param localX Defines the local x coordinates of the pointer when the event occured
  12632. * @param localY Defines the local y coordinates of the pointer when the event occured
  12633. */
  12634. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12635. }
  12636. /**
  12637. * This type contains all the data related to a pointer event in Babylon.js.
  12638. * 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.
  12639. */
  12640. export class PointerInfo extends PointerInfoBase {
  12641. /**
  12642. * Defines the picking info associated to the info (if any)\
  12643. */
  12644. pickInfo: Nullable<PickingInfo>;
  12645. /**
  12646. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12647. * @param type Defines the type of event (PointerEventTypes)
  12648. * @param event Defines the related dom event
  12649. * @param pickInfo Defines the picking info associated to the info (if any)\
  12650. */
  12651. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12652. /**
  12653. * Defines the picking info associated to the info (if any)\
  12654. */
  12655. pickInfo: Nullable<PickingInfo>);
  12656. }
  12657. /**
  12658. * Data relating to a touch event on the screen.
  12659. */
  12660. export interface PointerTouch {
  12661. /**
  12662. * X coordinate of touch.
  12663. */
  12664. x: number;
  12665. /**
  12666. * Y coordinate of touch.
  12667. */
  12668. y: number;
  12669. /**
  12670. * Id of touch. Unique for each finger.
  12671. */
  12672. pointerId: number;
  12673. /**
  12674. * Event type passed from DOM.
  12675. */
  12676. type: any;
  12677. }
  12678. }
  12679. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12680. import { Observable } from "babylonjs/Misc/observable";
  12681. import { Nullable } from "babylonjs/types";
  12682. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12683. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12684. /**
  12685. * Manage the mouse inputs to control the movement of a free camera.
  12686. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12687. */
  12688. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12689. /**
  12690. * Define if touch is enabled in the mouse input
  12691. */
  12692. touchEnabled: boolean;
  12693. /**
  12694. * Defines the camera the input is attached to.
  12695. */
  12696. camera: FreeCamera;
  12697. /**
  12698. * Defines the buttons associated with the input to handle camera move.
  12699. */
  12700. buttons: number[];
  12701. /**
  12702. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12703. */
  12704. angularSensibility: number;
  12705. private _pointerInput;
  12706. private _onMouseMove;
  12707. private _observer;
  12708. private previousPosition;
  12709. /**
  12710. * Observable for when a pointer move event occurs containing the move offset
  12711. */
  12712. onPointerMovedObservable: Observable<{
  12713. offsetX: number;
  12714. offsetY: number;
  12715. }>;
  12716. /**
  12717. * @hidden
  12718. * If the camera should be rotated automatically based on pointer movement
  12719. */
  12720. _allowCameraRotation: boolean;
  12721. /**
  12722. * Manage the mouse inputs to control the movement of a free camera.
  12723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12724. * @param touchEnabled Defines if touch is enabled or not
  12725. */
  12726. constructor(
  12727. /**
  12728. * Define if touch is enabled in the mouse input
  12729. */
  12730. touchEnabled?: boolean);
  12731. /**
  12732. * Attach the input controls to a specific dom element to get the input from.
  12733. * @param element Defines the element the controls should be listened from
  12734. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12735. */
  12736. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12737. /**
  12738. * Called on JS contextmenu event.
  12739. * Override this method to provide functionality.
  12740. */
  12741. protected onContextMenu(evt: PointerEvent): void;
  12742. /**
  12743. * Detach the current controls from the specified dom element.
  12744. * @param element Defines the element to stop listening the inputs from
  12745. */
  12746. detachControl(element: Nullable<HTMLElement>): void;
  12747. /**
  12748. * Gets the class name of the current intput.
  12749. * @returns the class name
  12750. */
  12751. getClassName(): string;
  12752. /**
  12753. * Get the friendly name associated with the input class.
  12754. * @returns the input friendly name
  12755. */
  12756. getSimpleName(): string;
  12757. }
  12758. }
  12759. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12760. import { Nullable } from "babylonjs/types";
  12761. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12762. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12763. /**
  12764. * Manage the touch inputs to control the movement of a free camera.
  12765. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12766. */
  12767. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12768. /**
  12769. * Defines the camera the input is attached to.
  12770. */
  12771. camera: FreeCamera;
  12772. /**
  12773. * Defines the touch sensibility for rotation.
  12774. * The higher the faster.
  12775. */
  12776. touchAngularSensibility: number;
  12777. /**
  12778. * Defines the touch sensibility for move.
  12779. * The higher the faster.
  12780. */
  12781. touchMoveSensibility: number;
  12782. private _offsetX;
  12783. private _offsetY;
  12784. private _pointerPressed;
  12785. private _pointerInput;
  12786. private _observer;
  12787. private _onLostFocus;
  12788. /**
  12789. * Attach the input controls to a specific dom element to get the input from.
  12790. * @param element Defines the element the controls should be listened from
  12791. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12792. */
  12793. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12794. /**
  12795. * Detach the current controls from the specified dom element.
  12796. * @param element Defines the element to stop listening the inputs from
  12797. */
  12798. detachControl(element: Nullable<HTMLElement>): void;
  12799. /**
  12800. * Update the current camera state depending on the inputs that have been used this frame.
  12801. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12802. */
  12803. checkInputs(): void;
  12804. /**
  12805. * Gets the class name of the current intput.
  12806. * @returns the class name
  12807. */
  12808. getClassName(): string;
  12809. /**
  12810. * Get the friendly name associated with the input class.
  12811. * @returns the input friendly name
  12812. */
  12813. getSimpleName(): string;
  12814. }
  12815. }
  12816. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12817. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12818. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12819. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12820. import { Nullable } from "babylonjs/types";
  12821. /**
  12822. * Default Inputs manager for the FreeCamera.
  12823. * It groups all the default supported inputs for ease of use.
  12824. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12825. */
  12826. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12827. /**
  12828. * @hidden
  12829. */
  12830. _mouseInput: Nullable<FreeCameraMouseInput>;
  12831. /**
  12832. * Instantiates a new FreeCameraInputsManager.
  12833. * @param camera Defines the camera the inputs belong to
  12834. */
  12835. constructor(camera: FreeCamera);
  12836. /**
  12837. * Add keyboard input support to the input manager.
  12838. * @returns the current input manager
  12839. */
  12840. addKeyboard(): FreeCameraInputsManager;
  12841. /**
  12842. * Add mouse input support to the input manager.
  12843. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12844. * @returns the current input manager
  12845. */
  12846. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12847. /**
  12848. * Removes the mouse input support from the manager
  12849. * @returns the current input manager
  12850. */
  12851. removeMouse(): FreeCameraInputsManager;
  12852. /**
  12853. * Add touch input support to the input manager.
  12854. * @returns the current input manager
  12855. */
  12856. addTouch(): FreeCameraInputsManager;
  12857. /**
  12858. * Remove all attached input methods from a camera
  12859. */
  12860. clear(): void;
  12861. }
  12862. }
  12863. declare module "babylonjs/Cameras/freeCamera" {
  12864. import { Vector3 } from "babylonjs/Maths/math";
  12865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12866. import { Scene } from "babylonjs/scene";
  12867. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12868. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12869. /**
  12870. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12871. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12872. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12873. */
  12874. export class FreeCamera extends TargetCamera {
  12875. /**
  12876. * Define the collision ellipsoid of the camera.
  12877. * This is helpful to simulate a camera body like the player body around the camera
  12878. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12879. */
  12880. ellipsoid: Vector3;
  12881. /**
  12882. * Define an offset for the position of the ellipsoid around the camera.
  12883. * This can be helpful to determine the center of the body near the gravity center of the body
  12884. * instead of its head.
  12885. */
  12886. ellipsoidOffset: Vector3;
  12887. /**
  12888. * Enable or disable collisions of the camera with the rest of the scene objects.
  12889. */
  12890. checkCollisions: boolean;
  12891. /**
  12892. * Enable or disable gravity on the camera.
  12893. */
  12894. applyGravity: boolean;
  12895. /**
  12896. * Define the input manager associated to the camera.
  12897. */
  12898. inputs: FreeCameraInputsManager;
  12899. /**
  12900. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12901. * Higher values reduce sensitivity.
  12902. */
  12903. /**
  12904. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12905. * Higher values reduce sensitivity.
  12906. */
  12907. angularSensibility: number;
  12908. /**
  12909. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12910. */
  12911. keysUp: number[];
  12912. /**
  12913. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12914. */
  12915. keysDown: number[];
  12916. /**
  12917. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12918. */
  12919. keysLeft: number[];
  12920. /**
  12921. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12922. */
  12923. keysRight: number[];
  12924. /**
  12925. * Event raised when the camera collide with a mesh in the scene.
  12926. */
  12927. onCollide: (collidedMesh: AbstractMesh) => void;
  12928. private _collider;
  12929. private _needMoveForGravity;
  12930. private _oldPosition;
  12931. private _diffPosition;
  12932. private _newPosition;
  12933. /** @hidden */
  12934. _localDirection: Vector3;
  12935. /** @hidden */
  12936. _transformedDirection: Vector3;
  12937. /**
  12938. * Instantiates a Free Camera.
  12939. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12940. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12941. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12942. * @param name Define the name of the camera in the scene
  12943. * @param position Define the start position of the camera in the scene
  12944. * @param scene Define the scene the camera belongs to
  12945. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12946. */
  12947. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12948. /**
  12949. * Attached controls to the current camera.
  12950. * @param element Defines the element the controls should be listened from
  12951. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12952. */
  12953. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12954. /**
  12955. * Detach the current controls from the camera.
  12956. * The camera will stop reacting to inputs.
  12957. * @param element Defines the element to stop listening the inputs from
  12958. */
  12959. detachControl(element: HTMLElement): void;
  12960. private _collisionMask;
  12961. /**
  12962. * Define a collision mask to limit the list of object the camera can collide with
  12963. */
  12964. collisionMask: number;
  12965. /** @hidden */
  12966. _collideWithWorld(displacement: Vector3): void;
  12967. private _onCollisionPositionChange;
  12968. /** @hidden */
  12969. _checkInputs(): void;
  12970. /** @hidden */
  12971. _decideIfNeedsToMove(): boolean;
  12972. /** @hidden */
  12973. _updatePosition(): void;
  12974. /**
  12975. * Destroy the camera and release the current resources hold by it.
  12976. */
  12977. dispose(): void;
  12978. /**
  12979. * Gets the current object class name.
  12980. * @return the class name
  12981. */
  12982. getClassName(): string;
  12983. }
  12984. }
  12985. declare module "babylonjs/Gamepads/gamepad" {
  12986. import { Observable } from "babylonjs/Misc/observable";
  12987. /**
  12988. * Represents a gamepad control stick position
  12989. */
  12990. export class StickValues {
  12991. /**
  12992. * The x component of the control stick
  12993. */
  12994. x: number;
  12995. /**
  12996. * The y component of the control stick
  12997. */
  12998. y: number;
  12999. /**
  13000. * Initializes the gamepad x and y control stick values
  13001. * @param x The x component of the gamepad control stick value
  13002. * @param y The y component of the gamepad control stick value
  13003. */
  13004. constructor(
  13005. /**
  13006. * The x component of the control stick
  13007. */
  13008. x: number,
  13009. /**
  13010. * The y component of the control stick
  13011. */
  13012. y: number);
  13013. }
  13014. /**
  13015. * An interface which manages callbacks for gamepad button changes
  13016. */
  13017. export interface GamepadButtonChanges {
  13018. /**
  13019. * Called when a gamepad has been changed
  13020. */
  13021. changed: boolean;
  13022. /**
  13023. * Called when a gamepad press event has been triggered
  13024. */
  13025. pressChanged: boolean;
  13026. /**
  13027. * Called when a touch event has been triggered
  13028. */
  13029. touchChanged: boolean;
  13030. /**
  13031. * Called when a value has changed
  13032. */
  13033. valueChanged: boolean;
  13034. }
  13035. /**
  13036. * Represents a gamepad
  13037. */
  13038. export class Gamepad {
  13039. /**
  13040. * The id of the gamepad
  13041. */
  13042. id: string;
  13043. /**
  13044. * The index of the gamepad
  13045. */
  13046. index: number;
  13047. /**
  13048. * The browser gamepad
  13049. */
  13050. browserGamepad: any;
  13051. /**
  13052. * Specifies what type of gamepad this represents
  13053. */
  13054. type: number;
  13055. private _leftStick;
  13056. private _rightStick;
  13057. /** @hidden */
  13058. _isConnected: boolean;
  13059. private _leftStickAxisX;
  13060. private _leftStickAxisY;
  13061. private _rightStickAxisX;
  13062. private _rightStickAxisY;
  13063. /**
  13064. * Triggered when the left control stick has been changed
  13065. */
  13066. private _onleftstickchanged;
  13067. /**
  13068. * Triggered when the right control stick has been changed
  13069. */
  13070. private _onrightstickchanged;
  13071. /**
  13072. * Represents a gamepad controller
  13073. */
  13074. static GAMEPAD: number;
  13075. /**
  13076. * Represents a generic controller
  13077. */
  13078. static GENERIC: number;
  13079. /**
  13080. * Represents an XBox controller
  13081. */
  13082. static XBOX: number;
  13083. /**
  13084. * Represents a pose-enabled controller
  13085. */
  13086. static POSE_ENABLED: number;
  13087. /**
  13088. * Specifies whether the left control stick should be Y-inverted
  13089. */
  13090. protected _invertLeftStickY: boolean;
  13091. /**
  13092. * Specifies if the gamepad has been connected
  13093. */
  13094. readonly isConnected: boolean;
  13095. /**
  13096. * Initializes the gamepad
  13097. * @param id The id of the gamepad
  13098. * @param index The index of the gamepad
  13099. * @param browserGamepad The browser gamepad
  13100. * @param leftStickX The x component of the left joystick
  13101. * @param leftStickY The y component of the left joystick
  13102. * @param rightStickX The x component of the right joystick
  13103. * @param rightStickY The y component of the right joystick
  13104. */
  13105. constructor(
  13106. /**
  13107. * The id of the gamepad
  13108. */
  13109. id: string,
  13110. /**
  13111. * The index of the gamepad
  13112. */
  13113. index: number,
  13114. /**
  13115. * The browser gamepad
  13116. */
  13117. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  13118. /**
  13119. * Callback triggered when the left joystick has changed
  13120. * @param callback
  13121. */
  13122. onleftstickchanged(callback: (values: StickValues) => void): void;
  13123. /**
  13124. * Callback triggered when the right joystick has changed
  13125. * @param callback
  13126. */
  13127. onrightstickchanged(callback: (values: StickValues) => void): void;
  13128. /**
  13129. * Gets the left joystick
  13130. */
  13131. /**
  13132. * Sets the left joystick values
  13133. */
  13134. leftStick: StickValues;
  13135. /**
  13136. * Gets the right joystick
  13137. */
  13138. /**
  13139. * Sets the right joystick value
  13140. */
  13141. rightStick: StickValues;
  13142. /**
  13143. * Updates the gamepad joystick positions
  13144. */
  13145. update(): void;
  13146. /**
  13147. * Disposes the gamepad
  13148. */
  13149. dispose(): void;
  13150. }
  13151. /**
  13152. * Represents a generic gamepad
  13153. */
  13154. export class GenericPad extends Gamepad {
  13155. private _buttons;
  13156. private _onbuttondown;
  13157. private _onbuttonup;
  13158. /**
  13159. * Observable triggered when a button has been pressed
  13160. */
  13161. onButtonDownObservable: Observable<number>;
  13162. /**
  13163. * Observable triggered when a button has been released
  13164. */
  13165. onButtonUpObservable: Observable<number>;
  13166. /**
  13167. * Callback triggered when a button has been pressed
  13168. * @param callback Called when a button has been pressed
  13169. */
  13170. onbuttondown(callback: (buttonPressed: number) => void): void;
  13171. /**
  13172. * Callback triggered when a button has been released
  13173. * @param callback Called when a button has been released
  13174. */
  13175. onbuttonup(callback: (buttonReleased: number) => void): void;
  13176. /**
  13177. * Initializes the generic gamepad
  13178. * @param id The id of the generic gamepad
  13179. * @param index The index of the generic gamepad
  13180. * @param browserGamepad The browser gamepad
  13181. */
  13182. constructor(id: string, index: number, browserGamepad: any);
  13183. private _setButtonValue;
  13184. /**
  13185. * Updates the generic gamepad
  13186. */
  13187. update(): void;
  13188. /**
  13189. * Disposes the generic gamepad
  13190. */
  13191. dispose(): void;
  13192. }
  13193. }
  13194. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  13195. import { Observable } from "babylonjs/Misc/observable";
  13196. import { Nullable } from "babylonjs/types";
  13197. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13198. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13200. import { Ray } from "babylonjs/Culling/ray";
  13201. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  13202. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  13203. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  13204. /**
  13205. * Defines the types of pose enabled controllers that are supported
  13206. */
  13207. export enum PoseEnabledControllerType {
  13208. /**
  13209. * HTC Vive
  13210. */
  13211. VIVE = 0,
  13212. /**
  13213. * Oculus Rift
  13214. */
  13215. OCULUS = 1,
  13216. /**
  13217. * Windows mixed reality
  13218. */
  13219. WINDOWS = 2,
  13220. /**
  13221. * Samsung gear VR
  13222. */
  13223. GEAR_VR = 3,
  13224. /**
  13225. * Google Daydream
  13226. */
  13227. DAYDREAM = 4,
  13228. /**
  13229. * Generic
  13230. */
  13231. GENERIC = 5
  13232. }
  13233. /**
  13234. * Defines the MutableGamepadButton interface for the state of a gamepad button
  13235. */
  13236. export interface MutableGamepadButton {
  13237. /**
  13238. * Value of the button/trigger
  13239. */
  13240. value: number;
  13241. /**
  13242. * If the button/trigger is currently touched
  13243. */
  13244. touched: boolean;
  13245. /**
  13246. * If the button/trigger is currently pressed
  13247. */
  13248. pressed: boolean;
  13249. }
  13250. /**
  13251. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13252. * @hidden
  13253. */
  13254. export interface ExtendedGamepadButton extends GamepadButton {
  13255. /**
  13256. * If the button/trigger is currently pressed
  13257. */
  13258. readonly pressed: boolean;
  13259. /**
  13260. * If the button/trigger is currently touched
  13261. */
  13262. readonly touched: boolean;
  13263. /**
  13264. * Value of the button/trigger
  13265. */
  13266. readonly value: number;
  13267. }
  13268. /** @hidden */
  13269. export interface _GamePadFactory {
  13270. /**
  13271. * Returns wether or not the current gamepad can be created for this type of controller.
  13272. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13273. * @returns true if it can be created, otherwise false
  13274. */
  13275. canCreate(gamepadInfo: any): boolean;
  13276. /**
  13277. * Creates a new instance of the Gamepad.
  13278. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13279. * @returns the new gamepad instance
  13280. */
  13281. create(gamepadInfo: any): Gamepad;
  13282. }
  13283. /**
  13284. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13285. */
  13286. export class PoseEnabledControllerHelper {
  13287. /** @hidden */
  13288. static _ControllerFactories: _GamePadFactory[];
  13289. /** @hidden */
  13290. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13291. /**
  13292. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13293. * @param vrGamepad the gamepad to initialized
  13294. * @returns a vr controller of the type the gamepad identified as
  13295. */
  13296. static InitiateController(vrGamepad: any): Gamepad;
  13297. }
  13298. /**
  13299. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13300. */
  13301. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13302. private _deviceRoomPosition;
  13303. private _deviceRoomRotationQuaternion;
  13304. /**
  13305. * The device position in babylon space
  13306. */
  13307. devicePosition: Vector3;
  13308. /**
  13309. * The device rotation in babylon space
  13310. */
  13311. deviceRotationQuaternion: Quaternion;
  13312. /**
  13313. * The scale factor of the device in babylon space
  13314. */
  13315. deviceScaleFactor: number;
  13316. /**
  13317. * (Likely devicePosition should be used instead) The device position in its room space
  13318. */
  13319. position: Vector3;
  13320. /**
  13321. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13322. */
  13323. rotationQuaternion: Quaternion;
  13324. /**
  13325. * The type of controller (Eg. Windows mixed reality)
  13326. */
  13327. controllerType: PoseEnabledControllerType;
  13328. protected _calculatedPosition: Vector3;
  13329. private _calculatedRotation;
  13330. /**
  13331. * The raw pose from the device
  13332. */
  13333. rawPose: DevicePose;
  13334. private _trackPosition;
  13335. private _maxRotationDistFromHeadset;
  13336. private _draggedRoomRotation;
  13337. /**
  13338. * @hidden
  13339. */
  13340. _disableTrackPosition(fixedPosition: Vector3): void;
  13341. /**
  13342. * Internal, the mesh attached to the controller
  13343. * @hidden
  13344. */
  13345. _mesh: Nullable<AbstractMesh>;
  13346. private _poseControlledCamera;
  13347. private _leftHandSystemQuaternion;
  13348. /**
  13349. * Internal, matrix used to convert room space to babylon space
  13350. * @hidden
  13351. */
  13352. _deviceToWorld: Matrix;
  13353. /**
  13354. * Node to be used when casting a ray from the controller
  13355. * @hidden
  13356. */
  13357. _pointingPoseNode: Nullable<TransformNode>;
  13358. /**
  13359. * Name of the child mesh that can be used to cast a ray from the controller
  13360. */
  13361. static readonly POINTING_POSE: string;
  13362. /**
  13363. * Creates a new PoseEnabledController from a gamepad
  13364. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13365. */
  13366. constructor(browserGamepad: any);
  13367. private _workingMatrix;
  13368. /**
  13369. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13370. */
  13371. update(): void;
  13372. /**
  13373. * Updates only the pose device and mesh without doing any button event checking
  13374. */
  13375. protected _updatePoseAndMesh(): void;
  13376. /**
  13377. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13378. * @param poseData raw pose fromthe device
  13379. */
  13380. updateFromDevice(poseData: DevicePose): void;
  13381. /**
  13382. * @hidden
  13383. */
  13384. _meshAttachedObservable: Observable<AbstractMesh>;
  13385. /**
  13386. * Attaches a mesh to the controller
  13387. * @param mesh the mesh to be attached
  13388. */
  13389. attachToMesh(mesh: AbstractMesh): void;
  13390. /**
  13391. * Attaches the controllers mesh to a camera
  13392. * @param camera the camera the mesh should be attached to
  13393. */
  13394. attachToPoseControlledCamera(camera: TargetCamera): void;
  13395. /**
  13396. * Disposes of the controller
  13397. */
  13398. dispose(): void;
  13399. /**
  13400. * The mesh that is attached to the controller
  13401. */
  13402. readonly mesh: Nullable<AbstractMesh>;
  13403. /**
  13404. * Gets the ray of the controller in the direction the controller is pointing
  13405. * @param length the length the resulting ray should be
  13406. * @returns a ray in the direction the controller is pointing
  13407. */
  13408. getForwardRay(length?: number): Ray;
  13409. }
  13410. }
  13411. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13412. import { Observable } from "babylonjs/Misc/observable";
  13413. import { Scene } from "babylonjs/scene";
  13414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13415. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13416. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13417. /**
  13418. * Defines the WebVRController object that represents controllers tracked in 3D space
  13419. */
  13420. export abstract class WebVRController extends PoseEnabledController {
  13421. /**
  13422. * Internal, the default controller model for the controller
  13423. */
  13424. protected _defaultModel: AbstractMesh;
  13425. /**
  13426. * Fired when the trigger state has changed
  13427. */
  13428. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13429. /**
  13430. * Fired when the main button state has changed
  13431. */
  13432. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13433. /**
  13434. * Fired when the secondary button state has changed
  13435. */
  13436. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13437. /**
  13438. * Fired when the pad state has changed
  13439. */
  13440. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13441. /**
  13442. * Fired when controllers stick values have changed
  13443. */
  13444. onPadValuesChangedObservable: Observable<StickValues>;
  13445. /**
  13446. * Array of button availible on the controller
  13447. */
  13448. protected _buttons: Array<MutableGamepadButton>;
  13449. private _onButtonStateChange;
  13450. /**
  13451. * Fired when a controller button's state has changed
  13452. * @param callback the callback containing the button that was modified
  13453. */
  13454. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13455. /**
  13456. * X and Y axis corrisponding to the controllers joystick
  13457. */
  13458. pad: StickValues;
  13459. /**
  13460. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13461. */
  13462. hand: string;
  13463. /**
  13464. * The default controller model for the controller
  13465. */
  13466. readonly defaultModel: AbstractMesh;
  13467. /**
  13468. * Creates a new WebVRController from a gamepad
  13469. * @param vrGamepad the gamepad that the WebVRController should be created from
  13470. */
  13471. constructor(vrGamepad: any);
  13472. /**
  13473. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13474. */
  13475. update(): void;
  13476. /**
  13477. * Function to be called when a button is modified
  13478. */
  13479. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13480. /**
  13481. * Loads a mesh and attaches it to the controller
  13482. * @param scene the scene the mesh should be added to
  13483. * @param meshLoaded callback for when the mesh has been loaded
  13484. */
  13485. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13486. private _setButtonValue;
  13487. private _changes;
  13488. private _checkChanges;
  13489. /**
  13490. * Disposes of th webVRCOntroller
  13491. */
  13492. dispose(): void;
  13493. }
  13494. }
  13495. declare module "babylonjs/Lights/hemisphericLight" {
  13496. import { Nullable } from "babylonjs/types";
  13497. import { Scene } from "babylonjs/scene";
  13498. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13499. import { Effect } from "babylonjs/Materials/effect";
  13500. import { Light } from "babylonjs/Lights/light";
  13501. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13502. /**
  13503. * The HemisphericLight simulates the ambient environment light,
  13504. * so the passed direction is the light reflection direction, not the incoming direction.
  13505. */
  13506. export class HemisphericLight extends Light {
  13507. /**
  13508. * The groundColor is the light in the opposite direction to the one specified during creation.
  13509. * 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.
  13510. */
  13511. groundColor: Color3;
  13512. /**
  13513. * The light reflection direction, not the incoming direction.
  13514. */
  13515. direction: Vector3;
  13516. /**
  13517. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13518. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13519. * The HemisphericLight can't cast shadows.
  13520. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13521. * @param name The friendly name of the light
  13522. * @param direction The direction of the light reflection
  13523. * @param scene The scene the light belongs to
  13524. */
  13525. constructor(name: string, direction: Vector3, scene: Scene);
  13526. protected _buildUniformLayout(): void;
  13527. /**
  13528. * Returns the string "HemisphericLight".
  13529. * @return The class name
  13530. */
  13531. getClassName(): string;
  13532. /**
  13533. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13534. * Returns the updated direction.
  13535. * @param target The target the direction should point to
  13536. * @return The computed direction
  13537. */
  13538. setDirectionToTarget(target: Vector3): Vector3;
  13539. /**
  13540. * Returns the shadow generator associated to the light.
  13541. * @returns Always null for hemispheric lights because it does not support shadows.
  13542. */
  13543. getShadowGenerator(): Nullable<IShadowGenerator>;
  13544. /**
  13545. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13546. * @param effect The effect to update
  13547. * @param lightIndex The index of the light in the effect to update
  13548. * @returns The hemispheric light
  13549. */
  13550. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13551. /**
  13552. * Computes the world matrix of the node
  13553. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13554. * @param useWasUpdatedFlag defines a reserved property
  13555. * @returns the world matrix
  13556. */
  13557. computeWorldMatrix(): Matrix;
  13558. /**
  13559. * Returns the integer 3.
  13560. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13561. */
  13562. getTypeID(): number;
  13563. /**
  13564. * Prepares the list of defines specific to the light type.
  13565. * @param defines the list of defines
  13566. * @param lightIndex defines the index of the light for the effect
  13567. */
  13568. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13569. }
  13570. }
  13571. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13572. /** @hidden */
  13573. export var vrMultiviewToSingleviewPixelShader: {
  13574. name: string;
  13575. shader: string;
  13576. };
  13577. }
  13578. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13579. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13580. import { Scene } from "babylonjs/scene";
  13581. /**
  13582. * Renders to multiple views with a single draw call
  13583. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13584. */
  13585. export class MultiviewRenderTarget extends RenderTargetTexture {
  13586. /**
  13587. * Creates a multiview render target
  13588. * @param scene scene used with the render target
  13589. * @param size the size of the render target (used for each view)
  13590. */
  13591. constructor(scene: Scene, size?: number | {
  13592. width: number;
  13593. height: number;
  13594. } | {
  13595. ratio: number;
  13596. });
  13597. /**
  13598. * @hidden
  13599. * @param faceIndex the face index, if its a cube texture
  13600. */
  13601. _bindFrameBuffer(faceIndex?: number): void;
  13602. /**
  13603. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13604. * @returns the view count
  13605. */
  13606. getViewCount(): number;
  13607. }
  13608. }
  13609. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13610. import { Camera } from "babylonjs/Cameras/camera";
  13611. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13612. import { Nullable } from "babylonjs/types";
  13613. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13614. import { Matrix } from "babylonjs/Maths/math";
  13615. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13616. module "babylonjs/Engines/engine" {
  13617. interface Engine {
  13618. /**
  13619. * Creates a new multiview render target
  13620. * @param width defines the width of the texture
  13621. * @param height defines the height of the texture
  13622. * @returns the created multiview texture
  13623. */
  13624. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13625. /**
  13626. * Binds a multiview framebuffer to be drawn to
  13627. * @param multiviewTexture texture to bind
  13628. */
  13629. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13630. }
  13631. }
  13632. module "babylonjs/Cameras/camera" {
  13633. interface Camera {
  13634. /**
  13635. * @hidden
  13636. * 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)
  13637. */
  13638. _useMultiviewToSingleView: boolean;
  13639. /**
  13640. * @hidden
  13641. * 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)
  13642. */
  13643. _multiviewTexture: Nullable<RenderTargetTexture>;
  13644. /**
  13645. * @hidden
  13646. * ensures the multiview texture of the camera exists and has the specified width/height
  13647. * @param width height to set on the multiview texture
  13648. * @param height width to set on the multiview texture
  13649. */
  13650. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13651. }
  13652. }
  13653. module "babylonjs/scene" {
  13654. interface Scene {
  13655. /** @hidden */
  13656. _transformMatrixR: Matrix;
  13657. /** @hidden */
  13658. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13659. /** @hidden */
  13660. _createMultiviewUbo(): void;
  13661. /** @hidden */
  13662. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13663. /** @hidden */
  13664. _renderMultiviewToSingleView(camera: Camera): void;
  13665. }
  13666. }
  13667. }
  13668. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13669. import { Camera } from "babylonjs/Cameras/camera";
  13670. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13671. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13672. import "babylonjs/Engines/Extensions/engine.multiview";
  13673. /**
  13674. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13675. * This will not be used for webXR as it supports displaying texture arrays directly
  13676. */
  13677. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13678. /**
  13679. * Initializes a VRMultiviewToSingleview
  13680. * @param name name of the post process
  13681. * @param camera camera to be applied to
  13682. * @param scaleFactor scaling factor to the size of the output texture
  13683. */
  13684. constructor(name: string, camera: Camera, scaleFactor: number);
  13685. }
  13686. }
  13687. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13688. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  13689. import { Nullable } from "babylonjs/types";
  13690. import { Size } from "babylonjs/Maths/math";
  13691. import { Observable } from "babylonjs/Misc/observable";
  13692. module "babylonjs/Engines/engine" {
  13693. interface Engine {
  13694. /** @hidden */
  13695. _vrDisplay: any;
  13696. /** @hidden */
  13697. _vrSupported: boolean;
  13698. /** @hidden */
  13699. _oldSize: Size;
  13700. /** @hidden */
  13701. _oldHardwareScaleFactor: number;
  13702. /** @hidden */
  13703. _vrExclusivePointerMode: boolean;
  13704. /** @hidden */
  13705. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13706. /** @hidden */
  13707. _onVRDisplayPointerRestricted: () => void;
  13708. /** @hidden */
  13709. _onVRDisplayPointerUnrestricted: () => void;
  13710. /** @hidden */
  13711. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13712. /** @hidden */
  13713. _onVrDisplayDisconnect: Nullable<() => void>;
  13714. /** @hidden */
  13715. _onVrDisplayPresentChange: Nullable<() => void>;
  13716. /**
  13717. * Observable signaled when VR display mode changes
  13718. */
  13719. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13720. /**
  13721. * Observable signaled when VR request present is complete
  13722. */
  13723. onVRRequestPresentComplete: Observable<boolean>;
  13724. /**
  13725. * Observable signaled when VR request present starts
  13726. */
  13727. onVRRequestPresentStart: Observable<Engine>;
  13728. /**
  13729. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13730. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13731. */
  13732. isInVRExclusivePointerMode: boolean;
  13733. /**
  13734. * Gets a boolean indicating if a webVR device was detected
  13735. * @returns true if a webVR device was detected
  13736. */
  13737. isVRDevicePresent(): boolean;
  13738. /**
  13739. * Gets the current webVR device
  13740. * @returns the current webVR device (or null)
  13741. */
  13742. getVRDevice(): any;
  13743. /**
  13744. * Initializes a webVR display and starts listening to display change events
  13745. * The onVRDisplayChangedObservable will be notified upon these changes
  13746. * @returns A promise containing a VRDisplay and if vr is supported
  13747. */
  13748. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13749. /** @hidden */
  13750. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13751. /**
  13752. * Call this function to switch to webVR mode
  13753. * Will do nothing if webVR is not supported or if there is no webVR device
  13754. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13755. */
  13756. enableVR(): void;
  13757. /** @hidden */
  13758. _onVRFullScreenTriggered(): void;
  13759. }
  13760. }
  13761. }
  13762. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13763. import { Nullable } from "babylonjs/types";
  13764. import { Observable } from "babylonjs/Misc/observable";
  13765. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13766. import { Scene } from "babylonjs/scene";
  13767. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13768. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13769. import { Node } from "babylonjs/node";
  13770. import { Ray } from "babylonjs/Culling/ray";
  13771. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13772. import "babylonjs/Engines/Extensions/engine.webVR";
  13773. /**
  13774. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13775. * IMPORTANT!! The data is right-hand data.
  13776. * @export
  13777. * @interface DevicePose
  13778. */
  13779. export interface DevicePose {
  13780. /**
  13781. * The position of the device, values in array are [x,y,z].
  13782. */
  13783. readonly position: Nullable<Float32Array>;
  13784. /**
  13785. * The linearVelocity of the device, values in array are [x,y,z].
  13786. */
  13787. readonly linearVelocity: Nullable<Float32Array>;
  13788. /**
  13789. * The linearAcceleration of the device, values in array are [x,y,z].
  13790. */
  13791. readonly linearAcceleration: Nullable<Float32Array>;
  13792. /**
  13793. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13794. */
  13795. readonly orientation: Nullable<Float32Array>;
  13796. /**
  13797. * The angularVelocity of the device, values in array are [x,y,z].
  13798. */
  13799. readonly angularVelocity: Nullable<Float32Array>;
  13800. /**
  13801. * The angularAcceleration of the device, values in array are [x,y,z].
  13802. */
  13803. readonly angularAcceleration: Nullable<Float32Array>;
  13804. }
  13805. /**
  13806. * Interface representing a pose controlled object in Babylon.
  13807. * A pose controlled object has both regular pose values as well as pose values
  13808. * from an external device such as a VR head mounted display
  13809. */
  13810. export interface PoseControlled {
  13811. /**
  13812. * The position of the object in babylon space.
  13813. */
  13814. position: Vector3;
  13815. /**
  13816. * The rotation quaternion of the object in babylon space.
  13817. */
  13818. rotationQuaternion: Quaternion;
  13819. /**
  13820. * The position of the device in babylon space.
  13821. */
  13822. devicePosition?: Vector3;
  13823. /**
  13824. * The rotation quaternion of the device in babylon space.
  13825. */
  13826. deviceRotationQuaternion: Quaternion;
  13827. /**
  13828. * The raw pose coming from the device.
  13829. */
  13830. rawPose: Nullable<DevicePose>;
  13831. /**
  13832. * The scale of the device to be used when translating from device space to babylon space.
  13833. */
  13834. deviceScaleFactor: number;
  13835. /**
  13836. * Updates the poseControlled values based on the input device pose.
  13837. * @param poseData the pose data to update the object with
  13838. */
  13839. updateFromDevice(poseData: DevicePose): void;
  13840. }
  13841. /**
  13842. * Set of options to customize the webVRCamera
  13843. */
  13844. export interface WebVROptions {
  13845. /**
  13846. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13847. */
  13848. trackPosition?: boolean;
  13849. /**
  13850. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13851. */
  13852. positionScale?: number;
  13853. /**
  13854. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13855. */
  13856. displayName?: string;
  13857. /**
  13858. * Should the native controller meshes be initialized. (default: true)
  13859. */
  13860. controllerMeshes?: boolean;
  13861. /**
  13862. * Creating a default HemiLight only on controllers. (default: true)
  13863. */
  13864. defaultLightingOnControllers?: boolean;
  13865. /**
  13866. * If you don't want to use the default VR button of the helper. (default: false)
  13867. */
  13868. useCustomVRButton?: boolean;
  13869. /**
  13870. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13871. */
  13872. customVRButton?: HTMLButtonElement;
  13873. /**
  13874. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13875. */
  13876. rayLength?: number;
  13877. /**
  13878. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13879. */
  13880. defaultHeight?: number;
  13881. /**
  13882. * If multiview should be used if availible (default: false)
  13883. */
  13884. useMultiview?: boolean;
  13885. }
  13886. /**
  13887. * This represents a WebVR camera.
  13888. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13889. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13890. */
  13891. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13892. private webVROptions;
  13893. /**
  13894. * @hidden
  13895. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13896. */
  13897. _vrDevice: any;
  13898. /**
  13899. * The rawPose of the vrDevice.
  13900. */
  13901. rawPose: Nullable<DevicePose>;
  13902. private _onVREnabled;
  13903. private _specsVersion;
  13904. private _attached;
  13905. private _frameData;
  13906. protected _descendants: Array<Node>;
  13907. private _deviceRoomPosition;
  13908. /** @hidden */
  13909. _deviceRoomRotationQuaternion: Quaternion;
  13910. private _standingMatrix;
  13911. /**
  13912. * Represents device position in babylon space.
  13913. */
  13914. devicePosition: Vector3;
  13915. /**
  13916. * Represents device rotation in babylon space.
  13917. */
  13918. deviceRotationQuaternion: Quaternion;
  13919. /**
  13920. * The scale of the device to be used when translating from device space to babylon space.
  13921. */
  13922. deviceScaleFactor: number;
  13923. private _deviceToWorld;
  13924. private _worldToDevice;
  13925. /**
  13926. * References to the webVR controllers for the vrDevice.
  13927. */
  13928. controllers: Array<WebVRController>;
  13929. /**
  13930. * Emits an event when a controller is attached.
  13931. */
  13932. onControllersAttachedObservable: Observable<WebVRController[]>;
  13933. /**
  13934. * Emits an event when a controller's mesh has been loaded;
  13935. */
  13936. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13937. /**
  13938. * Emits an event when the HMD's pose has been updated.
  13939. */
  13940. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13941. private _poseSet;
  13942. /**
  13943. * If the rig cameras be used as parent instead of this camera.
  13944. */
  13945. rigParenting: boolean;
  13946. private _lightOnControllers;
  13947. private _defaultHeight?;
  13948. /**
  13949. * Instantiates a WebVRFreeCamera.
  13950. * @param name The name of the WebVRFreeCamera
  13951. * @param position The starting anchor position for the camera
  13952. * @param scene The scene the camera belongs to
  13953. * @param webVROptions a set of customizable options for the webVRCamera
  13954. */
  13955. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13956. /**
  13957. * Gets the device distance from the ground in meters.
  13958. * @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.
  13959. */
  13960. deviceDistanceToRoomGround(): number;
  13961. /**
  13962. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13963. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13964. */
  13965. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13966. /**
  13967. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13968. * @returns A promise with a boolean set to if the standing matrix is supported.
  13969. */
  13970. useStandingMatrixAsync(): Promise<boolean>;
  13971. /**
  13972. * Disposes the camera
  13973. */
  13974. dispose(): void;
  13975. /**
  13976. * Gets a vrController by name.
  13977. * @param name The name of the controller to retreive
  13978. * @returns the controller matching the name specified or null if not found
  13979. */
  13980. getControllerByName(name: string): Nullable<WebVRController>;
  13981. private _leftController;
  13982. /**
  13983. * The controller corrisponding to the users left hand.
  13984. */
  13985. readonly leftController: Nullable<WebVRController>;
  13986. private _rightController;
  13987. /**
  13988. * The controller corrisponding to the users right hand.
  13989. */
  13990. readonly rightController: Nullable<WebVRController>;
  13991. /**
  13992. * Casts a ray forward from the vrCamera's gaze.
  13993. * @param length Length of the ray (default: 100)
  13994. * @returns the ray corrisponding to the gaze
  13995. */
  13996. getForwardRay(length?: number): Ray;
  13997. /**
  13998. * @hidden
  13999. * Updates the camera based on device's frame data
  14000. */
  14001. _checkInputs(): void;
  14002. /**
  14003. * Updates the poseControlled values based on the input device pose.
  14004. * @param poseData Pose coming from the device
  14005. */
  14006. updateFromDevice(poseData: DevicePose): void;
  14007. private _htmlElementAttached;
  14008. private _detachIfAttached;
  14009. /**
  14010. * WebVR's attach control will start broadcasting frames to the device.
  14011. * Note that in certain browsers (chrome for example) this function must be called
  14012. * within a user-interaction callback. Example:
  14013. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14014. *
  14015. * @param element html element to attach the vrDevice to
  14016. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14017. */
  14018. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14019. /**
  14020. * Detaches the camera from the html element and disables VR
  14021. *
  14022. * @param element html element to detach from
  14023. */
  14024. detachControl(element: HTMLElement): void;
  14025. /**
  14026. * @returns the name of this class
  14027. */
  14028. getClassName(): string;
  14029. /**
  14030. * Calls resetPose on the vrDisplay
  14031. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14032. */
  14033. resetToCurrentRotation(): void;
  14034. /**
  14035. * @hidden
  14036. * Updates the rig cameras (left and right eye)
  14037. */
  14038. _updateRigCameras(): void;
  14039. private _workingVector;
  14040. private _oneVector;
  14041. private _workingMatrix;
  14042. private updateCacheCalled;
  14043. private _correctPositionIfNotTrackPosition;
  14044. /**
  14045. * @hidden
  14046. * Updates the cached values of the camera
  14047. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14048. */
  14049. _updateCache(ignoreParentClass?: boolean): void;
  14050. /**
  14051. * @hidden
  14052. * Get current device position in babylon world
  14053. */
  14054. _computeDevicePosition(): void;
  14055. /**
  14056. * Updates the current device position and rotation in the babylon world
  14057. */
  14058. update(): void;
  14059. /**
  14060. * @hidden
  14061. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14062. * @returns an identity matrix
  14063. */
  14064. _getViewMatrix(): Matrix;
  14065. private _tmpMatrix;
  14066. /**
  14067. * This function is called by the two RIG cameras.
  14068. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14069. * @hidden
  14070. */
  14071. _getWebVRViewMatrix(): Matrix;
  14072. /** @hidden */
  14073. _getWebVRProjectionMatrix(): Matrix;
  14074. private _onGamepadConnectedObserver;
  14075. private _onGamepadDisconnectedObserver;
  14076. private _updateCacheWhenTrackingDisabledObserver;
  14077. /**
  14078. * Initializes the controllers and their meshes
  14079. */
  14080. initControllers(): void;
  14081. }
  14082. }
  14083. declare module "babylonjs/PostProcesses/postProcess" {
  14084. import { Nullable } from "babylonjs/types";
  14085. import { SmartArray } from "babylonjs/Misc/smartArray";
  14086. import { Observable } from "babylonjs/Misc/observable";
  14087. import { Color4, Vector2 } from "babylonjs/Maths/math";
  14088. import { Camera } from "babylonjs/Cameras/camera";
  14089. import { Effect } from "babylonjs/Materials/effect";
  14090. import "babylonjs/Shaders/postprocess.vertex";
  14091. import { IInspectable } from "babylonjs/Misc/iInspectable";
  14092. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14093. import { Engine } from "babylonjs/Engines/engine";
  14094. /**
  14095. * Size options for a post process
  14096. */
  14097. export type PostProcessOptions = {
  14098. width: number;
  14099. height: number;
  14100. };
  14101. /**
  14102. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14103. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14104. */
  14105. export class PostProcess {
  14106. /** Name of the PostProcess. */
  14107. name: string;
  14108. /**
  14109. * Gets or sets the unique id of the post process
  14110. */
  14111. uniqueId: number;
  14112. /**
  14113. * Width of the texture to apply the post process on
  14114. */
  14115. width: number;
  14116. /**
  14117. * Height of the texture to apply the post process on
  14118. */
  14119. height: number;
  14120. /**
  14121. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  14122. * @hidden
  14123. */
  14124. _outputTexture: Nullable<InternalTexture>;
  14125. /**
  14126. * Sampling mode used by the shader
  14127. * See https://doc.babylonjs.com/classes/3.1/texture
  14128. */
  14129. renderTargetSamplingMode: number;
  14130. /**
  14131. * Clear color to use when screen clearing
  14132. */
  14133. clearColor: Color4;
  14134. /**
  14135. * If the buffer needs to be cleared before applying the post process. (default: true)
  14136. * Should be set to false if shader will overwrite all previous pixels.
  14137. */
  14138. autoClear: boolean;
  14139. /**
  14140. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  14141. */
  14142. alphaMode: number;
  14143. /**
  14144. * Sets the setAlphaBlendConstants of the babylon engine
  14145. */
  14146. alphaConstants: Color4;
  14147. /**
  14148. * Animations to be used for the post processing
  14149. */
  14150. animations: import("babylonjs/Animations/animation").Animation[];
  14151. /**
  14152. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  14153. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  14154. */
  14155. enablePixelPerfectMode: boolean;
  14156. /**
  14157. * Force the postprocess to be applied without taking in account viewport
  14158. */
  14159. forceFullscreenViewport: boolean;
  14160. /**
  14161. * List of inspectable custom properties (used by the Inspector)
  14162. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14163. */
  14164. inspectableCustomProperties: IInspectable[];
  14165. /**
  14166. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  14167. *
  14168. * | Value | Type | Description |
  14169. * | ----- | ----------------------------------- | ----------- |
  14170. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  14171. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  14172. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  14173. *
  14174. */
  14175. scaleMode: number;
  14176. /**
  14177. * Force textures to be a power of two (default: false)
  14178. */
  14179. alwaysForcePOT: boolean;
  14180. private _samples;
  14181. /**
  14182. * Number of sample textures (default: 1)
  14183. */
  14184. samples: number;
  14185. /**
  14186. * Modify the scale of the post process to be the same as the viewport (default: false)
  14187. */
  14188. adaptScaleToCurrentViewport: boolean;
  14189. private _camera;
  14190. private _scene;
  14191. private _engine;
  14192. private _options;
  14193. private _reusable;
  14194. private _textureType;
  14195. /**
  14196. * Smart array of input and output textures for the post process.
  14197. * @hidden
  14198. */
  14199. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  14200. /**
  14201. * The index in _textures that corresponds to the output texture.
  14202. * @hidden
  14203. */
  14204. _currentRenderTextureInd: number;
  14205. private _effect;
  14206. private _samplers;
  14207. private _fragmentUrl;
  14208. private _vertexUrl;
  14209. private _parameters;
  14210. private _scaleRatio;
  14211. protected _indexParameters: any;
  14212. private _shareOutputWithPostProcess;
  14213. private _texelSize;
  14214. private _forcedOutputTexture;
  14215. /**
  14216. * Returns the fragment url or shader name used in the post process.
  14217. * @returns the fragment url or name in the shader store.
  14218. */
  14219. getEffectName(): string;
  14220. /**
  14221. * An event triggered when the postprocess is activated.
  14222. */
  14223. onActivateObservable: Observable<Camera>;
  14224. private _onActivateObserver;
  14225. /**
  14226. * A function that is added to the onActivateObservable
  14227. */
  14228. onActivate: Nullable<(camera: Camera) => void>;
  14229. /**
  14230. * An event triggered when the postprocess changes its size.
  14231. */
  14232. onSizeChangedObservable: Observable<PostProcess>;
  14233. private _onSizeChangedObserver;
  14234. /**
  14235. * A function that is added to the onSizeChangedObservable
  14236. */
  14237. onSizeChanged: (postProcess: PostProcess) => void;
  14238. /**
  14239. * An event triggered when the postprocess applies its effect.
  14240. */
  14241. onApplyObservable: Observable<Effect>;
  14242. private _onApplyObserver;
  14243. /**
  14244. * A function that is added to the onApplyObservable
  14245. */
  14246. onApply: (effect: Effect) => void;
  14247. /**
  14248. * An event triggered before rendering the postprocess
  14249. */
  14250. onBeforeRenderObservable: Observable<Effect>;
  14251. private _onBeforeRenderObserver;
  14252. /**
  14253. * A function that is added to the onBeforeRenderObservable
  14254. */
  14255. onBeforeRender: (effect: Effect) => void;
  14256. /**
  14257. * An event triggered after rendering the postprocess
  14258. */
  14259. onAfterRenderObservable: Observable<Effect>;
  14260. private _onAfterRenderObserver;
  14261. /**
  14262. * A function that is added to the onAfterRenderObservable
  14263. */
  14264. onAfterRender: (efect: Effect) => void;
  14265. /**
  14266. * 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
  14267. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14268. */
  14269. inputTexture: InternalTexture;
  14270. /**
  14271. * Gets the camera which post process is applied to.
  14272. * @returns The camera the post process is applied to.
  14273. */
  14274. getCamera(): Camera;
  14275. /**
  14276. * Gets the texel size of the postprocess.
  14277. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14278. */
  14279. readonly texelSize: Vector2;
  14280. /**
  14281. * Creates a new instance PostProcess
  14282. * @param name The name of the PostProcess.
  14283. * @param fragmentUrl The url of the fragment shader to be used.
  14284. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14285. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  14286. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  14287. * @param camera The camera to apply the render pass to.
  14288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14289. * @param engine The engine which the post process will be applied. (default: current engine)
  14290. * @param reusable If the post process can be reused on the same frame. (default: false)
  14291. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  14292. * @param textureType Type of textures used when performing the post process. (default: 0)
  14293. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  14294. * @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
  14295. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  14296. */
  14297. constructor(
  14298. /** Name of the PostProcess. */
  14299. 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);
  14300. /**
  14301. * Gets a string idenfifying the name of the class
  14302. * @returns "PostProcess" string
  14303. */
  14304. getClassName(): string;
  14305. /**
  14306. * Gets the engine which this post process belongs to.
  14307. * @returns The engine the post process was enabled with.
  14308. */
  14309. getEngine(): Engine;
  14310. /**
  14311. * The effect that is created when initializing the post process.
  14312. * @returns The created effect corrisponding the the postprocess.
  14313. */
  14314. getEffect(): Effect;
  14315. /**
  14316. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  14317. * @param postProcess The post process to share the output with.
  14318. * @returns This post process.
  14319. */
  14320. shareOutputWith(postProcess: PostProcess): PostProcess;
  14321. /**
  14322. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  14323. * This should be called if the post process that shares output with this post process is disabled/disposed.
  14324. */
  14325. useOwnOutput(): void;
  14326. /**
  14327. * Updates the effect with the current post process compile time values and recompiles the shader.
  14328. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14329. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14330. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14331. * @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
  14332. * @param onCompiled Called when the shader has been compiled.
  14333. * @param onError Called if there is an error when compiling a shader.
  14334. */
  14335. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14336. /**
  14337. * The post process is reusable if it can be used multiple times within one frame.
  14338. * @returns If the post process is reusable
  14339. */
  14340. isReusable(): boolean;
  14341. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14342. markTextureDirty(): void;
  14343. /**
  14344. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14345. * 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.
  14346. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14347. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14348. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14349. * @returns The target texture that was bound to be written to.
  14350. */
  14351. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14352. /**
  14353. * If the post process is supported.
  14354. */
  14355. readonly isSupported: boolean;
  14356. /**
  14357. * The aspect ratio of the output texture.
  14358. */
  14359. readonly aspectRatio: number;
  14360. /**
  14361. * Get a value indicating if the post-process is ready to be used
  14362. * @returns true if the post-process is ready (shader is compiled)
  14363. */
  14364. isReady(): boolean;
  14365. /**
  14366. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14367. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14368. */
  14369. apply(): Nullable<Effect>;
  14370. private _disposeTextures;
  14371. /**
  14372. * Disposes the post process.
  14373. * @param camera The camera to dispose the post process on.
  14374. */
  14375. dispose(camera?: Camera): void;
  14376. }
  14377. }
  14378. declare module "babylonjs/PostProcesses/postProcessManager" {
  14379. import { Nullable } from "babylonjs/types";
  14380. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14381. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14382. import { Scene } from "babylonjs/scene";
  14383. /**
  14384. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14385. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14386. */
  14387. export class PostProcessManager {
  14388. private _scene;
  14389. private _indexBuffer;
  14390. private _vertexBuffers;
  14391. /**
  14392. * Creates a new instance PostProcess
  14393. * @param scene The scene that the post process is associated with.
  14394. */
  14395. constructor(scene: Scene);
  14396. private _prepareBuffers;
  14397. private _buildIndexBuffer;
  14398. /**
  14399. * Rebuilds the vertex buffers of the manager.
  14400. * @hidden
  14401. */
  14402. _rebuild(): void;
  14403. /**
  14404. * Prepares a frame to be run through a post process.
  14405. * @param sourceTexture The input texture to the post procesess. (default: null)
  14406. * @param postProcesses An array of post processes to be run. (default: null)
  14407. * @returns True if the post processes were able to be run.
  14408. * @hidden
  14409. */
  14410. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14411. /**
  14412. * Manually render a set of post processes to a texture.
  14413. * @param postProcesses An array of post processes to be run.
  14414. * @param targetTexture The target texture to render to.
  14415. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14416. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14417. * @param lodLevel defines which lod of the texture to render to
  14418. */
  14419. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14420. /**
  14421. * Finalize the result of the output of the postprocesses.
  14422. * @param doNotPresent If true the result will not be displayed to the screen.
  14423. * @param targetTexture The target texture to render to.
  14424. * @param faceIndex The index of the face to bind the target texture to.
  14425. * @param postProcesses The array of post processes to render.
  14426. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14427. * @hidden
  14428. */
  14429. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14430. /**
  14431. * Disposes of the post process manager.
  14432. */
  14433. dispose(): void;
  14434. }
  14435. }
  14436. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14437. import { Scene } from "babylonjs/scene";
  14438. import { ISceneComponent } from "babylonjs/sceneComponent";
  14439. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14440. module "babylonjs/abstractScene" {
  14441. interface AbstractScene {
  14442. /**
  14443. * The list of procedural textures added to the scene
  14444. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14445. */
  14446. proceduralTextures: Array<ProceduralTexture>;
  14447. }
  14448. }
  14449. /**
  14450. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14451. * in a given scene.
  14452. */
  14453. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14454. /**
  14455. * The component name helpfull to identify the component in the list of scene components.
  14456. */
  14457. readonly name: string;
  14458. /**
  14459. * The scene the component belongs to.
  14460. */
  14461. scene: Scene;
  14462. /**
  14463. * Creates a new instance of the component for the given scene
  14464. * @param scene Defines the scene to register the component in
  14465. */
  14466. constructor(scene: Scene);
  14467. /**
  14468. * Registers the component in a given scene
  14469. */
  14470. register(): void;
  14471. /**
  14472. * Rebuilds the elements related to this component in case of
  14473. * context lost for instance.
  14474. */
  14475. rebuild(): void;
  14476. /**
  14477. * Disposes the component and the associated ressources.
  14478. */
  14479. dispose(): void;
  14480. private _beforeClear;
  14481. }
  14482. }
  14483. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  14484. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14485. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14486. module "babylonjs/Engines/engine" {
  14487. interface Engine {
  14488. /**
  14489. * Creates a new render target cube texture
  14490. * @param size defines the size of the texture
  14491. * @param options defines the options used to create the texture
  14492. * @returns a new render target cube texture stored in an InternalTexture
  14493. */
  14494. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14495. }
  14496. }
  14497. }
  14498. declare module "babylonjs/Shaders/procedural.vertex" {
  14499. /** @hidden */
  14500. export var proceduralVertexShader: {
  14501. name: string;
  14502. shader: string;
  14503. };
  14504. }
  14505. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14506. import { Observable } from "babylonjs/Misc/observable";
  14507. import { Nullable } from "babylonjs/types";
  14508. import { Scene } from "babylonjs/scene";
  14509. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14510. import { Effect } from "babylonjs/Materials/effect";
  14511. import { Texture } from "babylonjs/Materials/Textures/texture";
  14512. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14513. import "babylonjs/Shaders/procedural.vertex";
  14514. /**
  14515. * 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.
  14516. * This is the base class of any Procedural texture and contains most of the shareable code.
  14517. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14518. */
  14519. export class ProceduralTexture extends Texture {
  14520. isCube: boolean;
  14521. /**
  14522. * Define if the texture is enabled or not (disabled texture will not render)
  14523. */
  14524. isEnabled: boolean;
  14525. /**
  14526. * Define if the texture must be cleared before rendering (default is true)
  14527. */
  14528. autoClear: boolean;
  14529. /**
  14530. * Callback called when the texture is generated
  14531. */
  14532. onGenerated: () => void;
  14533. /**
  14534. * Event raised when the texture is generated
  14535. */
  14536. onGeneratedObservable: Observable<ProceduralTexture>;
  14537. /** @hidden */
  14538. _generateMipMaps: boolean;
  14539. /** @hidden **/
  14540. _effect: Effect;
  14541. /** @hidden */
  14542. _textures: {
  14543. [key: string]: Texture;
  14544. };
  14545. private _size;
  14546. private _currentRefreshId;
  14547. private _refreshRate;
  14548. private _vertexBuffers;
  14549. private _indexBuffer;
  14550. private _uniforms;
  14551. private _samplers;
  14552. private _fragment;
  14553. private _floats;
  14554. private _ints;
  14555. private _floatsArrays;
  14556. private _colors3;
  14557. private _colors4;
  14558. private _vectors2;
  14559. private _vectors3;
  14560. private _matrices;
  14561. private _fallbackTexture;
  14562. private _fallbackTextureUsed;
  14563. private _engine;
  14564. private _cachedDefines;
  14565. private _contentUpdateId;
  14566. private _contentData;
  14567. /**
  14568. * Instantiates a new procedural texture.
  14569. * 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.
  14570. * This is the base class of any Procedural texture and contains most of the shareable code.
  14571. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14572. * @param name Define the name of the texture
  14573. * @param size Define the size of the texture to create
  14574. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14575. * @param scene Define the scene the texture belongs to
  14576. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14577. * @param generateMipMaps Define if the texture should creates mip maps or not
  14578. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14579. */
  14580. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14581. /**
  14582. * The effect that is created when initializing the post process.
  14583. * @returns The created effect corrisponding the the postprocess.
  14584. */
  14585. getEffect(): Effect;
  14586. /**
  14587. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14588. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14589. */
  14590. getContent(): Nullable<ArrayBufferView>;
  14591. private _createIndexBuffer;
  14592. /** @hidden */
  14593. _rebuild(): void;
  14594. /**
  14595. * Resets the texture in order to recreate its associated resources.
  14596. * This can be called in case of context loss
  14597. */
  14598. reset(): void;
  14599. protected _getDefines(): string;
  14600. /**
  14601. * Is the texture ready to be used ? (rendered at least once)
  14602. * @returns true if ready, otherwise, false.
  14603. */
  14604. isReady(): boolean;
  14605. /**
  14606. * Resets the refresh counter of the texture and start bak from scratch.
  14607. * Could be useful to regenerate the texture if it is setup to render only once.
  14608. */
  14609. resetRefreshCounter(): void;
  14610. /**
  14611. * Set the fragment shader to use in order to render the texture.
  14612. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14613. */
  14614. setFragment(fragment: any): void;
  14615. /**
  14616. * Define the refresh rate of the texture or the rendering frequency.
  14617. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14618. */
  14619. refreshRate: number;
  14620. /** @hidden */
  14621. _shouldRender(): boolean;
  14622. /**
  14623. * Get the size the texture is rendering at.
  14624. * @returns the size (texture is always squared)
  14625. */
  14626. getRenderSize(): number;
  14627. /**
  14628. * Resize the texture to new value.
  14629. * @param size Define the new size the texture should have
  14630. * @param generateMipMaps Define whether the new texture should create mip maps
  14631. */
  14632. resize(size: number, generateMipMaps: boolean): void;
  14633. private _checkUniform;
  14634. /**
  14635. * Set a texture in the shader program used to render.
  14636. * @param name Define the name of the uniform samplers as defined in the shader
  14637. * @param texture Define the texture to bind to this sampler
  14638. * @return the texture itself allowing "fluent" like uniform updates
  14639. */
  14640. setTexture(name: string, texture: Texture): ProceduralTexture;
  14641. /**
  14642. * Set a float in the shader.
  14643. * @param name Define the name of the uniform as defined in the shader
  14644. * @param value Define the value to give to the uniform
  14645. * @return the texture itself allowing "fluent" like uniform updates
  14646. */
  14647. setFloat(name: string, value: number): ProceduralTexture;
  14648. /**
  14649. * Set a int in the shader.
  14650. * @param name Define the name of the uniform as defined in the shader
  14651. * @param value Define the value to give to the uniform
  14652. * @return the texture itself allowing "fluent" like uniform updates
  14653. */
  14654. setInt(name: string, value: number): ProceduralTexture;
  14655. /**
  14656. * Set an array of floats in the shader.
  14657. * @param name Define the name of the uniform as defined in the shader
  14658. * @param value Define the value to give to the uniform
  14659. * @return the texture itself allowing "fluent" like uniform updates
  14660. */
  14661. setFloats(name: string, value: number[]): ProceduralTexture;
  14662. /**
  14663. * Set a vec3 in the shader from a Color3.
  14664. * @param name Define the name of the uniform as defined in the shader
  14665. * @param value Define the value to give to the uniform
  14666. * @return the texture itself allowing "fluent" like uniform updates
  14667. */
  14668. setColor3(name: string, value: Color3): ProceduralTexture;
  14669. /**
  14670. * Set a vec4 in the shader from a Color4.
  14671. * @param name Define the name of the uniform as defined in the shader
  14672. * @param value Define the value to give to the uniform
  14673. * @return the texture itself allowing "fluent" like uniform updates
  14674. */
  14675. setColor4(name: string, value: Color4): ProceduralTexture;
  14676. /**
  14677. * Set a vec2 in the shader from a Vector2.
  14678. * @param name Define the name of the uniform as defined in the shader
  14679. * @param value Define the value to give to the uniform
  14680. * @return the texture itself allowing "fluent" like uniform updates
  14681. */
  14682. setVector2(name: string, value: Vector2): ProceduralTexture;
  14683. /**
  14684. * Set a vec3 in the shader from a Vector3.
  14685. * @param name Define the name of the uniform as defined in the shader
  14686. * @param value Define the value to give to the uniform
  14687. * @return the texture itself allowing "fluent" like uniform updates
  14688. */
  14689. setVector3(name: string, value: Vector3): ProceduralTexture;
  14690. /**
  14691. * Set a mat4 in the shader from a MAtrix.
  14692. * @param name Define the name of the uniform as defined in the shader
  14693. * @param value Define the value to give to the uniform
  14694. * @return the texture itself allowing "fluent" like uniform updates
  14695. */
  14696. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14697. /**
  14698. * Render the texture to its associated render target.
  14699. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14700. */
  14701. render(useCameraPostProcess?: boolean): void;
  14702. /**
  14703. * Clone the texture.
  14704. * @returns the cloned texture
  14705. */
  14706. clone(): ProceduralTexture;
  14707. /**
  14708. * Dispose the texture and release its asoociated resources.
  14709. */
  14710. dispose(): void;
  14711. }
  14712. }
  14713. declare module "babylonjs/Particles/baseParticleSystem" {
  14714. import { Nullable } from "babylonjs/types";
  14715. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14717. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14718. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14719. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14720. import { Scene } from "babylonjs/scene";
  14721. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14722. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14723. import { Texture } from "babylonjs/Materials/Textures/texture";
  14724. import { Animation } from "babylonjs/Animations/animation";
  14725. /**
  14726. * This represents the base class for particle system in Babylon.
  14727. * 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.
  14728. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14729. * @example https://doc.babylonjs.com/babylon101/particles
  14730. */
  14731. export class BaseParticleSystem {
  14732. /**
  14733. * Source color is added to the destination color without alpha affecting the result
  14734. */
  14735. static BLENDMODE_ONEONE: number;
  14736. /**
  14737. * Blend current color and particle color using particle’s alpha
  14738. */
  14739. static BLENDMODE_STANDARD: number;
  14740. /**
  14741. * Add current color and particle color multiplied by particle’s alpha
  14742. */
  14743. static BLENDMODE_ADD: number;
  14744. /**
  14745. * Multiply current color with particle color
  14746. */
  14747. static BLENDMODE_MULTIPLY: number;
  14748. /**
  14749. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14750. */
  14751. static BLENDMODE_MULTIPLYADD: number;
  14752. /**
  14753. * List of animations used by the particle system.
  14754. */
  14755. animations: Animation[];
  14756. /**
  14757. * The id of the Particle system.
  14758. */
  14759. id: string;
  14760. /**
  14761. * The friendly name of the Particle system.
  14762. */
  14763. name: string;
  14764. /**
  14765. * The rendering group used by the Particle system to chose when to render.
  14766. */
  14767. renderingGroupId: number;
  14768. /**
  14769. * The emitter represents the Mesh or position we are attaching the particle system to.
  14770. */
  14771. emitter: Nullable<AbstractMesh | Vector3>;
  14772. /**
  14773. * The maximum number of particles to emit per frame
  14774. */
  14775. emitRate: number;
  14776. /**
  14777. * If you want to launch only a few particles at once, that can be done, as well.
  14778. */
  14779. manualEmitCount: number;
  14780. /**
  14781. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14782. */
  14783. updateSpeed: number;
  14784. /**
  14785. * The amount of time the particle system is running (depends of the overall update speed).
  14786. */
  14787. targetStopDuration: number;
  14788. /**
  14789. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14790. */
  14791. disposeOnStop: boolean;
  14792. /**
  14793. * Minimum power of emitting particles.
  14794. */
  14795. minEmitPower: number;
  14796. /**
  14797. * Maximum power of emitting particles.
  14798. */
  14799. maxEmitPower: number;
  14800. /**
  14801. * Minimum life time of emitting particles.
  14802. */
  14803. minLifeTime: number;
  14804. /**
  14805. * Maximum life time of emitting particles.
  14806. */
  14807. maxLifeTime: number;
  14808. /**
  14809. * Minimum Size of emitting particles.
  14810. */
  14811. minSize: number;
  14812. /**
  14813. * Maximum Size of emitting particles.
  14814. */
  14815. maxSize: number;
  14816. /**
  14817. * Minimum scale of emitting particles on X axis.
  14818. */
  14819. minScaleX: number;
  14820. /**
  14821. * Maximum scale of emitting particles on X axis.
  14822. */
  14823. maxScaleX: number;
  14824. /**
  14825. * Minimum scale of emitting particles on Y axis.
  14826. */
  14827. minScaleY: number;
  14828. /**
  14829. * Maximum scale of emitting particles on Y axis.
  14830. */
  14831. maxScaleY: number;
  14832. /**
  14833. * Gets or sets the minimal initial rotation in radians.
  14834. */
  14835. minInitialRotation: number;
  14836. /**
  14837. * Gets or sets the maximal initial rotation in radians.
  14838. */
  14839. maxInitialRotation: number;
  14840. /**
  14841. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14842. */
  14843. minAngularSpeed: number;
  14844. /**
  14845. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14846. */
  14847. maxAngularSpeed: number;
  14848. /**
  14849. * The texture used to render each particle. (this can be a spritesheet)
  14850. */
  14851. particleTexture: Nullable<Texture>;
  14852. /**
  14853. * The layer mask we are rendering the particles through.
  14854. */
  14855. layerMask: number;
  14856. /**
  14857. * This can help using your own shader to render the particle system.
  14858. * The according effect will be created
  14859. */
  14860. customShader: any;
  14861. /**
  14862. * By default particle system starts as soon as they are created. This prevents the
  14863. * automatic start to happen and let you decide when to start emitting particles.
  14864. */
  14865. preventAutoStart: boolean;
  14866. private _noiseTexture;
  14867. /**
  14868. * Gets or sets a texture used to add random noise to particle positions
  14869. */
  14870. noiseTexture: Nullable<ProceduralTexture>;
  14871. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14872. noiseStrength: Vector3;
  14873. /**
  14874. * Callback triggered when the particle animation is ending.
  14875. */
  14876. onAnimationEnd: Nullable<() => void>;
  14877. /**
  14878. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14879. */
  14880. blendMode: number;
  14881. /**
  14882. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14883. * to override the particles.
  14884. */
  14885. forceDepthWrite: boolean;
  14886. /** 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 */
  14887. preWarmCycles: number;
  14888. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14889. preWarmStepOffset: number;
  14890. /**
  14891. * 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)
  14892. */
  14893. spriteCellChangeSpeed: number;
  14894. /**
  14895. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14896. */
  14897. startSpriteCellID: number;
  14898. /**
  14899. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14900. */
  14901. endSpriteCellID: number;
  14902. /**
  14903. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14904. */
  14905. spriteCellWidth: number;
  14906. /**
  14907. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14908. */
  14909. spriteCellHeight: number;
  14910. /**
  14911. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14912. */
  14913. spriteRandomStartCell: boolean;
  14914. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14915. translationPivot: Vector2;
  14916. /** @hidden */
  14917. protected _isAnimationSheetEnabled: boolean;
  14918. /**
  14919. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14920. */
  14921. beginAnimationOnStart: boolean;
  14922. /**
  14923. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14924. */
  14925. beginAnimationFrom: number;
  14926. /**
  14927. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14928. */
  14929. beginAnimationTo: number;
  14930. /**
  14931. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14932. */
  14933. beginAnimationLoop: boolean;
  14934. /**
  14935. * Gets or sets a world offset applied to all particles
  14936. */
  14937. worldOffset: Vector3;
  14938. /**
  14939. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14940. */
  14941. isAnimationSheetEnabled: boolean;
  14942. /**
  14943. * Get hosting scene
  14944. * @returns the scene
  14945. */
  14946. getScene(): Scene;
  14947. /**
  14948. * You can use gravity if you want to give an orientation to your particles.
  14949. */
  14950. gravity: Vector3;
  14951. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14952. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14953. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14954. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14955. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14956. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14957. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14958. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14959. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14960. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14961. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14962. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14963. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14964. /**
  14965. * Defines the delay in milliseconds before starting the system (0 by default)
  14966. */
  14967. startDelay: number;
  14968. /**
  14969. * Gets the current list of drag gradients.
  14970. * You must use addDragGradient and removeDragGradient to udpate this list
  14971. * @returns the list of drag gradients
  14972. */
  14973. getDragGradients(): Nullable<Array<FactorGradient>>;
  14974. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14975. limitVelocityDamping: number;
  14976. /**
  14977. * Gets the current list of limit velocity gradients.
  14978. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14979. * @returns the list of limit velocity gradients
  14980. */
  14981. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14982. /**
  14983. * Gets the current list of color gradients.
  14984. * You must use addColorGradient and removeColorGradient to udpate this list
  14985. * @returns the list of color gradients
  14986. */
  14987. getColorGradients(): Nullable<Array<ColorGradient>>;
  14988. /**
  14989. * Gets the current list of size gradients.
  14990. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14991. * @returns the list of size gradients
  14992. */
  14993. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14994. /**
  14995. * Gets the current list of color remap gradients.
  14996. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14997. * @returns the list of color remap gradients
  14998. */
  14999. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15000. /**
  15001. * Gets the current list of alpha remap gradients.
  15002. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15003. * @returns the list of alpha remap gradients
  15004. */
  15005. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15006. /**
  15007. * Gets the current list of life time gradients.
  15008. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15009. * @returns the list of life time gradients
  15010. */
  15011. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15012. /**
  15013. * Gets the current list of angular speed gradients.
  15014. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15015. * @returns the list of angular speed gradients
  15016. */
  15017. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15018. /**
  15019. * Gets the current list of velocity gradients.
  15020. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15021. * @returns the list of velocity gradients
  15022. */
  15023. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15024. /**
  15025. * Gets the current list of start size gradients.
  15026. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15027. * @returns the list of start size gradients
  15028. */
  15029. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15030. /**
  15031. * Gets the current list of emit rate gradients.
  15032. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15033. * @returns the list of emit rate gradients
  15034. */
  15035. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15036. /**
  15037. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15038. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15039. */
  15040. direction1: Vector3;
  15041. /**
  15042. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15043. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15044. */
  15045. direction2: Vector3;
  15046. /**
  15047. * 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.
  15048. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15049. */
  15050. minEmitBox: Vector3;
  15051. /**
  15052. * 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.
  15053. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15054. */
  15055. maxEmitBox: Vector3;
  15056. /**
  15057. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15058. */
  15059. color1: Color4;
  15060. /**
  15061. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15062. */
  15063. color2: Color4;
  15064. /**
  15065. * Color the particle will have at the end of its lifetime
  15066. */
  15067. colorDead: Color4;
  15068. /**
  15069. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15070. */
  15071. textureMask: Color4;
  15072. /**
  15073. * The particle emitter type defines the emitter used by the particle system.
  15074. * It can be for example box, sphere, or cone...
  15075. */
  15076. particleEmitterType: IParticleEmitterType;
  15077. /** @hidden */
  15078. _isSubEmitter: boolean;
  15079. /**
  15080. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15081. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15082. */
  15083. billboardMode: number;
  15084. protected _isBillboardBased: boolean;
  15085. /**
  15086. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15087. */
  15088. isBillboardBased: boolean;
  15089. /**
  15090. * The scene the particle system belongs to.
  15091. */
  15092. protected _scene: Scene;
  15093. /**
  15094. * Local cache of defines for image processing.
  15095. */
  15096. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15097. /**
  15098. * Default configuration related to image processing available in the standard Material.
  15099. */
  15100. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15101. /**
  15102. * Gets the image processing configuration used either in this material.
  15103. */
  15104. /**
  15105. * Sets the Default image processing configuration used either in the this material.
  15106. *
  15107. * If sets to null, the scene one is in use.
  15108. */
  15109. imageProcessingConfiguration: ImageProcessingConfiguration;
  15110. /**
  15111. * Attaches a new image processing configuration to the Standard Material.
  15112. * @param configuration
  15113. */
  15114. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15115. /** @hidden */
  15116. protected _reset(): void;
  15117. /** @hidden */
  15118. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15119. /**
  15120. * Instantiates a particle system.
  15121. * 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.
  15122. * @param name The name of the particle system
  15123. */
  15124. constructor(name: string);
  15125. /**
  15126. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15127. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15128. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15129. * @returns the emitter
  15130. */
  15131. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15132. /**
  15133. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15134. * @param radius The radius of the hemisphere to emit from
  15135. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15136. * @returns the emitter
  15137. */
  15138. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15139. /**
  15140. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15141. * @param radius The radius of the sphere to emit from
  15142. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15143. * @returns the emitter
  15144. */
  15145. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15146. /**
  15147. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15148. * @param radius The radius of the sphere to emit from
  15149. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15150. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15151. * @returns the emitter
  15152. */
  15153. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15154. /**
  15155. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15156. * @param radius The radius of the emission cylinder
  15157. * @param height The height of the emission cylinder
  15158. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15159. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15160. * @returns the emitter
  15161. */
  15162. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15163. /**
  15164. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15165. * @param radius The radius of the cylinder to emit from
  15166. * @param height The height of the emission cylinder
  15167. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15168. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15169. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15170. * @returns the emitter
  15171. */
  15172. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15173. /**
  15174. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15175. * @param radius The radius of the cone to emit from
  15176. * @param angle The base angle of the cone
  15177. * @returns the emitter
  15178. */
  15179. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15180. /**
  15181. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15182. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15183. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15184. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15185. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15186. * @returns the emitter
  15187. */
  15188. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15189. }
  15190. }
  15191. declare module "babylonjs/Particles/subEmitter" {
  15192. import { Scene } from "babylonjs/scene";
  15193. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15194. /**
  15195. * Type of sub emitter
  15196. */
  15197. export enum SubEmitterType {
  15198. /**
  15199. * Attached to the particle over it's lifetime
  15200. */
  15201. ATTACHED = 0,
  15202. /**
  15203. * Created when the particle dies
  15204. */
  15205. END = 1
  15206. }
  15207. /**
  15208. * Sub emitter class used to emit particles from an existing particle
  15209. */
  15210. export class SubEmitter {
  15211. /**
  15212. * the particle system to be used by the sub emitter
  15213. */
  15214. particleSystem: ParticleSystem;
  15215. /**
  15216. * Type of the submitter (Default: END)
  15217. */
  15218. type: SubEmitterType;
  15219. /**
  15220. * 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)
  15221. * Note: This only is supported when using an emitter of type Mesh
  15222. */
  15223. inheritDirection: boolean;
  15224. /**
  15225. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15226. */
  15227. inheritedVelocityAmount: number;
  15228. /**
  15229. * Creates a sub emitter
  15230. * @param particleSystem the particle system to be used by the sub emitter
  15231. */
  15232. constructor(
  15233. /**
  15234. * the particle system to be used by the sub emitter
  15235. */
  15236. particleSystem: ParticleSystem);
  15237. /**
  15238. * Clones the sub emitter
  15239. * @returns the cloned sub emitter
  15240. */
  15241. clone(): SubEmitter;
  15242. /**
  15243. * Serialize current object to a JSON object
  15244. * @returns the serialized object
  15245. */
  15246. serialize(): any;
  15247. /** @hidden */
  15248. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15249. /**
  15250. * Creates a new SubEmitter from a serialized JSON version
  15251. * @param serializationObject defines the JSON object to read from
  15252. * @param scene defines the hosting scene
  15253. * @param rootUrl defines the rootUrl for data loading
  15254. * @returns a new SubEmitter
  15255. */
  15256. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15257. /** Release associated resources */
  15258. dispose(): void;
  15259. }
  15260. }
  15261. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15262. /** @hidden */
  15263. export var clipPlaneFragmentDeclaration: {
  15264. name: string;
  15265. shader: string;
  15266. };
  15267. }
  15268. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15269. /** @hidden */
  15270. export var imageProcessingDeclaration: {
  15271. name: string;
  15272. shader: string;
  15273. };
  15274. }
  15275. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15276. /** @hidden */
  15277. export var imageProcessingFunctions: {
  15278. name: string;
  15279. shader: string;
  15280. };
  15281. }
  15282. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15283. /** @hidden */
  15284. export var clipPlaneFragment: {
  15285. name: string;
  15286. shader: string;
  15287. };
  15288. }
  15289. declare module "babylonjs/Shaders/particles.fragment" {
  15290. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15291. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15292. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15293. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15294. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15295. /** @hidden */
  15296. export var particlesPixelShader: {
  15297. name: string;
  15298. shader: string;
  15299. };
  15300. }
  15301. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15302. /** @hidden */
  15303. export var clipPlaneVertexDeclaration: {
  15304. name: string;
  15305. shader: string;
  15306. };
  15307. }
  15308. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15309. /** @hidden */
  15310. export var clipPlaneVertex: {
  15311. name: string;
  15312. shader: string;
  15313. };
  15314. }
  15315. declare module "babylonjs/Shaders/particles.vertex" {
  15316. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15317. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15318. /** @hidden */
  15319. export var particlesVertexShader: {
  15320. name: string;
  15321. shader: string;
  15322. };
  15323. }
  15324. declare module "babylonjs/Particles/particleSystem" {
  15325. import { Nullable } from "babylonjs/types";
  15326. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15327. import { Observable } from "babylonjs/Misc/observable";
  15328. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15329. import { Effect } from "babylonjs/Materials/effect";
  15330. import { Scene, IDisposable } from "babylonjs/scene";
  15331. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15332. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15333. import { Particle } from "babylonjs/Particles/particle";
  15334. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15335. import "babylonjs/Shaders/particles.fragment";
  15336. import "babylonjs/Shaders/particles.vertex";
  15337. /**
  15338. * This represents a particle system in Babylon.
  15339. * 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.
  15340. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15341. * @example https://doc.babylonjs.com/babylon101/particles
  15342. */
  15343. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15344. /**
  15345. * Billboard mode will only apply to Y axis
  15346. */
  15347. static readonly BILLBOARDMODE_Y: number;
  15348. /**
  15349. * Billboard mode will apply to all axes
  15350. */
  15351. static readonly BILLBOARDMODE_ALL: number;
  15352. /**
  15353. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15354. */
  15355. static readonly BILLBOARDMODE_STRETCHED: number;
  15356. /**
  15357. * This function can be defined to provide custom update for active particles.
  15358. * This function will be called instead of regular update (age, position, color, etc.).
  15359. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15360. */
  15361. updateFunction: (particles: Particle[]) => void;
  15362. private _emitterWorldMatrix;
  15363. /**
  15364. * This function can be defined to specify initial direction for every new particle.
  15365. * It by default use the emitterType defined function
  15366. */
  15367. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15368. /**
  15369. * This function can be defined to specify initial position for every new particle.
  15370. * It by default use the emitterType defined function
  15371. */
  15372. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15373. /**
  15374. * @hidden
  15375. */
  15376. _inheritedVelocityOffset: Vector3;
  15377. /**
  15378. * An event triggered when the system is disposed
  15379. */
  15380. onDisposeObservable: Observable<ParticleSystem>;
  15381. private _onDisposeObserver;
  15382. /**
  15383. * Sets a callback that will be triggered when the system is disposed
  15384. */
  15385. onDispose: () => void;
  15386. private _particles;
  15387. private _epsilon;
  15388. private _capacity;
  15389. private _stockParticles;
  15390. private _newPartsExcess;
  15391. private _vertexData;
  15392. private _vertexBuffer;
  15393. private _vertexBuffers;
  15394. private _spriteBuffer;
  15395. private _indexBuffer;
  15396. private _effect;
  15397. private _customEffect;
  15398. private _cachedDefines;
  15399. private _scaledColorStep;
  15400. private _colorDiff;
  15401. private _scaledDirection;
  15402. private _scaledGravity;
  15403. private _currentRenderId;
  15404. private _alive;
  15405. private _useInstancing;
  15406. private _started;
  15407. private _stopped;
  15408. private _actualFrame;
  15409. private _scaledUpdateSpeed;
  15410. private _vertexBufferSize;
  15411. /** @hidden */
  15412. _currentEmitRateGradient: Nullable<FactorGradient>;
  15413. /** @hidden */
  15414. _currentEmitRate1: number;
  15415. /** @hidden */
  15416. _currentEmitRate2: number;
  15417. /** @hidden */
  15418. _currentStartSizeGradient: Nullable<FactorGradient>;
  15419. /** @hidden */
  15420. _currentStartSize1: number;
  15421. /** @hidden */
  15422. _currentStartSize2: number;
  15423. private readonly _rawTextureWidth;
  15424. private _rampGradientsTexture;
  15425. private _useRampGradients;
  15426. /** Gets or sets a boolean indicating that ramp gradients must be used
  15427. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15428. */
  15429. useRampGradients: boolean;
  15430. /**
  15431. * 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.
  15432. * 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: [])
  15433. */
  15434. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15435. private _subEmitters;
  15436. /**
  15437. * @hidden
  15438. * If the particle systems emitter should be disposed when the particle system is disposed
  15439. */
  15440. _disposeEmitterOnDispose: boolean;
  15441. /**
  15442. * The current active Sub-systems, this property is used by the root particle system only.
  15443. */
  15444. activeSubSystems: Array<ParticleSystem>;
  15445. private _rootParticleSystem;
  15446. /**
  15447. * Gets the current list of active particles
  15448. */
  15449. readonly particles: Particle[];
  15450. /**
  15451. * Returns the string "ParticleSystem"
  15452. * @returns a string containing the class name
  15453. */
  15454. getClassName(): string;
  15455. /**
  15456. * Instantiates a particle system.
  15457. * 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.
  15458. * @param name The name of the particle system
  15459. * @param capacity The max number of particles alive at the same time
  15460. * @param scene The scene the particle system belongs to
  15461. * @param customEffect a custom effect used to change the way particles are rendered by default
  15462. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15463. * @param epsilon Offset used to render the particles
  15464. */
  15465. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15466. private _addFactorGradient;
  15467. private _removeFactorGradient;
  15468. /**
  15469. * Adds a new life time gradient
  15470. * @param gradient defines the gradient to use (between 0 and 1)
  15471. * @param factor defines the life time factor to affect to the specified gradient
  15472. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15473. * @returns the current particle system
  15474. */
  15475. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15476. /**
  15477. * Remove a specific life time gradient
  15478. * @param gradient defines the gradient to remove
  15479. * @returns the current particle system
  15480. */
  15481. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15482. /**
  15483. * Adds a new size gradient
  15484. * @param gradient defines the gradient to use (between 0 and 1)
  15485. * @param factor defines the size factor to affect to the specified gradient
  15486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15487. * @returns the current particle system
  15488. */
  15489. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15490. /**
  15491. * Remove a specific size gradient
  15492. * @param gradient defines the gradient to remove
  15493. * @returns the current particle system
  15494. */
  15495. removeSizeGradient(gradient: number): IParticleSystem;
  15496. /**
  15497. * Adds a new color remap gradient
  15498. * @param gradient defines the gradient to use (between 0 and 1)
  15499. * @param min defines the color remap minimal range
  15500. * @param max defines the color remap maximal range
  15501. * @returns the current particle system
  15502. */
  15503. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15504. /**
  15505. * Remove a specific color remap gradient
  15506. * @param gradient defines the gradient to remove
  15507. * @returns the current particle system
  15508. */
  15509. removeColorRemapGradient(gradient: number): IParticleSystem;
  15510. /**
  15511. * Adds a new alpha remap gradient
  15512. * @param gradient defines the gradient to use (between 0 and 1)
  15513. * @param min defines the alpha remap minimal range
  15514. * @param max defines the alpha remap maximal range
  15515. * @returns the current particle system
  15516. */
  15517. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15518. /**
  15519. * Remove a specific alpha remap gradient
  15520. * @param gradient defines the gradient to remove
  15521. * @returns the current particle system
  15522. */
  15523. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15524. /**
  15525. * Adds a new angular speed gradient
  15526. * @param gradient defines the gradient to use (between 0 and 1)
  15527. * @param factor defines the angular speed to affect to the specified gradient
  15528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15529. * @returns the current particle system
  15530. */
  15531. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15532. /**
  15533. * Remove a specific angular speed gradient
  15534. * @param gradient defines the gradient to remove
  15535. * @returns the current particle system
  15536. */
  15537. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15538. /**
  15539. * Adds a new velocity gradient
  15540. * @param gradient defines the gradient to use (between 0 and 1)
  15541. * @param factor defines the velocity to affect to the specified gradient
  15542. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15543. * @returns the current particle system
  15544. */
  15545. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15546. /**
  15547. * Remove a specific velocity gradient
  15548. * @param gradient defines the gradient to remove
  15549. * @returns the current particle system
  15550. */
  15551. removeVelocityGradient(gradient: number): IParticleSystem;
  15552. /**
  15553. * Adds a new limit velocity gradient
  15554. * @param gradient defines the gradient to use (between 0 and 1)
  15555. * @param factor defines the limit velocity value to affect to the specified gradient
  15556. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15557. * @returns the current particle system
  15558. */
  15559. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15560. /**
  15561. * Remove a specific limit velocity gradient
  15562. * @param gradient defines the gradient to remove
  15563. * @returns the current particle system
  15564. */
  15565. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15566. /**
  15567. * Adds a new drag gradient
  15568. * @param gradient defines the gradient to use (between 0 and 1)
  15569. * @param factor defines the drag value to affect to the specified gradient
  15570. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15571. * @returns the current particle system
  15572. */
  15573. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15574. /**
  15575. * Remove a specific drag gradient
  15576. * @param gradient defines the gradient to remove
  15577. * @returns the current particle system
  15578. */
  15579. removeDragGradient(gradient: number): IParticleSystem;
  15580. /**
  15581. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15582. * @param gradient defines the gradient to use (between 0 and 1)
  15583. * @param factor defines the emit rate value to affect to the specified gradient
  15584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15585. * @returns the current particle system
  15586. */
  15587. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15588. /**
  15589. * Remove a specific emit rate gradient
  15590. * @param gradient defines the gradient to remove
  15591. * @returns the current particle system
  15592. */
  15593. removeEmitRateGradient(gradient: number): IParticleSystem;
  15594. /**
  15595. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15596. * @param gradient defines the gradient to use (between 0 and 1)
  15597. * @param factor defines the start size value to affect to the specified gradient
  15598. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15599. * @returns the current particle system
  15600. */
  15601. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15602. /**
  15603. * Remove a specific start size gradient
  15604. * @param gradient defines the gradient to remove
  15605. * @returns the current particle system
  15606. */
  15607. removeStartSizeGradient(gradient: number): IParticleSystem;
  15608. private _createRampGradientTexture;
  15609. /**
  15610. * Gets the current list of ramp gradients.
  15611. * You must use addRampGradient and removeRampGradient to udpate this list
  15612. * @returns the list of ramp gradients
  15613. */
  15614. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15615. /**
  15616. * Adds a new ramp gradient used to remap particle colors
  15617. * @param gradient defines the gradient to use (between 0 and 1)
  15618. * @param color defines the color to affect to the specified gradient
  15619. * @returns the current particle system
  15620. */
  15621. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15622. /**
  15623. * Remove a specific ramp gradient
  15624. * @param gradient defines the gradient to remove
  15625. * @returns the current particle system
  15626. */
  15627. removeRampGradient(gradient: number): ParticleSystem;
  15628. /**
  15629. * Adds a new color gradient
  15630. * @param gradient defines the gradient to use (between 0 and 1)
  15631. * @param color1 defines the color to affect to the specified gradient
  15632. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15633. * @returns this particle system
  15634. */
  15635. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15636. /**
  15637. * Remove a specific color gradient
  15638. * @param gradient defines the gradient to remove
  15639. * @returns this particle system
  15640. */
  15641. removeColorGradient(gradient: number): IParticleSystem;
  15642. private _fetchR;
  15643. protected _reset(): void;
  15644. private _resetEffect;
  15645. private _createVertexBuffers;
  15646. private _createIndexBuffer;
  15647. /**
  15648. * Gets the maximum number of particles active at the same time.
  15649. * @returns The max number of active particles.
  15650. */
  15651. getCapacity(): number;
  15652. /**
  15653. * Gets whether there are still active particles in the system.
  15654. * @returns True if it is alive, otherwise false.
  15655. */
  15656. isAlive(): boolean;
  15657. /**
  15658. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15659. * @returns True if it has been started, otherwise false.
  15660. */
  15661. isStarted(): boolean;
  15662. private _prepareSubEmitterInternalArray;
  15663. /**
  15664. * Starts the particle system and begins to emit
  15665. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15666. */
  15667. start(delay?: number): void;
  15668. /**
  15669. * Stops the particle system.
  15670. * @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.
  15671. */
  15672. stop(stopSubEmitters?: boolean): void;
  15673. /**
  15674. * Remove all active particles
  15675. */
  15676. reset(): void;
  15677. /**
  15678. * @hidden (for internal use only)
  15679. */
  15680. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15681. /**
  15682. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15683. * Its lifetime will start back at 0.
  15684. */
  15685. recycleParticle: (particle: Particle) => void;
  15686. private _stopSubEmitters;
  15687. private _createParticle;
  15688. private _removeFromRoot;
  15689. private _emitFromParticle;
  15690. private _update;
  15691. /** @hidden */
  15692. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15693. /** @hidden */
  15694. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15695. /** @hidden */
  15696. private _getEffect;
  15697. /**
  15698. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15699. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15700. */
  15701. animate(preWarmOnly?: boolean): void;
  15702. private _appendParticleVertices;
  15703. /**
  15704. * Rebuilds the particle system.
  15705. */
  15706. rebuild(): void;
  15707. /**
  15708. * Is this system ready to be used/rendered
  15709. * @return true if the system is ready
  15710. */
  15711. isReady(): boolean;
  15712. private _render;
  15713. /**
  15714. * Renders the particle system in its current state.
  15715. * @returns the current number of particles
  15716. */
  15717. render(): number;
  15718. /**
  15719. * Disposes the particle system and free the associated resources
  15720. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15721. */
  15722. dispose(disposeTexture?: boolean): void;
  15723. /**
  15724. * Clones the particle system.
  15725. * @param name The name of the cloned object
  15726. * @param newEmitter The new emitter to use
  15727. * @returns the cloned particle system
  15728. */
  15729. clone(name: string, newEmitter: any): ParticleSystem;
  15730. /**
  15731. * Serializes the particle system to a JSON object.
  15732. * @returns the JSON object
  15733. */
  15734. serialize(): any;
  15735. /** @hidden */
  15736. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15737. /** @hidden */
  15738. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15739. /**
  15740. * Parses a JSON object to create a particle system.
  15741. * @param parsedParticleSystem The JSON object to parse
  15742. * @param scene The scene to create the particle system in
  15743. * @param rootUrl The root url to use to load external dependencies like texture
  15744. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15745. * @returns the Parsed particle system
  15746. */
  15747. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15748. }
  15749. }
  15750. declare module "babylonjs/Particles/particle" {
  15751. import { Nullable } from "babylonjs/types";
  15752. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15753. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15754. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15755. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15756. /**
  15757. * A particle represents one of the element emitted by a particle system.
  15758. * This is mainly define by its coordinates, direction, velocity and age.
  15759. */
  15760. export class Particle {
  15761. /**
  15762. * The particle system the particle belongs to.
  15763. */
  15764. particleSystem: ParticleSystem;
  15765. private static _Count;
  15766. /**
  15767. * Unique ID of the particle
  15768. */
  15769. id: number;
  15770. /**
  15771. * The world position of the particle in the scene.
  15772. */
  15773. position: Vector3;
  15774. /**
  15775. * The world direction of the particle in the scene.
  15776. */
  15777. direction: Vector3;
  15778. /**
  15779. * The color of the particle.
  15780. */
  15781. color: Color4;
  15782. /**
  15783. * The color change of the particle per step.
  15784. */
  15785. colorStep: Color4;
  15786. /**
  15787. * Defines how long will the life of the particle be.
  15788. */
  15789. lifeTime: number;
  15790. /**
  15791. * The current age of the particle.
  15792. */
  15793. age: number;
  15794. /**
  15795. * The current size of the particle.
  15796. */
  15797. size: number;
  15798. /**
  15799. * The current scale of the particle.
  15800. */
  15801. scale: Vector2;
  15802. /**
  15803. * The current angle of the particle.
  15804. */
  15805. angle: number;
  15806. /**
  15807. * Defines how fast is the angle changing.
  15808. */
  15809. angularSpeed: number;
  15810. /**
  15811. * Defines the cell index used by the particle to be rendered from a sprite.
  15812. */
  15813. cellIndex: number;
  15814. /**
  15815. * The information required to support color remapping
  15816. */
  15817. remapData: Vector4;
  15818. /** @hidden */
  15819. _randomCellOffset?: number;
  15820. /** @hidden */
  15821. _initialDirection: Nullable<Vector3>;
  15822. /** @hidden */
  15823. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15824. /** @hidden */
  15825. _initialStartSpriteCellID: number;
  15826. /** @hidden */
  15827. _initialEndSpriteCellID: number;
  15828. /** @hidden */
  15829. _currentColorGradient: Nullable<ColorGradient>;
  15830. /** @hidden */
  15831. _currentColor1: Color4;
  15832. /** @hidden */
  15833. _currentColor2: Color4;
  15834. /** @hidden */
  15835. _currentSizeGradient: Nullable<FactorGradient>;
  15836. /** @hidden */
  15837. _currentSize1: number;
  15838. /** @hidden */
  15839. _currentSize2: number;
  15840. /** @hidden */
  15841. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15842. /** @hidden */
  15843. _currentAngularSpeed1: number;
  15844. /** @hidden */
  15845. _currentAngularSpeed2: number;
  15846. /** @hidden */
  15847. _currentVelocityGradient: Nullable<FactorGradient>;
  15848. /** @hidden */
  15849. _currentVelocity1: number;
  15850. /** @hidden */
  15851. _currentVelocity2: number;
  15852. /** @hidden */
  15853. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15854. /** @hidden */
  15855. _currentLimitVelocity1: number;
  15856. /** @hidden */
  15857. _currentLimitVelocity2: number;
  15858. /** @hidden */
  15859. _currentDragGradient: Nullable<FactorGradient>;
  15860. /** @hidden */
  15861. _currentDrag1: number;
  15862. /** @hidden */
  15863. _currentDrag2: number;
  15864. /** @hidden */
  15865. _randomNoiseCoordinates1: Vector3;
  15866. /** @hidden */
  15867. _randomNoiseCoordinates2: Vector3;
  15868. /**
  15869. * Creates a new instance Particle
  15870. * @param particleSystem the particle system the particle belongs to
  15871. */
  15872. constructor(
  15873. /**
  15874. * The particle system the particle belongs to.
  15875. */
  15876. particleSystem: ParticleSystem);
  15877. private updateCellInfoFromSystem;
  15878. /**
  15879. * Defines how the sprite cell index is updated for the particle
  15880. */
  15881. updateCellIndex(): void;
  15882. /** @hidden */
  15883. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15884. /** @hidden */
  15885. _inheritParticleInfoToSubEmitters(): void;
  15886. /** @hidden */
  15887. _reset(): void;
  15888. /**
  15889. * Copy the properties of particle to another one.
  15890. * @param other the particle to copy the information to.
  15891. */
  15892. copyTo(other: Particle): void;
  15893. }
  15894. }
  15895. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15896. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15897. import { Effect } from "babylonjs/Materials/effect";
  15898. import { Particle } from "babylonjs/Particles/particle";
  15899. /**
  15900. * Particle emitter represents a volume emitting particles.
  15901. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15902. */
  15903. export interface IParticleEmitterType {
  15904. /**
  15905. * Called by the particle System when the direction is computed for the created particle.
  15906. * @param worldMatrix is the world matrix of the particle system
  15907. * @param directionToUpdate is the direction vector to update with the result
  15908. * @param particle is the particle we are computed the direction for
  15909. */
  15910. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15911. /**
  15912. * Called by the particle System when the position is computed for the created particle.
  15913. * @param worldMatrix is the world matrix of the particle system
  15914. * @param positionToUpdate is the position vector to update with the result
  15915. * @param particle is the particle we are computed the position for
  15916. */
  15917. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15918. /**
  15919. * Clones the current emitter and returns a copy of it
  15920. * @returns the new emitter
  15921. */
  15922. clone(): IParticleEmitterType;
  15923. /**
  15924. * Called by the GPUParticleSystem to setup the update shader
  15925. * @param effect defines the update shader
  15926. */
  15927. applyToShader(effect: Effect): void;
  15928. /**
  15929. * Returns a string to use to update the GPU particles update shader
  15930. * @returns the effect defines string
  15931. */
  15932. getEffectDefines(): string;
  15933. /**
  15934. * Returns a string representing the class name
  15935. * @returns a string containing the class name
  15936. */
  15937. getClassName(): string;
  15938. /**
  15939. * Serializes the particle system to a JSON object.
  15940. * @returns the JSON object
  15941. */
  15942. serialize(): any;
  15943. /**
  15944. * Parse properties from a JSON object
  15945. * @param serializationObject defines the JSON object
  15946. */
  15947. parse(serializationObject: any): void;
  15948. }
  15949. }
  15950. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15951. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15952. import { Effect } from "babylonjs/Materials/effect";
  15953. import { Particle } from "babylonjs/Particles/particle";
  15954. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15955. /**
  15956. * Particle emitter emitting particles from the inside of a box.
  15957. * It emits the particles randomly between 2 given directions.
  15958. */
  15959. export class BoxParticleEmitter implements IParticleEmitterType {
  15960. /**
  15961. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15962. */
  15963. direction1: Vector3;
  15964. /**
  15965. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15966. */
  15967. direction2: Vector3;
  15968. /**
  15969. * 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.
  15970. */
  15971. minEmitBox: Vector3;
  15972. /**
  15973. * 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.
  15974. */
  15975. maxEmitBox: Vector3;
  15976. /**
  15977. * Creates a new instance BoxParticleEmitter
  15978. */
  15979. constructor();
  15980. /**
  15981. * Called by the particle System when the direction is computed for the created particle.
  15982. * @param worldMatrix is the world matrix of the particle system
  15983. * @param directionToUpdate is the direction vector to update with the result
  15984. * @param particle is the particle we are computed the direction for
  15985. */
  15986. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15987. /**
  15988. * Called by the particle System when the position is computed for the created particle.
  15989. * @param worldMatrix is the world matrix of the particle system
  15990. * @param positionToUpdate is the position vector to update with the result
  15991. * @param particle is the particle we are computed the position for
  15992. */
  15993. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15994. /**
  15995. * Clones the current emitter and returns a copy of it
  15996. * @returns the new emitter
  15997. */
  15998. clone(): BoxParticleEmitter;
  15999. /**
  16000. * Called by the GPUParticleSystem to setup the update shader
  16001. * @param effect defines the update shader
  16002. */
  16003. applyToShader(effect: Effect): void;
  16004. /**
  16005. * Returns a string to use to update the GPU particles update shader
  16006. * @returns a string containng the defines string
  16007. */
  16008. getEffectDefines(): string;
  16009. /**
  16010. * Returns the string "BoxParticleEmitter"
  16011. * @returns a string containing the class name
  16012. */
  16013. getClassName(): string;
  16014. /**
  16015. * Serializes the particle system to a JSON object.
  16016. * @returns the JSON object
  16017. */
  16018. serialize(): any;
  16019. /**
  16020. * Parse properties from a JSON object
  16021. * @param serializationObject defines the JSON object
  16022. */
  16023. parse(serializationObject: any): void;
  16024. }
  16025. }
  16026. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16027. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16028. import { Effect } from "babylonjs/Materials/effect";
  16029. import { Particle } from "babylonjs/Particles/particle";
  16030. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16031. /**
  16032. * Particle emitter emitting particles from the inside of a cone.
  16033. * It emits the particles alongside the cone volume from the base to the particle.
  16034. * The emission direction might be randomized.
  16035. */
  16036. export class ConeParticleEmitter implements IParticleEmitterType {
  16037. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16038. directionRandomizer: number;
  16039. private _radius;
  16040. private _angle;
  16041. private _height;
  16042. /**
  16043. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16044. */
  16045. radiusRange: number;
  16046. /**
  16047. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16048. */
  16049. heightRange: number;
  16050. /**
  16051. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16052. */
  16053. emitFromSpawnPointOnly: boolean;
  16054. /**
  16055. * Gets or sets the radius of the emission cone
  16056. */
  16057. radius: number;
  16058. /**
  16059. * Gets or sets the angle of the emission cone
  16060. */
  16061. angle: number;
  16062. private _buildHeight;
  16063. /**
  16064. * Creates a new instance ConeParticleEmitter
  16065. * @param radius the radius of the emission cone (1 by default)
  16066. * @param angle the cone base angle (PI by default)
  16067. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16068. */
  16069. constructor(radius?: number, angle?: number,
  16070. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16071. directionRandomizer?: number);
  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. * Called by the particle System when the position is computed for the created particle.
  16081. * @param worldMatrix is the world matrix of the particle system
  16082. * @param positionToUpdate is the position vector to update with the result
  16083. * @param particle is the particle we are computed the position for
  16084. */
  16085. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16086. /**
  16087. * Clones the current emitter and returns a copy of it
  16088. * @returns the new emitter
  16089. */
  16090. clone(): ConeParticleEmitter;
  16091. /**
  16092. * Called by the GPUParticleSystem to setup the update shader
  16093. * @param effect defines the update shader
  16094. */
  16095. applyToShader(effect: Effect): void;
  16096. /**
  16097. * Returns a string to use to update the GPU particles update shader
  16098. * @returns a string containng the defines string
  16099. */
  16100. getEffectDefines(): string;
  16101. /**
  16102. * Returns the string "ConeParticleEmitter"
  16103. * @returns a string containing the class name
  16104. */
  16105. getClassName(): string;
  16106. /**
  16107. * Serializes the particle system to a JSON object.
  16108. * @returns the JSON object
  16109. */
  16110. serialize(): any;
  16111. /**
  16112. * Parse properties from a JSON object
  16113. * @param serializationObject defines the JSON object
  16114. */
  16115. parse(serializationObject: any): void;
  16116. }
  16117. }
  16118. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16119. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16120. import { Effect } from "babylonjs/Materials/effect";
  16121. import { Particle } from "babylonjs/Particles/particle";
  16122. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16123. /**
  16124. * Particle emitter emitting particles from the inside of a cylinder.
  16125. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16126. */
  16127. export class CylinderParticleEmitter implements IParticleEmitterType {
  16128. /**
  16129. * The radius of the emission cylinder.
  16130. */
  16131. radius: number;
  16132. /**
  16133. * The height of the emission cylinder.
  16134. */
  16135. height: number;
  16136. /**
  16137. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16138. */
  16139. radiusRange: number;
  16140. /**
  16141. * How much to randomize the particle direction [0-1].
  16142. */
  16143. directionRandomizer: number;
  16144. /**
  16145. * Creates a new instance CylinderParticleEmitter
  16146. * @param radius the radius of the emission cylinder (1 by default)
  16147. * @param height the height of the emission cylinder (1 by default)
  16148. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16149. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16150. */
  16151. constructor(
  16152. /**
  16153. * The radius of the emission cylinder.
  16154. */
  16155. radius?: number,
  16156. /**
  16157. * The height of the emission cylinder.
  16158. */
  16159. height?: number,
  16160. /**
  16161. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16162. */
  16163. radiusRange?: number,
  16164. /**
  16165. * How much to randomize the particle direction [0-1].
  16166. */
  16167. directionRandomizer?: number);
  16168. /**
  16169. * Called by the particle System when the direction is computed for the created particle.
  16170. * @param worldMatrix is the world matrix of the particle system
  16171. * @param directionToUpdate is the direction vector to update with the result
  16172. * @param particle is the particle we are computed the direction for
  16173. */
  16174. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16175. /**
  16176. * Called by the particle System when the position is computed for the created particle.
  16177. * @param worldMatrix is the world matrix of the particle system
  16178. * @param positionToUpdate is the position vector to update with the result
  16179. * @param particle is the particle we are computed the position for
  16180. */
  16181. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16182. /**
  16183. * Clones the current emitter and returns a copy of it
  16184. * @returns the new emitter
  16185. */
  16186. clone(): CylinderParticleEmitter;
  16187. /**
  16188. * Called by the GPUParticleSystem to setup the update shader
  16189. * @param effect defines the update shader
  16190. */
  16191. applyToShader(effect: Effect): void;
  16192. /**
  16193. * Returns a string to use to update the GPU particles update shader
  16194. * @returns a string containng the defines string
  16195. */
  16196. getEffectDefines(): string;
  16197. /**
  16198. * Returns the string "CylinderParticleEmitter"
  16199. * @returns a string containing the class name
  16200. */
  16201. getClassName(): string;
  16202. /**
  16203. * Serializes the particle system to a JSON object.
  16204. * @returns the JSON object
  16205. */
  16206. serialize(): any;
  16207. /**
  16208. * Parse properties from a JSON object
  16209. * @param serializationObject defines the JSON object
  16210. */
  16211. parse(serializationObject: any): void;
  16212. }
  16213. /**
  16214. * Particle emitter emitting particles from the inside of a cylinder.
  16215. * It emits the particles randomly between two vectors.
  16216. */
  16217. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16218. /**
  16219. * The min limit of the emission direction.
  16220. */
  16221. direction1: Vector3;
  16222. /**
  16223. * The max limit of the emission direction.
  16224. */
  16225. direction2: Vector3;
  16226. /**
  16227. * Creates a new instance CylinderDirectedParticleEmitter
  16228. * @param radius the radius of the emission cylinder (1 by default)
  16229. * @param height the height of the emission cylinder (1 by default)
  16230. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16231. * @param direction1 the min limit of the emission direction (up vector by default)
  16232. * @param direction2 the max limit of the emission direction (up vector by default)
  16233. */
  16234. constructor(radius?: number, height?: number, radiusRange?: number,
  16235. /**
  16236. * The min limit of the emission direction.
  16237. */
  16238. direction1?: Vector3,
  16239. /**
  16240. * The max limit of the emission direction.
  16241. */
  16242. direction2?: Vector3);
  16243. /**
  16244. * Called by the particle System when the direction is computed for the created particle.
  16245. * @param worldMatrix is the world matrix of the particle system
  16246. * @param directionToUpdate is the direction vector to update with the result
  16247. * @param particle is the particle we are computed the direction for
  16248. */
  16249. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16250. /**
  16251. * Clones the current emitter and returns a copy of it
  16252. * @returns the new emitter
  16253. */
  16254. clone(): CylinderDirectedParticleEmitter;
  16255. /**
  16256. * Called by the GPUParticleSystem to setup the update shader
  16257. * @param effect defines the update shader
  16258. */
  16259. applyToShader(effect: Effect): void;
  16260. /**
  16261. * Returns a string to use to update the GPU particles update shader
  16262. * @returns a string containng the defines string
  16263. */
  16264. getEffectDefines(): string;
  16265. /**
  16266. * Returns the string "CylinderDirectedParticleEmitter"
  16267. * @returns a string containing the class name
  16268. */
  16269. getClassName(): string;
  16270. /**
  16271. * Serializes the particle system to a JSON object.
  16272. * @returns the JSON object
  16273. */
  16274. serialize(): any;
  16275. /**
  16276. * Parse properties from a JSON object
  16277. * @param serializationObject defines the JSON object
  16278. */
  16279. parse(serializationObject: any): void;
  16280. }
  16281. }
  16282. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16283. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16284. import { Effect } from "babylonjs/Materials/effect";
  16285. import { Particle } from "babylonjs/Particles/particle";
  16286. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16287. /**
  16288. * Particle emitter emitting particles from the inside of a hemisphere.
  16289. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16290. */
  16291. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16292. /**
  16293. * The radius of the emission hemisphere.
  16294. */
  16295. radius: number;
  16296. /**
  16297. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16298. */
  16299. radiusRange: number;
  16300. /**
  16301. * How much to randomize the particle direction [0-1].
  16302. */
  16303. directionRandomizer: number;
  16304. /**
  16305. * Creates a new instance HemisphericParticleEmitter
  16306. * @param radius the radius of the emission hemisphere (1 by default)
  16307. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16308. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16309. */
  16310. constructor(
  16311. /**
  16312. * The radius of the emission hemisphere.
  16313. */
  16314. radius?: number,
  16315. /**
  16316. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16317. */
  16318. radiusRange?: number,
  16319. /**
  16320. * How much to randomize the particle direction [0-1].
  16321. */
  16322. directionRandomizer?: number);
  16323. /**
  16324. * Called by the particle System when the direction is computed for the created particle.
  16325. * @param worldMatrix is the world matrix of the particle system
  16326. * @param directionToUpdate is the direction vector to update with the result
  16327. * @param particle is the particle we are computed the direction for
  16328. */
  16329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16330. /**
  16331. * Called by the particle System when the position is computed for the created particle.
  16332. * @param worldMatrix is the world matrix of the particle system
  16333. * @param positionToUpdate is the position vector to update with the result
  16334. * @param particle is the particle we are computed the position for
  16335. */
  16336. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16337. /**
  16338. * Clones the current emitter and returns a copy of it
  16339. * @returns the new emitter
  16340. */
  16341. clone(): HemisphericParticleEmitter;
  16342. /**
  16343. * Called by the GPUParticleSystem to setup the update shader
  16344. * @param effect defines the update shader
  16345. */
  16346. applyToShader(effect: Effect): void;
  16347. /**
  16348. * Returns a string to use to update the GPU particles update shader
  16349. * @returns a string containng the defines string
  16350. */
  16351. getEffectDefines(): string;
  16352. /**
  16353. * Returns the string "HemisphericParticleEmitter"
  16354. * @returns a string containing the class name
  16355. */
  16356. getClassName(): string;
  16357. /**
  16358. * Serializes the particle system to a JSON object.
  16359. * @returns the JSON object
  16360. */
  16361. serialize(): any;
  16362. /**
  16363. * Parse properties from a JSON object
  16364. * @param serializationObject defines the JSON object
  16365. */
  16366. parse(serializationObject: any): void;
  16367. }
  16368. }
  16369. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16370. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16371. import { Effect } from "babylonjs/Materials/effect";
  16372. import { Particle } from "babylonjs/Particles/particle";
  16373. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16374. /**
  16375. * Particle emitter emitting particles from a point.
  16376. * It emits the particles randomly between 2 given directions.
  16377. */
  16378. export class PointParticleEmitter implements IParticleEmitterType {
  16379. /**
  16380. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16381. */
  16382. direction1: Vector3;
  16383. /**
  16384. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16385. */
  16386. direction2: Vector3;
  16387. /**
  16388. * Creates a new instance PointParticleEmitter
  16389. */
  16390. constructor();
  16391. /**
  16392. * Called by the particle System when the direction is computed for the created particle.
  16393. * @param worldMatrix is the world matrix of the particle system
  16394. * @param directionToUpdate is the direction vector to update with the result
  16395. * @param particle is the particle we are computed the direction for
  16396. */
  16397. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16398. /**
  16399. * Called by the particle System when the position is computed for the created particle.
  16400. * @param worldMatrix is the world matrix of the particle system
  16401. * @param positionToUpdate is the position vector to update with the result
  16402. * @param particle is the particle we are computed the position for
  16403. */
  16404. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16405. /**
  16406. * Clones the current emitter and returns a copy of it
  16407. * @returns the new emitter
  16408. */
  16409. clone(): PointParticleEmitter;
  16410. /**
  16411. * Called by the GPUParticleSystem to setup the update shader
  16412. * @param effect defines the update shader
  16413. */
  16414. applyToShader(effect: Effect): void;
  16415. /**
  16416. * Returns a string to use to update the GPU particles update shader
  16417. * @returns a string containng the defines string
  16418. */
  16419. getEffectDefines(): string;
  16420. /**
  16421. * Returns the string "PointParticleEmitter"
  16422. * @returns a string containing the class name
  16423. */
  16424. getClassName(): string;
  16425. /**
  16426. * Serializes the particle system to a JSON object.
  16427. * @returns the JSON object
  16428. */
  16429. serialize(): any;
  16430. /**
  16431. * Parse properties from a JSON object
  16432. * @param serializationObject defines the JSON object
  16433. */
  16434. parse(serializationObject: any): void;
  16435. }
  16436. }
  16437. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16438. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16439. import { Effect } from "babylonjs/Materials/effect";
  16440. import { Particle } from "babylonjs/Particles/particle";
  16441. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16442. /**
  16443. * Particle emitter emitting particles from the inside of a sphere.
  16444. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16445. */
  16446. export class SphereParticleEmitter implements IParticleEmitterType {
  16447. /**
  16448. * The radius of the emission sphere.
  16449. */
  16450. radius: number;
  16451. /**
  16452. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16453. */
  16454. radiusRange: number;
  16455. /**
  16456. * How much to randomize the particle direction [0-1].
  16457. */
  16458. directionRandomizer: number;
  16459. /**
  16460. * Creates a new instance SphereParticleEmitter
  16461. * @param radius the radius of the emission sphere (1 by default)
  16462. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16463. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16464. */
  16465. constructor(
  16466. /**
  16467. * The radius of the emission sphere.
  16468. */
  16469. radius?: number,
  16470. /**
  16471. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16472. */
  16473. radiusRange?: number,
  16474. /**
  16475. * How much to randomize the particle direction [0-1].
  16476. */
  16477. directionRandomizer?: number);
  16478. /**
  16479. * Called by the particle System when the direction is computed for the created particle.
  16480. * @param worldMatrix is the world matrix of the particle system
  16481. * @param directionToUpdate is the direction vector to update with the result
  16482. * @param particle is the particle we are computed the direction for
  16483. */
  16484. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16485. /**
  16486. * Called by the particle System when the position is computed for the created particle.
  16487. * @param worldMatrix is the world matrix of the particle system
  16488. * @param positionToUpdate is the position vector to update with the result
  16489. * @param particle is the particle we are computed the position for
  16490. */
  16491. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16492. /**
  16493. * Clones the current emitter and returns a copy of it
  16494. * @returns the new emitter
  16495. */
  16496. clone(): SphereParticleEmitter;
  16497. /**
  16498. * Called by the GPUParticleSystem to setup the update shader
  16499. * @param effect defines the update shader
  16500. */
  16501. applyToShader(effect: Effect): void;
  16502. /**
  16503. * Returns a string to use to update the GPU particles update shader
  16504. * @returns a string containng the defines string
  16505. */
  16506. getEffectDefines(): string;
  16507. /**
  16508. * Returns the string "SphereParticleEmitter"
  16509. * @returns a string containing the class name
  16510. */
  16511. getClassName(): string;
  16512. /**
  16513. * Serializes the particle system to a JSON object.
  16514. * @returns the JSON object
  16515. */
  16516. serialize(): any;
  16517. /**
  16518. * Parse properties from a JSON object
  16519. * @param serializationObject defines the JSON object
  16520. */
  16521. parse(serializationObject: any): void;
  16522. }
  16523. /**
  16524. * Particle emitter emitting particles from the inside of a sphere.
  16525. * It emits the particles randomly between two vectors.
  16526. */
  16527. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16528. /**
  16529. * The min limit of the emission direction.
  16530. */
  16531. direction1: Vector3;
  16532. /**
  16533. * The max limit of the emission direction.
  16534. */
  16535. direction2: Vector3;
  16536. /**
  16537. * Creates a new instance SphereDirectedParticleEmitter
  16538. * @param radius the radius of the emission sphere (1 by default)
  16539. * @param direction1 the min limit of the emission direction (up vector by default)
  16540. * @param direction2 the max limit of the emission direction (up vector by default)
  16541. */
  16542. constructor(radius?: number,
  16543. /**
  16544. * The min limit of the emission direction.
  16545. */
  16546. direction1?: Vector3,
  16547. /**
  16548. * The max limit of the emission direction.
  16549. */
  16550. direction2?: Vector3);
  16551. /**
  16552. * Called by the particle System when the direction is computed for the created particle.
  16553. * @param worldMatrix is the world matrix of the particle system
  16554. * @param directionToUpdate is the direction vector to update with the result
  16555. * @param particle is the particle we are computed the direction for
  16556. */
  16557. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16558. /**
  16559. * Clones the current emitter and returns a copy of it
  16560. * @returns the new emitter
  16561. */
  16562. clone(): SphereDirectedParticleEmitter;
  16563. /**
  16564. * Called by the GPUParticleSystem to setup the update shader
  16565. * @param effect defines the update shader
  16566. */
  16567. applyToShader(effect: Effect): void;
  16568. /**
  16569. * Returns a string to use to update the GPU particles update shader
  16570. * @returns a string containng the defines string
  16571. */
  16572. getEffectDefines(): string;
  16573. /**
  16574. * Returns the string "SphereDirectedParticleEmitter"
  16575. * @returns a string containing the class name
  16576. */
  16577. getClassName(): string;
  16578. /**
  16579. * Serializes the particle system to a JSON object.
  16580. * @returns the JSON object
  16581. */
  16582. serialize(): any;
  16583. /**
  16584. * Parse properties from a JSON object
  16585. * @param serializationObject defines the JSON object
  16586. */
  16587. parse(serializationObject: any): void;
  16588. }
  16589. }
  16590. declare module "babylonjs/Particles/EmitterTypes/index" {
  16591. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16592. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16593. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16594. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16595. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16596. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16597. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16598. }
  16599. declare module "babylonjs/Particles/IParticleSystem" {
  16600. import { Nullable } from "babylonjs/types";
  16601. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16603. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16604. import { Texture } from "babylonjs/Materials/Textures/texture";
  16605. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16606. import { Scene } from "babylonjs/scene";
  16607. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16608. import { Animation } from "babylonjs/Animations/animation";
  16609. /**
  16610. * Interface representing a particle system in Babylon.js.
  16611. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16612. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16613. */
  16614. export interface IParticleSystem {
  16615. /**
  16616. * List of animations used by the particle system.
  16617. */
  16618. animations: Animation[];
  16619. /**
  16620. * The id of the Particle system.
  16621. */
  16622. id: string;
  16623. /**
  16624. * The name of the Particle system.
  16625. */
  16626. name: string;
  16627. /**
  16628. * The emitter represents the Mesh or position we are attaching the particle system to.
  16629. */
  16630. emitter: Nullable<AbstractMesh | Vector3>;
  16631. /**
  16632. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16633. */
  16634. isBillboardBased: boolean;
  16635. /**
  16636. * The rendering group used by the Particle system to chose when to render.
  16637. */
  16638. renderingGroupId: number;
  16639. /**
  16640. * The layer mask we are rendering the particles through.
  16641. */
  16642. layerMask: number;
  16643. /**
  16644. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16645. */
  16646. updateSpeed: number;
  16647. /**
  16648. * The amount of time the particle system is running (depends of the overall update speed).
  16649. */
  16650. targetStopDuration: number;
  16651. /**
  16652. * The texture used to render each particle. (this can be a spritesheet)
  16653. */
  16654. particleTexture: Nullable<Texture>;
  16655. /**
  16656. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16657. */
  16658. blendMode: number;
  16659. /**
  16660. * Minimum life time of emitting particles.
  16661. */
  16662. minLifeTime: number;
  16663. /**
  16664. * Maximum life time of emitting particles.
  16665. */
  16666. maxLifeTime: number;
  16667. /**
  16668. * Minimum Size of emitting particles.
  16669. */
  16670. minSize: number;
  16671. /**
  16672. * Maximum Size of emitting particles.
  16673. */
  16674. maxSize: number;
  16675. /**
  16676. * Minimum scale of emitting particles on X axis.
  16677. */
  16678. minScaleX: number;
  16679. /**
  16680. * Maximum scale of emitting particles on X axis.
  16681. */
  16682. maxScaleX: number;
  16683. /**
  16684. * Minimum scale of emitting particles on Y axis.
  16685. */
  16686. minScaleY: number;
  16687. /**
  16688. * Maximum scale of emitting particles on Y axis.
  16689. */
  16690. maxScaleY: number;
  16691. /**
  16692. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16693. */
  16694. color1: Color4;
  16695. /**
  16696. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16697. */
  16698. color2: Color4;
  16699. /**
  16700. * Color the particle will have at the end of its lifetime.
  16701. */
  16702. colorDead: Color4;
  16703. /**
  16704. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16705. */
  16706. emitRate: number;
  16707. /**
  16708. * You can use gravity if you want to give an orientation to your particles.
  16709. */
  16710. gravity: Vector3;
  16711. /**
  16712. * Minimum power of emitting particles.
  16713. */
  16714. minEmitPower: number;
  16715. /**
  16716. * Maximum power of emitting particles.
  16717. */
  16718. maxEmitPower: number;
  16719. /**
  16720. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16721. */
  16722. minAngularSpeed: number;
  16723. /**
  16724. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16725. */
  16726. maxAngularSpeed: number;
  16727. /**
  16728. * Gets or sets the minimal initial rotation in radians.
  16729. */
  16730. minInitialRotation: number;
  16731. /**
  16732. * Gets or sets the maximal initial rotation in radians.
  16733. */
  16734. maxInitialRotation: number;
  16735. /**
  16736. * The particle emitter type defines the emitter used by the particle system.
  16737. * It can be for example box, sphere, or cone...
  16738. */
  16739. particleEmitterType: Nullable<IParticleEmitterType>;
  16740. /**
  16741. * Defines the delay in milliseconds before starting the system (0 by default)
  16742. */
  16743. startDelay: number;
  16744. /**
  16745. * 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
  16746. */
  16747. preWarmCycles: number;
  16748. /**
  16749. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16750. */
  16751. preWarmStepOffset: number;
  16752. /**
  16753. * 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)
  16754. */
  16755. spriteCellChangeSpeed: number;
  16756. /**
  16757. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16758. */
  16759. startSpriteCellID: number;
  16760. /**
  16761. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16762. */
  16763. endSpriteCellID: number;
  16764. /**
  16765. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16766. */
  16767. spriteCellWidth: number;
  16768. /**
  16769. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16770. */
  16771. spriteCellHeight: number;
  16772. /**
  16773. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16774. */
  16775. spriteRandomStartCell: boolean;
  16776. /**
  16777. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16778. */
  16779. isAnimationSheetEnabled: boolean;
  16780. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16781. translationPivot: Vector2;
  16782. /**
  16783. * Gets or sets a texture used to add random noise to particle positions
  16784. */
  16785. noiseTexture: Nullable<BaseTexture>;
  16786. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16787. noiseStrength: Vector3;
  16788. /**
  16789. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16790. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16791. */
  16792. billboardMode: number;
  16793. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16794. limitVelocityDamping: number;
  16795. /**
  16796. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16797. */
  16798. beginAnimationOnStart: boolean;
  16799. /**
  16800. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16801. */
  16802. beginAnimationFrom: number;
  16803. /**
  16804. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16805. */
  16806. beginAnimationTo: number;
  16807. /**
  16808. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16809. */
  16810. beginAnimationLoop: boolean;
  16811. /**
  16812. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16813. */
  16814. disposeOnStop: boolean;
  16815. /**
  16816. * Gets the maximum number of particles active at the same time.
  16817. * @returns The max number of active particles.
  16818. */
  16819. getCapacity(): number;
  16820. /**
  16821. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16822. * @returns True if it has been started, otherwise false.
  16823. */
  16824. isStarted(): boolean;
  16825. /**
  16826. * Animates the particle system for this frame.
  16827. */
  16828. animate(): void;
  16829. /**
  16830. * Renders the particle system in its current state.
  16831. * @returns the current number of particles
  16832. */
  16833. render(): number;
  16834. /**
  16835. * Dispose the particle system and frees its associated resources.
  16836. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16837. */
  16838. dispose(disposeTexture?: boolean): void;
  16839. /**
  16840. * Clones the particle system.
  16841. * @param name The name of the cloned object
  16842. * @param newEmitter The new emitter to use
  16843. * @returns the cloned particle system
  16844. */
  16845. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16846. /**
  16847. * Serializes the particle system to a JSON object.
  16848. * @returns the JSON object
  16849. */
  16850. serialize(): any;
  16851. /**
  16852. * Rebuild the particle system
  16853. */
  16854. rebuild(): void;
  16855. /**
  16856. * Starts the particle system and begins to emit
  16857. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16858. */
  16859. start(delay?: number): void;
  16860. /**
  16861. * Stops the particle system.
  16862. */
  16863. stop(): void;
  16864. /**
  16865. * Remove all active particles
  16866. */
  16867. reset(): void;
  16868. /**
  16869. * Is this system ready to be used/rendered
  16870. * @return true if the system is ready
  16871. */
  16872. isReady(): boolean;
  16873. /**
  16874. * Adds a new color gradient
  16875. * @param gradient defines the gradient to use (between 0 and 1)
  16876. * @param color1 defines the color to affect to the specified gradient
  16877. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16878. * @returns the current particle system
  16879. */
  16880. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16881. /**
  16882. * Remove a specific color gradient
  16883. * @param gradient defines the gradient to remove
  16884. * @returns the current particle system
  16885. */
  16886. removeColorGradient(gradient: number): IParticleSystem;
  16887. /**
  16888. * Adds a new size gradient
  16889. * @param gradient defines the gradient to use (between 0 and 1)
  16890. * @param factor defines the size factor to affect to the specified gradient
  16891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16892. * @returns the current particle system
  16893. */
  16894. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16895. /**
  16896. * Remove a specific size gradient
  16897. * @param gradient defines the gradient to remove
  16898. * @returns the current particle system
  16899. */
  16900. removeSizeGradient(gradient: number): IParticleSystem;
  16901. /**
  16902. * Gets the current list of color gradients.
  16903. * You must use addColorGradient and removeColorGradient to udpate this list
  16904. * @returns the list of color gradients
  16905. */
  16906. getColorGradients(): Nullable<Array<ColorGradient>>;
  16907. /**
  16908. * Gets the current list of size gradients.
  16909. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16910. * @returns the list of size gradients
  16911. */
  16912. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16913. /**
  16914. * Gets the current list of angular speed gradients.
  16915. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16916. * @returns the list of angular speed gradients
  16917. */
  16918. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16919. /**
  16920. * Adds a new angular speed gradient
  16921. * @param gradient defines the gradient to use (between 0 and 1)
  16922. * @param factor defines the angular speed to affect to the specified gradient
  16923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16924. * @returns the current particle system
  16925. */
  16926. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16927. /**
  16928. * Remove a specific angular speed gradient
  16929. * @param gradient defines the gradient to remove
  16930. * @returns the current particle system
  16931. */
  16932. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16933. /**
  16934. * Gets the current list of velocity gradients.
  16935. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16936. * @returns the list of velocity gradients
  16937. */
  16938. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16939. /**
  16940. * Adds a new velocity gradient
  16941. * @param gradient defines the gradient to use (between 0 and 1)
  16942. * @param factor defines the velocity to affect to the specified gradient
  16943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16944. * @returns the current particle system
  16945. */
  16946. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16947. /**
  16948. * Remove a specific velocity gradient
  16949. * @param gradient defines the gradient to remove
  16950. * @returns the current particle system
  16951. */
  16952. removeVelocityGradient(gradient: number): IParticleSystem;
  16953. /**
  16954. * Gets the current list of limit velocity gradients.
  16955. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16956. * @returns the list of limit velocity gradients
  16957. */
  16958. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16959. /**
  16960. * Adds a new limit velocity gradient
  16961. * @param gradient defines the gradient to use (between 0 and 1)
  16962. * @param factor defines the limit velocity to affect to the specified gradient
  16963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16964. * @returns the current particle system
  16965. */
  16966. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16967. /**
  16968. * Remove a specific limit velocity gradient
  16969. * @param gradient defines the gradient to remove
  16970. * @returns the current particle system
  16971. */
  16972. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16973. /**
  16974. * Adds a new drag gradient
  16975. * @param gradient defines the gradient to use (between 0 and 1)
  16976. * @param factor defines the drag to affect to the specified gradient
  16977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16978. * @returns the current particle system
  16979. */
  16980. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16981. /**
  16982. * Remove a specific drag gradient
  16983. * @param gradient defines the gradient to remove
  16984. * @returns the current particle system
  16985. */
  16986. removeDragGradient(gradient: number): IParticleSystem;
  16987. /**
  16988. * Gets the current list of drag gradients.
  16989. * You must use addDragGradient and removeDragGradient to udpate this list
  16990. * @returns the list of drag gradients
  16991. */
  16992. getDragGradients(): Nullable<Array<FactorGradient>>;
  16993. /**
  16994. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16995. * @param gradient defines the gradient to use (between 0 and 1)
  16996. * @param factor defines the emit rate to affect to the specified gradient
  16997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16998. * @returns the current particle system
  16999. */
  17000. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17001. /**
  17002. * Remove a specific emit rate gradient
  17003. * @param gradient defines the gradient to remove
  17004. * @returns the current particle system
  17005. */
  17006. removeEmitRateGradient(gradient: number): IParticleSystem;
  17007. /**
  17008. * Gets the current list of emit rate gradients.
  17009. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17010. * @returns the list of emit rate gradients
  17011. */
  17012. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17013. /**
  17014. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17015. * @param gradient defines the gradient to use (between 0 and 1)
  17016. * @param factor defines the start size to affect to the specified gradient
  17017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17018. * @returns the current particle system
  17019. */
  17020. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17021. /**
  17022. * Remove a specific start size gradient
  17023. * @param gradient defines the gradient to remove
  17024. * @returns the current particle system
  17025. */
  17026. removeStartSizeGradient(gradient: number): IParticleSystem;
  17027. /**
  17028. * Gets the current list of start size gradients.
  17029. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17030. * @returns the list of start size gradients
  17031. */
  17032. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17033. /**
  17034. * Adds a new life time gradient
  17035. * @param gradient defines the gradient to use (between 0 and 1)
  17036. * @param factor defines the life time factor to affect to the specified gradient
  17037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17038. * @returns the current particle system
  17039. */
  17040. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17041. /**
  17042. * Remove a specific life time gradient
  17043. * @param gradient defines the gradient to remove
  17044. * @returns the current particle system
  17045. */
  17046. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17047. /**
  17048. * Gets the current list of life time gradients.
  17049. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17050. * @returns the list of life time gradients
  17051. */
  17052. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17053. /**
  17054. * Gets the current list of color gradients.
  17055. * You must use addColorGradient and removeColorGradient to udpate this list
  17056. * @returns the list of color gradients
  17057. */
  17058. getColorGradients(): Nullable<Array<ColorGradient>>;
  17059. /**
  17060. * Adds a new ramp gradient used to remap particle colors
  17061. * @param gradient defines the gradient to use (between 0 and 1)
  17062. * @param color defines the color to affect to the specified gradient
  17063. * @returns the current particle system
  17064. */
  17065. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17066. /**
  17067. * Gets the current list of ramp gradients.
  17068. * You must use addRampGradient and removeRampGradient to udpate this list
  17069. * @returns the list of ramp gradients
  17070. */
  17071. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17072. /** Gets or sets a boolean indicating that ramp gradients must be used
  17073. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17074. */
  17075. useRampGradients: boolean;
  17076. /**
  17077. * Adds a new color remap gradient
  17078. * @param gradient defines the gradient to use (between 0 and 1)
  17079. * @param min defines the color remap minimal range
  17080. * @param max defines the color remap maximal range
  17081. * @returns the current particle system
  17082. */
  17083. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17084. /**
  17085. * Gets the current list of color remap gradients.
  17086. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17087. * @returns the list of color remap gradients
  17088. */
  17089. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17090. /**
  17091. * Adds a new alpha remap gradient
  17092. * @param gradient defines the gradient to use (between 0 and 1)
  17093. * @param min defines the alpha remap minimal range
  17094. * @param max defines the alpha remap maximal range
  17095. * @returns the current particle system
  17096. */
  17097. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17098. /**
  17099. * Gets the current list of alpha remap gradients.
  17100. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17101. * @returns the list of alpha remap gradients
  17102. */
  17103. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17104. /**
  17105. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17106. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17107. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17108. * @returns the emitter
  17109. */
  17110. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17111. /**
  17112. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17113. * @param radius The radius of the hemisphere to emit from
  17114. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17115. * @returns the emitter
  17116. */
  17117. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17118. /**
  17119. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17120. * @param radius The radius of the sphere to emit from
  17121. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17122. * @returns the emitter
  17123. */
  17124. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17125. /**
  17126. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17127. * @param radius The radius of the sphere to emit from
  17128. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17129. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17130. * @returns the emitter
  17131. */
  17132. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17133. /**
  17134. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17135. * @param radius The radius of the emission cylinder
  17136. * @param height The height of the emission cylinder
  17137. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17138. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17139. * @returns the emitter
  17140. */
  17141. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17142. /**
  17143. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17144. * @param radius The radius of the cylinder to emit from
  17145. * @param height The height of the emission cylinder
  17146. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17147. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17148. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17149. * @returns the emitter
  17150. */
  17151. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17152. /**
  17153. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17154. * @param radius The radius of the cone to emit from
  17155. * @param angle The base angle of the cone
  17156. * @returns the emitter
  17157. */
  17158. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17159. /**
  17160. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17161. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17162. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17163. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17164. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17165. * @returns the emitter
  17166. */
  17167. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17168. /**
  17169. * Get hosting scene
  17170. * @returns the scene
  17171. */
  17172. getScene(): Scene;
  17173. }
  17174. }
  17175. declare module "babylonjs/Meshes/instancedMesh" {
  17176. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17177. import { Vector3, Matrix } from "babylonjs/Maths/math";
  17178. import { Camera } from "babylonjs/Cameras/camera";
  17179. import { Node } from "babylonjs/node";
  17180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17181. import { Mesh } from "babylonjs/Meshes/mesh";
  17182. import { Material } from "babylonjs/Materials/material";
  17183. import { Skeleton } from "babylonjs/Bones/skeleton";
  17184. import { Light } from "babylonjs/Lights/light";
  17185. /**
  17186. * Creates an instance based on a source mesh.
  17187. */
  17188. export class InstancedMesh extends AbstractMesh {
  17189. private _sourceMesh;
  17190. private _currentLOD;
  17191. /** @hidden */
  17192. _indexInSourceMeshInstanceArray: number;
  17193. constructor(name: string, source: Mesh);
  17194. /**
  17195. * Returns the string "InstancedMesh".
  17196. */
  17197. getClassName(): string;
  17198. /** Gets the list of lights affecting that mesh */
  17199. readonly lightSources: Light[];
  17200. _resyncLightSources(): void;
  17201. _resyncLighSource(light: Light): void;
  17202. _removeLightSource(light: Light): void;
  17203. /**
  17204. * If the source mesh receives shadows
  17205. */
  17206. readonly receiveShadows: boolean;
  17207. /**
  17208. * The material of the source mesh
  17209. */
  17210. readonly material: Nullable<Material>;
  17211. /**
  17212. * Visibility of the source mesh
  17213. */
  17214. readonly visibility: number;
  17215. /**
  17216. * Skeleton of the source mesh
  17217. */
  17218. readonly skeleton: Nullable<Skeleton>;
  17219. /**
  17220. * Rendering ground id of the source mesh
  17221. */
  17222. renderingGroupId: number;
  17223. /**
  17224. * Returns the total number of vertices (integer).
  17225. */
  17226. getTotalVertices(): number;
  17227. /**
  17228. * Returns a positive integer : the total number of indices in this mesh geometry.
  17229. * @returns the numner of indices or zero if the mesh has no geometry.
  17230. */
  17231. getTotalIndices(): number;
  17232. /**
  17233. * The source mesh of the instance
  17234. */
  17235. readonly sourceMesh: Mesh;
  17236. /**
  17237. * Is this node ready to be used/rendered
  17238. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17239. * @return {boolean} is it ready
  17240. */
  17241. isReady(completeCheck?: boolean): boolean;
  17242. /**
  17243. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17244. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17245. * @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.
  17246. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17247. */
  17248. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17249. /**
  17250. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17251. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17252. * The `data` are either a numeric array either a Float32Array.
  17253. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17254. * 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).
  17255. * Note that a new underlying VertexBuffer object is created each call.
  17256. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17257. *
  17258. * Possible `kind` values :
  17259. * - VertexBuffer.PositionKind
  17260. * - VertexBuffer.UVKind
  17261. * - VertexBuffer.UV2Kind
  17262. * - VertexBuffer.UV3Kind
  17263. * - VertexBuffer.UV4Kind
  17264. * - VertexBuffer.UV5Kind
  17265. * - VertexBuffer.UV6Kind
  17266. * - VertexBuffer.ColorKind
  17267. * - VertexBuffer.MatricesIndicesKind
  17268. * - VertexBuffer.MatricesIndicesExtraKind
  17269. * - VertexBuffer.MatricesWeightsKind
  17270. * - VertexBuffer.MatricesWeightsExtraKind
  17271. *
  17272. * Returns the Mesh.
  17273. */
  17274. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17275. /**
  17276. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17277. * If the mesh has no geometry, it is simply returned as it is.
  17278. * The `data` are either a numeric array either a Float32Array.
  17279. * No new underlying VertexBuffer object is created.
  17280. * 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.
  17281. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17282. *
  17283. * Possible `kind` values :
  17284. * - VertexBuffer.PositionKind
  17285. * - VertexBuffer.UVKind
  17286. * - VertexBuffer.UV2Kind
  17287. * - VertexBuffer.UV3Kind
  17288. * - VertexBuffer.UV4Kind
  17289. * - VertexBuffer.UV5Kind
  17290. * - VertexBuffer.UV6Kind
  17291. * - VertexBuffer.ColorKind
  17292. * - VertexBuffer.MatricesIndicesKind
  17293. * - VertexBuffer.MatricesIndicesExtraKind
  17294. * - VertexBuffer.MatricesWeightsKind
  17295. * - VertexBuffer.MatricesWeightsExtraKind
  17296. *
  17297. * Returns the Mesh.
  17298. */
  17299. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17300. /**
  17301. * Sets the mesh indices.
  17302. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17303. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17304. * This method creates a new index buffer each call.
  17305. * Returns the Mesh.
  17306. */
  17307. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17308. /**
  17309. * Boolean : True if the mesh owns the requested kind of data.
  17310. */
  17311. isVerticesDataPresent(kind: string): boolean;
  17312. /**
  17313. * Returns an array of indices (IndicesArray).
  17314. */
  17315. getIndices(): Nullable<IndicesArray>;
  17316. readonly _positions: Nullable<Vector3[]>;
  17317. /**
  17318. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17319. * This means the mesh underlying bounding box and sphere are recomputed.
  17320. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17321. * @returns the current mesh
  17322. */
  17323. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17324. /** @hidden */
  17325. _preActivate(): InstancedMesh;
  17326. /** @hidden */
  17327. _activate(renderId: number, intermediateRendering: boolean): boolean;
  17328. /** @hidden */
  17329. _postActivate(): void;
  17330. getWorldMatrix(): Matrix;
  17331. readonly isAnInstance: boolean;
  17332. /**
  17333. * Returns the current associated LOD AbstractMesh.
  17334. */
  17335. getLOD(camera: Camera): AbstractMesh;
  17336. /** @hidden */
  17337. _syncSubMeshes(): InstancedMesh;
  17338. /** @hidden */
  17339. _generatePointsArray(): boolean;
  17340. /**
  17341. * Creates a new InstancedMesh from the current mesh.
  17342. * - name (string) : the cloned mesh name
  17343. * - newParent (optional Node) : the optional Node to parent the clone to.
  17344. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17345. *
  17346. * Returns the clone.
  17347. */
  17348. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17349. /**
  17350. * Disposes the InstancedMesh.
  17351. * Returns nothing.
  17352. */
  17353. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17354. }
  17355. }
  17356. declare module "babylonjs/Materials/shaderMaterial" {
  17357. import { Scene } from "babylonjs/scene";
  17358. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17360. import { Mesh } from "babylonjs/Meshes/mesh";
  17361. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17362. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17363. import { Texture } from "babylonjs/Materials/Textures/texture";
  17364. import { Material } from "babylonjs/Materials/material";
  17365. /**
  17366. * Defines the options associated with the creation of a shader material.
  17367. */
  17368. export interface IShaderMaterialOptions {
  17369. /**
  17370. * Does the material work in alpha blend mode
  17371. */
  17372. needAlphaBlending: boolean;
  17373. /**
  17374. * Does the material work in alpha test mode
  17375. */
  17376. needAlphaTesting: boolean;
  17377. /**
  17378. * The list of attribute names used in the shader
  17379. */
  17380. attributes: string[];
  17381. /**
  17382. * The list of unifrom names used in the shader
  17383. */
  17384. uniforms: string[];
  17385. /**
  17386. * The list of UBO names used in the shader
  17387. */
  17388. uniformBuffers: string[];
  17389. /**
  17390. * The list of sampler names used in the shader
  17391. */
  17392. samplers: string[];
  17393. /**
  17394. * The list of defines used in the shader
  17395. */
  17396. defines: string[];
  17397. }
  17398. /**
  17399. * 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.
  17400. *
  17401. * This returned material effects how the mesh will look based on the code in the shaders.
  17402. *
  17403. * @see http://doc.babylonjs.com/how_to/shader_material
  17404. */
  17405. export class ShaderMaterial extends Material {
  17406. private _shaderPath;
  17407. private _options;
  17408. private _textures;
  17409. private _textureArrays;
  17410. private _floats;
  17411. private _ints;
  17412. private _floatsArrays;
  17413. private _colors3;
  17414. private _colors3Arrays;
  17415. private _colors4;
  17416. private _vectors2;
  17417. private _vectors3;
  17418. private _vectors4;
  17419. private _matrices;
  17420. private _matrices3x3;
  17421. private _matrices2x2;
  17422. private _vectors2Arrays;
  17423. private _vectors3Arrays;
  17424. private _cachedWorldViewMatrix;
  17425. private _cachedWorldViewProjectionMatrix;
  17426. private _renderId;
  17427. /**
  17428. * Instantiate a new shader material.
  17429. * 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.
  17430. * This returned material effects how the mesh will look based on the code in the shaders.
  17431. * @see http://doc.babylonjs.com/how_to/shader_material
  17432. * @param name Define the name of the material in the scene
  17433. * @param scene Define the scene the material belongs to
  17434. * @param shaderPath Defines the route to the shader code in one of three ways:
  17435. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17436. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17437. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17438. * @param options Define the options used to create the shader
  17439. */
  17440. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17441. /**
  17442. * Gets the options used to compile the shader.
  17443. * They can be modified to trigger a new compilation
  17444. */
  17445. readonly options: IShaderMaterialOptions;
  17446. /**
  17447. * Gets the current class name of the material e.g. "ShaderMaterial"
  17448. * Mainly use in serialization.
  17449. * @returns the class name
  17450. */
  17451. getClassName(): string;
  17452. /**
  17453. * Specifies if the material will require alpha blending
  17454. * @returns a boolean specifying if alpha blending is needed
  17455. */
  17456. needAlphaBlending(): boolean;
  17457. /**
  17458. * Specifies if this material should be rendered in alpha test mode
  17459. * @returns a boolean specifying if an alpha test is needed.
  17460. */
  17461. needAlphaTesting(): boolean;
  17462. private _checkUniform;
  17463. /**
  17464. * Set a texture in the shader.
  17465. * @param name Define the name of the uniform samplers as defined in the shader
  17466. * @param texture Define the texture to bind to this sampler
  17467. * @return the material itself allowing "fluent" like uniform updates
  17468. */
  17469. setTexture(name: string, texture: Texture): ShaderMaterial;
  17470. /**
  17471. * Set a texture array in the shader.
  17472. * @param name Define the name of the uniform sampler array as defined in the shader
  17473. * @param textures Define the list of textures to bind to this sampler
  17474. * @return the material itself allowing "fluent" like uniform updates
  17475. */
  17476. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17477. /**
  17478. * Set a float in the shader.
  17479. * @param name Define the name of the uniform as defined in the shader
  17480. * @param value Define the value to give to the uniform
  17481. * @return the material itself allowing "fluent" like uniform updates
  17482. */
  17483. setFloat(name: string, value: number): ShaderMaterial;
  17484. /**
  17485. * Set a int in the shader.
  17486. * @param name Define the name of the uniform as defined in the shader
  17487. * @param value Define the value to give to the uniform
  17488. * @return the material itself allowing "fluent" like uniform updates
  17489. */
  17490. setInt(name: string, value: number): ShaderMaterial;
  17491. /**
  17492. * Set an array of floats in the shader.
  17493. * @param name Define the name of the uniform as defined in the shader
  17494. * @param value Define the value to give to the uniform
  17495. * @return the material itself allowing "fluent" like uniform updates
  17496. */
  17497. setFloats(name: string, value: number[]): ShaderMaterial;
  17498. /**
  17499. * Set a vec3 in the shader from a Color3.
  17500. * @param name Define the name of the uniform as defined in the shader
  17501. * @param value Define the value to give to the uniform
  17502. * @return the material itself allowing "fluent" like uniform updates
  17503. */
  17504. setColor3(name: string, value: Color3): ShaderMaterial;
  17505. /**
  17506. * Set a vec3 array in the shader from a Color3 array.
  17507. * @param name Define the name of the uniform as defined in the shader
  17508. * @param value Define the value to give to the uniform
  17509. * @return the material itself allowing "fluent" like uniform updates
  17510. */
  17511. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17512. /**
  17513. * Set a vec4 in the shader from a Color4.
  17514. * @param name Define the name of the uniform as defined in the shader
  17515. * @param value Define the value to give to the uniform
  17516. * @return the material itself allowing "fluent" like uniform updates
  17517. */
  17518. setColor4(name: string, value: Color4): ShaderMaterial;
  17519. /**
  17520. * Set a vec2 in the shader from a Vector2.
  17521. * @param name Define the name of the uniform as defined in the shader
  17522. * @param value Define the value to give to the uniform
  17523. * @return the material itself allowing "fluent" like uniform updates
  17524. */
  17525. setVector2(name: string, value: Vector2): ShaderMaterial;
  17526. /**
  17527. * Set a vec3 in the shader from a Vector3.
  17528. * @param name Define the name of the uniform as defined in the shader
  17529. * @param value Define the value to give to the uniform
  17530. * @return the material itself allowing "fluent" like uniform updates
  17531. */
  17532. setVector3(name: string, value: Vector3): ShaderMaterial;
  17533. /**
  17534. * Set a vec4 in the shader from a Vector4.
  17535. * @param name Define the name of the uniform as defined in the shader
  17536. * @param value Define the value to give to the uniform
  17537. * @return the material itself allowing "fluent" like uniform updates
  17538. */
  17539. setVector4(name: string, value: Vector4): ShaderMaterial;
  17540. /**
  17541. * Set a mat4 in the shader from a Matrix.
  17542. * @param name Define the name of the uniform as defined in the shader
  17543. * @param value Define the value to give to the uniform
  17544. * @return the material itself allowing "fluent" like uniform updates
  17545. */
  17546. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17547. /**
  17548. * Set a mat3 in the shader from a Float32Array.
  17549. * @param name Define the name of the uniform as defined in the shader
  17550. * @param value Define the value to give to the uniform
  17551. * @return the material itself allowing "fluent" like uniform updates
  17552. */
  17553. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17554. /**
  17555. * Set a mat2 in the shader from a Float32Array.
  17556. * @param name Define the name of the uniform as defined in the shader
  17557. * @param value Define the value to give to the uniform
  17558. * @return the material itself allowing "fluent" like uniform updates
  17559. */
  17560. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17561. /**
  17562. * Set a vec2 array in the shader from a number array.
  17563. * @param name Define the name of the uniform as defined in the shader
  17564. * @param value Define the value to give to the uniform
  17565. * @return the material itself allowing "fluent" like uniform updates
  17566. */
  17567. setArray2(name: string, value: number[]): ShaderMaterial;
  17568. /**
  17569. * Set a vec3 array in the shader from a number array.
  17570. * @param name Define the name of the uniform as defined in the shader
  17571. * @param value Define the value to give to the uniform
  17572. * @return the material itself allowing "fluent" like uniform updates
  17573. */
  17574. setArray3(name: string, value: number[]): ShaderMaterial;
  17575. private _checkCache;
  17576. /**
  17577. * Specifies that the submesh is ready to be used
  17578. * @param mesh defines the mesh to check
  17579. * @param subMesh defines which submesh to check
  17580. * @param useInstances specifies that instances should be used
  17581. * @returns a boolean indicating that the submesh is ready or not
  17582. */
  17583. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17584. /**
  17585. * Checks if the material is ready to render the requested mesh
  17586. * @param mesh Define the mesh to render
  17587. * @param useInstances Define whether or not the material is used with instances
  17588. * @returns true if ready, otherwise false
  17589. */
  17590. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17591. /**
  17592. * Binds the world matrix to the material
  17593. * @param world defines the world transformation matrix
  17594. */
  17595. bindOnlyWorldMatrix(world: Matrix): void;
  17596. /**
  17597. * Binds the material to the mesh
  17598. * @param world defines the world transformation matrix
  17599. * @param mesh defines the mesh to bind the material to
  17600. */
  17601. bind(world: Matrix, mesh?: Mesh): void;
  17602. /**
  17603. * Gets the active textures from the material
  17604. * @returns an array of textures
  17605. */
  17606. getActiveTextures(): BaseTexture[];
  17607. /**
  17608. * Specifies if the material uses a texture
  17609. * @param texture defines the texture to check against the material
  17610. * @returns a boolean specifying if the material uses the texture
  17611. */
  17612. hasTexture(texture: BaseTexture): boolean;
  17613. /**
  17614. * Makes a duplicate of the material, and gives it a new name
  17615. * @param name defines the new name for the duplicated material
  17616. * @returns the cloned material
  17617. */
  17618. clone(name: string): ShaderMaterial;
  17619. /**
  17620. * Disposes the material
  17621. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17622. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17623. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17624. */
  17625. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17626. /**
  17627. * Serializes this material in a JSON representation
  17628. * @returns the serialized material object
  17629. */
  17630. serialize(): any;
  17631. /**
  17632. * Creates a shader material from parsed shader material data
  17633. * @param source defines the JSON represnetation of the material
  17634. * @param scene defines the hosting scene
  17635. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17636. * @returns a new material
  17637. */
  17638. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17639. }
  17640. }
  17641. declare module "babylonjs/Shaders/color.fragment" {
  17642. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17643. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17644. /** @hidden */
  17645. export var colorPixelShader: {
  17646. name: string;
  17647. shader: string;
  17648. };
  17649. }
  17650. declare module "babylonjs/Shaders/color.vertex" {
  17651. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17652. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17653. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17654. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17655. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17656. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17657. /** @hidden */
  17658. export var colorVertexShader: {
  17659. name: string;
  17660. shader: string;
  17661. };
  17662. }
  17663. declare module "babylonjs/Meshes/linesMesh" {
  17664. import { Nullable } from "babylonjs/types";
  17665. import { Scene } from "babylonjs/scene";
  17666. import { Color3 } from "babylonjs/Maths/math";
  17667. import { Node } from "babylonjs/node";
  17668. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17669. import { Mesh } from "babylonjs/Meshes/mesh";
  17670. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17671. import { Effect } from "babylonjs/Materials/effect";
  17672. import { Material } from "babylonjs/Materials/material";
  17673. import "babylonjs/Shaders/color.fragment";
  17674. import "babylonjs/Shaders/color.vertex";
  17675. /**
  17676. * Line mesh
  17677. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17678. */
  17679. export class LinesMesh extends Mesh {
  17680. /**
  17681. * If vertex color should be applied to the mesh
  17682. */
  17683. readonly useVertexColor?: boolean | undefined;
  17684. /**
  17685. * If vertex alpha should be applied to the mesh
  17686. */
  17687. readonly useVertexAlpha?: boolean | undefined;
  17688. /**
  17689. * Color of the line (Default: White)
  17690. */
  17691. color: Color3;
  17692. /**
  17693. * Alpha of the line (Default: 1)
  17694. */
  17695. alpha: number;
  17696. /**
  17697. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17698. * This margin is expressed in world space coordinates, so its value may vary.
  17699. * Default value is 0.1
  17700. */
  17701. intersectionThreshold: number;
  17702. private _colorShader;
  17703. private color4;
  17704. /**
  17705. * Creates a new LinesMesh
  17706. * @param name defines the name
  17707. * @param scene defines the hosting scene
  17708. * @param parent defines the parent mesh if any
  17709. * @param source defines the optional source LinesMesh used to clone data from
  17710. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17711. * When false, achieved by calling a clone(), also passing False.
  17712. * This will make creation of children, recursive.
  17713. * @param useVertexColor defines if this LinesMesh supports vertex color
  17714. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17715. */
  17716. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17717. /**
  17718. * If vertex color should be applied to the mesh
  17719. */
  17720. useVertexColor?: boolean | undefined,
  17721. /**
  17722. * If vertex alpha should be applied to the mesh
  17723. */
  17724. useVertexAlpha?: boolean | undefined);
  17725. private _addClipPlaneDefine;
  17726. private _removeClipPlaneDefine;
  17727. isReady(): boolean;
  17728. /**
  17729. * Returns the string "LineMesh"
  17730. */
  17731. getClassName(): string;
  17732. /**
  17733. * @hidden
  17734. */
  17735. /**
  17736. * @hidden
  17737. */
  17738. material: Material;
  17739. /**
  17740. * @hidden
  17741. */
  17742. readonly checkCollisions: boolean;
  17743. /** @hidden */
  17744. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17745. /** @hidden */
  17746. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17747. /**
  17748. * Disposes of the line mesh
  17749. * @param doNotRecurse If children should be disposed
  17750. */
  17751. dispose(doNotRecurse?: boolean): void;
  17752. /**
  17753. * Returns a new LineMesh object cloned from the current one.
  17754. */
  17755. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17756. /**
  17757. * Creates a new InstancedLinesMesh object from the mesh model.
  17758. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17759. * @param name defines the name of the new instance
  17760. * @returns a new InstancedLinesMesh
  17761. */
  17762. createInstance(name: string): InstancedLinesMesh;
  17763. }
  17764. /**
  17765. * Creates an instance based on a source LinesMesh
  17766. */
  17767. export class InstancedLinesMesh extends InstancedMesh {
  17768. /**
  17769. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17770. * This margin is expressed in world space coordinates, so its value may vary.
  17771. * Initilized with the intersectionThreshold value of the source LinesMesh
  17772. */
  17773. intersectionThreshold: number;
  17774. constructor(name: string, source: LinesMesh);
  17775. /**
  17776. * Returns the string "InstancedLinesMesh".
  17777. */
  17778. getClassName(): string;
  17779. }
  17780. }
  17781. declare module "babylonjs/Shaders/line.fragment" {
  17782. /** @hidden */
  17783. export var linePixelShader: {
  17784. name: string;
  17785. shader: string;
  17786. };
  17787. }
  17788. declare module "babylonjs/Shaders/line.vertex" {
  17789. /** @hidden */
  17790. export var lineVertexShader: {
  17791. name: string;
  17792. shader: string;
  17793. };
  17794. }
  17795. declare module "babylonjs/Rendering/edgesRenderer" {
  17796. import { Nullable } from "babylonjs/types";
  17797. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17799. import { Vector3 } from "babylonjs/Maths/math";
  17800. import { IDisposable } from "babylonjs/scene";
  17801. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17802. import "babylonjs/Shaders/line.fragment";
  17803. import "babylonjs/Shaders/line.vertex";
  17804. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17805. module "babylonjs/Meshes/abstractMesh" {
  17806. interface AbstractMesh {
  17807. /**
  17808. * Gets the edgesRenderer associated with the mesh
  17809. */
  17810. edgesRenderer: Nullable<EdgesRenderer>;
  17811. }
  17812. }
  17813. module "babylonjs/Meshes/linesMesh" {
  17814. interface LinesMesh {
  17815. /**
  17816. * Enables the edge rendering mode on the mesh.
  17817. * This mode makes the mesh edges visible
  17818. * @param epsilon defines the maximal distance between two angles to detect a face
  17819. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17820. * @returns the currentAbstractMesh
  17821. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17822. */
  17823. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17824. }
  17825. }
  17826. module "babylonjs/Meshes/linesMesh" {
  17827. interface InstancedLinesMesh {
  17828. /**
  17829. * Enables the edge rendering mode on the mesh.
  17830. * This mode makes the mesh edges visible
  17831. * @param epsilon defines the maximal distance between two angles to detect a face
  17832. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17833. * @returns the current InstancedLinesMesh
  17834. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17835. */
  17836. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17837. }
  17838. }
  17839. /**
  17840. * Defines the minimum contract an Edges renderer should follow.
  17841. */
  17842. export interface IEdgesRenderer extends IDisposable {
  17843. /**
  17844. * Gets or sets a boolean indicating if the edgesRenderer is active
  17845. */
  17846. isEnabled: boolean;
  17847. /**
  17848. * Renders the edges of the attached mesh,
  17849. */
  17850. render(): void;
  17851. /**
  17852. * Checks wether or not the edges renderer is ready to render.
  17853. * @return true if ready, otherwise false.
  17854. */
  17855. isReady(): boolean;
  17856. }
  17857. /**
  17858. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17859. */
  17860. export class EdgesRenderer implements IEdgesRenderer {
  17861. /**
  17862. * Define the size of the edges with an orthographic camera
  17863. */
  17864. edgesWidthScalerForOrthographic: number;
  17865. /**
  17866. * Define the size of the edges with a perspective camera
  17867. */
  17868. edgesWidthScalerForPerspective: number;
  17869. protected _source: AbstractMesh;
  17870. protected _linesPositions: number[];
  17871. protected _linesNormals: number[];
  17872. protected _linesIndices: number[];
  17873. protected _epsilon: number;
  17874. protected _indicesCount: number;
  17875. protected _lineShader: ShaderMaterial;
  17876. protected _ib: DataBuffer;
  17877. protected _buffers: {
  17878. [key: string]: Nullable<VertexBuffer>;
  17879. };
  17880. protected _checkVerticesInsteadOfIndices: boolean;
  17881. private _meshRebuildObserver;
  17882. private _meshDisposeObserver;
  17883. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17884. isEnabled: boolean;
  17885. /**
  17886. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17887. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17888. * @param source Mesh used to create edges
  17889. * @param epsilon sum of angles in adjacency to check for edge
  17890. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17891. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17892. */
  17893. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17894. protected _prepareRessources(): void;
  17895. /** @hidden */
  17896. _rebuild(): void;
  17897. /**
  17898. * Releases the required resources for the edges renderer
  17899. */
  17900. dispose(): void;
  17901. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17902. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17903. /**
  17904. * Checks if the pair of p0 and p1 is en edge
  17905. * @param faceIndex
  17906. * @param edge
  17907. * @param faceNormals
  17908. * @param p0
  17909. * @param p1
  17910. * @private
  17911. */
  17912. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17913. /**
  17914. * push line into the position, normal and index buffer
  17915. * @protected
  17916. */
  17917. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17918. /**
  17919. * Generates lines edges from adjacencjes
  17920. * @private
  17921. */
  17922. _generateEdgesLines(): void;
  17923. /**
  17924. * Checks wether or not the edges renderer is ready to render.
  17925. * @return true if ready, otherwise false.
  17926. */
  17927. isReady(): boolean;
  17928. /**
  17929. * Renders the edges of the attached mesh,
  17930. */
  17931. render(): void;
  17932. }
  17933. /**
  17934. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17935. */
  17936. export class LineEdgesRenderer extends EdgesRenderer {
  17937. /**
  17938. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17939. * @param source LineMesh used to generate edges
  17940. * @param epsilon not important (specified angle for edge detection)
  17941. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17942. */
  17943. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17944. /**
  17945. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17946. */
  17947. _generateEdgesLines(): void;
  17948. }
  17949. }
  17950. declare module "babylonjs/Rendering/renderingGroup" {
  17951. import { SmartArray } from "babylonjs/Misc/smartArray";
  17952. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17954. import { Nullable } from "babylonjs/types";
  17955. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17956. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17957. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17958. import { Material } from "babylonjs/Materials/material";
  17959. import { Scene } from "babylonjs/scene";
  17960. /**
  17961. * This represents the object necessary to create a rendering group.
  17962. * This is exclusively used and created by the rendering manager.
  17963. * To modify the behavior, you use the available helpers in your scene or meshes.
  17964. * @hidden
  17965. */
  17966. export class RenderingGroup {
  17967. index: number;
  17968. private static _zeroVector;
  17969. private _scene;
  17970. private _opaqueSubMeshes;
  17971. private _transparentSubMeshes;
  17972. private _alphaTestSubMeshes;
  17973. private _depthOnlySubMeshes;
  17974. private _particleSystems;
  17975. private _spriteManagers;
  17976. private _opaqueSortCompareFn;
  17977. private _alphaTestSortCompareFn;
  17978. private _transparentSortCompareFn;
  17979. private _renderOpaque;
  17980. private _renderAlphaTest;
  17981. private _renderTransparent;
  17982. /** @hidden */
  17983. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17984. onBeforeTransparentRendering: () => void;
  17985. /**
  17986. * Set the opaque sort comparison function.
  17987. * If null the sub meshes will be render in the order they were created
  17988. */
  17989. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17990. /**
  17991. * Set the alpha test sort comparison function.
  17992. * If null the sub meshes will be render in the order they were created
  17993. */
  17994. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17995. /**
  17996. * Set the transparent sort comparison function.
  17997. * If null the sub meshes will be render in the order they were created
  17998. */
  17999. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  18000. /**
  18001. * Creates a new rendering group.
  18002. * @param index The rendering group index
  18003. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  18004. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  18005. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  18006. */
  18007. 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>);
  18008. /**
  18009. * Render all the sub meshes contained in the group.
  18010. * @param customRenderFunction Used to override the default render behaviour of the group.
  18011. * @returns true if rendered some submeshes.
  18012. */
  18013. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  18014. /**
  18015. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  18016. * @param subMeshes The submeshes to render
  18017. */
  18018. private renderOpaqueSorted;
  18019. /**
  18020. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  18021. * @param subMeshes The submeshes to render
  18022. */
  18023. private renderAlphaTestSorted;
  18024. /**
  18025. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  18026. * @param subMeshes The submeshes to render
  18027. */
  18028. private renderTransparentSorted;
  18029. /**
  18030. * Renders the submeshes in a specified order.
  18031. * @param subMeshes The submeshes to sort before render
  18032. * @param sortCompareFn The comparison function use to sort
  18033. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  18034. * @param transparent Specifies to activate blending if true
  18035. */
  18036. private static renderSorted;
  18037. /**
  18038. * Renders the submeshes in the order they were dispatched (no sort applied).
  18039. * @param subMeshes The submeshes to render
  18040. */
  18041. private static renderUnsorted;
  18042. /**
  18043. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18044. * are rendered back to front if in the same alpha index.
  18045. *
  18046. * @param a The first submesh
  18047. * @param b The second submesh
  18048. * @returns The result of the comparison
  18049. */
  18050. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  18051. /**
  18052. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18053. * are rendered back to front.
  18054. *
  18055. * @param a The first submesh
  18056. * @param b The second submesh
  18057. * @returns The result of the comparison
  18058. */
  18059. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  18060. /**
  18061. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18062. * are rendered front to back (prevent overdraw).
  18063. *
  18064. * @param a The first submesh
  18065. * @param b The second submesh
  18066. * @returns The result of the comparison
  18067. */
  18068. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  18069. /**
  18070. * Resets the different lists of submeshes to prepare a new frame.
  18071. */
  18072. prepare(): void;
  18073. dispose(): void;
  18074. /**
  18075. * Inserts the submesh in its correct queue depending on its material.
  18076. * @param subMesh The submesh to dispatch
  18077. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18078. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18079. */
  18080. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18081. dispatchSprites(spriteManager: ISpriteManager): void;
  18082. dispatchParticles(particleSystem: IParticleSystem): void;
  18083. private _renderParticles;
  18084. private _renderSprites;
  18085. }
  18086. }
  18087. declare module "babylonjs/Rendering/renderingManager" {
  18088. import { Nullable } from "babylonjs/types";
  18089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18090. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18091. import { SmartArray } from "babylonjs/Misc/smartArray";
  18092. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18093. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18094. import { Material } from "babylonjs/Materials/material";
  18095. import { Scene } from "babylonjs/scene";
  18096. import { Camera } from "babylonjs/Cameras/camera";
  18097. /**
  18098. * Interface describing the different options available in the rendering manager
  18099. * regarding Auto Clear between groups.
  18100. */
  18101. export interface IRenderingManagerAutoClearSetup {
  18102. /**
  18103. * Defines whether or not autoclear is enable.
  18104. */
  18105. autoClear: boolean;
  18106. /**
  18107. * Defines whether or not to autoclear the depth buffer.
  18108. */
  18109. depth: boolean;
  18110. /**
  18111. * Defines whether or not to autoclear the stencil buffer.
  18112. */
  18113. stencil: boolean;
  18114. }
  18115. /**
  18116. * This class is used by the onRenderingGroupObservable
  18117. */
  18118. export class RenderingGroupInfo {
  18119. /**
  18120. * The Scene that being rendered
  18121. */
  18122. scene: Scene;
  18123. /**
  18124. * The camera currently used for the rendering pass
  18125. */
  18126. camera: Nullable<Camera>;
  18127. /**
  18128. * The ID of the renderingGroup being processed
  18129. */
  18130. renderingGroupId: number;
  18131. }
  18132. /**
  18133. * This is the manager responsible of all the rendering for meshes sprites and particles.
  18134. * It is enable to manage the different groups as well as the different necessary sort functions.
  18135. * This should not be used directly aside of the few static configurations
  18136. */
  18137. export class RenderingManager {
  18138. /**
  18139. * The max id used for rendering groups (not included)
  18140. */
  18141. static MAX_RENDERINGGROUPS: number;
  18142. /**
  18143. * The min id used for rendering groups (included)
  18144. */
  18145. static MIN_RENDERINGGROUPS: number;
  18146. /**
  18147. * Used to globally prevent autoclearing scenes.
  18148. */
  18149. static AUTOCLEAR: boolean;
  18150. /**
  18151. * @hidden
  18152. */
  18153. _useSceneAutoClearSetup: boolean;
  18154. private _scene;
  18155. private _renderingGroups;
  18156. private _depthStencilBufferAlreadyCleaned;
  18157. private _autoClearDepthStencil;
  18158. private _customOpaqueSortCompareFn;
  18159. private _customAlphaTestSortCompareFn;
  18160. private _customTransparentSortCompareFn;
  18161. private _renderingGroupInfo;
  18162. /**
  18163. * Instantiates a new rendering group for a particular scene
  18164. * @param scene Defines the scene the groups belongs to
  18165. */
  18166. constructor(scene: Scene);
  18167. private _clearDepthStencilBuffer;
  18168. /**
  18169. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  18170. * @hidden
  18171. */
  18172. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18173. /**
  18174. * Resets the different information of the group to prepare a new frame
  18175. * @hidden
  18176. */
  18177. reset(): void;
  18178. /**
  18179. * Dispose and release the group and its associated resources.
  18180. * @hidden
  18181. */
  18182. dispose(): void;
  18183. /**
  18184. * Clear the info related to rendering groups preventing retention points during dispose.
  18185. */
  18186. freeRenderingGroups(): void;
  18187. private _prepareRenderingGroup;
  18188. /**
  18189. * Add a sprite manager to the rendering manager in order to render it this frame.
  18190. * @param spriteManager Define the sprite manager to render
  18191. */
  18192. dispatchSprites(spriteManager: ISpriteManager): void;
  18193. /**
  18194. * Add a particle system to the rendering manager in order to render it this frame.
  18195. * @param particleSystem Define the particle system to render
  18196. */
  18197. dispatchParticles(particleSystem: IParticleSystem): void;
  18198. /**
  18199. * Add a submesh to the manager in order to render it this frame
  18200. * @param subMesh The submesh to dispatch
  18201. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18202. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18203. */
  18204. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18205. /**
  18206. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18207. * This allowed control for front to back rendering or reversly depending of the special needs.
  18208. *
  18209. * @param renderingGroupId The rendering group id corresponding to its index
  18210. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18211. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18212. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18213. */
  18214. 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;
  18215. /**
  18216. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18217. *
  18218. * @param renderingGroupId The rendering group id corresponding to its index
  18219. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18220. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18221. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18222. */
  18223. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18224. /**
  18225. * Gets the current auto clear configuration for one rendering group of the rendering
  18226. * manager.
  18227. * @param index the rendering group index to get the information for
  18228. * @returns The auto clear setup for the requested rendering group
  18229. */
  18230. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18231. }
  18232. }
  18233. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18234. import { Observable } from "babylonjs/Misc/observable";
  18235. import { SmartArray } from "babylonjs/Misc/smartArray";
  18236. import { Nullable } from "babylonjs/types";
  18237. import { Camera } from "babylonjs/Cameras/camera";
  18238. import { Scene } from "babylonjs/scene";
  18239. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18240. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  18241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18242. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18243. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18244. import { Texture } from "babylonjs/Materials/Textures/texture";
  18245. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18246. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18247. import "babylonjs/Engines/Extensions/engine.renderTarget";
  18248. import { Engine } from "babylonjs/Engines/engine";
  18249. /**
  18250. * This Helps creating a texture that will be created from a camera in your scene.
  18251. * It is basically a dynamic texture that could be used to create special effects for instance.
  18252. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18253. */
  18254. export class RenderTargetTexture extends Texture {
  18255. isCube: boolean;
  18256. /**
  18257. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18258. */
  18259. static readonly REFRESHRATE_RENDER_ONCE: number;
  18260. /**
  18261. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18262. */
  18263. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18264. /**
  18265. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18266. * the central point of your effect and can save a lot of performances.
  18267. */
  18268. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18269. /**
  18270. * Use this predicate to dynamically define the list of mesh you want to render.
  18271. * If set, the renderList property will be overwritten.
  18272. */
  18273. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18274. private _renderList;
  18275. /**
  18276. * Use this list to define the list of mesh you want to render.
  18277. */
  18278. renderList: Nullable<Array<AbstractMesh>>;
  18279. private _hookArray;
  18280. /**
  18281. * Define if particles should be rendered in your texture.
  18282. */
  18283. renderParticles: boolean;
  18284. /**
  18285. * Define if sprites should be rendered in your texture.
  18286. */
  18287. renderSprites: boolean;
  18288. /**
  18289. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18290. */
  18291. coordinatesMode: number;
  18292. /**
  18293. * Define the camera used to render the texture.
  18294. */
  18295. activeCamera: Nullable<Camera>;
  18296. /**
  18297. * Override the render function of the texture with your own one.
  18298. */
  18299. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18300. /**
  18301. * Define if camera post processes should be use while rendering the texture.
  18302. */
  18303. useCameraPostProcesses: boolean;
  18304. /**
  18305. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18306. */
  18307. ignoreCameraViewport: boolean;
  18308. private _postProcessManager;
  18309. private _postProcesses;
  18310. private _resizeObserver;
  18311. /**
  18312. * An event triggered when the texture is unbind.
  18313. */
  18314. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18315. /**
  18316. * An event triggered when the texture is unbind.
  18317. */
  18318. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18319. private _onAfterUnbindObserver;
  18320. /**
  18321. * Set a after unbind callback in the texture.
  18322. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18323. */
  18324. onAfterUnbind: () => void;
  18325. /**
  18326. * An event triggered before rendering the texture
  18327. */
  18328. onBeforeRenderObservable: Observable<number>;
  18329. private _onBeforeRenderObserver;
  18330. /**
  18331. * Set a before render callback in the texture.
  18332. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18333. */
  18334. onBeforeRender: (faceIndex: number) => void;
  18335. /**
  18336. * An event triggered after rendering the texture
  18337. */
  18338. onAfterRenderObservable: Observable<number>;
  18339. private _onAfterRenderObserver;
  18340. /**
  18341. * Set a after render callback in the texture.
  18342. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18343. */
  18344. onAfterRender: (faceIndex: number) => void;
  18345. /**
  18346. * An event triggered after the texture clear
  18347. */
  18348. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18349. private _onClearObserver;
  18350. /**
  18351. * Set a clear callback in the texture.
  18352. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18353. */
  18354. onClear: (Engine: Engine) => void;
  18355. /**
  18356. * Define the clear color of the Render Target if it should be different from the scene.
  18357. */
  18358. clearColor: Color4;
  18359. protected _size: number | {
  18360. width: number;
  18361. height: number;
  18362. };
  18363. protected _initialSizeParameter: number | {
  18364. width: number;
  18365. height: number;
  18366. } | {
  18367. ratio: number;
  18368. };
  18369. protected _sizeRatio: Nullable<number>;
  18370. /** @hidden */
  18371. _generateMipMaps: boolean;
  18372. protected _renderingManager: RenderingManager;
  18373. /** @hidden */
  18374. _waitingRenderList: string[];
  18375. protected _doNotChangeAspectRatio: boolean;
  18376. protected _currentRefreshId: number;
  18377. protected _refreshRate: number;
  18378. protected _textureMatrix: Matrix;
  18379. protected _samples: number;
  18380. protected _renderTargetOptions: RenderTargetCreationOptions;
  18381. /**
  18382. * Gets render target creation options that were used.
  18383. */
  18384. readonly renderTargetOptions: RenderTargetCreationOptions;
  18385. protected _engine: Engine;
  18386. protected _onRatioRescale(): void;
  18387. /**
  18388. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18389. * It must define where the camera used to render the texture is set
  18390. */
  18391. boundingBoxPosition: Vector3;
  18392. private _boundingBoxSize;
  18393. /**
  18394. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18395. * When defined, the cubemap will switch to local mode
  18396. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18397. * @example https://www.babylonjs-playground.com/#RNASML
  18398. */
  18399. boundingBoxSize: Vector3;
  18400. /**
  18401. * In case the RTT has been created with a depth texture, get the associated
  18402. * depth texture.
  18403. * Otherwise, return null.
  18404. */
  18405. depthStencilTexture: Nullable<InternalTexture>;
  18406. /**
  18407. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18408. * or used a shadow, depth texture...
  18409. * @param name The friendly name of the texture
  18410. * @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)
  18411. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18412. * @param generateMipMaps True if mip maps need to be generated after render.
  18413. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18414. * @param type The type of the buffer in the RTT (int, half float, float...)
  18415. * @param isCube True if a cube texture needs to be created
  18416. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18417. * @param generateDepthBuffer True to generate a depth buffer
  18418. * @param generateStencilBuffer True to generate a stencil buffer
  18419. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18420. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18421. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18422. */
  18423. constructor(name: string, size: number | {
  18424. width: number;
  18425. height: number;
  18426. } | {
  18427. ratio: number;
  18428. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18429. /**
  18430. * Creates a depth stencil texture.
  18431. * This is only available in WebGL 2 or with the depth texture extension available.
  18432. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18433. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18434. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18435. */
  18436. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18437. private _processSizeParameter;
  18438. /**
  18439. * Define the number of samples to use in case of MSAA.
  18440. * It defaults to one meaning no MSAA has been enabled.
  18441. */
  18442. samples: number;
  18443. /**
  18444. * Resets the refresh counter of the texture and start bak from scratch.
  18445. * Could be useful to regenerate the texture if it is setup to render only once.
  18446. */
  18447. resetRefreshCounter(): void;
  18448. /**
  18449. * Define the refresh rate of the texture or the rendering frequency.
  18450. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18451. */
  18452. refreshRate: number;
  18453. /**
  18454. * Adds a post process to the render target rendering passes.
  18455. * @param postProcess define the post process to add
  18456. */
  18457. addPostProcess(postProcess: PostProcess): void;
  18458. /**
  18459. * Clear all the post processes attached to the render target
  18460. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18461. */
  18462. clearPostProcesses(dispose?: boolean): void;
  18463. /**
  18464. * Remove one of the post process from the list of attached post processes to the texture
  18465. * @param postProcess define the post process to remove from the list
  18466. */
  18467. removePostProcess(postProcess: PostProcess): void;
  18468. /** @hidden */
  18469. _shouldRender(): boolean;
  18470. /**
  18471. * Gets the actual render size of the texture.
  18472. * @returns the width of the render size
  18473. */
  18474. getRenderSize(): number;
  18475. /**
  18476. * Gets the actual render width of the texture.
  18477. * @returns the width of the render size
  18478. */
  18479. getRenderWidth(): number;
  18480. /**
  18481. * Gets the actual render height of the texture.
  18482. * @returns the height of the render size
  18483. */
  18484. getRenderHeight(): number;
  18485. /**
  18486. * Get if the texture can be rescaled or not.
  18487. */
  18488. readonly canRescale: boolean;
  18489. /**
  18490. * Resize the texture using a ratio.
  18491. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18492. */
  18493. scale(ratio: number): void;
  18494. /**
  18495. * Get the texture reflection matrix used to rotate/transform the reflection.
  18496. * @returns the reflection matrix
  18497. */
  18498. getReflectionTextureMatrix(): Matrix;
  18499. /**
  18500. * Resize the texture to a new desired size.
  18501. * Be carrefull as it will recreate all the data in the new texture.
  18502. * @param size Define the new size. It can be:
  18503. * - a number for squared texture,
  18504. * - an object containing { width: number, height: number }
  18505. * - or an object containing a ratio { ratio: number }
  18506. */
  18507. resize(size: number | {
  18508. width: number;
  18509. height: number;
  18510. } | {
  18511. ratio: number;
  18512. }): void;
  18513. /**
  18514. * Renders all the objects from the render list into the texture.
  18515. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18516. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18517. */
  18518. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18519. private _bestReflectionRenderTargetDimension;
  18520. /**
  18521. * @hidden
  18522. * @param faceIndex face index to bind to if this is a cubetexture
  18523. */
  18524. _bindFrameBuffer(faceIndex?: number): void;
  18525. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18526. private renderToTarget;
  18527. /**
  18528. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18529. * This allowed control for front to back rendering or reversly depending of the special needs.
  18530. *
  18531. * @param renderingGroupId The rendering group id corresponding to its index
  18532. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18533. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18534. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18535. */
  18536. 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;
  18537. /**
  18538. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18539. *
  18540. * @param renderingGroupId The rendering group id corresponding to its index
  18541. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18542. */
  18543. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18544. /**
  18545. * Clones the texture.
  18546. * @returns the cloned texture
  18547. */
  18548. clone(): RenderTargetTexture;
  18549. /**
  18550. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18551. * @returns The JSON representation of the texture
  18552. */
  18553. serialize(): any;
  18554. /**
  18555. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18556. */
  18557. disposeFramebufferObjects(): void;
  18558. /**
  18559. * Dispose the texture and release its associated resources.
  18560. */
  18561. dispose(): void;
  18562. /** @hidden */
  18563. _rebuild(): void;
  18564. /**
  18565. * Clear the info related to rendering groups preventing retention point in material dispose.
  18566. */
  18567. freeRenderingGroups(): void;
  18568. /**
  18569. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18570. * @returns the view count
  18571. */
  18572. getViewCount(): number;
  18573. }
  18574. }
  18575. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18576. import { Scene } from "babylonjs/scene";
  18577. import { Plane } from "babylonjs/Maths/math";
  18578. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18579. /**
  18580. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18581. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18582. * You can then easily use it as a reflectionTexture on a flat surface.
  18583. * In case the surface is not a plane, please consider relying on reflection probes.
  18584. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18585. */
  18586. export class MirrorTexture extends RenderTargetTexture {
  18587. private scene;
  18588. /**
  18589. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18590. * 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.
  18591. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18592. */
  18593. mirrorPlane: Plane;
  18594. /**
  18595. * Define the blur ratio used to blur the reflection if needed.
  18596. */
  18597. blurRatio: number;
  18598. /**
  18599. * Define the adaptive blur kernel used to blur the reflection if needed.
  18600. * This will autocompute the closest best match for the `blurKernel`
  18601. */
  18602. adaptiveBlurKernel: number;
  18603. /**
  18604. * Define the blur kernel used to blur the reflection if needed.
  18605. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18606. */
  18607. blurKernel: number;
  18608. /**
  18609. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18610. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18611. */
  18612. blurKernelX: number;
  18613. /**
  18614. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18615. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18616. */
  18617. blurKernelY: number;
  18618. private _autoComputeBlurKernel;
  18619. protected _onRatioRescale(): void;
  18620. private _updateGammaSpace;
  18621. private _imageProcessingConfigChangeObserver;
  18622. private _transformMatrix;
  18623. private _mirrorMatrix;
  18624. private _savedViewMatrix;
  18625. private _blurX;
  18626. private _blurY;
  18627. private _adaptiveBlurKernel;
  18628. private _blurKernelX;
  18629. private _blurKernelY;
  18630. private _blurRatio;
  18631. /**
  18632. * Instantiates a Mirror Texture.
  18633. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18634. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18635. * You can then easily use it as a reflectionTexture on a flat surface.
  18636. * In case the surface is not a plane, please consider relying on reflection probes.
  18637. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18638. * @param name
  18639. * @param size
  18640. * @param scene
  18641. * @param generateMipMaps
  18642. * @param type
  18643. * @param samplingMode
  18644. * @param generateDepthBuffer
  18645. */
  18646. constructor(name: string, size: number | {
  18647. width: number;
  18648. height: number;
  18649. } | {
  18650. ratio: number;
  18651. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18652. private _preparePostProcesses;
  18653. /**
  18654. * Clone the mirror texture.
  18655. * @returns the cloned texture
  18656. */
  18657. clone(): MirrorTexture;
  18658. /**
  18659. * Serialize the texture to a JSON representation you could use in Parse later on
  18660. * @returns the serialized JSON representation
  18661. */
  18662. serialize(): any;
  18663. /**
  18664. * Dispose the texture and release its associated resources.
  18665. */
  18666. dispose(): void;
  18667. }
  18668. }
  18669. declare module "babylonjs/Materials/Textures/texture" {
  18670. import { Observable } from "babylonjs/Misc/observable";
  18671. import { Nullable } from "babylonjs/types";
  18672. import { Scene } from "babylonjs/scene";
  18673. import { Matrix } from "babylonjs/Maths/math";
  18674. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18675. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18676. /**
  18677. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18678. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18679. */
  18680. export class Texture extends BaseTexture {
  18681. /** @hidden */
  18682. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18683. /** @hidden */
  18684. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18685. /** @hidden */
  18686. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18687. /** nearest is mag = nearest and min = nearest and mip = linear */
  18688. static readonly NEAREST_SAMPLINGMODE: number;
  18689. /** nearest is mag = nearest and min = nearest and mip = linear */
  18690. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18691. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18692. static readonly BILINEAR_SAMPLINGMODE: number;
  18693. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18694. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18695. /** Trilinear is mag = linear and min = linear and mip = linear */
  18696. static readonly TRILINEAR_SAMPLINGMODE: number;
  18697. /** Trilinear is mag = linear and min = linear and mip = linear */
  18698. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18699. /** mag = nearest and min = nearest and mip = nearest */
  18700. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18701. /** mag = nearest and min = linear and mip = nearest */
  18702. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18703. /** mag = nearest and min = linear and mip = linear */
  18704. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18705. /** mag = nearest and min = linear and mip = none */
  18706. static readonly NEAREST_LINEAR: number;
  18707. /** mag = nearest and min = nearest and mip = none */
  18708. static readonly NEAREST_NEAREST: number;
  18709. /** mag = linear and min = nearest and mip = nearest */
  18710. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18711. /** mag = linear and min = nearest and mip = linear */
  18712. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18713. /** mag = linear and min = linear and mip = none */
  18714. static readonly LINEAR_LINEAR: number;
  18715. /** mag = linear and min = nearest and mip = none */
  18716. static readonly LINEAR_NEAREST: number;
  18717. /** Explicit coordinates mode */
  18718. static readonly EXPLICIT_MODE: number;
  18719. /** Spherical coordinates mode */
  18720. static readonly SPHERICAL_MODE: number;
  18721. /** Planar coordinates mode */
  18722. static readonly PLANAR_MODE: number;
  18723. /** Cubic coordinates mode */
  18724. static readonly CUBIC_MODE: number;
  18725. /** Projection coordinates mode */
  18726. static readonly PROJECTION_MODE: number;
  18727. /** Inverse Cubic coordinates mode */
  18728. static readonly SKYBOX_MODE: number;
  18729. /** Inverse Cubic coordinates mode */
  18730. static readonly INVCUBIC_MODE: number;
  18731. /** Equirectangular coordinates mode */
  18732. static readonly EQUIRECTANGULAR_MODE: number;
  18733. /** Equirectangular Fixed coordinates mode */
  18734. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18735. /** Equirectangular Fixed Mirrored coordinates mode */
  18736. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18737. /** Texture is not repeating outside of 0..1 UVs */
  18738. static readonly CLAMP_ADDRESSMODE: number;
  18739. /** Texture is repeating outside of 0..1 UVs */
  18740. static readonly WRAP_ADDRESSMODE: number;
  18741. /** Texture is repeating and mirrored */
  18742. static readonly MIRROR_ADDRESSMODE: number;
  18743. /**
  18744. * 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
  18745. */
  18746. static UseSerializedUrlIfAny: boolean;
  18747. /**
  18748. * Define the url of the texture.
  18749. */
  18750. url: Nullable<string>;
  18751. /**
  18752. * Define an offset on the texture to offset the u coordinates of the UVs
  18753. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18754. */
  18755. uOffset: number;
  18756. /**
  18757. * Define an offset on the texture to offset the v coordinates of the UVs
  18758. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18759. */
  18760. vOffset: number;
  18761. /**
  18762. * Define an offset on the texture to scale the u coordinates of the UVs
  18763. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18764. */
  18765. uScale: number;
  18766. /**
  18767. * Define an offset on the texture to scale the v coordinates of the UVs
  18768. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18769. */
  18770. vScale: number;
  18771. /**
  18772. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18773. * @see http://doc.babylonjs.com/how_to/more_materials
  18774. */
  18775. uAng: number;
  18776. /**
  18777. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18778. * @see http://doc.babylonjs.com/how_to/more_materials
  18779. */
  18780. vAng: number;
  18781. /**
  18782. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18783. * @see http://doc.babylonjs.com/how_to/more_materials
  18784. */
  18785. wAng: number;
  18786. /**
  18787. * Defines the center of rotation (U)
  18788. */
  18789. uRotationCenter: number;
  18790. /**
  18791. * Defines the center of rotation (V)
  18792. */
  18793. vRotationCenter: number;
  18794. /**
  18795. * Defines the center of rotation (W)
  18796. */
  18797. wRotationCenter: number;
  18798. /**
  18799. * Are mip maps generated for this texture or not.
  18800. */
  18801. readonly noMipmap: boolean;
  18802. /**
  18803. * List of inspectable custom properties (used by the Inspector)
  18804. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18805. */
  18806. inspectableCustomProperties: Nullable<IInspectable[]>;
  18807. private _noMipmap;
  18808. /** @hidden */
  18809. _invertY: boolean;
  18810. private _rowGenerationMatrix;
  18811. private _cachedTextureMatrix;
  18812. private _projectionModeMatrix;
  18813. private _t0;
  18814. private _t1;
  18815. private _t2;
  18816. private _cachedUOffset;
  18817. private _cachedVOffset;
  18818. private _cachedUScale;
  18819. private _cachedVScale;
  18820. private _cachedUAng;
  18821. private _cachedVAng;
  18822. private _cachedWAng;
  18823. private _cachedProjectionMatrixId;
  18824. private _cachedCoordinatesMode;
  18825. /** @hidden */
  18826. protected _initialSamplingMode: number;
  18827. /** @hidden */
  18828. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18829. private _deleteBuffer;
  18830. protected _format: Nullable<number>;
  18831. private _delayedOnLoad;
  18832. private _delayedOnError;
  18833. /**
  18834. * Observable triggered once the texture has been loaded.
  18835. */
  18836. onLoadObservable: Observable<Texture>;
  18837. protected _isBlocking: boolean;
  18838. /**
  18839. * Is the texture preventing material to render while loading.
  18840. * If false, a default texture will be used instead of the loading one during the preparation step.
  18841. */
  18842. isBlocking: boolean;
  18843. /**
  18844. * Get the current sampling mode associated with the texture.
  18845. */
  18846. readonly samplingMode: number;
  18847. /**
  18848. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18849. */
  18850. readonly invertY: boolean;
  18851. /**
  18852. * Instantiates a new texture.
  18853. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18854. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18855. * @param url define the url of the picture to load as a texture
  18856. * @param scene define the scene the texture will belong to
  18857. * @param noMipmap define if the texture will require mip maps or not
  18858. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18859. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18860. * @param onLoad define a callback triggered when the texture has been loaded
  18861. * @param onError define a callback triggered when an error occurred during the loading session
  18862. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18863. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18864. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18865. */
  18866. 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);
  18867. /**
  18868. * Update the url (and optional buffer) of this texture if url was null during construction.
  18869. * @param url the url of the texture
  18870. * @param buffer the buffer of the texture (defaults to null)
  18871. * @param onLoad callback called when the texture is loaded (defaults to null)
  18872. */
  18873. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18874. /**
  18875. * Finish the loading sequence of a texture flagged as delayed load.
  18876. * @hidden
  18877. */
  18878. delayLoad(): void;
  18879. private _prepareRowForTextureGeneration;
  18880. /**
  18881. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18882. * @returns the transform matrix of the texture.
  18883. */
  18884. getTextureMatrix(): Matrix;
  18885. /**
  18886. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18887. * @returns The reflection texture transform
  18888. */
  18889. getReflectionTextureMatrix(): Matrix;
  18890. /**
  18891. * Clones the texture.
  18892. * @returns the cloned texture
  18893. */
  18894. clone(): Texture;
  18895. /**
  18896. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18897. * @returns The JSON representation of the texture
  18898. */
  18899. serialize(): any;
  18900. /**
  18901. * Get the current class name of the texture useful for serialization or dynamic coding.
  18902. * @returns "Texture"
  18903. */
  18904. getClassName(): string;
  18905. /**
  18906. * Dispose the texture and release its associated resources.
  18907. */
  18908. dispose(): void;
  18909. /**
  18910. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18911. * @param parsedTexture Define the JSON representation of the texture
  18912. * @param scene Define the scene the parsed texture should be instantiated in
  18913. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18914. * @returns The parsed texture if successful
  18915. */
  18916. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18917. /**
  18918. * Creates a texture from its base 64 representation.
  18919. * @param data Define the base64 payload without the data: prefix
  18920. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18921. * @param scene Define the scene the texture should belong to
  18922. * @param noMipmap Forces the texture to not create mip map information if true
  18923. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18924. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18925. * @param onLoad define a callback triggered when the texture has been loaded
  18926. * @param onError define a callback triggered when an error occurred during the loading session
  18927. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18928. * @returns the created texture
  18929. */
  18930. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18931. /**
  18932. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18933. * @param data Define the base64 payload without the data: prefix
  18934. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18935. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18936. * @param scene Define the scene the texture should belong to
  18937. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18938. * @param noMipmap Forces the texture to not create mip map information if true
  18939. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18940. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18941. * @param onLoad define a callback triggered when the texture has been loaded
  18942. * @param onError define a callback triggered when an error occurred during the loading session
  18943. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18944. * @returns the created texture
  18945. */
  18946. 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;
  18947. }
  18948. }
  18949. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18950. import { Nullable } from "babylonjs/types";
  18951. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18952. import { Scene } from "babylonjs/scene";
  18953. module "babylonjs/Engines/engine" {
  18954. interface Engine {
  18955. /**
  18956. * Creates a raw texture
  18957. * @param data defines the data to store in the texture
  18958. * @param width defines the width of the texture
  18959. * @param height defines the height of the texture
  18960. * @param format defines the format of the data
  18961. * @param generateMipMaps defines if the engine should generate the mip levels
  18962. * @param invertY defines if data must be stored with Y axis inverted
  18963. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18964. * @param compression defines the compression used (null by default)
  18965. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18966. * @returns the raw texture inside an InternalTexture
  18967. */
  18968. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18969. /**
  18970. * Update a raw texture
  18971. * @param texture defines the texture to update
  18972. * @param data defines the data to store in the texture
  18973. * @param format defines the format of the data
  18974. * @param invertY defines if data must be stored with Y axis inverted
  18975. */
  18976. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18977. /**
  18978. * Update a raw texture
  18979. * @param texture defines the texture to update
  18980. * @param data defines the data to store in the texture
  18981. * @param format defines the format of the data
  18982. * @param invertY defines if data must be stored with Y axis inverted
  18983. * @param compression defines the compression used (null by default)
  18984. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18985. */
  18986. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18987. /**
  18988. * Creates a new raw cube texture
  18989. * @param data defines the array of data to use to create each face
  18990. * @param size defines the size of the textures
  18991. * @param format defines the format of the data
  18992. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18993. * @param generateMipMaps defines if the engine should generate the mip levels
  18994. * @param invertY defines if data must be stored with Y axis inverted
  18995. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18996. * @param compression defines the compression used (null by default)
  18997. * @returns the cube texture as an InternalTexture
  18998. */
  18999. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  19000. /**
  19001. * Update a raw cube texture
  19002. * @param texture defines the texture to udpdate
  19003. * @param data defines the data to store
  19004. * @param format defines the data format
  19005. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19006. * @param invertY defines if data must be stored with Y axis inverted
  19007. */
  19008. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  19009. /**
  19010. * Update a raw cube texture
  19011. * @param texture defines the texture to udpdate
  19012. * @param data defines the data to store
  19013. * @param format defines the data format
  19014. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19015. * @param invertY defines if data must be stored with Y axis inverted
  19016. * @param compression defines the compression used (null by default)
  19017. */
  19018. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  19019. /**
  19020. * Update a raw cube texture
  19021. * @param texture defines the texture to udpdate
  19022. * @param data defines the data to store
  19023. * @param format defines the data format
  19024. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19025. * @param invertY defines if data must be stored with Y axis inverted
  19026. * @param compression defines the compression used (null by default)
  19027. * @param level defines which level of the texture to update
  19028. */
  19029. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  19030. /**
  19031. * Creates a new raw cube texture from a specified url
  19032. * @param url defines the url where the data is located
  19033. * @param scene defines the current scene
  19034. * @param size defines the size of the textures
  19035. * @param format defines the format of the data
  19036. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19037. * @param noMipmap defines if the engine should avoid generating the mip levels
  19038. * @param callback defines a callback used to extract texture data from loaded data
  19039. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19040. * @param onLoad defines a callback called when texture is loaded
  19041. * @param onError defines a callback called if there is an error
  19042. * @returns the cube texture as an InternalTexture
  19043. */
  19044. 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;
  19045. /**
  19046. * Creates a new raw cube texture from a specified url
  19047. * @param url defines the url where the data is located
  19048. * @param scene defines the current scene
  19049. * @param size defines the size of the textures
  19050. * @param format defines the format of the data
  19051. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19052. * @param noMipmap defines if the engine should avoid generating the mip levels
  19053. * @param callback defines a callback used to extract texture data from loaded data
  19054. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19055. * @param onLoad defines a callback called when texture is loaded
  19056. * @param onError defines a callback called if there is an error
  19057. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19058. * @param invertY defines if data must be stored with Y axis inverted
  19059. * @returns the cube texture as an InternalTexture
  19060. */
  19061. 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;
  19062. /**
  19063. * Creates a new raw 3D texture
  19064. * @param data defines the data used to create the texture
  19065. * @param width defines the width of the texture
  19066. * @param height defines the height of the texture
  19067. * @param depth defines the depth of the texture
  19068. * @param format defines the format of the texture
  19069. * @param generateMipMaps defines if the engine must generate mip levels
  19070. * @param invertY defines if data must be stored with Y axis inverted
  19071. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19072. * @param compression defines the compressed used (can be null)
  19073. * @param textureType defines the compressed used (can be null)
  19074. * @returns a new raw 3D texture (stored in an InternalTexture)
  19075. */
  19076. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  19077. /**
  19078. * Update a raw 3D texture
  19079. * @param texture defines the texture to update
  19080. * @param data defines the data to store
  19081. * @param format defines the data format
  19082. * @param invertY defines if data must be stored with Y axis inverted
  19083. */
  19084. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  19085. /**
  19086. * Update a raw 3D texture
  19087. * @param texture defines the texture to update
  19088. * @param data defines the data to store
  19089. * @param format defines the data format
  19090. * @param invertY defines if data must be stored with Y axis inverted
  19091. * @param compression defines the used compression (can be null)
  19092. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  19093. */
  19094. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  19095. }
  19096. }
  19097. }
  19098. declare module "babylonjs/Materials/Textures/rawTexture" {
  19099. import { Scene } from "babylonjs/scene";
  19100. import { Texture } from "babylonjs/Materials/Textures/texture";
  19101. import "babylonjs/Engines/Extensions/engine.rawTexture";
  19102. /**
  19103. * Raw texture can help creating a texture directly from an array of data.
  19104. * This can be super useful if you either get the data from an uncompressed source or
  19105. * if you wish to create your texture pixel by pixel.
  19106. */
  19107. export class RawTexture extends Texture {
  19108. /**
  19109. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19110. */
  19111. format: number;
  19112. private _engine;
  19113. /**
  19114. * Instantiates a new RawTexture.
  19115. * Raw texture can help creating a texture directly from an array of data.
  19116. * This can be super useful if you either get the data from an uncompressed source or
  19117. * if you wish to create your texture pixel by pixel.
  19118. * @param data define the array of data to use to create the texture
  19119. * @param width define the width of the texture
  19120. * @param height define the height of the texture
  19121. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19122. * @param scene define the scene the texture belongs to
  19123. * @param generateMipMaps define whether mip maps should be generated or not
  19124. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19125. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19126. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19127. */
  19128. constructor(data: ArrayBufferView, width: number, height: number,
  19129. /**
  19130. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19131. */
  19132. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  19133. /**
  19134. * Updates the texture underlying data.
  19135. * @param data Define the new data of the texture
  19136. */
  19137. update(data: ArrayBufferView): void;
  19138. /**
  19139. * Creates a luminance texture from some data.
  19140. * @param data Define the texture data
  19141. * @param width Define the width of the texture
  19142. * @param height Define the height of the texture
  19143. * @param scene Define the scene the texture belongs to
  19144. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19145. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19146. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19147. * @returns the luminance texture
  19148. */
  19149. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19150. /**
  19151. * Creates a luminance alpha texture from some data.
  19152. * @param data Define the texture data
  19153. * @param width Define the width of the texture
  19154. * @param height Define the height of the texture
  19155. * @param scene Define the scene the texture belongs to
  19156. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19157. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19158. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19159. * @returns the luminance alpha texture
  19160. */
  19161. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19162. /**
  19163. * Creates an alpha texture from some data.
  19164. * @param data Define the texture data
  19165. * @param width Define the width of the texture
  19166. * @param height Define the height of the texture
  19167. * @param scene Define the scene the texture belongs to
  19168. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19169. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19170. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19171. * @returns the alpha texture
  19172. */
  19173. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19174. /**
  19175. * Creates a RGB texture from some data.
  19176. * @param data Define the texture data
  19177. * @param width Define the width of the texture
  19178. * @param height Define the height of the texture
  19179. * @param scene Define the scene the texture belongs to
  19180. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19181. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19182. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19183. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19184. * @returns the RGB alpha texture
  19185. */
  19186. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19187. /**
  19188. * Creates a RGBA texture from some data.
  19189. * @param data Define the texture data
  19190. * @param width Define the width of the texture
  19191. * @param height Define the height of the texture
  19192. * @param scene Define the scene the texture belongs to
  19193. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19194. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19195. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19196. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19197. * @returns the RGBA texture
  19198. */
  19199. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19200. /**
  19201. * Creates a R texture from some data.
  19202. * @param data Define the texture data
  19203. * @param width Define the width of the texture
  19204. * @param height Define the height of the texture
  19205. * @param scene Define the scene the texture belongs to
  19206. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19207. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19208. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19209. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19210. * @returns the R texture
  19211. */
  19212. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19213. }
  19214. }
  19215. declare module "babylonjs/Animations/runtimeAnimation" {
  19216. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  19217. import { Animatable } from "babylonjs/Animations/animatable";
  19218. import { Scene } from "babylonjs/scene";
  19219. /**
  19220. * Defines a runtime animation
  19221. */
  19222. export class RuntimeAnimation {
  19223. private _events;
  19224. /**
  19225. * The current frame of the runtime animation
  19226. */
  19227. private _currentFrame;
  19228. /**
  19229. * The animation used by the runtime animation
  19230. */
  19231. private _animation;
  19232. /**
  19233. * The target of the runtime animation
  19234. */
  19235. private _target;
  19236. /**
  19237. * The initiating animatable
  19238. */
  19239. private _host;
  19240. /**
  19241. * The original value of the runtime animation
  19242. */
  19243. private _originalValue;
  19244. /**
  19245. * The original blend value of the runtime animation
  19246. */
  19247. private _originalBlendValue;
  19248. /**
  19249. * The offsets cache of the runtime animation
  19250. */
  19251. private _offsetsCache;
  19252. /**
  19253. * The high limits cache of the runtime animation
  19254. */
  19255. private _highLimitsCache;
  19256. /**
  19257. * Specifies if the runtime animation has been stopped
  19258. */
  19259. private _stopped;
  19260. /**
  19261. * The blending factor of the runtime animation
  19262. */
  19263. private _blendingFactor;
  19264. /**
  19265. * The BabylonJS scene
  19266. */
  19267. private _scene;
  19268. /**
  19269. * The current value of the runtime animation
  19270. */
  19271. private _currentValue;
  19272. /** @hidden */
  19273. _animationState: _IAnimationState;
  19274. /**
  19275. * The active target of the runtime animation
  19276. */
  19277. private _activeTargets;
  19278. private _currentActiveTarget;
  19279. private _directTarget;
  19280. /**
  19281. * The target path of the runtime animation
  19282. */
  19283. private _targetPath;
  19284. /**
  19285. * The weight of the runtime animation
  19286. */
  19287. private _weight;
  19288. /**
  19289. * The ratio offset of the runtime animation
  19290. */
  19291. private _ratioOffset;
  19292. /**
  19293. * The previous delay of the runtime animation
  19294. */
  19295. private _previousDelay;
  19296. /**
  19297. * The previous ratio of the runtime animation
  19298. */
  19299. private _previousRatio;
  19300. private _enableBlending;
  19301. private _keys;
  19302. private _minFrame;
  19303. private _maxFrame;
  19304. private _minValue;
  19305. private _maxValue;
  19306. private _targetIsArray;
  19307. /**
  19308. * Gets the current frame of the runtime animation
  19309. */
  19310. readonly currentFrame: number;
  19311. /**
  19312. * Gets the weight of the runtime animation
  19313. */
  19314. readonly weight: number;
  19315. /**
  19316. * Gets the current value of the runtime animation
  19317. */
  19318. readonly currentValue: any;
  19319. /**
  19320. * Gets the target path of the runtime animation
  19321. */
  19322. readonly targetPath: string;
  19323. /**
  19324. * Gets the actual target of the runtime animation
  19325. */
  19326. readonly target: any;
  19327. /** @hidden */
  19328. _onLoop: () => void;
  19329. /**
  19330. * Create a new RuntimeAnimation object
  19331. * @param target defines the target of the animation
  19332. * @param animation defines the source animation object
  19333. * @param scene defines the hosting scene
  19334. * @param host defines the initiating Animatable
  19335. */
  19336. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19337. private _preparePath;
  19338. /**
  19339. * Gets the animation from the runtime animation
  19340. */
  19341. readonly animation: Animation;
  19342. /**
  19343. * Resets the runtime animation to the beginning
  19344. * @param restoreOriginal defines whether to restore the target property to the original value
  19345. */
  19346. reset(restoreOriginal?: boolean): void;
  19347. /**
  19348. * Specifies if the runtime animation is stopped
  19349. * @returns Boolean specifying if the runtime animation is stopped
  19350. */
  19351. isStopped(): boolean;
  19352. /**
  19353. * Disposes of the runtime animation
  19354. */
  19355. dispose(): void;
  19356. /**
  19357. * Apply the interpolated value to the target
  19358. * @param currentValue defines the value computed by the animation
  19359. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19360. */
  19361. setValue(currentValue: any, weight: number): void;
  19362. private _getOriginalValues;
  19363. private _setValue;
  19364. /**
  19365. * Gets the loop pmode of the runtime animation
  19366. * @returns Loop Mode
  19367. */
  19368. private _getCorrectLoopMode;
  19369. /**
  19370. * Move the current animation to a given frame
  19371. * @param frame defines the frame to move to
  19372. */
  19373. goToFrame(frame: number): void;
  19374. /**
  19375. * @hidden Internal use only
  19376. */
  19377. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19378. /**
  19379. * Execute the current animation
  19380. * @param delay defines the delay to add to the current frame
  19381. * @param from defines the lower bound of the animation range
  19382. * @param to defines the upper bound of the animation range
  19383. * @param loop defines if the current animation must loop
  19384. * @param speedRatio defines the current speed ratio
  19385. * @param weight defines the weight of the animation (default is -1 so no weight)
  19386. * @param onLoop optional callback called when animation loops
  19387. * @returns a boolean indicating if the animation is running
  19388. */
  19389. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19390. }
  19391. }
  19392. declare module "babylonjs/Animations/animatable" {
  19393. import { Animation } from "babylonjs/Animations/animation";
  19394. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19395. import { Nullable } from "babylonjs/types";
  19396. import { Observable } from "babylonjs/Misc/observable";
  19397. import { Scene } from "babylonjs/scene";
  19398. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19399. import { Node } from "babylonjs/node";
  19400. /**
  19401. * Class used to store an actual running animation
  19402. */
  19403. export class Animatable {
  19404. /** defines the target object */
  19405. target: any;
  19406. /** defines the starting frame number (default is 0) */
  19407. fromFrame: number;
  19408. /** defines the ending frame number (default is 100) */
  19409. toFrame: number;
  19410. /** defines if the animation must loop (default is false) */
  19411. loopAnimation: boolean;
  19412. /** defines a callback to call when animation ends if it is not looping */
  19413. onAnimationEnd?: (() => void) | null | undefined;
  19414. /** defines a callback to call when animation loops */
  19415. onAnimationLoop?: (() => void) | null | undefined;
  19416. private _localDelayOffset;
  19417. private _pausedDelay;
  19418. private _runtimeAnimations;
  19419. private _paused;
  19420. private _scene;
  19421. private _speedRatio;
  19422. private _weight;
  19423. private _syncRoot;
  19424. /**
  19425. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19426. * This will only apply for non looping animation (default is true)
  19427. */
  19428. disposeOnEnd: boolean;
  19429. /**
  19430. * Gets a boolean indicating if the animation has started
  19431. */
  19432. animationStarted: boolean;
  19433. /**
  19434. * Observer raised when the animation ends
  19435. */
  19436. onAnimationEndObservable: Observable<Animatable>;
  19437. /**
  19438. * Observer raised when the animation loops
  19439. */
  19440. onAnimationLoopObservable: Observable<Animatable>;
  19441. /**
  19442. * Gets the root Animatable used to synchronize and normalize animations
  19443. */
  19444. readonly syncRoot: Nullable<Animatable>;
  19445. /**
  19446. * Gets the current frame of the first RuntimeAnimation
  19447. * Used to synchronize Animatables
  19448. */
  19449. readonly masterFrame: number;
  19450. /**
  19451. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19452. */
  19453. weight: number;
  19454. /**
  19455. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19456. */
  19457. speedRatio: number;
  19458. /**
  19459. * Creates a new Animatable
  19460. * @param scene defines the hosting scene
  19461. * @param target defines the target object
  19462. * @param fromFrame defines the starting frame number (default is 0)
  19463. * @param toFrame defines the ending frame number (default is 100)
  19464. * @param loopAnimation defines if the animation must loop (default is false)
  19465. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19466. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19467. * @param animations defines a group of animation to add to the new Animatable
  19468. * @param onAnimationLoop defines a callback to call when animation loops
  19469. */
  19470. constructor(scene: Scene,
  19471. /** defines the target object */
  19472. target: any,
  19473. /** defines the starting frame number (default is 0) */
  19474. fromFrame?: number,
  19475. /** defines the ending frame number (default is 100) */
  19476. toFrame?: number,
  19477. /** defines if the animation must loop (default is false) */
  19478. loopAnimation?: boolean, speedRatio?: number,
  19479. /** defines a callback to call when animation ends if it is not looping */
  19480. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19481. /** defines a callback to call when animation loops */
  19482. onAnimationLoop?: (() => void) | null | undefined);
  19483. /**
  19484. * Synchronize and normalize current Animatable with a source Animatable
  19485. * This is useful when using animation weights and when animations are not of the same length
  19486. * @param root defines the root Animatable to synchronize with
  19487. * @returns the current Animatable
  19488. */
  19489. syncWith(root: Animatable): Animatable;
  19490. /**
  19491. * Gets the list of runtime animations
  19492. * @returns an array of RuntimeAnimation
  19493. */
  19494. getAnimations(): RuntimeAnimation[];
  19495. /**
  19496. * Adds more animations to the current animatable
  19497. * @param target defines the target of the animations
  19498. * @param animations defines the new animations to add
  19499. */
  19500. appendAnimations(target: any, animations: Animation[]): void;
  19501. /**
  19502. * Gets the source animation for a specific property
  19503. * @param property defines the propertyu to look for
  19504. * @returns null or the source animation for the given property
  19505. */
  19506. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19507. /**
  19508. * Gets the runtime animation for a specific property
  19509. * @param property defines the propertyu to look for
  19510. * @returns null or the runtime animation for the given property
  19511. */
  19512. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19513. /**
  19514. * Resets the animatable to its original state
  19515. */
  19516. reset(): void;
  19517. /**
  19518. * Allows the animatable to blend with current running animations
  19519. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19520. * @param blendingSpeed defines the blending speed to use
  19521. */
  19522. enableBlending(blendingSpeed: number): void;
  19523. /**
  19524. * Disable animation blending
  19525. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19526. */
  19527. disableBlending(): void;
  19528. /**
  19529. * Jump directly to a given frame
  19530. * @param frame defines the frame to jump to
  19531. */
  19532. goToFrame(frame: number): void;
  19533. /**
  19534. * Pause the animation
  19535. */
  19536. pause(): void;
  19537. /**
  19538. * Restart the animation
  19539. */
  19540. restart(): void;
  19541. private _raiseOnAnimationEnd;
  19542. /**
  19543. * Stop and delete the current animation
  19544. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19545. * @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)
  19546. */
  19547. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19548. /**
  19549. * Wait asynchronously for the animation to end
  19550. * @returns a promise which will be fullfilled when the animation ends
  19551. */
  19552. waitAsync(): Promise<Animatable>;
  19553. /** @hidden */
  19554. _animate(delay: number): boolean;
  19555. }
  19556. module "babylonjs/scene" {
  19557. interface Scene {
  19558. /** @hidden */
  19559. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19560. /** @hidden */
  19561. _processLateAnimationBindingsForMatrices(holder: {
  19562. totalWeight: number;
  19563. animations: RuntimeAnimation[];
  19564. originalValue: Matrix;
  19565. }): any;
  19566. /** @hidden */
  19567. _processLateAnimationBindingsForQuaternions(holder: {
  19568. totalWeight: number;
  19569. animations: RuntimeAnimation[];
  19570. originalValue: Quaternion;
  19571. }, refQuaternion: Quaternion): Quaternion;
  19572. /** @hidden */
  19573. _processLateAnimationBindings(): void;
  19574. /**
  19575. * Will start the animation sequence of a given target
  19576. * @param target defines the target
  19577. * @param from defines from which frame should animation start
  19578. * @param to defines until which frame should animation run.
  19579. * @param weight defines the weight to apply to the animation (1.0 by default)
  19580. * @param loop defines if the animation loops
  19581. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19582. * @param onAnimationEnd defines the function to be executed when the animation ends
  19583. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19584. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19585. * @param onAnimationLoop defines the callback to call when an animation loops
  19586. * @returns the animatable object created for this animation
  19587. */
  19588. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19589. /**
  19590. * Will start the animation sequence of a given target
  19591. * @param target defines the target
  19592. * @param from defines from which frame should animation start
  19593. * @param to defines until which frame should animation run.
  19594. * @param loop defines if the animation loops
  19595. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19596. * @param onAnimationEnd defines the function to be executed when the animation ends
  19597. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19598. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19599. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19600. * @param onAnimationLoop defines the callback to call when an animation loops
  19601. * @returns the animatable object created for this animation
  19602. */
  19603. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19604. /**
  19605. * Will start the animation sequence of a given target and its hierarchy
  19606. * @param target defines the target
  19607. * @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.
  19608. * @param from defines from which frame should animation start
  19609. * @param to defines until which frame should animation run.
  19610. * @param loop defines if the animation loops
  19611. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19612. * @param onAnimationEnd defines the function to be executed when the animation ends
  19613. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19614. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19615. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19616. * @param onAnimationLoop defines the callback to call when an animation loops
  19617. * @returns the list of created animatables
  19618. */
  19619. 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[];
  19620. /**
  19621. * Begin a new animation on a given node
  19622. * @param target defines the target where the animation will take place
  19623. * @param animations defines the list of animations to start
  19624. * @param from defines the initial value
  19625. * @param to defines the final value
  19626. * @param loop defines if you want animation to loop (off by default)
  19627. * @param speedRatio defines the speed ratio to apply to all animations
  19628. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19629. * @param onAnimationLoop defines the callback to call when an animation loops
  19630. * @returns the list of created animatables
  19631. */
  19632. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19633. /**
  19634. * Begin a new animation on a given node and its hierarchy
  19635. * @param target defines the root node where the animation will take place
  19636. * @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.
  19637. * @param animations defines the list of animations to start
  19638. * @param from defines the initial value
  19639. * @param to defines the final value
  19640. * @param loop defines if you want animation to loop (off by default)
  19641. * @param speedRatio defines the speed ratio to apply to all animations
  19642. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19643. * @param onAnimationLoop defines the callback to call when an animation loops
  19644. * @returns the list of animatables created for all nodes
  19645. */
  19646. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19647. /**
  19648. * Gets the animatable associated with a specific target
  19649. * @param target defines the target of the animatable
  19650. * @returns the required animatable if found
  19651. */
  19652. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19653. /**
  19654. * Gets all animatables associated with a given target
  19655. * @param target defines the target to look animatables for
  19656. * @returns an array of Animatables
  19657. */
  19658. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19659. /**
  19660. * Stops and removes all animations that have been applied to the scene
  19661. */
  19662. stopAllAnimations(): void;
  19663. }
  19664. }
  19665. module "babylonjs/Bones/bone" {
  19666. interface Bone {
  19667. /**
  19668. * Copy an animation range from another bone
  19669. * @param source defines the source bone
  19670. * @param rangeName defines the range name to copy
  19671. * @param frameOffset defines the frame offset
  19672. * @param rescaleAsRequired defines if rescaling must be applied if required
  19673. * @param skelDimensionsRatio defines the scaling ratio
  19674. * @returns true if operation was successful
  19675. */
  19676. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19677. }
  19678. }
  19679. }
  19680. declare module "babylonjs/Bones/skeleton" {
  19681. import { Bone } from "babylonjs/Bones/bone";
  19682. import { IAnimatable } from "babylonjs/Misc/tools";
  19683. import { Observable } from "babylonjs/Misc/observable";
  19684. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19685. import { Scene } from "babylonjs/scene";
  19686. import { Nullable } from "babylonjs/types";
  19687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19688. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19689. import { Animatable } from "babylonjs/Animations/animatable";
  19690. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19691. import { Animation } from "babylonjs/Animations/animation";
  19692. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19693. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19694. /**
  19695. * Class used to handle skinning animations
  19696. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19697. */
  19698. export class Skeleton implements IAnimatable {
  19699. /** defines the skeleton name */
  19700. name: string;
  19701. /** defines the skeleton Id */
  19702. id: string;
  19703. /**
  19704. * Defines the list of child bones
  19705. */
  19706. bones: Bone[];
  19707. /**
  19708. * Defines an estimate of the dimension of the skeleton at rest
  19709. */
  19710. dimensionsAtRest: Vector3;
  19711. /**
  19712. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19713. */
  19714. needInitialSkinMatrix: boolean;
  19715. /**
  19716. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19717. */
  19718. overrideMesh: Nullable<AbstractMesh>;
  19719. /**
  19720. * Gets the list of animations attached to this skeleton
  19721. */
  19722. animations: Array<Animation>;
  19723. private _scene;
  19724. private _isDirty;
  19725. private _transformMatrices;
  19726. private _transformMatrixTexture;
  19727. private _meshesWithPoseMatrix;
  19728. private _animatables;
  19729. private _identity;
  19730. private _synchronizedWithMesh;
  19731. private _ranges;
  19732. private _lastAbsoluteTransformsUpdateId;
  19733. private _canUseTextureForBones;
  19734. private _uniqueId;
  19735. /** @hidden */
  19736. _numBonesWithLinkedTransformNode: number;
  19737. /** @hidden */
  19738. _hasWaitingData: Nullable<boolean>;
  19739. /**
  19740. * Specifies if the skeleton should be serialized
  19741. */
  19742. doNotSerialize: boolean;
  19743. private _useTextureToStoreBoneMatrices;
  19744. /**
  19745. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19746. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19747. */
  19748. useTextureToStoreBoneMatrices: boolean;
  19749. private _animationPropertiesOverride;
  19750. /**
  19751. * Gets or sets the animation properties override
  19752. */
  19753. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19754. /**
  19755. * List of inspectable custom properties (used by the Inspector)
  19756. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19757. */
  19758. inspectableCustomProperties: IInspectable[];
  19759. /**
  19760. * An observable triggered before computing the skeleton's matrices
  19761. */
  19762. onBeforeComputeObservable: Observable<Skeleton>;
  19763. /**
  19764. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19765. */
  19766. readonly isUsingTextureForMatrices: boolean;
  19767. /**
  19768. * Gets the unique ID of this skeleton
  19769. */
  19770. readonly uniqueId: number;
  19771. /**
  19772. * Creates a new skeleton
  19773. * @param name defines the skeleton name
  19774. * @param id defines the skeleton Id
  19775. * @param scene defines the hosting scene
  19776. */
  19777. constructor(
  19778. /** defines the skeleton name */
  19779. name: string,
  19780. /** defines the skeleton Id */
  19781. id: string, scene: Scene);
  19782. /**
  19783. * Gets the current object class name.
  19784. * @return the class name
  19785. */
  19786. getClassName(): string;
  19787. /**
  19788. * Returns an array containing the root bones
  19789. * @returns an array containing the root bones
  19790. */
  19791. getChildren(): Array<Bone>;
  19792. /**
  19793. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19794. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19795. * @returns a Float32Array containing matrices data
  19796. */
  19797. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19798. /**
  19799. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19800. * @returns a raw texture containing the data
  19801. */
  19802. getTransformMatrixTexture(): Nullable<RawTexture>;
  19803. /**
  19804. * Gets the current hosting scene
  19805. * @returns a scene object
  19806. */
  19807. getScene(): Scene;
  19808. /**
  19809. * Gets a string representing the current skeleton data
  19810. * @param fullDetails defines a boolean indicating if we want a verbose version
  19811. * @returns a string representing the current skeleton data
  19812. */
  19813. toString(fullDetails?: boolean): string;
  19814. /**
  19815. * Get bone's index searching by name
  19816. * @param name defines bone's name to search for
  19817. * @return the indice of the bone. Returns -1 if not found
  19818. */
  19819. getBoneIndexByName(name: string): number;
  19820. /**
  19821. * Creater a new animation range
  19822. * @param name defines the name of the range
  19823. * @param from defines the start key
  19824. * @param to defines the end key
  19825. */
  19826. createAnimationRange(name: string, from: number, to: number): void;
  19827. /**
  19828. * Delete a specific animation range
  19829. * @param name defines the name of the range
  19830. * @param deleteFrames defines if frames must be removed as well
  19831. */
  19832. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19833. /**
  19834. * Gets a specific animation range
  19835. * @param name defines the name of the range to look for
  19836. * @returns the requested animation range or null if not found
  19837. */
  19838. getAnimationRange(name: string): Nullable<AnimationRange>;
  19839. /**
  19840. * Gets the list of all animation ranges defined on this skeleton
  19841. * @returns an array
  19842. */
  19843. getAnimationRanges(): Nullable<AnimationRange>[];
  19844. /**
  19845. * Copy animation range from a source skeleton.
  19846. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19847. * @param source defines the source skeleton
  19848. * @param name defines the name of the range to copy
  19849. * @param rescaleAsRequired defines if rescaling must be applied if required
  19850. * @returns true if operation was successful
  19851. */
  19852. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19853. /**
  19854. * Forces the skeleton to go to rest pose
  19855. */
  19856. returnToRest(): void;
  19857. private _getHighestAnimationFrame;
  19858. /**
  19859. * Begin a specific animation range
  19860. * @param name defines the name of the range to start
  19861. * @param loop defines if looping must be turned on (false by default)
  19862. * @param speedRatio defines the speed ratio to apply (1 by default)
  19863. * @param onAnimationEnd defines a callback which will be called when animation will end
  19864. * @returns a new animatable
  19865. */
  19866. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19867. /** @hidden */
  19868. _markAsDirty(): void;
  19869. /** @hidden */
  19870. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19871. /** @hidden */
  19872. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19873. private _computeTransformMatrices;
  19874. /**
  19875. * Build all resources required to render a skeleton
  19876. */
  19877. prepare(): void;
  19878. /**
  19879. * Gets the list of animatables currently running for this skeleton
  19880. * @returns an array of animatables
  19881. */
  19882. getAnimatables(): IAnimatable[];
  19883. /**
  19884. * Clone the current skeleton
  19885. * @param name defines the name of the new skeleton
  19886. * @param id defines the id of the new skeleton
  19887. * @returns the new skeleton
  19888. */
  19889. clone(name: string, id: string): Skeleton;
  19890. /**
  19891. * Enable animation blending for this skeleton
  19892. * @param blendingSpeed defines the blending speed to apply
  19893. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19894. */
  19895. enableBlending(blendingSpeed?: number): void;
  19896. /**
  19897. * Releases all resources associated with the current skeleton
  19898. */
  19899. dispose(): void;
  19900. /**
  19901. * Serialize the skeleton in a JSON object
  19902. * @returns a JSON object
  19903. */
  19904. serialize(): any;
  19905. /**
  19906. * Creates a new skeleton from serialized data
  19907. * @param parsedSkeleton defines the serialized data
  19908. * @param scene defines the hosting scene
  19909. * @returns a new skeleton
  19910. */
  19911. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19912. /**
  19913. * Compute all node absolute transforms
  19914. * @param forceUpdate defines if computation must be done even if cache is up to date
  19915. */
  19916. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19917. /**
  19918. * Gets the root pose matrix
  19919. * @returns a matrix
  19920. */
  19921. getPoseMatrix(): Nullable<Matrix>;
  19922. /**
  19923. * Sorts bones per internal index
  19924. */
  19925. sortBones(): void;
  19926. private _sortBones;
  19927. }
  19928. }
  19929. declare module "babylonjs/Morph/morphTarget" {
  19930. import { IAnimatable } from "babylonjs/Misc/tools";
  19931. import { Observable } from "babylonjs/Misc/observable";
  19932. import { Nullable, FloatArray } from "babylonjs/types";
  19933. import { Scene } from "babylonjs/scene";
  19934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19935. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19936. /**
  19937. * Defines a target to use with MorphTargetManager
  19938. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19939. */
  19940. export class MorphTarget implements IAnimatable {
  19941. /** defines the name of the target */
  19942. name: string;
  19943. /**
  19944. * Gets or sets the list of animations
  19945. */
  19946. animations: import("babylonjs/Animations/animation").Animation[];
  19947. private _scene;
  19948. private _positions;
  19949. private _normals;
  19950. private _tangents;
  19951. private _influence;
  19952. /**
  19953. * Observable raised when the influence changes
  19954. */
  19955. onInfluenceChanged: Observable<boolean>;
  19956. /** @hidden */
  19957. _onDataLayoutChanged: Observable<void>;
  19958. /**
  19959. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19960. */
  19961. influence: number;
  19962. /**
  19963. * Gets or sets the id of the morph Target
  19964. */
  19965. id: string;
  19966. private _animationPropertiesOverride;
  19967. /**
  19968. * Gets or sets the animation properties override
  19969. */
  19970. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19971. /**
  19972. * Creates a new MorphTarget
  19973. * @param name defines the name of the target
  19974. * @param influence defines the influence to use
  19975. * @param scene defines the scene the morphtarget belongs to
  19976. */
  19977. constructor(
  19978. /** defines the name of the target */
  19979. name: string, influence?: number, scene?: Nullable<Scene>);
  19980. /**
  19981. * Gets a boolean defining if the target contains position data
  19982. */
  19983. readonly hasPositions: boolean;
  19984. /**
  19985. * Gets a boolean defining if the target contains normal data
  19986. */
  19987. readonly hasNormals: boolean;
  19988. /**
  19989. * Gets a boolean defining if the target contains tangent data
  19990. */
  19991. readonly hasTangents: boolean;
  19992. /**
  19993. * Affects position data to this target
  19994. * @param data defines the position data to use
  19995. */
  19996. setPositions(data: Nullable<FloatArray>): void;
  19997. /**
  19998. * Gets the position data stored in this target
  19999. * @returns a FloatArray containing the position data (or null if not present)
  20000. */
  20001. getPositions(): Nullable<FloatArray>;
  20002. /**
  20003. * Affects normal data to this target
  20004. * @param data defines the normal data to use
  20005. */
  20006. setNormals(data: Nullable<FloatArray>): void;
  20007. /**
  20008. * Gets the normal data stored in this target
  20009. * @returns a FloatArray containing the normal data (or null if not present)
  20010. */
  20011. getNormals(): Nullable<FloatArray>;
  20012. /**
  20013. * Affects tangent data to this target
  20014. * @param data defines the tangent data to use
  20015. */
  20016. setTangents(data: Nullable<FloatArray>): void;
  20017. /**
  20018. * Gets the tangent data stored in this target
  20019. * @returns a FloatArray containing the tangent data (or null if not present)
  20020. */
  20021. getTangents(): Nullable<FloatArray>;
  20022. /**
  20023. * Serializes the current target into a Serialization object
  20024. * @returns the serialized object
  20025. */
  20026. serialize(): any;
  20027. /**
  20028. * Returns the string "MorphTarget"
  20029. * @returns "MorphTarget"
  20030. */
  20031. getClassName(): string;
  20032. /**
  20033. * Creates a new target from serialized data
  20034. * @param serializationObject defines the serialized data to use
  20035. * @returns a new MorphTarget
  20036. */
  20037. static Parse(serializationObject: any): MorphTarget;
  20038. /**
  20039. * Creates a MorphTarget from mesh data
  20040. * @param mesh defines the source mesh
  20041. * @param name defines the name to use for the new target
  20042. * @param influence defines the influence to attach to the target
  20043. * @returns a new MorphTarget
  20044. */
  20045. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  20046. }
  20047. }
  20048. declare module "babylonjs/Morph/morphTargetManager" {
  20049. import { Nullable } from "babylonjs/types";
  20050. import { Scene } from "babylonjs/scene";
  20051. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  20052. /**
  20053. * This class is used to deform meshes using morphing between different targets
  20054. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20055. */
  20056. export class MorphTargetManager {
  20057. private _targets;
  20058. private _targetInfluenceChangedObservers;
  20059. private _targetDataLayoutChangedObservers;
  20060. private _activeTargets;
  20061. private _scene;
  20062. private _influences;
  20063. private _supportsNormals;
  20064. private _supportsTangents;
  20065. private _vertexCount;
  20066. private _uniqueId;
  20067. private _tempInfluences;
  20068. /**
  20069. * Creates a new MorphTargetManager
  20070. * @param scene defines the current scene
  20071. */
  20072. constructor(scene?: Nullable<Scene>);
  20073. /**
  20074. * Gets the unique ID of this manager
  20075. */
  20076. readonly uniqueId: number;
  20077. /**
  20078. * Gets the number of vertices handled by this manager
  20079. */
  20080. readonly vertexCount: number;
  20081. /**
  20082. * Gets a boolean indicating if this manager supports morphing of normals
  20083. */
  20084. readonly supportsNormals: boolean;
  20085. /**
  20086. * Gets a boolean indicating if this manager supports morphing of tangents
  20087. */
  20088. readonly supportsTangents: boolean;
  20089. /**
  20090. * Gets the number of targets stored in this manager
  20091. */
  20092. readonly numTargets: number;
  20093. /**
  20094. * Gets the number of influencers (ie. the number of targets with influences > 0)
  20095. */
  20096. readonly numInfluencers: number;
  20097. /**
  20098. * Gets the list of influences (one per target)
  20099. */
  20100. readonly influences: Float32Array;
  20101. /**
  20102. * Gets the active target at specified index. An active target is a target with an influence > 0
  20103. * @param index defines the index to check
  20104. * @returns the requested target
  20105. */
  20106. getActiveTarget(index: number): MorphTarget;
  20107. /**
  20108. * Gets the target at specified index
  20109. * @param index defines the index to check
  20110. * @returns the requested target
  20111. */
  20112. getTarget(index: number): MorphTarget;
  20113. /**
  20114. * Add a new target to this manager
  20115. * @param target defines the target to add
  20116. */
  20117. addTarget(target: MorphTarget): void;
  20118. /**
  20119. * Removes a target from the manager
  20120. * @param target defines the target to remove
  20121. */
  20122. removeTarget(target: MorphTarget): void;
  20123. /**
  20124. * Serializes the current manager into a Serialization object
  20125. * @returns the serialized object
  20126. */
  20127. serialize(): any;
  20128. private _syncActiveTargets;
  20129. /**
  20130. * Syncrhonize the targets with all the meshes using this morph target manager
  20131. */
  20132. synchronize(): void;
  20133. /**
  20134. * Creates a new MorphTargetManager from serialized data
  20135. * @param serializationObject defines the serialized data
  20136. * @param scene defines the hosting scene
  20137. * @returns the new MorphTargetManager
  20138. */
  20139. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  20140. }
  20141. }
  20142. declare module "babylonjs/Meshes/meshLODLevel" {
  20143. import { Mesh } from "babylonjs/Meshes/mesh";
  20144. import { Nullable } from "babylonjs/types";
  20145. /**
  20146. * Class used to represent a specific level of detail of a mesh
  20147. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20148. */
  20149. export class MeshLODLevel {
  20150. /** Defines the distance where this level should star being displayed */
  20151. distance: number;
  20152. /** Defines the mesh to use to render this level */
  20153. mesh: Nullable<Mesh>;
  20154. /**
  20155. * Creates a new LOD level
  20156. * @param distance defines the distance where this level should star being displayed
  20157. * @param mesh defines the mesh to use to render this level
  20158. */
  20159. constructor(
  20160. /** Defines the distance where this level should star being displayed */
  20161. distance: number,
  20162. /** Defines the mesh to use to render this level */
  20163. mesh: Nullable<Mesh>);
  20164. }
  20165. }
  20166. declare module "babylonjs/Meshes/groundMesh" {
  20167. import { Scene } from "babylonjs/scene";
  20168. import { Vector3 } from "babylonjs/Maths/math";
  20169. import { Mesh } from "babylonjs/Meshes/mesh";
  20170. /**
  20171. * Mesh representing the gorund
  20172. */
  20173. export class GroundMesh extends Mesh {
  20174. /** If octree should be generated */
  20175. generateOctree: boolean;
  20176. private _heightQuads;
  20177. /** @hidden */
  20178. _subdivisionsX: number;
  20179. /** @hidden */
  20180. _subdivisionsY: number;
  20181. /** @hidden */
  20182. _width: number;
  20183. /** @hidden */
  20184. _height: number;
  20185. /** @hidden */
  20186. _minX: number;
  20187. /** @hidden */
  20188. _maxX: number;
  20189. /** @hidden */
  20190. _minZ: number;
  20191. /** @hidden */
  20192. _maxZ: number;
  20193. constructor(name: string, scene: Scene);
  20194. /**
  20195. * "GroundMesh"
  20196. * @returns "GroundMesh"
  20197. */
  20198. getClassName(): string;
  20199. /**
  20200. * The minimum of x and y subdivisions
  20201. */
  20202. readonly subdivisions: number;
  20203. /**
  20204. * X subdivisions
  20205. */
  20206. readonly subdivisionsX: number;
  20207. /**
  20208. * Y subdivisions
  20209. */
  20210. readonly subdivisionsY: number;
  20211. /**
  20212. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20213. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20214. * @param chunksCount the number of subdivisions for x and y
  20215. * @param octreeBlocksSize (Default: 32)
  20216. */
  20217. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20218. /**
  20219. * Returns a height (y) value in the Worl system :
  20220. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20221. * @param x x coordinate
  20222. * @param z z coordinate
  20223. * @returns the ground y position if (x, z) are outside the ground surface.
  20224. */
  20225. getHeightAtCoordinates(x: number, z: number): number;
  20226. /**
  20227. * Returns a normalized vector (Vector3) orthogonal to the ground
  20228. * at the ground coordinates (x, z) expressed in the World system.
  20229. * @param x x coordinate
  20230. * @param z z coordinate
  20231. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20232. */
  20233. getNormalAtCoordinates(x: number, z: number): Vector3;
  20234. /**
  20235. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20236. * at the ground coordinates (x, z) expressed in the World system.
  20237. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20238. * @param x x coordinate
  20239. * @param z z coordinate
  20240. * @param ref vector to store the result
  20241. * @returns the GroundMesh.
  20242. */
  20243. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20244. /**
  20245. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20246. * if the ground has been updated.
  20247. * This can be used in the render loop.
  20248. * @returns the GroundMesh.
  20249. */
  20250. updateCoordinateHeights(): GroundMesh;
  20251. private _getFacetAt;
  20252. private _initHeightQuads;
  20253. private _computeHeightQuads;
  20254. /**
  20255. * Serializes this ground mesh
  20256. * @param serializationObject object to write serialization to
  20257. */
  20258. serialize(serializationObject: any): void;
  20259. /**
  20260. * Parses a serialized ground mesh
  20261. * @param parsedMesh the serialized mesh
  20262. * @param scene the scene to create the ground mesh in
  20263. * @returns the created ground mesh
  20264. */
  20265. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20266. }
  20267. }
  20268. declare module "babylonjs/Physics/physicsJoint" {
  20269. import { Vector3 } from "babylonjs/Maths/math";
  20270. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  20271. /**
  20272. * Interface for Physics-Joint data
  20273. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20274. */
  20275. export interface PhysicsJointData {
  20276. /**
  20277. * The main pivot of the joint
  20278. */
  20279. mainPivot?: Vector3;
  20280. /**
  20281. * The connected pivot of the joint
  20282. */
  20283. connectedPivot?: Vector3;
  20284. /**
  20285. * The main axis of the joint
  20286. */
  20287. mainAxis?: Vector3;
  20288. /**
  20289. * The connected axis of the joint
  20290. */
  20291. connectedAxis?: Vector3;
  20292. /**
  20293. * The collision of the joint
  20294. */
  20295. collision?: boolean;
  20296. /**
  20297. * Native Oimo/Cannon/Energy data
  20298. */
  20299. nativeParams?: any;
  20300. }
  20301. /**
  20302. * This is a holder class for the physics joint created by the physics plugin
  20303. * It holds a set of functions to control the underlying joint
  20304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20305. */
  20306. export class PhysicsJoint {
  20307. /**
  20308. * The type of the physics joint
  20309. */
  20310. type: number;
  20311. /**
  20312. * The data for the physics joint
  20313. */
  20314. jointData: PhysicsJointData;
  20315. private _physicsJoint;
  20316. protected _physicsPlugin: IPhysicsEnginePlugin;
  20317. /**
  20318. * Initializes the physics joint
  20319. * @param type The type of the physics joint
  20320. * @param jointData The data for the physics joint
  20321. */
  20322. constructor(
  20323. /**
  20324. * The type of the physics joint
  20325. */
  20326. type: number,
  20327. /**
  20328. * The data for the physics joint
  20329. */
  20330. jointData: PhysicsJointData);
  20331. /**
  20332. * Gets the physics joint
  20333. */
  20334. /**
  20335. * Sets the physics joint
  20336. */
  20337. physicsJoint: any;
  20338. /**
  20339. * Sets the physics plugin
  20340. */
  20341. physicsPlugin: IPhysicsEnginePlugin;
  20342. /**
  20343. * Execute a function that is physics-plugin specific.
  20344. * @param {Function} func the function that will be executed.
  20345. * It accepts two parameters: the physics world and the physics joint
  20346. */
  20347. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20348. /**
  20349. * Distance-Joint type
  20350. */
  20351. static DistanceJoint: number;
  20352. /**
  20353. * Hinge-Joint type
  20354. */
  20355. static HingeJoint: number;
  20356. /**
  20357. * Ball-and-Socket joint type
  20358. */
  20359. static BallAndSocketJoint: number;
  20360. /**
  20361. * Wheel-Joint type
  20362. */
  20363. static WheelJoint: number;
  20364. /**
  20365. * Slider-Joint type
  20366. */
  20367. static SliderJoint: number;
  20368. /**
  20369. * Prismatic-Joint type
  20370. */
  20371. static PrismaticJoint: number;
  20372. /**
  20373. * Universal-Joint type
  20374. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20375. */
  20376. static UniversalJoint: number;
  20377. /**
  20378. * Hinge-Joint 2 type
  20379. */
  20380. static Hinge2Joint: number;
  20381. /**
  20382. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20383. */
  20384. static PointToPointJoint: number;
  20385. /**
  20386. * Spring-Joint type
  20387. */
  20388. static SpringJoint: number;
  20389. /**
  20390. * Lock-Joint type
  20391. */
  20392. static LockJoint: number;
  20393. }
  20394. /**
  20395. * A class representing a physics distance joint
  20396. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20397. */
  20398. export class DistanceJoint extends PhysicsJoint {
  20399. /**
  20400. *
  20401. * @param jointData The data for the Distance-Joint
  20402. */
  20403. constructor(jointData: DistanceJointData);
  20404. /**
  20405. * Update the predefined distance.
  20406. * @param maxDistance The maximum preferred distance
  20407. * @param minDistance The minimum preferred distance
  20408. */
  20409. updateDistance(maxDistance: number, minDistance?: number): void;
  20410. }
  20411. /**
  20412. * Represents a Motor-Enabled Joint
  20413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20414. */
  20415. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20416. /**
  20417. * Initializes the Motor-Enabled Joint
  20418. * @param type The type of the joint
  20419. * @param jointData The physica joint data for the joint
  20420. */
  20421. constructor(type: number, jointData: PhysicsJointData);
  20422. /**
  20423. * Set the motor values.
  20424. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20425. * @param force the force to apply
  20426. * @param maxForce max force for this motor.
  20427. */
  20428. setMotor(force?: number, maxForce?: number): void;
  20429. /**
  20430. * Set the motor's limits.
  20431. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20432. * @param upperLimit The upper limit of the motor
  20433. * @param lowerLimit The lower limit of the motor
  20434. */
  20435. setLimit(upperLimit: number, lowerLimit?: number): void;
  20436. }
  20437. /**
  20438. * This class represents a single physics Hinge-Joint
  20439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20440. */
  20441. export class HingeJoint extends MotorEnabledJoint {
  20442. /**
  20443. * Initializes the Hinge-Joint
  20444. * @param jointData The joint data for the Hinge-Joint
  20445. */
  20446. constructor(jointData: PhysicsJointData);
  20447. /**
  20448. * Set the motor values.
  20449. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20450. * @param {number} force the force to apply
  20451. * @param {number} maxForce max force for this motor.
  20452. */
  20453. setMotor(force?: number, maxForce?: number): void;
  20454. /**
  20455. * Set the motor's limits.
  20456. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20457. * @param upperLimit The upper limit of the motor
  20458. * @param lowerLimit The lower limit of the motor
  20459. */
  20460. setLimit(upperLimit: number, lowerLimit?: number): void;
  20461. }
  20462. /**
  20463. * This class represents a dual hinge physics joint (same as wheel joint)
  20464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20465. */
  20466. export class Hinge2Joint extends MotorEnabledJoint {
  20467. /**
  20468. * Initializes the Hinge2-Joint
  20469. * @param jointData The joint data for the Hinge2-Joint
  20470. */
  20471. constructor(jointData: PhysicsJointData);
  20472. /**
  20473. * Set the motor values.
  20474. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20475. * @param {number} targetSpeed the speed the motor is to reach
  20476. * @param {number} maxForce max force for this motor.
  20477. * @param {motorIndex} the motor's index, 0 or 1.
  20478. */
  20479. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20480. /**
  20481. * Set the motor limits.
  20482. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20483. * @param {number} upperLimit the upper limit
  20484. * @param {number} lowerLimit lower limit
  20485. * @param {motorIndex} the motor's index, 0 or 1.
  20486. */
  20487. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20488. }
  20489. /**
  20490. * Interface for a motor enabled joint
  20491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20492. */
  20493. export interface IMotorEnabledJoint {
  20494. /**
  20495. * Physics joint
  20496. */
  20497. physicsJoint: any;
  20498. /**
  20499. * Sets the motor of the motor-enabled joint
  20500. * @param force The force of the motor
  20501. * @param maxForce The maximum force of the motor
  20502. * @param motorIndex The index of the motor
  20503. */
  20504. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20505. /**
  20506. * Sets the limit of the motor
  20507. * @param upperLimit The upper limit of the motor
  20508. * @param lowerLimit The lower limit of the motor
  20509. * @param motorIndex The index of the motor
  20510. */
  20511. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20512. }
  20513. /**
  20514. * Joint data for a Distance-Joint
  20515. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20516. */
  20517. export interface DistanceJointData extends PhysicsJointData {
  20518. /**
  20519. * Max distance the 2 joint objects can be apart
  20520. */
  20521. maxDistance: number;
  20522. }
  20523. /**
  20524. * Joint data from a spring joint
  20525. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20526. */
  20527. export interface SpringJointData extends PhysicsJointData {
  20528. /**
  20529. * Length of the spring
  20530. */
  20531. length: number;
  20532. /**
  20533. * Stiffness of the spring
  20534. */
  20535. stiffness: number;
  20536. /**
  20537. * Damping of the spring
  20538. */
  20539. damping: number;
  20540. /** this callback will be called when applying the force to the impostors. */
  20541. forceApplicationCallback: () => void;
  20542. }
  20543. }
  20544. declare module "babylonjs/Physics/physicsRaycastResult" {
  20545. import { Vector3 } from "babylonjs/Maths/math";
  20546. /**
  20547. * Holds the data for the raycast result
  20548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20549. */
  20550. export class PhysicsRaycastResult {
  20551. private _hasHit;
  20552. private _hitDistance;
  20553. private _hitNormalWorld;
  20554. private _hitPointWorld;
  20555. private _rayFromWorld;
  20556. private _rayToWorld;
  20557. /**
  20558. * Gets if there was a hit
  20559. */
  20560. readonly hasHit: boolean;
  20561. /**
  20562. * Gets the distance from the hit
  20563. */
  20564. readonly hitDistance: number;
  20565. /**
  20566. * Gets the hit normal/direction in the world
  20567. */
  20568. readonly hitNormalWorld: Vector3;
  20569. /**
  20570. * Gets the hit point in the world
  20571. */
  20572. readonly hitPointWorld: Vector3;
  20573. /**
  20574. * Gets the ray "start point" of the ray in the world
  20575. */
  20576. readonly rayFromWorld: Vector3;
  20577. /**
  20578. * Gets the ray "end point" of the ray in the world
  20579. */
  20580. readonly rayToWorld: Vector3;
  20581. /**
  20582. * Sets the hit data (normal & point in world space)
  20583. * @param hitNormalWorld defines the normal in world space
  20584. * @param hitPointWorld defines the point in world space
  20585. */
  20586. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20587. /**
  20588. * Sets the distance from the start point to the hit point
  20589. * @param distance
  20590. */
  20591. setHitDistance(distance: number): void;
  20592. /**
  20593. * Calculates the distance manually
  20594. */
  20595. calculateHitDistance(): void;
  20596. /**
  20597. * Resets all the values to default
  20598. * @param from The from point on world space
  20599. * @param to The to point on world space
  20600. */
  20601. reset(from?: Vector3, to?: Vector3): void;
  20602. }
  20603. /**
  20604. * Interface for the size containing width and height
  20605. */
  20606. interface IXYZ {
  20607. /**
  20608. * X
  20609. */
  20610. x: number;
  20611. /**
  20612. * Y
  20613. */
  20614. y: number;
  20615. /**
  20616. * Z
  20617. */
  20618. z: number;
  20619. }
  20620. }
  20621. declare module "babylonjs/Physics/IPhysicsEngine" {
  20622. import { Nullable } from "babylonjs/types";
  20623. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20625. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20626. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20627. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20628. /**
  20629. * Interface used to describe a physics joint
  20630. */
  20631. export interface PhysicsImpostorJoint {
  20632. /** Defines the main impostor to which the joint is linked */
  20633. mainImpostor: PhysicsImpostor;
  20634. /** Defines the impostor that is connected to the main impostor using this joint */
  20635. connectedImpostor: PhysicsImpostor;
  20636. /** Defines the joint itself */
  20637. joint: PhysicsJoint;
  20638. }
  20639. /** @hidden */
  20640. export interface IPhysicsEnginePlugin {
  20641. world: any;
  20642. name: string;
  20643. setGravity(gravity: Vector3): void;
  20644. setTimeStep(timeStep: number): void;
  20645. getTimeStep(): number;
  20646. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20647. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20648. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20649. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20650. removePhysicsBody(impostor: PhysicsImpostor): void;
  20651. generateJoint(joint: PhysicsImpostorJoint): void;
  20652. removeJoint(joint: PhysicsImpostorJoint): void;
  20653. isSupported(): boolean;
  20654. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20655. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20656. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20657. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20658. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20659. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20660. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20661. getBodyMass(impostor: PhysicsImpostor): number;
  20662. getBodyFriction(impostor: PhysicsImpostor): number;
  20663. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20664. getBodyRestitution(impostor: PhysicsImpostor): number;
  20665. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20666. getBodyPressure?(impostor: PhysicsImpostor): number;
  20667. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20668. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20669. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20670. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20671. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20672. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20673. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20674. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20675. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20676. sleepBody(impostor: PhysicsImpostor): void;
  20677. wakeUpBody(impostor: PhysicsImpostor): void;
  20678. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20679. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20680. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20681. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20682. getRadius(impostor: PhysicsImpostor): number;
  20683. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20684. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20685. dispose(): void;
  20686. }
  20687. /**
  20688. * Interface used to define a physics engine
  20689. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20690. */
  20691. export interface IPhysicsEngine {
  20692. /**
  20693. * Gets the gravity vector used by the simulation
  20694. */
  20695. gravity: Vector3;
  20696. /**
  20697. * Sets the gravity vector used by the simulation
  20698. * @param gravity defines the gravity vector to use
  20699. */
  20700. setGravity(gravity: Vector3): void;
  20701. /**
  20702. * Set the time step of the physics engine.
  20703. * Default is 1/60.
  20704. * To slow it down, enter 1/600 for example.
  20705. * To speed it up, 1/30
  20706. * @param newTimeStep the new timestep to apply to this world.
  20707. */
  20708. setTimeStep(newTimeStep: number): void;
  20709. /**
  20710. * Get the time step of the physics engine.
  20711. * @returns the current time step
  20712. */
  20713. getTimeStep(): number;
  20714. /**
  20715. * Release all resources
  20716. */
  20717. dispose(): void;
  20718. /**
  20719. * Gets the name of the current physics plugin
  20720. * @returns the name of the plugin
  20721. */
  20722. getPhysicsPluginName(): string;
  20723. /**
  20724. * Adding a new impostor for the impostor tracking.
  20725. * This will be done by the impostor itself.
  20726. * @param impostor the impostor to add
  20727. */
  20728. addImpostor(impostor: PhysicsImpostor): void;
  20729. /**
  20730. * Remove an impostor from the engine.
  20731. * This impostor and its mesh will not longer be updated by the physics engine.
  20732. * @param impostor the impostor to remove
  20733. */
  20734. removeImpostor(impostor: PhysicsImpostor): void;
  20735. /**
  20736. * Add a joint to the physics engine
  20737. * @param mainImpostor defines the main impostor to which the joint is added.
  20738. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20739. * @param joint defines the joint that will connect both impostors.
  20740. */
  20741. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20742. /**
  20743. * Removes a joint from the simulation
  20744. * @param mainImpostor defines the impostor used with the joint
  20745. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20746. * @param joint defines the joint to remove
  20747. */
  20748. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20749. /**
  20750. * Gets the current plugin used to run the simulation
  20751. * @returns current plugin
  20752. */
  20753. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20754. /**
  20755. * Gets the list of physic impostors
  20756. * @returns an array of PhysicsImpostor
  20757. */
  20758. getImpostors(): Array<PhysicsImpostor>;
  20759. /**
  20760. * Gets the impostor for a physics enabled object
  20761. * @param object defines the object impersonated by the impostor
  20762. * @returns the PhysicsImpostor or null if not found
  20763. */
  20764. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20765. /**
  20766. * Gets the impostor for a physics body object
  20767. * @param body defines physics body used by the impostor
  20768. * @returns the PhysicsImpostor or null if not found
  20769. */
  20770. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20771. /**
  20772. * Does a raycast in the physics world
  20773. * @param from when should the ray start?
  20774. * @param to when should the ray end?
  20775. * @returns PhysicsRaycastResult
  20776. */
  20777. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20778. /**
  20779. * Called by the scene. No need to call it.
  20780. * @param delta defines the timespam between frames
  20781. */
  20782. _step(delta: number): void;
  20783. }
  20784. }
  20785. declare module "babylonjs/Physics/physicsImpostor" {
  20786. import { Nullable, IndicesArray } from "babylonjs/types";
  20787. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20788. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20790. import { Scene } from "babylonjs/scene";
  20791. import { Bone } from "babylonjs/Bones/bone";
  20792. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20793. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20794. /**
  20795. * The interface for the physics imposter parameters
  20796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20797. */
  20798. export interface PhysicsImpostorParameters {
  20799. /**
  20800. * The mass of the physics imposter
  20801. */
  20802. mass: number;
  20803. /**
  20804. * The friction of the physics imposter
  20805. */
  20806. friction?: number;
  20807. /**
  20808. * The coefficient of restitution of the physics imposter
  20809. */
  20810. restitution?: number;
  20811. /**
  20812. * The native options of the physics imposter
  20813. */
  20814. nativeOptions?: any;
  20815. /**
  20816. * Specifies if the parent should be ignored
  20817. */
  20818. ignoreParent?: boolean;
  20819. /**
  20820. * Specifies if bi-directional transformations should be disabled
  20821. */
  20822. disableBidirectionalTransformation?: boolean;
  20823. /**
  20824. * The pressure inside the physics imposter, soft object only
  20825. */
  20826. pressure?: number;
  20827. /**
  20828. * The stiffness the physics imposter, soft object only
  20829. */
  20830. stiffness?: number;
  20831. /**
  20832. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20833. */
  20834. velocityIterations?: number;
  20835. /**
  20836. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20837. */
  20838. positionIterations?: number;
  20839. /**
  20840. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20841. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20842. * Add to fix multiple points
  20843. */
  20844. fixedPoints?: number;
  20845. /**
  20846. * The collision margin around a soft object
  20847. */
  20848. margin?: number;
  20849. /**
  20850. * The collision margin around a soft object
  20851. */
  20852. damping?: number;
  20853. /**
  20854. * The path for a rope based on an extrusion
  20855. */
  20856. path?: any;
  20857. /**
  20858. * The shape of an extrusion used for a rope based on an extrusion
  20859. */
  20860. shape?: any;
  20861. }
  20862. /**
  20863. * Interface for a physics-enabled object
  20864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20865. */
  20866. export interface IPhysicsEnabledObject {
  20867. /**
  20868. * The position of the physics-enabled object
  20869. */
  20870. position: Vector3;
  20871. /**
  20872. * The rotation of the physics-enabled object
  20873. */
  20874. rotationQuaternion: Nullable<Quaternion>;
  20875. /**
  20876. * The scale of the physics-enabled object
  20877. */
  20878. scaling: Vector3;
  20879. /**
  20880. * The rotation of the physics-enabled object
  20881. */
  20882. rotation?: Vector3;
  20883. /**
  20884. * The parent of the physics-enabled object
  20885. */
  20886. parent?: any;
  20887. /**
  20888. * The bounding info of the physics-enabled object
  20889. * @returns The bounding info of the physics-enabled object
  20890. */
  20891. getBoundingInfo(): BoundingInfo;
  20892. /**
  20893. * Computes the world matrix
  20894. * @param force Specifies if the world matrix should be computed by force
  20895. * @returns A world matrix
  20896. */
  20897. computeWorldMatrix(force: boolean): Matrix;
  20898. /**
  20899. * Gets the world matrix
  20900. * @returns A world matrix
  20901. */
  20902. getWorldMatrix?(): Matrix;
  20903. /**
  20904. * Gets the child meshes
  20905. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20906. * @returns An array of abstract meshes
  20907. */
  20908. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20909. /**
  20910. * Gets the vertex data
  20911. * @param kind The type of vertex data
  20912. * @returns A nullable array of numbers, or a float32 array
  20913. */
  20914. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20915. /**
  20916. * Gets the indices from the mesh
  20917. * @returns A nullable array of index arrays
  20918. */
  20919. getIndices?(): Nullable<IndicesArray>;
  20920. /**
  20921. * Gets the scene from the mesh
  20922. * @returns the indices array or null
  20923. */
  20924. getScene?(): Scene;
  20925. /**
  20926. * Gets the absolute position from the mesh
  20927. * @returns the absolute position
  20928. */
  20929. getAbsolutePosition(): Vector3;
  20930. /**
  20931. * Gets the absolute pivot point from the mesh
  20932. * @returns the absolute pivot point
  20933. */
  20934. getAbsolutePivotPoint(): Vector3;
  20935. /**
  20936. * Rotates the mesh
  20937. * @param axis The axis of rotation
  20938. * @param amount The amount of rotation
  20939. * @param space The space of the rotation
  20940. * @returns The rotation transform node
  20941. */
  20942. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20943. /**
  20944. * Translates the mesh
  20945. * @param axis The axis of translation
  20946. * @param distance The distance of translation
  20947. * @param space The space of the translation
  20948. * @returns The transform node
  20949. */
  20950. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20951. /**
  20952. * Sets the absolute position of the mesh
  20953. * @param absolutePosition The absolute position of the mesh
  20954. * @returns The transform node
  20955. */
  20956. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20957. /**
  20958. * Gets the class name of the mesh
  20959. * @returns The class name
  20960. */
  20961. getClassName(): string;
  20962. }
  20963. /**
  20964. * Represents a physics imposter
  20965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20966. */
  20967. export class PhysicsImpostor {
  20968. /**
  20969. * The physics-enabled object used as the physics imposter
  20970. */
  20971. object: IPhysicsEnabledObject;
  20972. /**
  20973. * The type of the physics imposter
  20974. */
  20975. type: number;
  20976. private _options;
  20977. private _scene?;
  20978. /**
  20979. * The default object size of the imposter
  20980. */
  20981. static DEFAULT_OBJECT_SIZE: Vector3;
  20982. /**
  20983. * The identity quaternion of the imposter
  20984. */
  20985. static IDENTITY_QUATERNION: Quaternion;
  20986. /** @hidden */
  20987. _pluginData: any;
  20988. private _physicsEngine;
  20989. private _physicsBody;
  20990. private _bodyUpdateRequired;
  20991. private _onBeforePhysicsStepCallbacks;
  20992. private _onAfterPhysicsStepCallbacks;
  20993. /** @hidden */
  20994. _onPhysicsCollideCallbacks: Array<{
  20995. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20996. otherImpostors: Array<PhysicsImpostor>;
  20997. }>;
  20998. private _deltaPosition;
  20999. private _deltaRotation;
  21000. private _deltaRotationConjugated;
  21001. /** @hidden */
  21002. _isFromLine: boolean;
  21003. private _parent;
  21004. private _isDisposed;
  21005. private static _tmpVecs;
  21006. private static _tmpQuat;
  21007. /**
  21008. * Specifies if the physics imposter is disposed
  21009. */
  21010. readonly isDisposed: boolean;
  21011. /**
  21012. * Gets the mass of the physics imposter
  21013. */
  21014. mass: number;
  21015. /**
  21016. * Gets the coefficient of friction
  21017. */
  21018. /**
  21019. * Sets the coefficient of friction
  21020. */
  21021. friction: number;
  21022. /**
  21023. * Gets the coefficient of restitution
  21024. */
  21025. /**
  21026. * Sets the coefficient of restitution
  21027. */
  21028. restitution: number;
  21029. /**
  21030. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  21031. */
  21032. /**
  21033. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  21034. */
  21035. pressure: number;
  21036. /**
  21037. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21038. */
  21039. /**
  21040. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21041. */
  21042. stiffness: number;
  21043. /**
  21044. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21045. */
  21046. /**
  21047. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21048. */
  21049. velocityIterations: number;
  21050. /**
  21051. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21052. */
  21053. /**
  21054. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21055. */
  21056. positionIterations: number;
  21057. /**
  21058. * The unique id of the physics imposter
  21059. * set by the physics engine when adding this impostor to the array
  21060. */
  21061. uniqueId: number;
  21062. /**
  21063. * @hidden
  21064. */
  21065. soft: boolean;
  21066. /**
  21067. * @hidden
  21068. */
  21069. segments: number;
  21070. private _joints;
  21071. /**
  21072. * Initializes the physics imposter
  21073. * @param object The physics-enabled object used as the physics imposter
  21074. * @param type The type of the physics imposter
  21075. * @param _options The options for the physics imposter
  21076. * @param _scene The Babylon scene
  21077. */
  21078. constructor(
  21079. /**
  21080. * The physics-enabled object used as the physics imposter
  21081. */
  21082. object: IPhysicsEnabledObject,
  21083. /**
  21084. * The type of the physics imposter
  21085. */
  21086. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  21087. /**
  21088. * This function will completly initialize this impostor.
  21089. * It will create a new body - but only if this mesh has no parent.
  21090. * If it has, this impostor will not be used other than to define the impostor
  21091. * of the child mesh.
  21092. * @hidden
  21093. */
  21094. _init(): void;
  21095. private _getPhysicsParent;
  21096. /**
  21097. * Should a new body be generated.
  21098. * @returns boolean specifying if body initialization is required
  21099. */
  21100. isBodyInitRequired(): boolean;
  21101. /**
  21102. * Sets the updated scaling
  21103. * @param updated Specifies if the scaling is updated
  21104. */
  21105. setScalingUpdated(): void;
  21106. /**
  21107. * Force a regeneration of this or the parent's impostor's body.
  21108. * Use under cautious - This will remove all joints already implemented.
  21109. */
  21110. forceUpdate(): void;
  21111. /**
  21112. * Gets the body that holds this impostor. Either its own, or its parent.
  21113. */
  21114. /**
  21115. * Set the physics body. Used mainly by the physics engine/plugin
  21116. */
  21117. physicsBody: any;
  21118. /**
  21119. * Get the parent of the physics imposter
  21120. * @returns Physics imposter or null
  21121. */
  21122. /**
  21123. * Sets the parent of the physics imposter
  21124. */
  21125. parent: Nullable<PhysicsImpostor>;
  21126. /**
  21127. * Resets the update flags
  21128. */
  21129. resetUpdateFlags(): void;
  21130. /**
  21131. * Gets the object extend size
  21132. * @returns the object extend size
  21133. */
  21134. getObjectExtendSize(): Vector3;
  21135. /**
  21136. * Gets the object center
  21137. * @returns The object center
  21138. */
  21139. getObjectCenter(): Vector3;
  21140. /**
  21141. * Get a specific parametes from the options parameter
  21142. * @param paramName The object parameter name
  21143. * @returns The object parameter
  21144. */
  21145. getParam(paramName: string): any;
  21146. /**
  21147. * Sets a specific parameter in the options given to the physics plugin
  21148. * @param paramName The parameter name
  21149. * @param value The value of the parameter
  21150. */
  21151. setParam(paramName: string, value: number): void;
  21152. /**
  21153. * Specifically change the body's mass option. Won't recreate the physics body object
  21154. * @param mass The mass of the physics imposter
  21155. */
  21156. setMass(mass: number): void;
  21157. /**
  21158. * Gets the linear velocity
  21159. * @returns linear velocity or null
  21160. */
  21161. getLinearVelocity(): Nullable<Vector3>;
  21162. /**
  21163. * Sets the linear velocity
  21164. * @param velocity linear velocity or null
  21165. */
  21166. setLinearVelocity(velocity: Nullable<Vector3>): void;
  21167. /**
  21168. * Gets the angular velocity
  21169. * @returns angular velocity or null
  21170. */
  21171. getAngularVelocity(): Nullable<Vector3>;
  21172. /**
  21173. * Sets the angular velocity
  21174. * @param velocity The velocity or null
  21175. */
  21176. setAngularVelocity(velocity: Nullable<Vector3>): void;
  21177. /**
  21178. * Execute a function with the physics plugin native code
  21179. * Provide a function the will have two variables - the world object and the physics body object
  21180. * @param func The function to execute with the physics plugin native code
  21181. */
  21182. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  21183. /**
  21184. * Register a function that will be executed before the physics world is stepping forward
  21185. * @param func The function to execute before the physics world is stepped forward
  21186. */
  21187. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21188. /**
  21189. * Unregister a function that will be executed before the physics world is stepping forward
  21190. * @param func The function to execute before the physics world is stepped forward
  21191. */
  21192. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21193. /**
  21194. * Register a function that will be executed after the physics step
  21195. * @param func The function to execute after physics step
  21196. */
  21197. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21198. /**
  21199. * Unregisters a function that will be executed after the physics step
  21200. * @param func The function to execute after physics step
  21201. */
  21202. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21203. /**
  21204. * register a function that will be executed when this impostor collides against a different body
  21205. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  21206. * @param func Callback that is executed on collision
  21207. */
  21208. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  21209. /**
  21210. * Unregisters the physics imposter on contact
  21211. * @param collideAgainst The physics object to collide against
  21212. * @param func Callback to execute on collision
  21213. */
  21214. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  21215. private _tmpQuat;
  21216. private _tmpQuat2;
  21217. /**
  21218. * Get the parent rotation
  21219. * @returns The parent rotation
  21220. */
  21221. getParentsRotation(): Quaternion;
  21222. /**
  21223. * this function is executed by the physics engine.
  21224. */
  21225. beforeStep: () => void;
  21226. /**
  21227. * this function is executed by the physics engine
  21228. */
  21229. afterStep: () => void;
  21230. /**
  21231. * Legacy collision detection event support
  21232. */
  21233. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  21234. /**
  21235. * event and body object due to cannon's event-based architecture.
  21236. */
  21237. onCollide: (e: {
  21238. body: any;
  21239. }) => void;
  21240. /**
  21241. * Apply a force
  21242. * @param force The force to apply
  21243. * @param contactPoint The contact point for the force
  21244. * @returns The physics imposter
  21245. */
  21246. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21247. /**
  21248. * Apply an impulse
  21249. * @param force The impulse force
  21250. * @param contactPoint The contact point for the impulse force
  21251. * @returns The physics imposter
  21252. */
  21253. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21254. /**
  21255. * A help function to create a joint
  21256. * @param otherImpostor A physics imposter used to create a joint
  21257. * @param jointType The type of joint
  21258. * @param jointData The data for the joint
  21259. * @returns The physics imposter
  21260. */
  21261. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  21262. /**
  21263. * Add a joint to this impostor with a different impostor
  21264. * @param otherImpostor A physics imposter used to add a joint
  21265. * @param joint The joint to add
  21266. * @returns The physics imposter
  21267. */
  21268. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  21269. /**
  21270. * Add an anchor to a cloth impostor
  21271. * @param otherImpostor rigid impostor to anchor to
  21272. * @param width ratio across width from 0 to 1
  21273. * @param height ratio up height from 0 to 1
  21274. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  21275. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  21276. * @returns impostor the soft imposter
  21277. */
  21278. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21279. /**
  21280. * Add a hook to a rope impostor
  21281. * @param otherImpostor rigid impostor to anchor to
  21282. * @param length ratio across rope from 0 to 1
  21283. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  21284. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  21285. * @returns impostor the rope imposter
  21286. */
  21287. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21288. /**
  21289. * Will keep this body still, in a sleep mode.
  21290. * @returns the physics imposter
  21291. */
  21292. sleep(): PhysicsImpostor;
  21293. /**
  21294. * Wake the body up.
  21295. * @returns The physics imposter
  21296. */
  21297. wakeUp(): PhysicsImpostor;
  21298. /**
  21299. * Clones the physics imposter
  21300. * @param newObject The physics imposter clones to this physics-enabled object
  21301. * @returns A nullable physics imposter
  21302. */
  21303. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21304. /**
  21305. * Disposes the physics imposter
  21306. */
  21307. dispose(): void;
  21308. /**
  21309. * Sets the delta position
  21310. * @param position The delta position amount
  21311. */
  21312. setDeltaPosition(position: Vector3): void;
  21313. /**
  21314. * Sets the delta rotation
  21315. * @param rotation The delta rotation amount
  21316. */
  21317. setDeltaRotation(rotation: Quaternion): void;
  21318. /**
  21319. * Gets the box size of the physics imposter and stores the result in the input parameter
  21320. * @param result Stores the box size
  21321. * @returns The physics imposter
  21322. */
  21323. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  21324. /**
  21325. * Gets the radius of the physics imposter
  21326. * @returns Radius of the physics imposter
  21327. */
  21328. getRadius(): number;
  21329. /**
  21330. * Sync a bone with this impostor
  21331. * @param bone The bone to sync to the impostor.
  21332. * @param boneMesh The mesh that the bone is influencing.
  21333. * @param jointPivot The pivot of the joint / bone in local space.
  21334. * @param distToJoint Optional distance from the impostor to the joint.
  21335. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21336. */
  21337. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21338. /**
  21339. * Sync impostor to a bone
  21340. * @param bone The bone that the impostor will be synced to.
  21341. * @param boneMesh The mesh that the bone is influencing.
  21342. * @param jointPivot The pivot of the joint / bone in local space.
  21343. * @param distToJoint Optional distance from the impostor to the joint.
  21344. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21345. * @param boneAxis Optional vector3 axis the bone is aligned with
  21346. */
  21347. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21348. /**
  21349. * No-Imposter type
  21350. */
  21351. static NoImpostor: number;
  21352. /**
  21353. * Sphere-Imposter type
  21354. */
  21355. static SphereImpostor: number;
  21356. /**
  21357. * Box-Imposter type
  21358. */
  21359. static BoxImpostor: number;
  21360. /**
  21361. * Plane-Imposter type
  21362. */
  21363. static PlaneImpostor: number;
  21364. /**
  21365. * Mesh-imposter type
  21366. */
  21367. static MeshImpostor: number;
  21368. /**
  21369. * Cylinder-Imposter type
  21370. */
  21371. static CylinderImpostor: number;
  21372. /**
  21373. * Particle-Imposter type
  21374. */
  21375. static ParticleImpostor: number;
  21376. /**
  21377. * Heightmap-Imposter type
  21378. */
  21379. static HeightmapImpostor: number;
  21380. /**
  21381. * ConvexHull-Impostor type (Ammo.js plugin only)
  21382. */
  21383. static ConvexHullImpostor: number;
  21384. /**
  21385. * Rope-Imposter type
  21386. */
  21387. static RopeImpostor: number;
  21388. /**
  21389. * Cloth-Imposter type
  21390. */
  21391. static ClothImpostor: number;
  21392. /**
  21393. * Softbody-Imposter type
  21394. */
  21395. static SoftbodyImpostor: number;
  21396. }
  21397. }
  21398. declare module "babylonjs/Meshes/mesh" {
  21399. import { Observable } from "babylonjs/Misc/observable";
  21400. import { IAnimatable } from "babylonjs/Misc/tools";
  21401. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21402. import { Camera } from "babylonjs/Cameras/camera";
  21403. import { Scene } from "babylonjs/scene";
  21404. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21405. import { Engine } from "babylonjs/Engines/engine";
  21406. import { Node } from "babylonjs/node";
  21407. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21408. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21409. import { Buffer } from "babylonjs/Meshes/buffer";
  21410. import { Geometry } from "babylonjs/Meshes/geometry";
  21411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21412. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21413. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21414. import { Effect } from "babylonjs/Materials/effect";
  21415. import { Material } from "babylonjs/Materials/material";
  21416. import { Skeleton } from "babylonjs/Bones/skeleton";
  21417. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21418. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  21419. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21420. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21421. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21422. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21423. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21424. /**
  21425. * @hidden
  21426. **/
  21427. export class _CreationDataStorage {
  21428. closePath?: boolean;
  21429. closeArray?: boolean;
  21430. idx: number[];
  21431. dashSize: number;
  21432. gapSize: number;
  21433. path3D: Path3D;
  21434. pathArray: Vector3[][];
  21435. arc: number;
  21436. radius: number;
  21437. cap: number;
  21438. tessellation: number;
  21439. }
  21440. /**
  21441. * @hidden
  21442. **/
  21443. class _InstanceDataStorage {
  21444. visibleInstances: any;
  21445. batchCache: _InstancesBatch;
  21446. instancesBufferSize: number;
  21447. instancesBuffer: Nullable<Buffer>;
  21448. instancesData: Float32Array;
  21449. overridenInstanceCount: number;
  21450. isFrozen: boolean;
  21451. previousBatch: _InstancesBatch;
  21452. hardwareInstancedRendering: boolean;
  21453. sideOrientation: number;
  21454. }
  21455. /**
  21456. * @hidden
  21457. **/
  21458. export class _InstancesBatch {
  21459. mustReturn: boolean;
  21460. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21461. renderSelf: boolean[];
  21462. hardwareInstancedRendering: boolean[];
  21463. }
  21464. /**
  21465. * Class used to represent renderable models
  21466. */
  21467. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21468. /**
  21469. * Mesh side orientation : usually the external or front surface
  21470. */
  21471. static readonly FRONTSIDE: number;
  21472. /**
  21473. * Mesh side orientation : usually the internal or back surface
  21474. */
  21475. static readonly BACKSIDE: number;
  21476. /**
  21477. * Mesh side orientation : both internal and external or front and back surfaces
  21478. */
  21479. static readonly DOUBLESIDE: number;
  21480. /**
  21481. * Mesh side orientation : by default, `FRONTSIDE`
  21482. */
  21483. static readonly DEFAULTSIDE: number;
  21484. /**
  21485. * Mesh cap setting : no cap
  21486. */
  21487. static readonly NO_CAP: number;
  21488. /**
  21489. * Mesh cap setting : one cap at the beginning of the mesh
  21490. */
  21491. static readonly CAP_START: number;
  21492. /**
  21493. * Mesh cap setting : one cap at the end of the mesh
  21494. */
  21495. static readonly CAP_END: number;
  21496. /**
  21497. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21498. */
  21499. static readonly CAP_ALL: number;
  21500. /**
  21501. * Mesh pattern setting : no flip or rotate
  21502. */
  21503. static readonly NO_FLIP: number;
  21504. /**
  21505. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  21506. */
  21507. static readonly FLIP_TILE: number;
  21508. /**
  21509. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  21510. */
  21511. static readonly ROTATE_TILE: number;
  21512. /**
  21513. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  21514. */
  21515. static readonly FLIP_ROW: number;
  21516. /**
  21517. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  21518. */
  21519. static readonly ROTATE_ROW: number;
  21520. /**
  21521. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  21522. */
  21523. static readonly FLIP_N_ROTATE_TILE: number;
  21524. /**
  21525. * Mesh pattern setting : rotate pattern and rotate
  21526. */
  21527. static readonly FLIP_N_ROTATE_ROW: number;
  21528. /**
  21529. * Mesh tile positioning : part tiles same on left/right or top/bottom
  21530. */
  21531. static readonly CENTER: number;
  21532. /**
  21533. * Mesh tile positioning : part tiles on left
  21534. */
  21535. static readonly LEFT: number;
  21536. /**
  21537. * Mesh tile positioning : part tiles on right
  21538. */
  21539. static readonly RIGHT: number;
  21540. /**
  21541. * Mesh tile positioning : part tiles on top
  21542. */
  21543. static readonly TOP: number;
  21544. /**
  21545. * Mesh tile positioning : part tiles on bottom
  21546. */
  21547. static readonly BOTTOM: number;
  21548. /**
  21549. * Gets the default side orientation.
  21550. * @param orientation the orientation to value to attempt to get
  21551. * @returns the default orientation
  21552. * @hidden
  21553. */
  21554. static _GetDefaultSideOrientation(orientation?: number): number;
  21555. private _internalMeshDataInfo;
  21556. /**
  21557. * An event triggered before rendering the mesh
  21558. */
  21559. readonly onBeforeRenderObservable: Observable<Mesh>;
  21560. /**
  21561. * An event triggered before binding the mesh
  21562. */
  21563. readonly onBeforeBindObservable: Observable<Mesh>;
  21564. /**
  21565. * An event triggered after rendering the mesh
  21566. */
  21567. readonly onAfterRenderObservable: Observable<Mesh>;
  21568. /**
  21569. * An event triggered before drawing the mesh
  21570. */
  21571. readonly onBeforeDrawObservable: Observable<Mesh>;
  21572. private _onBeforeDrawObserver;
  21573. /**
  21574. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21575. */
  21576. onBeforeDraw: () => void;
  21577. /**
  21578. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21579. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21580. */
  21581. delayLoadState: number;
  21582. /**
  21583. * Gets the list of instances created from this mesh
  21584. * it is not supposed to be modified manually.
  21585. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21586. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21587. */
  21588. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21589. /**
  21590. * Gets the file containing delay loading data for this mesh
  21591. */
  21592. delayLoadingFile: string;
  21593. /** @hidden */
  21594. _binaryInfo: any;
  21595. /**
  21596. * User defined function used to change how LOD level selection is done
  21597. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21598. */
  21599. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21600. /**
  21601. * Gets or sets the morph target manager
  21602. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21603. */
  21604. morphTargetManager: Nullable<MorphTargetManager>;
  21605. /** @hidden */
  21606. _creationDataStorage: Nullable<_CreationDataStorage>;
  21607. /** @hidden */
  21608. _geometry: Nullable<Geometry>;
  21609. /** @hidden */
  21610. _delayInfo: Array<string>;
  21611. /** @hidden */
  21612. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21613. /** @hidden */
  21614. _instanceDataStorage: _InstanceDataStorage;
  21615. private _effectiveMaterial;
  21616. /** @hidden */
  21617. _shouldGenerateFlatShading: boolean;
  21618. /** @hidden */
  21619. _originalBuilderSideOrientation: number;
  21620. /**
  21621. * Use this property to change the original side orientation defined at construction time
  21622. */
  21623. overrideMaterialSideOrientation: Nullable<number>;
  21624. /**
  21625. * Gets the source mesh (the one used to clone this one from)
  21626. */
  21627. readonly source: Nullable<Mesh>;
  21628. /**
  21629. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21630. */
  21631. isUnIndexed: boolean;
  21632. /**
  21633. * @constructor
  21634. * @param name The value used by scene.getMeshByName() to do a lookup.
  21635. * @param scene The scene to add this mesh to.
  21636. * @param parent The parent of this mesh, if it has one
  21637. * @param source An optional Mesh from which geometry is shared, cloned.
  21638. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21639. * When false, achieved by calling a clone(), also passing False.
  21640. * This will make creation of children, recursive.
  21641. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21642. */
  21643. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21644. /**
  21645. * Gets the class name
  21646. * @returns the string "Mesh".
  21647. */
  21648. getClassName(): string;
  21649. /** @hidden */
  21650. readonly _isMesh: boolean;
  21651. /**
  21652. * Returns a description of this mesh
  21653. * @param fullDetails define if full details about this mesh must be used
  21654. * @returns a descriptive string representing this mesh
  21655. */
  21656. toString(fullDetails?: boolean): string;
  21657. /** @hidden */
  21658. _unBindEffect(): void;
  21659. /**
  21660. * Gets a boolean indicating if this mesh has LOD
  21661. */
  21662. readonly hasLODLevels: boolean;
  21663. /**
  21664. * Gets the list of MeshLODLevel associated with the current mesh
  21665. * @returns an array of MeshLODLevel
  21666. */
  21667. getLODLevels(): MeshLODLevel[];
  21668. private _sortLODLevels;
  21669. /**
  21670. * Add a mesh as LOD level triggered at the given distance.
  21671. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21672. * @param distance The distance from the center of the object to show this level
  21673. * @param mesh The mesh to be added as LOD level (can be null)
  21674. * @return This mesh (for chaining)
  21675. */
  21676. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21677. /**
  21678. * Returns the LOD level mesh at the passed distance or null if not found.
  21679. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21680. * @param distance The distance from the center of the object to show this level
  21681. * @returns a Mesh or `null`
  21682. */
  21683. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21684. /**
  21685. * Remove a mesh from the LOD array
  21686. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21687. * @param mesh defines the mesh to be removed
  21688. * @return This mesh (for chaining)
  21689. */
  21690. removeLODLevel(mesh: Mesh): Mesh;
  21691. /**
  21692. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21693. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21694. * @param camera defines the camera to use to compute distance
  21695. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21696. * @return This mesh (for chaining)
  21697. */
  21698. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21699. /**
  21700. * Gets the mesh internal Geometry object
  21701. */
  21702. readonly geometry: Nullable<Geometry>;
  21703. /**
  21704. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21705. * @returns the total number of vertices
  21706. */
  21707. getTotalVertices(): number;
  21708. /**
  21709. * Returns the content of an associated vertex buffer
  21710. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21711. * - VertexBuffer.PositionKind
  21712. * - VertexBuffer.UVKind
  21713. * - VertexBuffer.UV2Kind
  21714. * - VertexBuffer.UV3Kind
  21715. * - VertexBuffer.UV4Kind
  21716. * - VertexBuffer.UV5Kind
  21717. * - VertexBuffer.UV6Kind
  21718. * - VertexBuffer.ColorKind
  21719. * - VertexBuffer.MatricesIndicesKind
  21720. * - VertexBuffer.MatricesIndicesExtraKind
  21721. * - VertexBuffer.MatricesWeightsKind
  21722. * - VertexBuffer.MatricesWeightsExtraKind
  21723. * @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
  21724. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21725. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21726. */
  21727. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21728. /**
  21729. * Returns the mesh VertexBuffer object from the requested `kind`
  21730. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21731. * - VertexBuffer.PositionKind
  21732. * - VertexBuffer.NormalKind
  21733. * - VertexBuffer.UVKind
  21734. * - VertexBuffer.UV2Kind
  21735. * - VertexBuffer.UV3Kind
  21736. * - VertexBuffer.UV4Kind
  21737. * - VertexBuffer.UV5Kind
  21738. * - VertexBuffer.UV6Kind
  21739. * - VertexBuffer.ColorKind
  21740. * - VertexBuffer.MatricesIndicesKind
  21741. * - VertexBuffer.MatricesIndicesExtraKind
  21742. * - VertexBuffer.MatricesWeightsKind
  21743. * - VertexBuffer.MatricesWeightsExtraKind
  21744. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21745. */
  21746. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21747. /**
  21748. * Tests if a specific vertex buffer is associated with this mesh
  21749. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21750. * - VertexBuffer.PositionKind
  21751. * - VertexBuffer.NormalKind
  21752. * - VertexBuffer.UVKind
  21753. * - VertexBuffer.UV2Kind
  21754. * - VertexBuffer.UV3Kind
  21755. * - VertexBuffer.UV4Kind
  21756. * - VertexBuffer.UV5Kind
  21757. * - VertexBuffer.UV6Kind
  21758. * - VertexBuffer.ColorKind
  21759. * - VertexBuffer.MatricesIndicesKind
  21760. * - VertexBuffer.MatricesIndicesExtraKind
  21761. * - VertexBuffer.MatricesWeightsKind
  21762. * - VertexBuffer.MatricesWeightsExtraKind
  21763. * @returns a boolean
  21764. */
  21765. isVerticesDataPresent(kind: string): boolean;
  21766. /**
  21767. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21768. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21769. * - VertexBuffer.PositionKind
  21770. * - VertexBuffer.UVKind
  21771. * - VertexBuffer.UV2Kind
  21772. * - VertexBuffer.UV3Kind
  21773. * - VertexBuffer.UV4Kind
  21774. * - VertexBuffer.UV5Kind
  21775. * - VertexBuffer.UV6Kind
  21776. * - VertexBuffer.ColorKind
  21777. * - VertexBuffer.MatricesIndicesKind
  21778. * - VertexBuffer.MatricesIndicesExtraKind
  21779. * - VertexBuffer.MatricesWeightsKind
  21780. * - VertexBuffer.MatricesWeightsExtraKind
  21781. * @returns a boolean
  21782. */
  21783. isVertexBufferUpdatable(kind: string): boolean;
  21784. /**
  21785. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21786. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21787. * - VertexBuffer.PositionKind
  21788. * - VertexBuffer.NormalKind
  21789. * - VertexBuffer.UVKind
  21790. * - VertexBuffer.UV2Kind
  21791. * - VertexBuffer.UV3Kind
  21792. * - VertexBuffer.UV4Kind
  21793. * - VertexBuffer.UV5Kind
  21794. * - VertexBuffer.UV6Kind
  21795. * - VertexBuffer.ColorKind
  21796. * - VertexBuffer.MatricesIndicesKind
  21797. * - VertexBuffer.MatricesIndicesExtraKind
  21798. * - VertexBuffer.MatricesWeightsKind
  21799. * - VertexBuffer.MatricesWeightsExtraKind
  21800. * @returns an array of strings
  21801. */
  21802. getVerticesDataKinds(): string[];
  21803. /**
  21804. * Returns a positive integer : the total number of indices in this mesh geometry.
  21805. * @returns the numner of indices or zero if the mesh has no geometry.
  21806. */
  21807. getTotalIndices(): number;
  21808. /**
  21809. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21810. * @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.
  21811. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21812. * @returns the indices array or an empty array if the mesh has no geometry
  21813. */
  21814. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21815. readonly isBlocked: boolean;
  21816. /**
  21817. * Determine if the current mesh is ready to be rendered
  21818. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21819. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21820. * @returns true if all associated assets are ready (material, textures, shaders)
  21821. */
  21822. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21823. /**
  21824. * 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.
  21825. */
  21826. readonly areNormalsFrozen: boolean;
  21827. /**
  21828. * 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.
  21829. * @returns the current mesh
  21830. */
  21831. freezeNormals(): Mesh;
  21832. /**
  21833. * 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
  21834. * @returns the current mesh
  21835. */
  21836. unfreezeNormals(): Mesh;
  21837. /**
  21838. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21839. */
  21840. overridenInstanceCount: number;
  21841. /** @hidden */
  21842. _preActivate(): Mesh;
  21843. /** @hidden */
  21844. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21845. /** @hidden */
  21846. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21847. /**
  21848. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21849. * This means the mesh underlying bounding box and sphere are recomputed.
  21850. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21851. * @returns the current mesh
  21852. */
  21853. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21854. /** @hidden */
  21855. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21856. /**
  21857. * This function will subdivide the mesh into multiple submeshes
  21858. * @param count defines the expected number of submeshes
  21859. */
  21860. subdivide(count: number): void;
  21861. /**
  21862. * Copy a FloatArray into a specific associated vertex buffer
  21863. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21864. * - VertexBuffer.PositionKind
  21865. * - VertexBuffer.UVKind
  21866. * - VertexBuffer.UV2Kind
  21867. * - VertexBuffer.UV3Kind
  21868. * - VertexBuffer.UV4Kind
  21869. * - VertexBuffer.UV5Kind
  21870. * - VertexBuffer.UV6Kind
  21871. * - VertexBuffer.ColorKind
  21872. * - VertexBuffer.MatricesIndicesKind
  21873. * - VertexBuffer.MatricesIndicesExtraKind
  21874. * - VertexBuffer.MatricesWeightsKind
  21875. * - VertexBuffer.MatricesWeightsExtraKind
  21876. * @param data defines the data source
  21877. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21878. * @param stride defines the data stride size (can be null)
  21879. * @returns the current mesh
  21880. */
  21881. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21882. /**
  21883. * Flags an associated vertex buffer as updatable
  21884. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21885. * - VertexBuffer.PositionKind
  21886. * - VertexBuffer.UVKind
  21887. * - VertexBuffer.UV2Kind
  21888. * - VertexBuffer.UV3Kind
  21889. * - VertexBuffer.UV4Kind
  21890. * - VertexBuffer.UV5Kind
  21891. * - VertexBuffer.UV6Kind
  21892. * - VertexBuffer.ColorKind
  21893. * - VertexBuffer.MatricesIndicesKind
  21894. * - VertexBuffer.MatricesIndicesExtraKind
  21895. * - VertexBuffer.MatricesWeightsKind
  21896. * - VertexBuffer.MatricesWeightsExtraKind
  21897. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21898. */
  21899. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21900. /**
  21901. * Sets the mesh global Vertex Buffer
  21902. * @param buffer defines the buffer to use
  21903. * @returns the current mesh
  21904. */
  21905. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21906. /**
  21907. * Update a specific associated vertex buffer
  21908. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21909. * - VertexBuffer.PositionKind
  21910. * - VertexBuffer.UVKind
  21911. * - VertexBuffer.UV2Kind
  21912. * - VertexBuffer.UV3Kind
  21913. * - VertexBuffer.UV4Kind
  21914. * - VertexBuffer.UV5Kind
  21915. * - VertexBuffer.UV6Kind
  21916. * - VertexBuffer.ColorKind
  21917. * - VertexBuffer.MatricesIndicesKind
  21918. * - VertexBuffer.MatricesIndicesExtraKind
  21919. * - VertexBuffer.MatricesWeightsKind
  21920. * - VertexBuffer.MatricesWeightsExtraKind
  21921. * @param data defines the data source
  21922. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21923. * @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)
  21924. * @returns the current mesh
  21925. */
  21926. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21927. /**
  21928. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21929. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21930. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21931. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21932. * @returns the current mesh
  21933. */
  21934. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21935. /**
  21936. * Creates a un-shared specific occurence of the geometry for the mesh.
  21937. * @returns the current mesh
  21938. */
  21939. makeGeometryUnique(): Mesh;
  21940. /**
  21941. * Set the index buffer of this mesh
  21942. * @param indices defines the source data
  21943. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21944. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21945. * @returns the current mesh
  21946. */
  21947. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21948. /**
  21949. * Update the current index buffer
  21950. * @param indices defines the source data
  21951. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21952. * @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)
  21953. * @returns the current mesh
  21954. */
  21955. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21956. /**
  21957. * Invert the geometry to move from a right handed system to a left handed one.
  21958. * @returns the current mesh
  21959. */
  21960. toLeftHanded(): Mesh;
  21961. /** @hidden */
  21962. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21963. /** @hidden */
  21964. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21965. /**
  21966. * Registers for this mesh a javascript function called just before the rendering process
  21967. * @param func defines the function to call before rendering this mesh
  21968. * @returns the current mesh
  21969. */
  21970. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21971. /**
  21972. * Disposes a previously registered javascript function called before the rendering
  21973. * @param func defines the function to remove
  21974. * @returns the current mesh
  21975. */
  21976. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21977. /**
  21978. * Registers for this mesh a javascript function called just after the rendering is complete
  21979. * @param func defines the function to call after rendering this mesh
  21980. * @returns the current mesh
  21981. */
  21982. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21983. /**
  21984. * Disposes a previously registered javascript function called after the rendering.
  21985. * @param func defines the function to remove
  21986. * @returns the current mesh
  21987. */
  21988. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21989. /** @hidden */
  21990. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21991. /** @hidden */
  21992. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21993. /** @hidden */
  21994. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21995. /** @hidden */
  21996. _freeze(): void;
  21997. /** @hidden */
  21998. _unFreeze(): void;
  21999. /**
  22000. * 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
  22001. * @param subMesh defines the subMesh to render
  22002. * @param enableAlphaMode defines if alpha mode can be changed
  22003. * @returns the current mesh
  22004. */
  22005. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  22006. private _onBeforeDraw;
  22007. /**
  22008. * Renormalize the mesh and patch it up if there are no weights
  22009. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  22010. * However in the case of zero weights then we set just a single influence to 1.
  22011. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  22012. */
  22013. cleanMatrixWeights(): void;
  22014. private normalizeSkinFourWeights;
  22015. private normalizeSkinWeightsAndExtra;
  22016. /**
  22017. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  22018. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  22019. * the user know there was an issue with importing the mesh
  22020. * @returns a validation object with skinned, valid and report string
  22021. */
  22022. validateSkinning(): {
  22023. skinned: boolean;
  22024. valid: boolean;
  22025. report: string;
  22026. };
  22027. /** @hidden */
  22028. _checkDelayState(): Mesh;
  22029. private _queueLoad;
  22030. /**
  22031. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  22032. * A mesh is in the frustum if its bounding box intersects the frustum
  22033. * @param frustumPlanes defines the frustum to test
  22034. * @returns true if the mesh is in the frustum planes
  22035. */
  22036. isInFrustum(frustumPlanes: Plane[]): boolean;
  22037. /**
  22038. * Sets the mesh material by the material or multiMaterial `id` property
  22039. * @param id is a string identifying the material or the multiMaterial
  22040. * @returns the current mesh
  22041. */
  22042. setMaterialByID(id: string): Mesh;
  22043. /**
  22044. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  22045. * @returns an array of IAnimatable
  22046. */
  22047. getAnimatables(): IAnimatable[];
  22048. /**
  22049. * Modifies the mesh geometry according to the passed transformation matrix.
  22050. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  22051. * The mesh normals are modified using the same transformation.
  22052. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22053. * @param transform defines the transform matrix to use
  22054. * @see http://doc.babylonjs.com/resources/baking_transformations
  22055. * @returns the current mesh
  22056. */
  22057. bakeTransformIntoVertices(transform: Matrix): Mesh;
  22058. /**
  22059. * Modifies the mesh geometry according to its own current World Matrix.
  22060. * The mesh World Matrix is then reset.
  22061. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  22062. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22063. * @see http://doc.babylonjs.com/resources/baking_transformations
  22064. * @returns the current mesh
  22065. */
  22066. bakeCurrentTransformIntoVertices(): Mesh;
  22067. /** @hidden */
  22068. readonly _positions: Nullable<Vector3[]>;
  22069. /** @hidden */
  22070. _resetPointsArrayCache(): Mesh;
  22071. /** @hidden */
  22072. _generatePointsArray(): boolean;
  22073. /**
  22074. * Returns a new Mesh object generated from the current mesh properties.
  22075. * This method must not get confused with createInstance()
  22076. * @param name is a string, the name given to the new mesh
  22077. * @param newParent can be any Node object (default `null`)
  22078. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  22079. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  22080. * @returns a new mesh
  22081. */
  22082. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  22083. /**
  22084. * Releases resources associated with this mesh.
  22085. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22086. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22087. */
  22088. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22089. /**
  22090. * Modifies the mesh geometry according to a displacement map.
  22091. * 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.
  22092. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22093. * @param url is a string, the URL from the image file is to be downloaded.
  22094. * @param minHeight is the lower limit of the displacement.
  22095. * @param maxHeight is the upper limit of the displacement.
  22096. * @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.
  22097. * @param uvOffset is an optional vector2 used to offset UV.
  22098. * @param uvScale is an optional vector2 used to scale UV.
  22099. * @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.
  22100. * @returns the Mesh.
  22101. */
  22102. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22103. /**
  22104. * Modifies the mesh geometry according to a displacementMap buffer.
  22105. * 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.
  22106. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22107. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  22108. * @param heightMapWidth is the width of the buffer image.
  22109. * @param heightMapHeight is the height of the buffer image.
  22110. * @param minHeight is the lower limit of the displacement.
  22111. * @param maxHeight is the upper limit of the displacement.
  22112. * @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.
  22113. * @param uvOffset is an optional vector2 used to offset UV.
  22114. * @param uvScale is an optional vector2 used to scale UV.
  22115. * @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.
  22116. * @returns the Mesh.
  22117. */
  22118. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22119. /**
  22120. * Modify the mesh to get a flat shading rendering.
  22121. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22122. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22123. * @returns current mesh
  22124. */
  22125. convertToFlatShadedMesh(): Mesh;
  22126. /**
  22127. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22128. * In other words, more vertices, no more indices and a single bigger VBO.
  22129. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22130. * @returns current mesh
  22131. */
  22132. convertToUnIndexedMesh(): Mesh;
  22133. /**
  22134. * Inverses facet orientations.
  22135. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22136. * @param flipNormals will also inverts the normals
  22137. * @returns current mesh
  22138. */
  22139. flipFaces(flipNormals?: boolean): Mesh;
  22140. /**
  22141. * Increase the number of facets and hence vertices in a mesh
  22142. * Vertex normals are interpolated from existing vertex normals
  22143. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22144. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  22145. */
  22146. increaseVertices(numberPerEdge: number): void;
  22147. /**
  22148. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  22149. * This will undo any application of covertToFlatShadedMesh
  22150. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22151. */
  22152. forceSharedVertices(): void;
  22153. /** @hidden */
  22154. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  22155. /** @hidden */
  22156. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  22157. /**
  22158. * Creates a new InstancedMesh object from the mesh model.
  22159. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22160. * @param name defines the name of the new instance
  22161. * @returns a new InstancedMesh
  22162. */
  22163. createInstance(name: string): InstancedMesh;
  22164. /**
  22165. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22166. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22167. * @returns the current mesh
  22168. */
  22169. synchronizeInstances(): Mesh;
  22170. /**
  22171. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22172. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22173. * This should be used together with the simplification to avoid disappearing triangles.
  22174. * @param successCallback an optional success callback to be called after the optimization finished.
  22175. * @returns the current mesh
  22176. */
  22177. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22178. /**
  22179. * Serialize current mesh
  22180. * @param serializationObject defines the object which will receive the serialization data
  22181. */
  22182. serialize(serializationObject: any): void;
  22183. /** @hidden */
  22184. _syncGeometryWithMorphTargetManager(): void;
  22185. /** @hidden */
  22186. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  22187. /**
  22188. * Returns a new Mesh object parsed from the source provided.
  22189. * @param parsedMesh is the source
  22190. * @param scene defines the hosting scene
  22191. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  22192. * @returns a new Mesh
  22193. */
  22194. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22195. /**
  22196. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  22197. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22198. * @param name defines the name of the mesh to create
  22199. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22200. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  22201. * @param closePath creates a seam between the first and the last points of each path of the path array
  22202. * @param offset is taken in account only if the `pathArray` is containing a single path
  22203. * @param scene defines the hosting scene
  22204. * @param updatable defines if the mesh must be flagged as updatable
  22205. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22206. * @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)
  22207. * @returns a new Mesh
  22208. */
  22209. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22210. /**
  22211. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  22212. * @param name defines the name of the mesh to create
  22213. * @param radius sets the radius size (float) of the polygon (default 0.5)
  22214. * @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
  22215. * @param scene defines the hosting scene
  22216. * @param updatable defines if the mesh must be flagged as updatable
  22217. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22218. * @returns a new Mesh
  22219. */
  22220. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22221. /**
  22222. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  22223. * @param name defines the name of the mesh to create
  22224. * @param size sets the size (float) of each box side (default 1)
  22225. * @param scene defines the hosting scene
  22226. * @param updatable defines if the mesh must be flagged as updatable
  22227. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22228. * @returns a new Mesh
  22229. */
  22230. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22231. /**
  22232. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  22233. * @param name defines the name of the mesh to create
  22234. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22235. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22236. * @param scene defines the hosting scene
  22237. * @param updatable defines if the mesh must be flagged as updatable
  22238. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22239. * @returns a new Mesh
  22240. */
  22241. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22242. /**
  22243. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  22244. * @param name defines the name of the mesh to create
  22245. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22246. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22247. * @param scene defines the hosting scene
  22248. * @returns a new Mesh
  22249. */
  22250. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  22251. /**
  22252. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  22253. * @param name defines the name of the mesh to create
  22254. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  22255. * @param diameterTop set the top cap diameter (floats, default 1)
  22256. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  22257. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  22258. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  22259. * @param scene defines the hosting scene
  22260. * @param updatable defines if the mesh must be flagged as updatable
  22261. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22262. * @returns a new Mesh
  22263. */
  22264. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22265. /**
  22266. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  22267. * @param name defines the name of the mesh to create
  22268. * @param diameter sets the diameter size (float) of the torus (default 1)
  22269. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  22270. * @param tessellation sets the number of torus sides (postive integer, default 16)
  22271. * @param scene defines the hosting scene
  22272. * @param updatable defines if the mesh must be flagged as updatable
  22273. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22274. * @returns a new Mesh
  22275. */
  22276. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22277. /**
  22278. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  22279. * @param name defines the name of the mesh to create
  22280. * @param radius sets the global radius size (float) of the torus knot (default 2)
  22281. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  22282. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  22283. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  22284. * @param p the number of windings on X axis (positive integers, default 2)
  22285. * @param q the number of windings on Y axis (positive integers, default 3)
  22286. * @param scene defines the hosting scene
  22287. * @param updatable defines if the mesh must be flagged as updatable
  22288. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22289. * @returns a new Mesh
  22290. */
  22291. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22292. /**
  22293. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  22294. * @param name defines the name of the mesh to create
  22295. * @param points is an array successive Vector3
  22296. * @param scene defines the hosting scene
  22297. * @param updatable defines if the mesh must be flagged as updatable
  22298. * @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).
  22299. * @returns a new Mesh
  22300. */
  22301. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22302. /**
  22303. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  22304. * @param name defines the name of the mesh to create
  22305. * @param points is an array successive Vector3
  22306. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  22307. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22308. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  22309. * @param scene defines the hosting scene
  22310. * @param updatable defines if the mesh must be flagged as updatable
  22311. * @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)
  22312. * @returns a new Mesh
  22313. */
  22314. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22315. /**
  22316. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  22317. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22318. * 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.
  22319. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22320. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22321. * Remember you can only change the shape positions, not their number when updating a polygon.
  22322. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22323. * @param name defines the name of the mesh to create
  22324. * @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
  22325. * @param scene defines the hosting scene
  22326. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22327. * @param updatable defines if the mesh must be flagged as updatable
  22328. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22329. * @param earcutInjection can be used to inject your own earcut reference
  22330. * @returns a new Mesh
  22331. */
  22332. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22333. /**
  22334. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  22335. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  22336. * @param name defines the name of the mesh to create
  22337. * @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
  22338. * @param depth defines the height of extrusion
  22339. * @param scene defines the hosting scene
  22340. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22341. * @param updatable defines if the mesh must be flagged as updatable
  22342. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22343. * @param earcutInjection can be used to inject your own earcut reference
  22344. * @returns a new Mesh
  22345. */
  22346. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22347. /**
  22348. * Creates an extruded shape mesh.
  22349. * 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
  22350. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22351. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22352. * @param name defines the name of the mesh to create
  22353. * @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
  22354. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22355. * @param scale is the value to scale the shape
  22356. * @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
  22357. * @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
  22358. * @param scene defines the hosting scene
  22359. * @param updatable defines if the mesh must be flagged as updatable
  22360. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22361. * @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)
  22362. * @returns a new Mesh
  22363. */
  22364. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22365. /**
  22366. * Creates an custom extruded shape mesh.
  22367. * The custom extrusion is a parametric shape.
  22368. * It has no predefined shape. Its final shape will depend on the input parameters.
  22369. * Please consider using the same method from the MeshBuilder class instead
  22370. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22371. * @param name defines the name of the mesh to create
  22372. * @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
  22373. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22374. * @param scaleFunction is a custom Javascript function called on each path point
  22375. * @param rotationFunction is a custom Javascript function called on each path point
  22376. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22377. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22378. * @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
  22379. * @param scene defines the hosting scene
  22380. * @param updatable defines if the mesh must be flagged as updatable
  22381. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22382. * @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)
  22383. * @returns a new Mesh
  22384. */
  22385. 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;
  22386. /**
  22387. * Creates lathe mesh.
  22388. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22389. * Please consider using the same method from the MeshBuilder class instead
  22390. * @param name defines the name of the mesh to create
  22391. * @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
  22392. * @param radius is the radius value of the lathe
  22393. * @param tessellation is the side number of the lathe.
  22394. * @param scene defines the hosting scene
  22395. * @param updatable defines if the mesh must be flagged as updatable
  22396. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22397. * @returns a new Mesh
  22398. */
  22399. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22400. /**
  22401. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22402. * @param name defines the name of the mesh to create
  22403. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22404. * @param scene defines the hosting scene
  22405. * @param updatable defines if the mesh must be flagged as updatable
  22406. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22407. * @returns a new Mesh
  22408. */
  22409. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22410. /**
  22411. * Creates a ground mesh.
  22412. * Please consider using the same method from the MeshBuilder class instead
  22413. * @param name defines the name of the mesh to create
  22414. * @param width set the width of the ground
  22415. * @param height set the height of the ground
  22416. * @param subdivisions sets the number of subdivisions per side
  22417. * @param scene defines the hosting scene
  22418. * @param updatable defines if the mesh must be flagged as updatable
  22419. * @returns a new Mesh
  22420. */
  22421. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22422. /**
  22423. * Creates a tiled ground mesh.
  22424. * Please consider using the same method from the MeshBuilder class instead
  22425. * @param name defines the name of the mesh to create
  22426. * @param xmin set the ground minimum X coordinate
  22427. * @param zmin set the ground minimum Y coordinate
  22428. * @param xmax set the ground maximum X coordinate
  22429. * @param zmax set the ground maximum Z coordinate
  22430. * @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
  22431. * @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
  22432. * @param scene defines the hosting scene
  22433. * @param updatable defines if the mesh must be flagged as updatable
  22434. * @returns a new Mesh
  22435. */
  22436. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22437. w: number;
  22438. h: number;
  22439. }, precision: {
  22440. w: number;
  22441. h: number;
  22442. }, scene: Scene, updatable?: boolean): Mesh;
  22443. /**
  22444. * Creates a ground mesh from a height map.
  22445. * Please consider using the same method from the MeshBuilder class instead
  22446. * @see http://doc.babylonjs.com/babylon101/height_map
  22447. * @param name defines the name of the mesh to create
  22448. * @param url sets the URL of the height map image resource
  22449. * @param width set the ground width size
  22450. * @param height set the ground height size
  22451. * @param subdivisions sets the number of subdivision per side
  22452. * @param minHeight is the minimum altitude on the ground
  22453. * @param maxHeight is the maximum altitude on the ground
  22454. * @param scene defines the hosting scene
  22455. * @param updatable defines if the mesh must be flagged as updatable
  22456. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22457. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22458. * @returns a new Mesh
  22459. */
  22460. 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;
  22461. /**
  22462. * Creates a tube mesh.
  22463. * The tube is a parametric shape.
  22464. * It has no predefined shape. Its final shape will depend on the input parameters.
  22465. * Please consider using the same method from the MeshBuilder class instead
  22466. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22467. * @param name defines the name of the mesh to create
  22468. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22469. * @param radius sets the tube radius size
  22470. * @param tessellation is the number of sides on the tubular surface
  22471. * @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
  22472. * @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
  22473. * @param scene defines the hosting scene
  22474. * @param updatable defines if the mesh must be flagged as updatable
  22475. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22476. * @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)
  22477. * @returns a new Mesh
  22478. */
  22479. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22480. (i: number, distance: number): number;
  22481. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22482. /**
  22483. * Creates a polyhedron mesh.
  22484. * Please consider using the same method from the MeshBuilder class instead.
  22485. * * 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
  22486. * * The parameter `size` (positive float, default 1) sets the polygon size
  22487. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22488. * * 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`
  22489. * * 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
  22490. * * 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)`)
  22491. * * 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
  22492. * * 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
  22493. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22494. * * If you create a double-sided mesh, you can choose what parts of 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
  22495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22496. * @param name defines the name of the mesh to create
  22497. * @param options defines the options used to create the mesh
  22498. * @param scene defines the hosting scene
  22499. * @returns a new Mesh
  22500. */
  22501. static CreatePolyhedron(name: string, options: {
  22502. type?: number;
  22503. size?: number;
  22504. sizeX?: number;
  22505. sizeY?: number;
  22506. sizeZ?: number;
  22507. custom?: any;
  22508. faceUV?: Vector4[];
  22509. faceColors?: Color4[];
  22510. updatable?: boolean;
  22511. sideOrientation?: number;
  22512. }, scene: Scene): Mesh;
  22513. /**
  22514. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22515. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22516. * * 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`)
  22517. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22518. * * 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
  22519. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22520. * * If you create a double-sided mesh, you can choose what parts of 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
  22521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22522. * @param name defines the name of the mesh
  22523. * @param options defines the options used to create the mesh
  22524. * @param scene defines the hosting scene
  22525. * @returns a new Mesh
  22526. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22527. */
  22528. static CreateIcoSphere(name: string, options: {
  22529. radius?: number;
  22530. flat?: boolean;
  22531. subdivisions?: number;
  22532. sideOrientation?: number;
  22533. updatable?: boolean;
  22534. }, scene: Scene): Mesh;
  22535. /**
  22536. * Creates a decal mesh.
  22537. * Please consider using the same method from the MeshBuilder class instead.
  22538. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22539. * @param name defines the name of the mesh
  22540. * @param sourceMesh defines the mesh receiving the decal
  22541. * @param position sets the position of the decal in world coordinates
  22542. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22543. * @param size sets the decal scaling
  22544. * @param angle sets the angle to rotate the decal
  22545. * @returns a new Mesh
  22546. */
  22547. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22548. /**
  22549. * Prepare internal position array for software CPU skinning
  22550. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22551. */
  22552. setPositionsForCPUSkinning(): Float32Array;
  22553. /**
  22554. * Prepare internal normal array for software CPU skinning
  22555. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22556. */
  22557. setNormalsForCPUSkinning(): Float32Array;
  22558. /**
  22559. * Updates the vertex buffer by applying transformation from the bones
  22560. * @param skeleton defines the skeleton to apply to current mesh
  22561. * @returns the current mesh
  22562. */
  22563. applySkeleton(skeleton: Skeleton): Mesh;
  22564. /**
  22565. * 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
  22566. * @param meshes defines the list of meshes to scan
  22567. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22568. */
  22569. static MinMax(meshes: AbstractMesh[]): {
  22570. min: Vector3;
  22571. max: Vector3;
  22572. };
  22573. /**
  22574. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22575. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22576. * @returns a vector3
  22577. */
  22578. static Center(meshesOrMinMaxVector: {
  22579. min: Vector3;
  22580. max: Vector3;
  22581. } | AbstractMesh[]): Vector3;
  22582. /**
  22583. * Merge the array of meshes into a single mesh for performance reasons.
  22584. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22585. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22586. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22587. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22588. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22589. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22590. * @returns a new mesh
  22591. */
  22592. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22593. /** @hidden */
  22594. addInstance(instance: InstancedMesh): void;
  22595. /** @hidden */
  22596. removeInstance(instance: InstancedMesh): void;
  22597. }
  22598. }
  22599. declare module "babylonjs/Materials/material" {
  22600. import { IAnimatable } from "babylonjs/Misc/tools";
  22601. import { SmartArray } from "babylonjs/Misc/smartArray";
  22602. import { Observable } from "babylonjs/Misc/observable";
  22603. import { Nullable } from "babylonjs/types";
  22604. import { Scene } from "babylonjs/scene";
  22605. import { Matrix } from "babylonjs/Maths/math";
  22606. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22608. import { Mesh } from "babylonjs/Meshes/mesh";
  22609. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22610. import { Effect } from "babylonjs/Materials/effect";
  22611. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22612. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22613. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22614. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22615. import { Animation } from "babylonjs/Animations/animation";
  22616. /**
  22617. * Base class for the main features of a material in Babylon.js
  22618. */
  22619. export class Material implements IAnimatable {
  22620. /**
  22621. * Returns the triangle fill mode
  22622. */
  22623. static readonly TriangleFillMode: number;
  22624. /**
  22625. * Returns the wireframe mode
  22626. */
  22627. static readonly WireFrameFillMode: number;
  22628. /**
  22629. * Returns the point fill mode
  22630. */
  22631. static readonly PointFillMode: number;
  22632. /**
  22633. * Returns the point list draw mode
  22634. */
  22635. static readonly PointListDrawMode: number;
  22636. /**
  22637. * Returns the line list draw mode
  22638. */
  22639. static readonly LineListDrawMode: number;
  22640. /**
  22641. * Returns the line loop draw mode
  22642. */
  22643. static readonly LineLoopDrawMode: number;
  22644. /**
  22645. * Returns the line strip draw mode
  22646. */
  22647. static readonly LineStripDrawMode: number;
  22648. /**
  22649. * Returns the triangle strip draw mode
  22650. */
  22651. static readonly TriangleStripDrawMode: number;
  22652. /**
  22653. * Returns the triangle fan draw mode
  22654. */
  22655. static readonly TriangleFanDrawMode: number;
  22656. /**
  22657. * Stores the clock-wise side orientation
  22658. */
  22659. static readonly ClockWiseSideOrientation: number;
  22660. /**
  22661. * Stores the counter clock-wise side orientation
  22662. */
  22663. static readonly CounterClockWiseSideOrientation: number;
  22664. /**
  22665. * The dirty texture flag value
  22666. */
  22667. static readonly TextureDirtyFlag: number;
  22668. /**
  22669. * The dirty light flag value
  22670. */
  22671. static readonly LightDirtyFlag: number;
  22672. /**
  22673. * The dirty fresnel flag value
  22674. */
  22675. static readonly FresnelDirtyFlag: number;
  22676. /**
  22677. * The dirty attribute flag value
  22678. */
  22679. static readonly AttributesDirtyFlag: number;
  22680. /**
  22681. * The dirty misc flag value
  22682. */
  22683. static readonly MiscDirtyFlag: number;
  22684. /**
  22685. * The all dirty flag value
  22686. */
  22687. static readonly AllDirtyFlag: number;
  22688. /**
  22689. * The ID of the material
  22690. */
  22691. id: string;
  22692. /**
  22693. * Gets or sets the unique id of the material
  22694. */
  22695. uniqueId: number;
  22696. /**
  22697. * The name of the material
  22698. */
  22699. name: string;
  22700. /**
  22701. * Gets or sets user defined metadata
  22702. */
  22703. metadata: any;
  22704. /**
  22705. * For internal use only. Please do not use.
  22706. */
  22707. reservedDataStore: any;
  22708. /**
  22709. * Specifies if the ready state should be checked on each call
  22710. */
  22711. checkReadyOnEveryCall: boolean;
  22712. /**
  22713. * Specifies if the ready state should be checked once
  22714. */
  22715. checkReadyOnlyOnce: boolean;
  22716. /**
  22717. * The state of the material
  22718. */
  22719. state: string;
  22720. /**
  22721. * The alpha value of the material
  22722. */
  22723. protected _alpha: number;
  22724. /**
  22725. * List of inspectable custom properties (used by the Inspector)
  22726. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22727. */
  22728. inspectableCustomProperties: IInspectable[];
  22729. /**
  22730. * Sets the alpha value of the material
  22731. */
  22732. /**
  22733. * Gets the alpha value of the material
  22734. */
  22735. alpha: number;
  22736. /**
  22737. * Specifies if back face culling is enabled
  22738. */
  22739. protected _backFaceCulling: boolean;
  22740. /**
  22741. * Sets the back-face culling state
  22742. */
  22743. /**
  22744. * Gets the back-face culling state
  22745. */
  22746. backFaceCulling: boolean;
  22747. /**
  22748. * Stores the value for side orientation
  22749. */
  22750. sideOrientation: number;
  22751. /**
  22752. * Callback triggered when the material is compiled
  22753. */
  22754. onCompiled: Nullable<(effect: Effect) => void>;
  22755. /**
  22756. * Callback triggered when an error occurs
  22757. */
  22758. onError: Nullable<(effect: Effect, errors: string) => void>;
  22759. /**
  22760. * Callback triggered to get the render target textures
  22761. */
  22762. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22763. /**
  22764. * Gets a boolean indicating that current material needs to register RTT
  22765. */
  22766. readonly hasRenderTargetTextures: boolean;
  22767. /**
  22768. * Specifies if the material should be serialized
  22769. */
  22770. doNotSerialize: boolean;
  22771. /**
  22772. * @hidden
  22773. */
  22774. _storeEffectOnSubMeshes: boolean;
  22775. /**
  22776. * Stores the animations for the material
  22777. */
  22778. animations: Nullable<Array<Animation>>;
  22779. /**
  22780. * An event triggered when the material is disposed
  22781. */
  22782. onDisposeObservable: Observable<Material>;
  22783. /**
  22784. * An observer which watches for dispose events
  22785. */
  22786. private _onDisposeObserver;
  22787. private _onUnBindObservable;
  22788. /**
  22789. * Called during a dispose event
  22790. */
  22791. onDispose: () => void;
  22792. private _onBindObservable;
  22793. /**
  22794. * An event triggered when the material is bound
  22795. */
  22796. readonly onBindObservable: Observable<AbstractMesh>;
  22797. /**
  22798. * An observer which watches for bind events
  22799. */
  22800. private _onBindObserver;
  22801. /**
  22802. * Called during a bind event
  22803. */
  22804. onBind: (Mesh: AbstractMesh) => void;
  22805. /**
  22806. * An event triggered when the material is unbound
  22807. */
  22808. readonly onUnBindObservable: Observable<Material>;
  22809. /**
  22810. * Stores the value of the alpha mode
  22811. */
  22812. private _alphaMode;
  22813. /**
  22814. * Sets the value of the alpha mode.
  22815. *
  22816. * | Value | Type | Description |
  22817. * | --- | --- | --- |
  22818. * | 0 | ALPHA_DISABLE | |
  22819. * | 1 | ALPHA_ADD | |
  22820. * | 2 | ALPHA_COMBINE | |
  22821. * | 3 | ALPHA_SUBTRACT | |
  22822. * | 4 | ALPHA_MULTIPLY | |
  22823. * | 5 | ALPHA_MAXIMIZED | |
  22824. * | 6 | ALPHA_ONEONE | |
  22825. * | 7 | ALPHA_PREMULTIPLIED | |
  22826. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22827. * | 9 | ALPHA_INTERPOLATE | |
  22828. * | 10 | ALPHA_SCREENMODE | |
  22829. *
  22830. */
  22831. /**
  22832. * Gets the value of the alpha mode
  22833. */
  22834. alphaMode: number;
  22835. /**
  22836. * Stores the state of the need depth pre-pass value
  22837. */
  22838. private _needDepthPrePass;
  22839. /**
  22840. * Sets the need depth pre-pass value
  22841. */
  22842. /**
  22843. * Gets the depth pre-pass value
  22844. */
  22845. needDepthPrePass: boolean;
  22846. /**
  22847. * Specifies if depth writing should be disabled
  22848. */
  22849. disableDepthWrite: boolean;
  22850. /**
  22851. * Specifies if depth writing should be forced
  22852. */
  22853. forceDepthWrite: boolean;
  22854. /**
  22855. * Specifies if there should be a separate pass for culling
  22856. */
  22857. separateCullingPass: boolean;
  22858. /**
  22859. * Stores the state specifing if fog should be enabled
  22860. */
  22861. private _fogEnabled;
  22862. /**
  22863. * Sets the state for enabling fog
  22864. */
  22865. /**
  22866. * Gets the value of the fog enabled state
  22867. */
  22868. fogEnabled: boolean;
  22869. /**
  22870. * Stores the size of points
  22871. */
  22872. pointSize: number;
  22873. /**
  22874. * Stores the z offset value
  22875. */
  22876. zOffset: number;
  22877. /**
  22878. * Gets a value specifying if wireframe mode is enabled
  22879. */
  22880. /**
  22881. * Sets the state of wireframe mode
  22882. */
  22883. wireframe: boolean;
  22884. /**
  22885. * Gets the value specifying if point clouds are enabled
  22886. */
  22887. /**
  22888. * Sets the state of point cloud mode
  22889. */
  22890. pointsCloud: boolean;
  22891. /**
  22892. * Gets the material fill mode
  22893. */
  22894. /**
  22895. * Sets the material fill mode
  22896. */
  22897. fillMode: number;
  22898. /**
  22899. * @hidden
  22900. * Stores the effects for the material
  22901. */
  22902. _effect: Nullable<Effect>;
  22903. /**
  22904. * @hidden
  22905. * Specifies if the material was previously ready
  22906. */
  22907. _wasPreviouslyReady: boolean;
  22908. /**
  22909. * Specifies if uniform buffers should be used
  22910. */
  22911. private _useUBO;
  22912. /**
  22913. * Stores a reference to the scene
  22914. */
  22915. private _scene;
  22916. /**
  22917. * Stores the fill mode state
  22918. */
  22919. private _fillMode;
  22920. /**
  22921. * Specifies if the depth write state should be cached
  22922. */
  22923. private _cachedDepthWriteState;
  22924. /**
  22925. * Stores the uniform buffer
  22926. */
  22927. protected _uniformBuffer: UniformBuffer;
  22928. /** @hidden */
  22929. _indexInSceneMaterialArray: number;
  22930. /** @hidden */
  22931. meshMap: Nullable<{
  22932. [id: string]: AbstractMesh | undefined;
  22933. }>;
  22934. /**
  22935. * Creates a material instance
  22936. * @param name defines the name of the material
  22937. * @param scene defines the scene to reference
  22938. * @param doNotAdd specifies if the material should be added to the scene
  22939. */
  22940. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22941. /**
  22942. * Returns a string representation of the current material
  22943. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22944. * @returns a string with material information
  22945. */
  22946. toString(fullDetails?: boolean): string;
  22947. /**
  22948. * Gets the class name of the material
  22949. * @returns a string with the class name of the material
  22950. */
  22951. getClassName(): string;
  22952. /**
  22953. * Specifies if updates for the material been locked
  22954. */
  22955. readonly isFrozen: boolean;
  22956. /**
  22957. * Locks updates for the material
  22958. */
  22959. freeze(): void;
  22960. /**
  22961. * Unlocks updates for the material
  22962. */
  22963. unfreeze(): void;
  22964. /**
  22965. * Specifies if the material is ready to be used
  22966. * @param mesh defines the mesh to check
  22967. * @param useInstances specifies if instances should be used
  22968. * @returns a boolean indicating if the material is ready to be used
  22969. */
  22970. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22971. /**
  22972. * Specifies that the submesh is ready to be used
  22973. * @param mesh defines the mesh to check
  22974. * @param subMesh defines which submesh to check
  22975. * @param useInstances specifies that instances should be used
  22976. * @returns a boolean indicating that the submesh is ready or not
  22977. */
  22978. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22979. /**
  22980. * Returns the material effect
  22981. * @returns the effect associated with the material
  22982. */
  22983. getEffect(): Nullable<Effect>;
  22984. /**
  22985. * Returns the current scene
  22986. * @returns a Scene
  22987. */
  22988. getScene(): Scene;
  22989. /**
  22990. * Specifies if the material will require alpha blending
  22991. * @returns a boolean specifying if alpha blending is needed
  22992. */
  22993. needAlphaBlending(): boolean;
  22994. /**
  22995. * Specifies if the mesh will require alpha blending
  22996. * @param mesh defines the mesh to check
  22997. * @returns a boolean specifying if alpha blending is needed for the mesh
  22998. */
  22999. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  23000. /**
  23001. * Specifies if this material should be rendered in alpha test mode
  23002. * @returns a boolean specifying if an alpha test is needed.
  23003. */
  23004. needAlphaTesting(): boolean;
  23005. /**
  23006. * Gets the texture used for the alpha test
  23007. * @returns the texture to use for alpha testing
  23008. */
  23009. getAlphaTestTexture(): Nullable<BaseTexture>;
  23010. /**
  23011. * Marks the material to indicate that it needs to be re-calculated
  23012. */
  23013. markDirty(): void;
  23014. /** @hidden */
  23015. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  23016. /**
  23017. * Binds the material to the mesh
  23018. * @param world defines the world transformation matrix
  23019. * @param mesh defines the mesh to bind the material to
  23020. */
  23021. bind(world: Matrix, mesh?: Mesh): void;
  23022. /**
  23023. * Binds the submesh to the material
  23024. * @param world defines the world transformation matrix
  23025. * @param mesh defines the mesh containing the submesh
  23026. * @param subMesh defines the submesh to bind the material to
  23027. */
  23028. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23029. /**
  23030. * Binds the world matrix to the material
  23031. * @param world defines the world transformation matrix
  23032. */
  23033. bindOnlyWorldMatrix(world: Matrix): void;
  23034. /**
  23035. * Binds the scene's uniform buffer to the effect.
  23036. * @param effect defines the effect to bind to the scene uniform buffer
  23037. * @param sceneUbo defines the uniform buffer storing scene data
  23038. */
  23039. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  23040. /**
  23041. * Binds the view matrix to the effect
  23042. * @param effect defines the effect to bind the view matrix to
  23043. */
  23044. bindView(effect: Effect): void;
  23045. /**
  23046. * Binds the view projection matrix to the effect
  23047. * @param effect defines the effect to bind the view projection matrix to
  23048. */
  23049. bindViewProjection(effect: Effect): void;
  23050. /**
  23051. * Specifies if material alpha testing should be turned on for the mesh
  23052. * @param mesh defines the mesh to check
  23053. */
  23054. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  23055. /**
  23056. * Processes to execute after binding the material to a mesh
  23057. * @param mesh defines the rendered mesh
  23058. */
  23059. protected _afterBind(mesh?: Mesh): void;
  23060. /**
  23061. * Unbinds the material from the mesh
  23062. */
  23063. unbind(): void;
  23064. /**
  23065. * Gets the active textures from the material
  23066. * @returns an array of textures
  23067. */
  23068. getActiveTextures(): BaseTexture[];
  23069. /**
  23070. * Specifies if the material uses a texture
  23071. * @param texture defines the texture to check against the material
  23072. * @returns a boolean specifying if the material uses the texture
  23073. */
  23074. hasTexture(texture: BaseTexture): boolean;
  23075. /**
  23076. * Makes a duplicate of the material, and gives it a new name
  23077. * @param name defines the new name for the duplicated material
  23078. * @returns the cloned material
  23079. */
  23080. clone(name: string): Nullable<Material>;
  23081. /**
  23082. * Gets the meshes bound to the material
  23083. * @returns an array of meshes bound to the material
  23084. */
  23085. getBindedMeshes(): AbstractMesh[];
  23086. /**
  23087. * Force shader compilation
  23088. * @param mesh defines the mesh associated with this material
  23089. * @param onCompiled defines a function to execute once the material is compiled
  23090. * @param options defines the options to configure the compilation
  23091. */
  23092. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23093. clipPlane: boolean;
  23094. }>): void;
  23095. /**
  23096. * Force shader compilation
  23097. * @param mesh defines the mesh that will use this material
  23098. * @param options defines additional options for compiling the shaders
  23099. * @returns a promise that resolves when the compilation completes
  23100. */
  23101. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23102. clipPlane: boolean;
  23103. }>): Promise<void>;
  23104. private static readonly _AllDirtyCallBack;
  23105. private static readonly _ImageProcessingDirtyCallBack;
  23106. private static readonly _TextureDirtyCallBack;
  23107. private static readonly _FresnelDirtyCallBack;
  23108. private static readonly _MiscDirtyCallBack;
  23109. private static readonly _LightsDirtyCallBack;
  23110. private static readonly _AttributeDirtyCallBack;
  23111. private static _FresnelAndMiscDirtyCallBack;
  23112. private static _TextureAndMiscDirtyCallBack;
  23113. private static readonly _DirtyCallbackArray;
  23114. private static readonly _RunDirtyCallBacks;
  23115. /**
  23116. * Marks a define in the material to indicate that it needs to be re-computed
  23117. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23118. */
  23119. markAsDirty(flag: number): void;
  23120. /**
  23121. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23122. * @param func defines a function which checks material defines against the submeshes
  23123. */
  23124. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23125. /**
  23126. * Indicates that we need to re-calculated for all submeshes
  23127. */
  23128. protected _markAllSubMeshesAsAllDirty(): void;
  23129. /**
  23130. * Indicates that image processing needs to be re-calculated for all submeshes
  23131. */
  23132. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23133. /**
  23134. * Indicates that textures need to be re-calculated for all submeshes
  23135. */
  23136. protected _markAllSubMeshesAsTexturesDirty(): void;
  23137. /**
  23138. * Indicates that fresnel needs to be re-calculated for all submeshes
  23139. */
  23140. protected _markAllSubMeshesAsFresnelDirty(): void;
  23141. /**
  23142. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23143. */
  23144. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23145. /**
  23146. * Indicates that lights need to be re-calculated for all submeshes
  23147. */
  23148. protected _markAllSubMeshesAsLightsDirty(): void;
  23149. /**
  23150. * Indicates that attributes need to be re-calculated for all submeshes
  23151. */
  23152. protected _markAllSubMeshesAsAttributesDirty(): void;
  23153. /**
  23154. * Indicates that misc needs to be re-calculated for all submeshes
  23155. */
  23156. protected _markAllSubMeshesAsMiscDirty(): void;
  23157. /**
  23158. * Indicates that textures and misc need to be re-calculated for all submeshes
  23159. */
  23160. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23161. /**
  23162. * Disposes the material
  23163. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23164. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23165. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23166. */
  23167. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23168. /** @hidden */
  23169. private releaseVertexArrayObject;
  23170. /**
  23171. * Serializes this material
  23172. * @returns the serialized material object
  23173. */
  23174. serialize(): any;
  23175. /**
  23176. * Creates a material from parsed material data
  23177. * @param parsedMaterial defines parsed material data
  23178. * @param scene defines the hosting scene
  23179. * @param rootUrl defines the root URL to use to load textures
  23180. * @returns a new material
  23181. */
  23182. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23183. }
  23184. }
  23185. declare module "babylonjs/Meshes/subMesh" {
  23186. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23187. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23188. import { Engine } from "babylonjs/Engines/engine";
  23189. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23190. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23191. import { Effect } from "babylonjs/Materials/effect";
  23192. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23193. import { Collider } from "babylonjs/Collisions/collider";
  23194. import { Material } from "babylonjs/Materials/material";
  23195. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23197. import { Mesh } from "babylonjs/Meshes/mesh";
  23198. import { Ray } from "babylonjs/Culling/ray";
  23199. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23200. /**
  23201. * Base class for submeshes
  23202. */
  23203. export class BaseSubMesh {
  23204. /** @hidden */
  23205. _materialDefines: Nullable<MaterialDefines>;
  23206. /** @hidden */
  23207. _materialEffect: Nullable<Effect>;
  23208. /**
  23209. * Gets associated effect
  23210. */
  23211. readonly effect: Nullable<Effect>;
  23212. /**
  23213. * Sets associated effect (effect used to render this submesh)
  23214. * @param effect defines the effect to associate with
  23215. * @param defines defines the set of defines used to compile this effect
  23216. */
  23217. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23218. }
  23219. /**
  23220. * Defines a subdivision inside a mesh
  23221. */
  23222. export class SubMesh extends BaseSubMesh implements ICullable {
  23223. /** the material index to use */
  23224. materialIndex: number;
  23225. /** vertex index start */
  23226. verticesStart: number;
  23227. /** vertices count */
  23228. verticesCount: number;
  23229. /** index start */
  23230. indexStart: number;
  23231. /** indices count */
  23232. indexCount: number;
  23233. /** @hidden */
  23234. _linesIndexCount: number;
  23235. private _mesh;
  23236. private _renderingMesh;
  23237. private _boundingInfo;
  23238. private _linesIndexBuffer;
  23239. /** @hidden */
  23240. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23241. /** @hidden */
  23242. _trianglePlanes: Plane[];
  23243. /** @hidden */
  23244. _lastColliderTransformMatrix: Nullable<Matrix>;
  23245. /** @hidden */
  23246. _renderId: number;
  23247. /** @hidden */
  23248. _alphaIndex: number;
  23249. /** @hidden */
  23250. _distanceToCamera: number;
  23251. /** @hidden */
  23252. _id: number;
  23253. private _currentMaterial;
  23254. /**
  23255. * Add a new submesh to a mesh
  23256. * @param materialIndex defines the material index to use
  23257. * @param verticesStart defines vertex index start
  23258. * @param verticesCount defines vertices count
  23259. * @param indexStart defines index start
  23260. * @param indexCount defines indices count
  23261. * @param mesh defines the parent mesh
  23262. * @param renderingMesh defines an optional rendering mesh
  23263. * @param createBoundingBox defines if bounding box should be created for this submesh
  23264. * @returns the new submesh
  23265. */
  23266. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23267. /**
  23268. * Creates a new submesh
  23269. * @param materialIndex defines the material index to use
  23270. * @param verticesStart defines vertex index start
  23271. * @param verticesCount defines vertices count
  23272. * @param indexStart defines index start
  23273. * @param indexCount defines indices count
  23274. * @param mesh defines the parent mesh
  23275. * @param renderingMesh defines an optional rendering mesh
  23276. * @param createBoundingBox defines if bounding box should be created for this submesh
  23277. */
  23278. constructor(
  23279. /** the material index to use */
  23280. materialIndex: number,
  23281. /** vertex index start */
  23282. verticesStart: number,
  23283. /** vertices count */
  23284. verticesCount: number,
  23285. /** index start */
  23286. indexStart: number,
  23287. /** indices count */
  23288. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23289. /**
  23290. * Returns true if this submesh covers the entire parent mesh
  23291. * @ignorenaming
  23292. */
  23293. readonly IsGlobal: boolean;
  23294. /**
  23295. * Returns the submesh BoudingInfo object
  23296. * @returns current bounding info (or mesh's one if the submesh is global)
  23297. */
  23298. getBoundingInfo(): BoundingInfo;
  23299. /**
  23300. * Sets the submesh BoundingInfo
  23301. * @param boundingInfo defines the new bounding info to use
  23302. * @returns the SubMesh
  23303. */
  23304. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23305. /**
  23306. * Returns the mesh of the current submesh
  23307. * @return the parent mesh
  23308. */
  23309. getMesh(): AbstractMesh;
  23310. /**
  23311. * Returns the rendering mesh of the submesh
  23312. * @returns the rendering mesh (could be different from parent mesh)
  23313. */
  23314. getRenderingMesh(): Mesh;
  23315. /**
  23316. * Returns the submesh material
  23317. * @returns null or the current material
  23318. */
  23319. getMaterial(): Nullable<Material>;
  23320. /**
  23321. * Sets a new updated BoundingInfo object to the submesh
  23322. * @param data defines an optional position array to use to determine the bounding info
  23323. * @returns the SubMesh
  23324. */
  23325. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23326. /** @hidden */
  23327. _checkCollision(collider: Collider): boolean;
  23328. /**
  23329. * Updates the submesh BoundingInfo
  23330. * @param world defines the world matrix to use to update the bounding info
  23331. * @returns the submesh
  23332. */
  23333. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23334. /**
  23335. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23336. * @param frustumPlanes defines the frustum planes
  23337. * @returns true if the submesh is intersecting with the frustum
  23338. */
  23339. isInFrustum(frustumPlanes: Plane[]): boolean;
  23340. /**
  23341. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23342. * @param frustumPlanes defines the frustum planes
  23343. * @returns true if the submesh is inside the frustum
  23344. */
  23345. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23346. /**
  23347. * Renders the submesh
  23348. * @param enableAlphaMode defines if alpha needs to be used
  23349. * @returns the submesh
  23350. */
  23351. render(enableAlphaMode: boolean): SubMesh;
  23352. /**
  23353. * @hidden
  23354. */
  23355. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23356. /**
  23357. * Checks if the submesh intersects with a ray
  23358. * @param ray defines the ray to test
  23359. * @returns true is the passed ray intersects the submesh bounding box
  23360. */
  23361. canIntersects(ray: Ray): boolean;
  23362. /**
  23363. * Intersects current submesh with a ray
  23364. * @param ray defines the ray to test
  23365. * @param positions defines mesh's positions array
  23366. * @param indices defines mesh's indices array
  23367. * @param fastCheck defines if only bounding info should be used
  23368. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23369. * @returns intersection info or null if no intersection
  23370. */
  23371. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23372. /** @hidden */
  23373. private _intersectLines;
  23374. /** @hidden */
  23375. private _intersectUnIndexedLines;
  23376. /** @hidden */
  23377. private _intersectTriangles;
  23378. /** @hidden */
  23379. private _intersectUnIndexedTriangles;
  23380. /** @hidden */
  23381. _rebuild(): void;
  23382. /**
  23383. * Creates a new submesh from the passed mesh
  23384. * @param newMesh defines the new hosting mesh
  23385. * @param newRenderingMesh defines an optional rendering mesh
  23386. * @returns the new submesh
  23387. */
  23388. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23389. /**
  23390. * Release associated resources
  23391. */
  23392. dispose(): void;
  23393. /**
  23394. * Gets the class name
  23395. * @returns the string "SubMesh".
  23396. */
  23397. getClassName(): string;
  23398. /**
  23399. * Creates a new submesh from indices data
  23400. * @param materialIndex the index of the main mesh material
  23401. * @param startIndex the index where to start the copy in the mesh indices array
  23402. * @param indexCount the number of indices to copy then from the startIndex
  23403. * @param mesh the main mesh to create the submesh from
  23404. * @param renderingMesh the optional rendering mesh
  23405. * @returns a new submesh
  23406. */
  23407. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23408. }
  23409. }
  23410. declare module "babylonjs/Meshes/geometry" {
  23411. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23412. import { Scene } from "babylonjs/scene";
  23413. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23414. import { Engine } from "babylonjs/Engines/engine";
  23415. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23416. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23417. import { Effect } from "babylonjs/Materials/effect";
  23418. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23419. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23420. import { Mesh } from "babylonjs/Meshes/mesh";
  23421. /**
  23422. * Class used to store geometry data (vertex buffers + index buffer)
  23423. */
  23424. export class Geometry implements IGetSetVerticesData {
  23425. /**
  23426. * Gets or sets the ID of the geometry
  23427. */
  23428. id: string;
  23429. /**
  23430. * Gets or sets the unique ID of the geometry
  23431. */
  23432. uniqueId: number;
  23433. /**
  23434. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23435. */
  23436. delayLoadState: number;
  23437. /**
  23438. * Gets the file containing the data to load when running in delay load state
  23439. */
  23440. delayLoadingFile: Nullable<string>;
  23441. /**
  23442. * Callback called when the geometry is updated
  23443. */
  23444. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23445. private _scene;
  23446. private _engine;
  23447. private _meshes;
  23448. private _totalVertices;
  23449. /** @hidden */
  23450. _indices: IndicesArray;
  23451. /** @hidden */
  23452. _vertexBuffers: {
  23453. [key: string]: VertexBuffer;
  23454. };
  23455. private _isDisposed;
  23456. private _extend;
  23457. private _boundingBias;
  23458. /** @hidden */
  23459. _delayInfo: Array<string>;
  23460. private _indexBuffer;
  23461. private _indexBufferIsUpdatable;
  23462. /** @hidden */
  23463. _boundingInfo: Nullable<BoundingInfo>;
  23464. /** @hidden */
  23465. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23466. /** @hidden */
  23467. _softwareSkinningFrameId: number;
  23468. private _vertexArrayObjects;
  23469. private _updatable;
  23470. /** @hidden */
  23471. _positions: Nullable<Vector3[]>;
  23472. /**
  23473. * 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
  23474. */
  23475. /**
  23476. * 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
  23477. */
  23478. boundingBias: Vector2;
  23479. /**
  23480. * Static function used to attach a new empty geometry to a mesh
  23481. * @param mesh defines the mesh to attach the geometry to
  23482. * @returns the new Geometry
  23483. */
  23484. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23485. /**
  23486. * Creates a new geometry
  23487. * @param id defines the unique ID
  23488. * @param scene defines the hosting scene
  23489. * @param vertexData defines the VertexData used to get geometry data
  23490. * @param updatable defines if geometry must be updatable (false by default)
  23491. * @param mesh defines the mesh that will be associated with the geometry
  23492. */
  23493. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23494. /**
  23495. * Gets the current extend of the geometry
  23496. */
  23497. readonly extend: {
  23498. minimum: Vector3;
  23499. maximum: Vector3;
  23500. };
  23501. /**
  23502. * Gets the hosting scene
  23503. * @returns the hosting Scene
  23504. */
  23505. getScene(): Scene;
  23506. /**
  23507. * Gets the hosting engine
  23508. * @returns the hosting Engine
  23509. */
  23510. getEngine(): Engine;
  23511. /**
  23512. * Defines if the geometry is ready to use
  23513. * @returns true if the geometry is ready to be used
  23514. */
  23515. isReady(): boolean;
  23516. /**
  23517. * Gets a value indicating that the geometry should not be serialized
  23518. */
  23519. readonly doNotSerialize: boolean;
  23520. /** @hidden */
  23521. _rebuild(): void;
  23522. /**
  23523. * Affects all geometry data in one call
  23524. * @param vertexData defines the geometry data
  23525. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23526. */
  23527. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23528. /**
  23529. * Set specific vertex data
  23530. * @param kind defines the data kind (Position, normal, etc...)
  23531. * @param data defines the vertex data to use
  23532. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23533. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23534. */
  23535. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23536. /**
  23537. * Removes a specific vertex data
  23538. * @param kind defines the data kind (Position, normal, etc...)
  23539. */
  23540. removeVerticesData(kind: string): void;
  23541. /**
  23542. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23543. * @param buffer defines the vertex buffer to use
  23544. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23545. */
  23546. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23547. /**
  23548. * Update a specific vertex buffer
  23549. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23550. * It will do nothing if the buffer is not updatable
  23551. * @param kind defines the data kind (Position, normal, etc...)
  23552. * @param data defines the data to use
  23553. * @param offset defines the offset in the target buffer where to store the data
  23554. * @param useBytes set to true if the offset is in bytes
  23555. */
  23556. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23557. /**
  23558. * Update a specific vertex buffer
  23559. * This function will create a new buffer if the current one is not updatable
  23560. * @param kind defines the data kind (Position, normal, etc...)
  23561. * @param data defines the data to use
  23562. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23563. */
  23564. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23565. private _updateBoundingInfo;
  23566. /** @hidden */
  23567. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23568. /**
  23569. * Gets total number of vertices
  23570. * @returns the total number of vertices
  23571. */
  23572. getTotalVertices(): number;
  23573. /**
  23574. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23575. * @param kind defines the data kind (Position, normal, etc...)
  23576. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23577. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23578. * @returns a float array containing vertex data
  23579. */
  23580. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23581. /**
  23582. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23583. * @param kind defines the data kind (Position, normal, etc...)
  23584. * @returns true if the vertex buffer with the specified kind is updatable
  23585. */
  23586. isVertexBufferUpdatable(kind: string): boolean;
  23587. /**
  23588. * Gets a specific vertex buffer
  23589. * @param kind defines the data kind (Position, normal, etc...)
  23590. * @returns a VertexBuffer
  23591. */
  23592. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23593. /**
  23594. * Returns all vertex buffers
  23595. * @return an object holding all vertex buffers indexed by kind
  23596. */
  23597. getVertexBuffers(): Nullable<{
  23598. [key: string]: VertexBuffer;
  23599. }>;
  23600. /**
  23601. * Gets a boolean indicating if specific vertex buffer is present
  23602. * @param kind defines the data kind (Position, normal, etc...)
  23603. * @returns true if data is present
  23604. */
  23605. isVerticesDataPresent(kind: string): boolean;
  23606. /**
  23607. * Gets a list of all attached data kinds (Position, normal, etc...)
  23608. * @returns a list of string containing all kinds
  23609. */
  23610. getVerticesDataKinds(): string[];
  23611. /**
  23612. * Update index buffer
  23613. * @param indices defines the indices to store in the index buffer
  23614. * @param offset defines the offset in the target buffer where to store the data
  23615. * @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)
  23616. */
  23617. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23618. /**
  23619. * Creates a new index buffer
  23620. * @param indices defines the indices to store in the index buffer
  23621. * @param totalVertices defines the total number of vertices (could be null)
  23622. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23623. */
  23624. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23625. /**
  23626. * Return the total number of indices
  23627. * @returns the total number of indices
  23628. */
  23629. getTotalIndices(): number;
  23630. /**
  23631. * Gets the index buffer array
  23632. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23633. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23634. * @returns the index buffer array
  23635. */
  23636. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23637. /**
  23638. * Gets the index buffer
  23639. * @return the index buffer
  23640. */
  23641. getIndexBuffer(): Nullable<DataBuffer>;
  23642. /** @hidden */
  23643. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23644. /**
  23645. * Release the associated resources for a specific mesh
  23646. * @param mesh defines the source mesh
  23647. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23648. */
  23649. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23650. /**
  23651. * Apply current geometry to a given mesh
  23652. * @param mesh defines the mesh to apply geometry to
  23653. */
  23654. applyToMesh(mesh: Mesh): void;
  23655. private _updateExtend;
  23656. private _applyToMesh;
  23657. private notifyUpdate;
  23658. /**
  23659. * Load the geometry if it was flagged as delay loaded
  23660. * @param scene defines the hosting scene
  23661. * @param onLoaded defines a callback called when the geometry is loaded
  23662. */
  23663. load(scene: Scene, onLoaded?: () => void): void;
  23664. private _queueLoad;
  23665. /**
  23666. * Invert the geometry to move from a right handed system to a left handed one.
  23667. */
  23668. toLeftHanded(): void;
  23669. /** @hidden */
  23670. _resetPointsArrayCache(): void;
  23671. /** @hidden */
  23672. _generatePointsArray(): boolean;
  23673. /**
  23674. * Gets a value indicating if the geometry is disposed
  23675. * @returns true if the geometry was disposed
  23676. */
  23677. isDisposed(): boolean;
  23678. private _disposeVertexArrayObjects;
  23679. /**
  23680. * Free all associated resources
  23681. */
  23682. dispose(): void;
  23683. /**
  23684. * Clone the current geometry into a new geometry
  23685. * @param id defines the unique ID of the new geometry
  23686. * @returns a new geometry object
  23687. */
  23688. copy(id: string): Geometry;
  23689. /**
  23690. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23691. * @return a JSON representation of the current geometry data (without the vertices data)
  23692. */
  23693. serialize(): any;
  23694. private toNumberArray;
  23695. /**
  23696. * Serialize all vertices data into a JSON oject
  23697. * @returns a JSON representation of the current geometry data
  23698. */
  23699. serializeVerticeData(): any;
  23700. /**
  23701. * Extracts a clone of a mesh geometry
  23702. * @param mesh defines the source mesh
  23703. * @param id defines the unique ID of the new geometry object
  23704. * @returns the new geometry object
  23705. */
  23706. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23707. /**
  23708. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23709. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23710. * Be aware Math.random() could cause collisions, but:
  23711. * "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"
  23712. * @returns a string containing a new GUID
  23713. */
  23714. static RandomId(): string;
  23715. /** @hidden */
  23716. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23717. private static _CleanMatricesWeights;
  23718. /**
  23719. * Create a new geometry from persisted data (Using .babylon file format)
  23720. * @param parsedVertexData defines the persisted data
  23721. * @param scene defines the hosting scene
  23722. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23723. * @returns the new geometry object
  23724. */
  23725. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23726. }
  23727. }
  23728. declare module "babylonjs/Meshes/mesh.vertexData" {
  23729. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23730. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23731. import { Geometry } from "babylonjs/Meshes/geometry";
  23732. import { Mesh } from "babylonjs/Meshes/mesh";
  23733. /**
  23734. * Define an interface for all classes that will get and set the data on vertices
  23735. */
  23736. export interface IGetSetVerticesData {
  23737. /**
  23738. * Gets a boolean indicating if specific vertex data is present
  23739. * @param kind defines the vertex data kind to use
  23740. * @returns true is data kind is present
  23741. */
  23742. isVerticesDataPresent(kind: string): boolean;
  23743. /**
  23744. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23745. * @param kind defines the data kind (Position, normal, etc...)
  23746. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23747. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23748. * @returns a float array containing vertex data
  23749. */
  23750. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23751. /**
  23752. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23753. * @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.
  23754. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23755. * @returns the indices array or an empty array if the mesh has no geometry
  23756. */
  23757. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23758. /**
  23759. * Set specific vertex data
  23760. * @param kind defines the data kind (Position, normal, etc...)
  23761. * @param data defines the vertex data to use
  23762. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23763. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23764. */
  23765. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23766. /**
  23767. * Update a specific associated vertex buffer
  23768. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23769. * - VertexBuffer.PositionKind
  23770. * - VertexBuffer.UVKind
  23771. * - VertexBuffer.UV2Kind
  23772. * - VertexBuffer.UV3Kind
  23773. * - VertexBuffer.UV4Kind
  23774. * - VertexBuffer.UV5Kind
  23775. * - VertexBuffer.UV6Kind
  23776. * - VertexBuffer.ColorKind
  23777. * - VertexBuffer.MatricesIndicesKind
  23778. * - VertexBuffer.MatricesIndicesExtraKind
  23779. * - VertexBuffer.MatricesWeightsKind
  23780. * - VertexBuffer.MatricesWeightsExtraKind
  23781. * @param data defines the data source
  23782. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23783. * @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)
  23784. */
  23785. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23786. /**
  23787. * Creates a new index buffer
  23788. * @param indices defines the indices to store in the index buffer
  23789. * @param totalVertices defines the total number of vertices (could be null)
  23790. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23791. */
  23792. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23793. }
  23794. /**
  23795. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23796. */
  23797. export class VertexData {
  23798. /**
  23799. * Mesh side orientation : usually the external or front surface
  23800. */
  23801. static readonly FRONTSIDE: number;
  23802. /**
  23803. * Mesh side orientation : usually the internal or back surface
  23804. */
  23805. static readonly BACKSIDE: number;
  23806. /**
  23807. * Mesh side orientation : both internal and external or front and back surfaces
  23808. */
  23809. static readonly DOUBLESIDE: number;
  23810. /**
  23811. * Mesh side orientation : by default, `FRONTSIDE`
  23812. */
  23813. static readonly DEFAULTSIDE: number;
  23814. /**
  23815. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23816. */
  23817. positions: Nullable<FloatArray>;
  23818. /**
  23819. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23820. */
  23821. normals: Nullable<FloatArray>;
  23822. /**
  23823. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23824. */
  23825. tangents: Nullable<FloatArray>;
  23826. /**
  23827. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23828. */
  23829. uvs: Nullable<FloatArray>;
  23830. /**
  23831. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23832. */
  23833. uvs2: Nullable<FloatArray>;
  23834. /**
  23835. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23836. */
  23837. uvs3: Nullable<FloatArray>;
  23838. /**
  23839. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23840. */
  23841. uvs4: Nullable<FloatArray>;
  23842. /**
  23843. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23844. */
  23845. uvs5: Nullable<FloatArray>;
  23846. /**
  23847. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23848. */
  23849. uvs6: Nullable<FloatArray>;
  23850. /**
  23851. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23852. */
  23853. colors: Nullable<FloatArray>;
  23854. /**
  23855. * 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).
  23856. */
  23857. matricesIndices: Nullable<FloatArray>;
  23858. /**
  23859. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23860. */
  23861. matricesWeights: Nullable<FloatArray>;
  23862. /**
  23863. * An array extending the number of possible indices
  23864. */
  23865. matricesIndicesExtra: Nullable<FloatArray>;
  23866. /**
  23867. * An array extending the number of possible weights when the number of indices is extended
  23868. */
  23869. matricesWeightsExtra: Nullable<FloatArray>;
  23870. /**
  23871. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23872. */
  23873. indices: Nullable<IndicesArray>;
  23874. /**
  23875. * Uses the passed data array to set the set the values for the specified kind of data
  23876. * @param data a linear array of floating numbers
  23877. * @param kind the type of data that is being set, eg positions, colors etc
  23878. */
  23879. set(data: FloatArray, kind: string): void;
  23880. /**
  23881. * Associates the vertexData to the passed Mesh.
  23882. * Sets it as updatable or not (default `false`)
  23883. * @param mesh the mesh the vertexData is applied to
  23884. * @param updatable when used and having the value true allows new data to update the vertexData
  23885. * @returns the VertexData
  23886. */
  23887. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23888. /**
  23889. * Associates the vertexData to the passed Geometry.
  23890. * Sets it as updatable or not (default `false`)
  23891. * @param geometry the geometry the vertexData is applied to
  23892. * @param updatable when used and having the value true allows new data to update the vertexData
  23893. * @returns VertexData
  23894. */
  23895. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23896. /**
  23897. * Updates the associated mesh
  23898. * @param mesh the mesh to be updated
  23899. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23900. * @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
  23901. * @returns VertexData
  23902. */
  23903. updateMesh(mesh: Mesh): VertexData;
  23904. /**
  23905. * Updates the associated geometry
  23906. * @param geometry the geometry to be updated
  23907. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23908. * @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
  23909. * @returns VertexData.
  23910. */
  23911. updateGeometry(geometry: Geometry): VertexData;
  23912. private _applyTo;
  23913. private _update;
  23914. /**
  23915. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23916. * @param matrix the transforming matrix
  23917. * @returns the VertexData
  23918. */
  23919. transform(matrix: Matrix): VertexData;
  23920. /**
  23921. * Merges the passed VertexData into the current one
  23922. * @param other the VertexData to be merged into the current one
  23923. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23924. * @returns the modified VertexData
  23925. */
  23926. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23927. private _mergeElement;
  23928. private _validate;
  23929. /**
  23930. * Serializes the VertexData
  23931. * @returns a serialized object
  23932. */
  23933. serialize(): any;
  23934. /**
  23935. * Extracts the vertexData from a mesh
  23936. * @param mesh the mesh from which to extract the VertexData
  23937. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23938. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23939. * @returns the object VertexData associated to the passed mesh
  23940. */
  23941. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23942. /**
  23943. * Extracts the vertexData from the geometry
  23944. * @param geometry the geometry from which to extract the VertexData
  23945. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23946. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23947. * @returns the object VertexData associated to the passed mesh
  23948. */
  23949. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23950. private static _ExtractFrom;
  23951. /**
  23952. * Creates the VertexData for a Ribbon
  23953. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23954. * * pathArray array of paths, each of which an array of successive Vector3
  23955. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23956. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23957. * * 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
  23958. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23959. * * 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)
  23960. * * 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)
  23961. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23962. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23963. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23964. * @returns the VertexData of the ribbon
  23965. */
  23966. static CreateRibbon(options: {
  23967. pathArray: Vector3[][];
  23968. closeArray?: boolean;
  23969. closePath?: boolean;
  23970. offset?: number;
  23971. sideOrientation?: number;
  23972. frontUVs?: Vector4;
  23973. backUVs?: Vector4;
  23974. invertUV?: boolean;
  23975. uvs?: Vector2[];
  23976. colors?: Color4[];
  23977. }): VertexData;
  23978. /**
  23979. * Creates the VertexData for a box
  23980. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23981. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23982. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23983. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23984. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23985. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23986. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23987. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23988. * * 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)
  23989. * * 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)
  23990. * @returns the VertexData of the box
  23991. */
  23992. static CreateBox(options: {
  23993. size?: number;
  23994. width?: number;
  23995. height?: number;
  23996. depth?: number;
  23997. faceUV?: Vector4[];
  23998. faceColors?: Color4[];
  23999. sideOrientation?: number;
  24000. frontUVs?: Vector4;
  24001. backUVs?: Vector4;
  24002. }): VertexData;
  24003. /**
  24004. * Creates the VertexData for a tiled box
  24005. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24006. * * faceTiles sets the pattern, tile size and number of tiles for a face
  24007. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24008. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24009. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24010. * @returns the VertexData of the box
  24011. */
  24012. static CreateTiledBox(options: {
  24013. pattern?: number;
  24014. width?: number;
  24015. height?: number;
  24016. depth?: number;
  24017. tileSize?: number;
  24018. tileWidth?: number;
  24019. tileHeight?: number;
  24020. alignHorizontal?: number;
  24021. alignVertical?: number;
  24022. faceUV?: Vector4[];
  24023. faceColors?: Color4[];
  24024. sideOrientation?: number;
  24025. }): VertexData;
  24026. /**
  24027. * Creates the VertexData for a tiled plane
  24028. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24029. * * pattern a limited pattern arrangement depending on the number
  24030. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  24031. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  24032. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  24033. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24034. * * 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)
  24035. * * 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)
  24036. * @returns the VertexData of the tiled plane
  24037. */
  24038. static CreateTiledPlane(options: {
  24039. pattern?: number;
  24040. tileSize?: number;
  24041. tileWidth?: number;
  24042. tileHeight?: number;
  24043. size?: number;
  24044. width?: number;
  24045. height?: number;
  24046. alignHorizontal?: number;
  24047. alignVertical?: number;
  24048. sideOrientation?: number;
  24049. frontUVs?: Vector4;
  24050. backUVs?: Vector4;
  24051. }): VertexData;
  24052. /**
  24053. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24054. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24055. * * segments sets the number of horizontal strips optional, default 32
  24056. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24057. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24058. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24059. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24060. * * 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
  24061. * * 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
  24062. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24063. * * 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)
  24064. * * 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)
  24065. * @returns the VertexData of the ellipsoid
  24066. */
  24067. static CreateSphere(options: {
  24068. segments?: number;
  24069. diameter?: number;
  24070. diameterX?: number;
  24071. diameterY?: number;
  24072. diameterZ?: number;
  24073. arc?: number;
  24074. slice?: number;
  24075. sideOrientation?: number;
  24076. frontUVs?: Vector4;
  24077. backUVs?: Vector4;
  24078. }): VertexData;
  24079. /**
  24080. * Creates the VertexData for a cylinder, cone or prism
  24081. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24082. * * height sets the height (y direction) of the cylinder, optional, default 2
  24083. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24084. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24085. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24086. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24087. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24088. * * 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
  24089. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24090. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24091. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24092. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24093. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24094. * * 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)
  24095. * * 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)
  24096. * @returns the VertexData of the cylinder, cone or prism
  24097. */
  24098. static CreateCylinder(options: {
  24099. height?: number;
  24100. diameterTop?: number;
  24101. diameterBottom?: number;
  24102. diameter?: number;
  24103. tessellation?: number;
  24104. subdivisions?: number;
  24105. arc?: number;
  24106. faceColors?: Color4[];
  24107. faceUV?: Vector4[];
  24108. hasRings?: boolean;
  24109. enclose?: boolean;
  24110. sideOrientation?: number;
  24111. frontUVs?: Vector4;
  24112. backUVs?: Vector4;
  24113. }): VertexData;
  24114. /**
  24115. * Creates the VertexData for a torus
  24116. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24117. * * diameter the diameter of the torus, optional default 1
  24118. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24119. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24120. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24121. * * 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)
  24122. * * 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)
  24123. * @returns the VertexData of the torus
  24124. */
  24125. static CreateTorus(options: {
  24126. diameter?: number;
  24127. thickness?: number;
  24128. tessellation?: number;
  24129. sideOrientation?: number;
  24130. frontUVs?: Vector4;
  24131. backUVs?: Vector4;
  24132. }): VertexData;
  24133. /**
  24134. * Creates the VertexData of the LineSystem
  24135. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24136. * - lines an array of lines, each line being an array of successive Vector3
  24137. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24138. * @returns the VertexData of the LineSystem
  24139. */
  24140. static CreateLineSystem(options: {
  24141. lines: Vector3[][];
  24142. colors?: Nullable<Color4[][]>;
  24143. }): VertexData;
  24144. /**
  24145. * Create the VertexData for a DashedLines
  24146. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24147. * - points an array successive Vector3
  24148. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24149. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24150. * - dashNb the intended total number of dashes, optional, default 200
  24151. * @returns the VertexData for the DashedLines
  24152. */
  24153. static CreateDashedLines(options: {
  24154. points: Vector3[];
  24155. dashSize?: number;
  24156. gapSize?: number;
  24157. dashNb?: number;
  24158. }): VertexData;
  24159. /**
  24160. * Creates the VertexData for a Ground
  24161. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24162. * - width the width (x direction) of the ground, optional, default 1
  24163. * - height the height (z direction) of the ground, optional, default 1
  24164. * - subdivisions the number of subdivisions per side, optional, default 1
  24165. * @returns the VertexData of the Ground
  24166. */
  24167. static CreateGround(options: {
  24168. width?: number;
  24169. height?: number;
  24170. subdivisions?: number;
  24171. subdivisionsX?: number;
  24172. subdivisionsY?: number;
  24173. }): VertexData;
  24174. /**
  24175. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24176. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24177. * * xmin the ground minimum X coordinate, optional, default -1
  24178. * * zmin the ground minimum Z coordinate, optional, default -1
  24179. * * xmax the ground maximum X coordinate, optional, default 1
  24180. * * zmax the ground maximum Z coordinate, optional, default 1
  24181. * * 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}
  24182. * * 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}
  24183. * @returns the VertexData of the TiledGround
  24184. */
  24185. static CreateTiledGround(options: {
  24186. xmin: number;
  24187. zmin: number;
  24188. xmax: number;
  24189. zmax: number;
  24190. subdivisions?: {
  24191. w: number;
  24192. h: number;
  24193. };
  24194. precision?: {
  24195. w: number;
  24196. h: number;
  24197. };
  24198. }): VertexData;
  24199. /**
  24200. * Creates the VertexData of the Ground designed from a heightmap
  24201. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24202. * * width the width (x direction) of the ground
  24203. * * height the height (z direction) of the ground
  24204. * * subdivisions the number of subdivisions per side
  24205. * * minHeight the minimum altitude on the ground, optional, default 0
  24206. * * maxHeight the maximum altitude on the ground, optional default 1
  24207. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24208. * * buffer the array holding the image color data
  24209. * * bufferWidth the width of image
  24210. * * bufferHeight the height of image
  24211. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24212. * @returns the VertexData of the Ground designed from a heightmap
  24213. */
  24214. static CreateGroundFromHeightMap(options: {
  24215. width: number;
  24216. height: number;
  24217. subdivisions: number;
  24218. minHeight: number;
  24219. maxHeight: number;
  24220. colorFilter: Color3;
  24221. buffer: Uint8Array;
  24222. bufferWidth: number;
  24223. bufferHeight: number;
  24224. alphaFilter: number;
  24225. }): VertexData;
  24226. /**
  24227. * Creates the VertexData for a Plane
  24228. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24229. * * size sets the width and height of the plane to the value of size, optional default 1
  24230. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24231. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24232. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24233. * * 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)
  24234. * * 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)
  24235. * @returns the VertexData of the box
  24236. */
  24237. static CreatePlane(options: {
  24238. size?: number;
  24239. width?: number;
  24240. height?: number;
  24241. sideOrientation?: number;
  24242. frontUVs?: Vector4;
  24243. backUVs?: Vector4;
  24244. }): VertexData;
  24245. /**
  24246. * Creates the VertexData of the Disc or regular Polygon
  24247. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24248. * * radius the radius of the disc, optional default 0.5
  24249. * * tessellation the number of polygon sides, optional, default 64
  24250. * * 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
  24251. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24252. * * 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)
  24253. * * 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)
  24254. * @returns the VertexData of the box
  24255. */
  24256. static CreateDisc(options: {
  24257. radius?: number;
  24258. tessellation?: number;
  24259. arc?: number;
  24260. sideOrientation?: number;
  24261. frontUVs?: Vector4;
  24262. backUVs?: Vector4;
  24263. }): VertexData;
  24264. /**
  24265. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24266. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24267. * @param polygon a mesh built from polygonTriangulation.build()
  24268. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24269. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24270. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24271. * @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)
  24272. * @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)
  24273. * @returns the VertexData of the Polygon
  24274. */
  24275. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24276. /**
  24277. * Creates the VertexData of the IcoSphere
  24278. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24279. * * radius the radius of the IcoSphere, optional default 1
  24280. * * radiusX allows stretching in the x direction, optional, default radius
  24281. * * radiusY allows stretching in the y direction, optional, default radius
  24282. * * radiusZ allows stretching in the z direction, optional, default radius
  24283. * * flat when true creates a flat shaded mesh, optional, default true
  24284. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24285. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24286. * * 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)
  24287. * * 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)
  24288. * @returns the VertexData of the IcoSphere
  24289. */
  24290. static CreateIcoSphere(options: {
  24291. radius?: number;
  24292. radiusX?: number;
  24293. radiusY?: number;
  24294. radiusZ?: number;
  24295. flat?: boolean;
  24296. subdivisions?: number;
  24297. sideOrientation?: number;
  24298. frontUVs?: Vector4;
  24299. backUVs?: Vector4;
  24300. }): VertexData;
  24301. /**
  24302. * Creates the VertexData for a Polyhedron
  24303. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24304. * * type provided types are:
  24305. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24306. * * 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)
  24307. * * size the size of the IcoSphere, optional default 1
  24308. * * sizeX allows stretching in the x direction, optional, default size
  24309. * * sizeY allows stretching in the y direction, optional, default size
  24310. * * sizeZ allows stretching in the z direction, optional, default size
  24311. * * 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
  24312. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24313. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24314. * * flat when true creates a flat shaded mesh, optional, default true
  24315. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24316. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24317. * * 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)
  24318. * * 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)
  24319. * @returns the VertexData of the Polyhedron
  24320. */
  24321. static CreatePolyhedron(options: {
  24322. type?: number;
  24323. size?: number;
  24324. sizeX?: number;
  24325. sizeY?: number;
  24326. sizeZ?: number;
  24327. custom?: any;
  24328. faceUV?: Vector4[];
  24329. faceColors?: Color4[];
  24330. flat?: boolean;
  24331. sideOrientation?: number;
  24332. frontUVs?: Vector4;
  24333. backUVs?: Vector4;
  24334. }): VertexData;
  24335. /**
  24336. * Creates the VertexData for a TorusKnot
  24337. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24338. * * radius the radius of the torus knot, optional, default 2
  24339. * * tube the thickness of the tube, optional, default 0.5
  24340. * * radialSegments the number of sides on each tube segments, optional, default 32
  24341. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24342. * * p the number of windings around the z axis, optional, default 2
  24343. * * q the number of windings around the x axis, optional, default 3
  24344. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24345. * * 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)
  24346. * * 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)
  24347. * @returns the VertexData of the Torus Knot
  24348. */
  24349. static CreateTorusKnot(options: {
  24350. radius?: number;
  24351. tube?: number;
  24352. radialSegments?: number;
  24353. tubularSegments?: number;
  24354. p?: number;
  24355. q?: number;
  24356. sideOrientation?: number;
  24357. frontUVs?: Vector4;
  24358. backUVs?: Vector4;
  24359. }): VertexData;
  24360. /**
  24361. * Compute normals for given positions and indices
  24362. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24363. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24364. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24365. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24366. * * facetNormals : optional array of facet normals (vector3)
  24367. * * facetPositions : optional array of facet positions (vector3)
  24368. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24369. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24370. * * bInfo : optional bounding info, required for facetPartitioning computation
  24371. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24372. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24373. * * useRightHandedSystem: optional boolean to for right handed system computation
  24374. * * depthSort : optional boolean to enable the facet depth sort computation
  24375. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24376. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24377. */
  24378. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24379. facetNormals?: any;
  24380. facetPositions?: any;
  24381. facetPartitioning?: any;
  24382. ratio?: number;
  24383. bInfo?: any;
  24384. bbSize?: Vector3;
  24385. subDiv?: any;
  24386. useRightHandedSystem?: boolean;
  24387. depthSort?: boolean;
  24388. distanceTo?: Vector3;
  24389. depthSortedFacets?: any;
  24390. }): void;
  24391. /** @hidden */
  24392. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24393. /**
  24394. * Applies VertexData created from the imported parameters to the geometry
  24395. * @param parsedVertexData the parsed data from an imported file
  24396. * @param geometry the geometry to apply the VertexData to
  24397. */
  24398. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24399. }
  24400. }
  24401. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24402. import { Nullable } from "babylonjs/types";
  24403. import { Scene } from "babylonjs/scene";
  24404. import { Vector4 } from "babylonjs/Maths/math";
  24405. import { Mesh } from "babylonjs/Meshes/mesh";
  24406. /**
  24407. * Class containing static functions to help procedurally build meshes
  24408. */
  24409. export class DiscBuilder {
  24410. /**
  24411. * Creates a plane polygonal mesh. By default, this is a disc
  24412. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24413. * * 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
  24414. * * 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
  24415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24418. * @param name defines the name of the mesh
  24419. * @param options defines the options used to create the mesh
  24420. * @param scene defines the hosting scene
  24421. * @returns the plane polygonal mesh
  24422. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24423. */
  24424. static CreateDisc(name: string, options: {
  24425. radius?: number;
  24426. tessellation?: number;
  24427. arc?: number;
  24428. updatable?: boolean;
  24429. sideOrientation?: number;
  24430. frontUVs?: Vector4;
  24431. backUVs?: Vector4;
  24432. }, scene?: Nullable<Scene>): Mesh;
  24433. }
  24434. }
  24435. declare module "babylonjs/Particles/solidParticleSystem" {
  24436. import { Vector3 } from "babylonjs/Maths/math";
  24437. import { Mesh } from "babylonjs/Meshes/mesh";
  24438. import { Scene, IDisposable } from "babylonjs/scene";
  24439. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24440. /**
  24441. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24442. *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.
  24443. * The SPS is also a particle system. It provides some methods to manage the particles.
  24444. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24445. *
  24446. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24447. */
  24448. export class SolidParticleSystem implements IDisposable {
  24449. /**
  24450. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24451. * Example : var p = SPS.particles[i];
  24452. */
  24453. particles: SolidParticle[];
  24454. /**
  24455. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24456. */
  24457. nbParticles: number;
  24458. /**
  24459. * If the particles must ever face the camera (default false). Useful for planar particles.
  24460. */
  24461. billboard: boolean;
  24462. /**
  24463. * Recompute normals when adding a shape
  24464. */
  24465. recomputeNormals: boolean;
  24466. /**
  24467. * This a counter ofr your own usage. It's not set by any SPS functions.
  24468. */
  24469. counter: number;
  24470. /**
  24471. * The SPS name. This name is also given to the underlying mesh.
  24472. */
  24473. name: string;
  24474. /**
  24475. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24476. */
  24477. mesh: Mesh;
  24478. /**
  24479. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24480. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24481. */
  24482. vars: any;
  24483. /**
  24484. * This array is populated when the SPS is set as 'pickable'.
  24485. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24486. * Each element of this array is an object `{idx: int, faceId: int}`.
  24487. * `idx` is the picked particle index in the `SPS.particles` array
  24488. * `faceId` is the picked face index counted within this particle.
  24489. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24490. */
  24491. pickedParticles: {
  24492. idx: number;
  24493. faceId: number;
  24494. }[];
  24495. /**
  24496. * This array is populated when `enableDepthSort` is set to true.
  24497. * Each element of this array is an instance of the class DepthSortedParticle.
  24498. */
  24499. depthSortedParticles: DepthSortedParticle[];
  24500. /**
  24501. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24502. * @hidden
  24503. */
  24504. _bSphereOnly: boolean;
  24505. /**
  24506. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24507. * @hidden
  24508. */
  24509. _bSphereRadiusFactor: number;
  24510. private _scene;
  24511. private _positions;
  24512. private _indices;
  24513. private _normals;
  24514. private _colors;
  24515. private _uvs;
  24516. private _indices32;
  24517. private _positions32;
  24518. private _normals32;
  24519. private _fixedNormal32;
  24520. private _colors32;
  24521. private _uvs32;
  24522. private _index;
  24523. private _updatable;
  24524. private _pickable;
  24525. private _isVisibilityBoxLocked;
  24526. private _alwaysVisible;
  24527. private _depthSort;
  24528. private _shapeCounter;
  24529. private _copy;
  24530. private _color;
  24531. private _computeParticleColor;
  24532. private _computeParticleTexture;
  24533. private _computeParticleRotation;
  24534. private _computeParticleVertex;
  24535. private _computeBoundingBox;
  24536. private _depthSortParticles;
  24537. private _camera;
  24538. private _mustUnrotateFixedNormals;
  24539. private _particlesIntersect;
  24540. private _needs32Bits;
  24541. /**
  24542. * Creates a SPS (Solid Particle System) object.
  24543. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24544. * @param scene (Scene) is the scene in which the SPS is added.
  24545. * @param options defines the options of the sps e.g.
  24546. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24547. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24548. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24549. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24550. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24551. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24552. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24553. */
  24554. constructor(name: string, scene: Scene, options?: {
  24555. updatable?: boolean;
  24556. isPickable?: boolean;
  24557. enableDepthSort?: boolean;
  24558. particleIntersection?: boolean;
  24559. boundingSphereOnly?: boolean;
  24560. bSphereRadiusFactor?: number;
  24561. });
  24562. /**
  24563. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24564. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24565. * @returns the created mesh
  24566. */
  24567. buildMesh(): Mesh;
  24568. /**
  24569. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24570. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24571. * Thus the particles generated from `digest()` have their property `position` set yet.
  24572. * @param mesh ( Mesh ) is the mesh to be digested
  24573. * @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
  24574. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24575. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24576. * @returns the current SPS
  24577. */
  24578. digest(mesh: Mesh, options?: {
  24579. facetNb?: number;
  24580. number?: number;
  24581. delta?: number;
  24582. }): SolidParticleSystem;
  24583. private _unrotateFixedNormals;
  24584. private _resetCopy;
  24585. private _meshBuilder;
  24586. private _posToShape;
  24587. private _uvsToShapeUV;
  24588. private _addParticle;
  24589. /**
  24590. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24591. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24592. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24593. * @param nb (positive integer) the number of particles to be created from this model
  24594. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24595. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24596. * @returns the number of shapes in the system
  24597. */
  24598. addShape(mesh: Mesh, nb: number, options?: {
  24599. positionFunction?: any;
  24600. vertexFunction?: any;
  24601. }): number;
  24602. private _rebuildParticle;
  24603. /**
  24604. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24605. * @returns the SPS.
  24606. */
  24607. rebuildMesh(): SolidParticleSystem;
  24608. /**
  24609. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24610. * This method calls `updateParticle()` for each particle of the SPS.
  24611. * For an animated SPS, it is usually called within the render loop.
  24612. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24613. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24614. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24615. * @returns the SPS.
  24616. */
  24617. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24618. /**
  24619. * Disposes the SPS.
  24620. */
  24621. dispose(): void;
  24622. /**
  24623. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24624. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24625. * @returns the SPS.
  24626. */
  24627. refreshVisibleSize(): SolidParticleSystem;
  24628. /**
  24629. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24630. * @param size the size (float) of the visibility box
  24631. * note : this doesn't lock the SPS mesh bounding box.
  24632. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24633. */
  24634. setVisibilityBox(size: number): void;
  24635. /**
  24636. * Gets whether the SPS as always visible or not
  24637. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24638. */
  24639. /**
  24640. * Sets the SPS as always visible or not
  24641. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24642. */
  24643. isAlwaysVisible: boolean;
  24644. /**
  24645. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24646. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24647. */
  24648. /**
  24649. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24650. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24651. */
  24652. isVisibilityBoxLocked: boolean;
  24653. /**
  24654. * Tells to `setParticles()` to compute the particle rotations or not.
  24655. * Default value : true. The SPS is faster when it's set to false.
  24656. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24657. */
  24658. /**
  24659. * Gets if `setParticles()` computes the particle rotations or not.
  24660. * Default value : true. The SPS is faster when it's set to false.
  24661. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24662. */
  24663. computeParticleRotation: boolean;
  24664. /**
  24665. * Tells to `setParticles()` to compute the particle colors or not.
  24666. * Default value : true. The SPS is faster when it's set to false.
  24667. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24668. */
  24669. /**
  24670. * Gets if `setParticles()` computes the particle colors or not.
  24671. * Default value : true. The SPS is faster when it's set to false.
  24672. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24673. */
  24674. computeParticleColor: boolean;
  24675. /**
  24676. * Gets if `setParticles()` computes the particle textures or not.
  24677. * Default value : true. The SPS is faster when it's set to false.
  24678. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24679. */
  24680. computeParticleTexture: boolean;
  24681. /**
  24682. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24683. * Default value : false. The SPS is faster when it's set to false.
  24684. * Note : the particle custom vertex positions aren't stored values.
  24685. */
  24686. /**
  24687. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24688. * Default value : false. The SPS is faster when it's set to false.
  24689. * Note : the particle custom vertex positions aren't stored values.
  24690. */
  24691. computeParticleVertex: boolean;
  24692. /**
  24693. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24694. */
  24695. /**
  24696. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24697. */
  24698. computeBoundingBox: boolean;
  24699. /**
  24700. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24701. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24702. * Default : `true`
  24703. */
  24704. /**
  24705. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24706. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24707. * Default : `true`
  24708. */
  24709. depthSortParticles: boolean;
  24710. /**
  24711. * This function does nothing. It may be overwritten to set all the particle first values.
  24712. * The SPS doesn't call this function, you may have to call it by your own.
  24713. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24714. */
  24715. initParticles(): void;
  24716. /**
  24717. * This function does nothing. It may be overwritten to recycle a particle.
  24718. * The SPS doesn't call this function, you may have to call it by your own.
  24719. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24720. * @param particle The particle to recycle
  24721. * @returns the recycled particle
  24722. */
  24723. recycleParticle(particle: SolidParticle): SolidParticle;
  24724. /**
  24725. * Updates a particle : this function should be overwritten by the user.
  24726. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24727. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24728. * @example : just set a particle position or velocity and recycle conditions
  24729. * @param particle The particle to update
  24730. * @returns the updated particle
  24731. */
  24732. updateParticle(particle: SolidParticle): SolidParticle;
  24733. /**
  24734. * Updates a vertex of a particle : it can be overwritten by the user.
  24735. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24736. * @param particle the current particle
  24737. * @param vertex the current index of the current particle
  24738. * @param pt the index of the current vertex in the particle shape
  24739. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24740. * @example : just set a vertex particle position
  24741. * @returns the updated vertex
  24742. */
  24743. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24744. /**
  24745. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24746. * This does nothing and may be overwritten by the user.
  24747. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24748. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24749. * @param update the boolean update value actually passed to setParticles()
  24750. */
  24751. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24752. /**
  24753. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24754. * This will be passed three parameters.
  24755. * This does nothing and may be overwritten by the user.
  24756. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24757. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24758. * @param update the boolean update value actually passed to setParticles()
  24759. */
  24760. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24761. }
  24762. }
  24763. declare module "babylonjs/Particles/solidParticle" {
  24764. import { Nullable } from "babylonjs/types";
  24765. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24766. import { Mesh } from "babylonjs/Meshes/mesh";
  24767. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24768. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24769. /**
  24770. * Represents one particle of a solid particle system.
  24771. */
  24772. export class SolidParticle {
  24773. /**
  24774. * particle global index
  24775. */
  24776. idx: number;
  24777. /**
  24778. * The color of the particle
  24779. */
  24780. color: Nullable<Color4>;
  24781. /**
  24782. * The world space position of the particle.
  24783. */
  24784. position: Vector3;
  24785. /**
  24786. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24787. */
  24788. rotation: Vector3;
  24789. /**
  24790. * The world space rotation quaternion of the particle.
  24791. */
  24792. rotationQuaternion: Nullable<Quaternion>;
  24793. /**
  24794. * The scaling of the particle.
  24795. */
  24796. scaling: Vector3;
  24797. /**
  24798. * The uvs of the particle.
  24799. */
  24800. uvs: Vector4;
  24801. /**
  24802. * The current speed of the particle.
  24803. */
  24804. velocity: Vector3;
  24805. /**
  24806. * The pivot point in the particle local space.
  24807. */
  24808. pivot: Vector3;
  24809. /**
  24810. * Must the particle be translated from its pivot point in its local space ?
  24811. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24812. * Default : false
  24813. */
  24814. translateFromPivot: boolean;
  24815. /**
  24816. * Is the particle active or not ?
  24817. */
  24818. alive: boolean;
  24819. /**
  24820. * Is the particle visible or not ?
  24821. */
  24822. isVisible: boolean;
  24823. /**
  24824. * Index of this particle in the global "positions" array (Internal use)
  24825. * @hidden
  24826. */
  24827. _pos: number;
  24828. /**
  24829. * @hidden Index of this particle in the global "indices" array (Internal use)
  24830. */
  24831. _ind: number;
  24832. /**
  24833. * @hidden ModelShape of this particle (Internal use)
  24834. */
  24835. _model: ModelShape;
  24836. /**
  24837. * ModelShape id of this particle
  24838. */
  24839. shapeId: number;
  24840. /**
  24841. * Index of the particle in its shape id (Internal use)
  24842. */
  24843. idxInShape: number;
  24844. /**
  24845. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24846. */
  24847. _modelBoundingInfo: BoundingInfo;
  24848. /**
  24849. * @hidden Particle BoundingInfo object (Internal use)
  24850. */
  24851. _boundingInfo: BoundingInfo;
  24852. /**
  24853. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24854. */
  24855. _sps: SolidParticleSystem;
  24856. /**
  24857. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24858. */
  24859. _stillInvisible: boolean;
  24860. /**
  24861. * @hidden Last computed particle rotation matrix
  24862. */
  24863. _rotationMatrix: number[];
  24864. /**
  24865. * Parent particle Id, if any.
  24866. * Default null.
  24867. */
  24868. parentId: Nullable<number>;
  24869. /**
  24870. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24871. * The possible values are :
  24872. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24873. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24874. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24875. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24876. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24877. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24878. * */
  24879. cullingStrategy: number;
  24880. /**
  24881. * @hidden Internal global position in the SPS.
  24882. */
  24883. _globalPosition: Vector3;
  24884. /**
  24885. * Creates a Solid Particle object.
  24886. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24887. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24888. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24889. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24890. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24891. * @param shapeId (integer) is the model shape identifier in the SPS.
  24892. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24893. * @param sps defines the sps it is associated to
  24894. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24895. */
  24896. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24897. /**
  24898. * Legacy support, changed scale to scaling
  24899. */
  24900. /**
  24901. * Legacy support, changed scale to scaling
  24902. */
  24903. scale: Vector3;
  24904. /**
  24905. * Legacy support, changed quaternion to rotationQuaternion
  24906. */
  24907. /**
  24908. * Legacy support, changed quaternion to rotationQuaternion
  24909. */
  24910. quaternion: Nullable<Quaternion>;
  24911. /**
  24912. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24913. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24914. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24915. * @returns true if it intersects
  24916. */
  24917. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24918. /**
  24919. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24920. * A particle is in the frustum if its bounding box intersects the frustum
  24921. * @param frustumPlanes defines the frustum to test
  24922. * @returns true if the particle is in the frustum planes
  24923. */
  24924. isInFrustum(frustumPlanes: Plane[]): boolean;
  24925. /**
  24926. * get the rotation matrix of the particle
  24927. * @hidden
  24928. */
  24929. getRotationMatrix(m: Matrix): void;
  24930. }
  24931. /**
  24932. * Represents the shape of the model used by one particle of a solid particle system.
  24933. * SPS internal tool, don't use it manually.
  24934. */
  24935. export class ModelShape {
  24936. /**
  24937. * The shape id
  24938. * @hidden
  24939. */
  24940. shapeID: number;
  24941. /**
  24942. * flat array of model positions (internal use)
  24943. * @hidden
  24944. */
  24945. _shape: Vector3[];
  24946. /**
  24947. * flat array of model UVs (internal use)
  24948. * @hidden
  24949. */
  24950. _shapeUV: number[];
  24951. /**
  24952. * length of the shape in the model indices array (internal use)
  24953. * @hidden
  24954. */
  24955. _indicesLength: number;
  24956. /**
  24957. * Custom position function (internal use)
  24958. * @hidden
  24959. */
  24960. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24961. /**
  24962. * Custom vertex function (internal use)
  24963. * @hidden
  24964. */
  24965. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24966. /**
  24967. * 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.
  24968. * SPS internal tool, don't use it manually.
  24969. * @hidden
  24970. */
  24971. 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>);
  24972. }
  24973. /**
  24974. * Represents a Depth Sorted Particle in the solid particle system.
  24975. */
  24976. export class DepthSortedParticle {
  24977. /**
  24978. * Index of the particle in the "indices" array
  24979. */
  24980. ind: number;
  24981. /**
  24982. * Length of the particle shape in the "indices" array
  24983. */
  24984. indicesLength: number;
  24985. /**
  24986. * Squared distance from the particle to the camera
  24987. */
  24988. sqDistance: number;
  24989. }
  24990. }
  24991. declare module "babylonjs/Collisions/meshCollisionData" {
  24992. import { Collider } from "babylonjs/Collisions/collider";
  24993. import { Vector3 } from "babylonjs/Maths/math";
  24994. import { Nullable } from "babylonjs/types";
  24995. import { Observer } from "babylonjs/Misc/observable";
  24996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24997. /**
  24998. * @hidden
  24999. */
  25000. export class _MeshCollisionData {
  25001. _checkCollisions: boolean;
  25002. _collisionMask: number;
  25003. _collisionGroup: number;
  25004. _collider: Nullable<Collider>;
  25005. _oldPositionForCollisions: Vector3;
  25006. _diffPositionForCollisions: Vector3;
  25007. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25008. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25009. }
  25010. }
  25011. declare module "babylonjs/Meshes/abstractMesh" {
  25012. import { Observable } from "babylonjs/Misc/observable";
  25013. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25014. import { Camera } from "babylonjs/Cameras/camera";
  25015. import { Scene, IDisposable } from "babylonjs/scene";
  25016. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25017. import { Node } from "babylonjs/node";
  25018. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25019. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25020. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25021. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25022. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25023. import { Material } from "babylonjs/Materials/material";
  25024. import { Light } from "babylonjs/Lights/light";
  25025. import { Skeleton } from "babylonjs/Bones/skeleton";
  25026. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25027. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25028. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25029. import { Ray } from "babylonjs/Culling/ray";
  25030. import { Collider } from "babylonjs/Collisions/collider";
  25031. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25032. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  25033. /** @hidden */
  25034. class _FacetDataStorage {
  25035. facetPositions: Vector3[];
  25036. facetNormals: Vector3[];
  25037. facetPartitioning: number[][];
  25038. facetNb: number;
  25039. partitioningSubdivisions: number;
  25040. partitioningBBoxRatio: number;
  25041. facetDataEnabled: boolean;
  25042. facetParameters: any;
  25043. bbSize: Vector3;
  25044. subDiv: {
  25045. max: number;
  25046. X: number;
  25047. Y: number;
  25048. Z: number;
  25049. };
  25050. facetDepthSort: boolean;
  25051. facetDepthSortEnabled: boolean;
  25052. depthSortedIndices: IndicesArray;
  25053. depthSortedFacets: {
  25054. ind: number;
  25055. sqDistance: number;
  25056. }[];
  25057. facetDepthSortFunction: (f1: {
  25058. ind: number;
  25059. sqDistance: number;
  25060. }, f2: {
  25061. ind: number;
  25062. sqDistance: number;
  25063. }) => number;
  25064. facetDepthSortFrom: Vector3;
  25065. facetDepthSortOrigin: Vector3;
  25066. invertedMatrix: Matrix;
  25067. }
  25068. /**
  25069. * @hidden
  25070. **/
  25071. class _InternalAbstractMeshDataInfo {
  25072. _hasVertexAlpha: boolean;
  25073. _useVertexColors: boolean;
  25074. _numBoneInfluencers: number;
  25075. _applyFog: boolean;
  25076. _receiveShadows: boolean;
  25077. _facetData: _FacetDataStorage;
  25078. _visibility: number;
  25079. _skeleton: Nullable<Skeleton>;
  25080. _layerMask: number;
  25081. _computeBonesUsingShaders: boolean;
  25082. _isActive: boolean;
  25083. _onlyForInstances: boolean;
  25084. _isActiveIntermediate: boolean;
  25085. _onlyForInstancesIntermediate: boolean;
  25086. }
  25087. /**
  25088. * Class used to store all common mesh properties
  25089. */
  25090. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25091. /** No occlusion */
  25092. static OCCLUSION_TYPE_NONE: number;
  25093. /** Occlusion set to optimisitic */
  25094. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25095. /** Occlusion set to strict */
  25096. static OCCLUSION_TYPE_STRICT: number;
  25097. /** Use an accurante occlusion algorithm */
  25098. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25099. /** Use a conservative occlusion algorithm */
  25100. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25101. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25102. * Test order :
  25103. * Is the bounding sphere outside the frustum ?
  25104. * If not, are the bounding box vertices outside the frustum ?
  25105. * It not, then the cullable object is in the frustum.
  25106. */
  25107. static readonly CULLINGSTRATEGY_STANDARD: number;
  25108. /** Culling strategy : Bounding Sphere Only.
  25109. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25110. * It's also less accurate than the standard because some not visible objects can still be selected.
  25111. * Test : is the bounding sphere outside the frustum ?
  25112. * If not, then the cullable object is in the frustum.
  25113. */
  25114. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25115. /** Culling strategy : Optimistic Inclusion.
  25116. * This in an inclusion test first, then the standard exclusion test.
  25117. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25118. * 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.
  25119. * Anyway, it's as accurate as the standard strategy.
  25120. * Test :
  25121. * Is the cullable object bounding sphere center in the frustum ?
  25122. * If not, apply the default culling strategy.
  25123. */
  25124. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25125. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25126. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25127. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25128. * 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.
  25129. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25130. * Test :
  25131. * Is the cullable object bounding sphere center in the frustum ?
  25132. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25133. */
  25134. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25135. /**
  25136. * No billboard
  25137. */
  25138. static readonly BILLBOARDMODE_NONE: number;
  25139. /** Billboard on X axis */
  25140. static readonly BILLBOARDMODE_X: number;
  25141. /** Billboard on Y axis */
  25142. static readonly BILLBOARDMODE_Y: number;
  25143. /** Billboard on Z axis */
  25144. static readonly BILLBOARDMODE_Z: number;
  25145. /** Billboard on all axes */
  25146. static readonly BILLBOARDMODE_ALL: number;
  25147. /** @hidden */
  25148. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25149. /**
  25150. * The culling strategy to use to check whether the mesh must be rendered or not.
  25151. * This value can be changed at any time and will be used on the next render mesh selection.
  25152. * The possible values are :
  25153. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25154. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25155. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25156. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25157. * Please read each static variable documentation to get details about the culling process.
  25158. * */
  25159. cullingStrategy: number;
  25160. /**
  25161. * Gets the number of facets in the mesh
  25162. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25163. */
  25164. readonly facetNb: number;
  25165. /**
  25166. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25168. */
  25169. partitioningSubdivisions: number;
  25170. /**
  25171. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25172. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25173. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25174. */
  25175. partitioningBBoxRatio: number;
  25176. /**
  25177. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25178. * Works only for updatable meshes.
  25179. * Doesn't work with multi-materials
  25180. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25181. */
  25182. mustDepthSortFacets: boolean;
  25183. /**
  25184. * The location (Vector3) where the facet depth sort must be computed from.
  25185. * By default, the active camera position.
  25186. * Used only when facet depth sort is enabled
  25187. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25188. */
  25189. facetDepthSortFrom: Vector3;
  25190. /**
  25191. * gets a boolean indicating if facetData is enabled
  25192. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25193. */
  25194. readonly isFacetDataEnabled: boolean;
  25195. /** @hidden */
  25196. _updateNonUniformScalingState(value: boolean): boolean;
  25197. /**
  25198. * An event triggered when this mesh collides with another one
  25199. */
  25200. onCollideObservable: Observable<AbstractMesh>;
  25201. /** Set a function to call when this mesh collides with another one */
  25202. onCollide: () => void;
  25203. /**
  25204. * An event triggered when the collision's position changes
  25205. */
  25206. onCollisionPositionChangeObservable: Observable<Vector3>;
  25207. /** Set a function to call when the collision's position changes */
  25208. onCollisionPositionChange: () => void;
  25209. /**
  25210. * An event triggered when material is changed
  25211. */
  25212. onMaterialChangedObservable: Observable<AbstractMesh>;
  25213. /**
  25214. * Gets or sets the orientation for POV movement & rotation
  25215. */
  25216. definedFacingForward: boolean;
  25217. /** @hidden */
  25218. _occlusionQuery: Nullable<WebGLQuery>;
  25219. /** @hidden */
  25220. _renderingGroup: Nullable<RenderingGroup>;
  25221. /**
  25222. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25223. */
  25224. /**
  25225. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25226. */
  25227. visibility: number;
  25228. /** Gets or sets the alpha index used to sort transparent meshes
  25229. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25230. */
  25231. alphaIndex: number;
  25232. /**
  25233. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25234. */
  25235. isVisible: boolean;
  25236. /**
  25237. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25238. */
  25239. isPickable: boolean;
  25240. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25241. showSubMeshesBoundingBox: boolean;
  25242. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25243. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25244. */
  25245. isBlocker: boolean;
  25246. /**
  25247. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25248. */
  25249. enablePointerMoveEvents: boolean;
  25250. /**
  25251. * Specifies the rendering group id for this mesh (0 by default)
  25252. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25253. */
  25254. renderingGroupId: number;
  25255. private _material;
  25256. /** Gets or sets current material */
  25257. material: Nullable<Material>;
  25258. /**
  25259. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25260. * @see http://doc.babylonjs.com/babylon101/shadows
  25261. */
  25262. receiveShadows: boolean;
  25263. /** Defines color to use when rendering outline */
  25264. outlineColor: Color3;
  25265. /** Define width to use when rendering outline */
  25266. outlineWidth: number;
  25267. /** Defines color to use when rendering overlay */
  25268. overlayColor: Color3;
  25269. /** Defines alpha to use when rendering overlay */
  25270. overlayAlpha: number;
  25271. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25272. hasVertexAlpha: boolean;
  25273. /** 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) */
  25274. useVertexColors: boolean;
  25275. /**
  25276. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25277. */
  25278. computeBonesUsingShaders: boolean;
  25279. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25280. numBoneInfluencers: number;
  25281. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25282. applyFog: boolean;
  25283. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25284. useOctreeForRenderingSelection: boolean;
  25285. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25286. useOctreeForPicking: boolean;
  25287. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25288. useOctreeForCollisions: boolean;
  25289. /**
  25290. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25291. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25292. */
  25293. layerMask: number;
  25294. /**
  25295. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25296. */
  25297. alwaysSelectAsActiveMesh: boolean;
  25298. /**
  25299. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25300. */
  25301. doNotSyncBoundingInfo: boolean;
  25302. /**
  25303. * Gets or sets the current action manager
  25304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25305. */
  25306. actionManager: Nullable<AbstractActionManager>;
  25307. private _meshCollisionData;
  25308. /**
  25309. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25310. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25311. */
  25312. ellipsoid: Vector3;
  25313. /**
  25314. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25315. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25316. */
  25317. ellipsoidOffset: Vector3;
  25318. /**
  25319. * Gets or sets a collision mask used to mask collisions (default is -1).
  25320. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25321. */
  25322. collisionMask: number;
  25323. /**
  25324. * Gets or sets the current collision group mask (-1 by default).
  25325. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25326. */
  25327. collisionGroup: number;
  25328. /**
  25329. * Defines edge width used when edgesRenderer is enabled
  25330. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25331. */
  25332. edgesWidth: number;
  25333. /**
  25334. * Defines edge color used when edgesRenderer is enabled
  25335. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25336. */
  25337. edgesColor: Color4;
  25338. /** @hidden */
  25339. _edgesRenderer: Nullable<IEdgesRenderer>;
  25340. /** @hidden */
  25341. _masterMesh: Nullable<AbstractMesh>;
  25342. /** @hidden */
  25343. _boundingInfo: Nullable<BoundingInfo>;
  25344. /** @hidden */
  25345. _renderId: number;
  25346. /**
  25347. * Gets or sets the list of subMeshes
  25348. * @see http://doc.babylonjs.com/how_to/multi_materials
  25349. */
  25350. subMeshes: SubMesh[];
  25351. /** @hidden */
  25352. _intersectionsInProgress: AbstractMesh[];
  25353. /** @hidden */
  25354. _unIndexed: boolean;
  25355. /** @hidden */
  25356. _lightSources: Light[];
  25357. /** Gets the list of lights affecting that mesh */
  25358. readonly lightSources: Light[];
  25359. /** @hidden */
  25360. readonly _positions: Nullable<Vector3[]>;
  25361. /** @hidden */
  25362. _waitingData: {
  25363. lods: Nullable<any>;
  25364. actions: Nullable<any>;
  25365. freezeWorldMatrix: Nullable<boolean>;
  25366. };
  25367. /** @hidden */
  25368. _bonesTransformMatrices: Nullable<Float32Array>;
  25369. /**
  25370. * Gets or sets a skeleton to apply skining transformations
  25371. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25372. */
  25373. skeleton: Nullable<Skeleton>;
  25374. /**
  25375. * An event triggered when the mesh is rebuilt.
  25376. */
  25377. onRebuildObservable: Observable<AbstractMesh>;
  25378. /**
  25379. * Creates a new AbstractMesh
  25380. * @param name defines the name of the mesh
  25381. * @param scene defines the hosting scene
  25382. */
  25383. constructor(name: string, scene?: Nullable<Scene>);
  25384. /**
  25385. * Returns the string "AbstractMesh"
  25386. * @returns "AbstractMesh"
  25387. */
  25388. getClassName(): string;
  25389. /**
  25390. * Gets a string representation of the current mesh
  25391. * @param fullDetails defines a boolean indicating if full details must be included
  25392. * @returns a string representation of the current mesh
  25393. */
  25394. toString(fullDetails?: boolean): string;
  25395. /**
  25396. * @hidden
  25397. */
  25398. protected _getEffectiveParent(): Nullable<Node>;
  25399. /** @hidden */
  25400. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25401. /** @hidden */
  25402. _rebuild(): void;
  25403. /** @hidden */
  25404. _resyncLightSources(): void;
  25405. /** @hidden */
  25406. _resyncLighSource(light: Light): void;
  25407. /** @hidden */
  25408. _unBindEffect(): void;
  25409. /** @hidden */
  25410. _removeLightSource(light: Light): void;
  25411. private _markSubMeshesAsDirty;
  25412. /** @hidden */
  25413. _markSubMeshesAsLightDirty(): void;
  25414. /** @hidden */
  25415. _markSubMeshesAsAttributesDirty(): void;
  25416. /** @hidden */
  25417. _markSubMeshesAsMiscDirty(): void;
  25418. /**
  25419. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25420. */
  25421. scaling: Vector3;
  25422. /**
  25423. * Returns true if the mesh is blocked. Implemented by child classes
  25424. */
  25425. readonly isBlocked: boolean;
  25426. /**
  25427. * Returns the mesh itself by default. Implemented by child classes
  25428. * @param camera defines the camera to use to pick the right LOD level
  25429. * @returns the currentAbstractMesh
  25430. */
  25431. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25432. /**
  25433. * Returns 0 by default. Implemented by child classes
  25434. * @returns an integer
  25435. */
  25436. getTotalVertices(): number;
  25437. /**
  25438. * Returns a positive integer : the total number of indices in this mesh geometry.
  25439. * @returns the numner of indices or zero if the mesh has no geometry.
  25440. */
  25441. getTotalIndices(): number;
  25442. /**
  25443. * Returns null by default. Implemented by child classes
  25444. * @returns null
  25445. */
  25446. getIndices(): Nullable<IndicesArray>;
  25447. /**
  25448. * Returns the array of the requested vertex data kind. Implemented by child classes
  25449. * @param kind defines the vertex data kind to use
  25450. * @returns null
  25451. */
  25452. getVerticesData(kind: string): Nullable<FloatArray>;
  25453. /**
  25454. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25455. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25456. * Note that a new underlying VertexBuffer object is created each call.
  25457. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25458. * @param kind defines vertex data kind:
  25459. * * VertexBuffer.PositionKind
  25460. * * VertexBuffer.UVKind
  25461. * * VertexBuffer.UV2Kind
  25462. * * VertexBuffer.UV3Kind
  25463. * * VertexBuffer.UV4Kind
  25464. * * VertexBuffer.UV5Kind
  25465. * * VertexBuffer.UV6Kind
  25466. * * VertexBuffer.ColorKind
  25467. * * VertexBuffer.MatricesIndicesKind
  25468. * * VertexBuffer.MatricesIndicesExtraKind
  25469. * * VertexBuffer.MatricesWeightsKind
  25470. * * VertexBuffer.MatricesWeightsExtraKind
  25471. * @param data defines the data source
  25472. * @param updatable defines if the data must be flagged as updatable (or static)
  25473. * @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
  25474. * @returns the current mesh
  25475. */
  25476. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25477. /**
  25478. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25479. * If the mesh has no geometry, it is simply returned as it is.
  25480. * @param kind defines vertex data kind:
  25481. * * VertexBuffer.PositionKind
  25482. * * VertexBuffer.UVKind
  25483. * * VertexBuffer.UV2Kind
  25484. * * VertexBuffer.UV3Kind
  25485. * * VertexBuffer.UV4Kind
  25486. * * VertexBuffer.UV5Kind
  25487. * * VertexBuffer.UV6Kind
  25488. * * VertexBuffer.ColorKind
  25489. * * VertexBuffer.MatricesIndicesKind
  25490. * * VertexBuffer.MatricesIndicesExtraKind
  25491. * * VertexBuffer.MatricesWeightsKind
  25492. * * VertexBuffer.MatricesWeightsExtraKind
  25493. * @param data defines the data source
  25494. * @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
  25495. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25496. * @returns the current mesh
  25497. */
  25498. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25499. /**
  25500. * Sets the mesh indices,
  25501. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25502. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25503. * @param totalVertices Defines the total number of vertices
  25504. * @returns the current mesh
  25505. */
  25506. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25507. /**
  25508. * Gets a boolean indicating if specific vertex data is present
  25509. * @param kind defines the vertex data kind to use
  25510. * @returns true is data kind is present
  25511. */
  25512. isVerticesDataPresent(kind: string): boolean;
  25513. /**
  25514. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25515. * @returns a BoundingInfo
  25516. */
  25517. getBoundingInfo(): BoundingInfo;
  25518. /**
  25519. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25520. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25521. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25522. * @returns the current mesh
  25523. */
  25524. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25525. /**
  25526. * Overwrite the current bounding info
  25527. * @param boundingInfo defines the new bounding info
  25528. * @returns the current mesh
  25529. */
  25530. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25531. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25532. readonly useBones: boolean;
  25533. /** @hidden */
  25534. _preActivate(): void;
  25535. /** @hidden */
  25536. _preActivateForIntermediateRendering(renderId: number): void;
  25537. /** @hidden */
  25538. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25539. /** @hidden */
  25540. _postActivate(): void;
  25541. /** @hidden */
  25542. _freeze(): void;
  25543. /** @hidden */
  25544. _unFreeze(): void;
  25545. /**
  25546. * Gets the current world matrix
  25547. * @returns a Matrix
  25548. */
  25549. getWorldMatrix(): Matrix;
  25550. /** @hidden */
  25551. _getWorldMatrixDeterminant(): number;
  25552. /**
  25553. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25554. */
  25555. readonly isAnInstance: boolean;
  25556. /**
  25557. * Perform relative position change from the point of view of behind the front of the mesh.
  25558. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25559. * Supports definition of mesh facing forward or backward
  25560. * @param amountRight defines the distance on the right axis
  25561. * @param amountUp defines the distance on the up axis
  25562. * @param amountForward defines the distance on the forward axis
  25563. * @returns the current mesh
  25564. */
  25565. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25566. /**
  25567. * Calculate relative position change from the point of view of behind the front of the mesh.
  25568. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25569. * Supports definition of mesh facing forward or backward
  25570. * @param amountRight defines the distance on the right axis
  25571. * @param amountUp defines the distance on the up axis
  25572. * @param amountForward defines the distance on the forward axis
  25573. * @returns the new displacement vector
  25574. */
  25575. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25576. /**
  25577. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25578. * Supports definition of mesh facing forward or backward
  25579. * @param flipBack defines the flip
  25580. * @param twirlClockwise defines the twirl
  25581. * @param tiltRight defines the tilt
  25582. * @returns the current mesh
  25583. */
  25584. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25585. /**
  25586. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25587. * Supports definition of mesh facing forward or backward.
  25588. * @param flipBack defines the flip
  25589. * @param twirlClockwise defines the twirl
  25590. * @param tiltRight defines the tilt
  25591. * @returns the new rotation vector
  25592. */
  25593. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25594. /**
  25595. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25596. * This means the mesh underlying bounding box and sphere are recomputed.
  25597. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25598. * @returns the current mesh
  25599. */
  25600. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25601. /** @hidden */
  25602. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25603. /** @hidden */
  25604. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25605. /** @hidden */
  25606. _updateBoundingInfo(): AbstractMesh;
  25607. /** @hidden */
  25608. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25609. /** @hidden */
  25610. protected _afterComputeWorldMatrix(): void;
  25611. /** @hidden */
  25612. readonly _effectiveMesh: AbstractMesh;
  25613. /**
  25614. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25615. * A mesh is in the frustum if its bounding box intersects the frustum
  25616. * @param frustumPlanes defines the frustum to test
  25617. * @returns true if the mesh is in the frustum planes
  25618. */
  25619. isInFrustum(frustumPlanes: Plane[]): boolean;
  25620. /**
  25621. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25622. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25623. * @param frustumPlanes defines the frustum to test
  25624. * @returns true if the mesh is completely in the frustum planes
  25625. */
  25626. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25627. /**
  25628. * True if the mesh intersects another mesh or a SolidParticle object
  25629. * @param mesh defines a target mesh or SolidParticle to test
  25630. * @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)
  25631. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25632. * @returns true if there is an intersection
  25633. */
  25634. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25635. /**
  25636. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25637. * @param point defines the point to test
  25638. * @returns true if there is an intersection
  25639. */
  25640. intersectsPoint(point: Vector3): boolean;
  25641. /**
  25642. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25643. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25644. */
  25645. checkCollisions: boolean;
  25646. /**
  25647. * Gets Collider object used to compute collisions (not physics)
  25648. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25649. */
  25650. readonly collider: Nullable<Collider>;
  25651. /**
  25652. * Move the mesh using collision engine
  25653. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25654. * @param displacement defines the requested displacement vector
  25655. * @returns the current mesh
  25656. */
  25657. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25658. private _onCollisionPositionChange;
  25659. /** @hidden */
  25660. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25661. /** @hidden */
  25662. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25663. /** @hidden */
  25664. _checkCollision(collider: Collider): AbstractMesh;
  25665. /** @hidden */
  25666. _generatePointsArray(): boolean;
  25667. /**
  25668. * Checks if the passed Ray intersects with the mesh
  25669. * @param ray defines the ray to use
  25670. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25671. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25672. * @returns the picking info
  25673. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25674. */
  25675. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25676. /**
  25677. * Clones the current mesh
  25678. * @param name defines the mesh name
  25679. * @param newParent defines the new mesh parent
  25680. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25681. * @returns the new mesh
  25682. */
  25683. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25684. /**
  25685. * Disposes all the submeshes of the current meshnp
  25686. * @returns the current mesh
  25687. */
  25688. releaseSubMeshes(): AbstractMesh;
  25689. /**
  25690. * Releases resources associated with this abstract mesh.
  25691. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25692. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25693. */
  25694. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25695. /**
  25696. * Adds the passed mesh as a child to the current mesh
  25697. * @param mesh defines the child mesh
  25698. * @returns the current mesh
  25699. */
  25700. addChild(mesh: AbstractMesh): AbstractMesh;
  25701. /**
  25702. * Removes the passed mesh from the current mesh children list
  25703. * @param mesh defines the child mesh
  25704. * @returns the current mesh
  25705. */
  25706. removeChild(mesh: AbstractMesh): AbstractMesh;
  25707. /** @hidden */
  25708. private _initFacetData;
  25709. /**
  25710. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25711. * This method can be called within the render loop.
  25712. * 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
  25713. * @returns the current mesh
  25714. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25715. */
  25716. updateFacetData(): AbstractMesh;
  25717. /**
  25718. * Returns the facetLocalNormals array.
  25719. * The normals are expressed in the mesh local spac
  25720. * @returns an array of Vector3
  25721. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25722. */
  25723. getFacetLocalNormals(): Vector3[];
  25724. /**
  25725. * Returns the facetLocalPositions array.
  25726. * The facet positions are expressed in the mesh local space
  25727. * @returns an array of Vector3
  25728. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25729. */
  25730. getFacetLocalPositions(): Vector3[];
  25731. /**
  25732. * Returns the facetLocalPartioning array
  25733. * @returns an array of array of numbers
  25734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25735. */
  25736. getFacetLocalPartitioning(): number[][];
  25737. /**
  25738. * Returns the i-th facet position in the world system.
  25739. * This method allocates a new Vector3 per call
  25740. * @param i defines the facet index
  25741. * @returns a new Vector3
  25742. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25743. */
  25744. getFacetPosition(i: number): Vector3;
  25745. /**
  25746. * Sets the reference Vector3 with the i-th facet position in the world system
  25747. * @param i defines the facet index
  25748. * @param ref defines the target vector
  25749. * @returns the current mesh
  25750. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25751. */
  25752. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25753. /**
  25754. * Returns the i-th facet normal in the world system.
  25755. * This method allocates a new Vector3 per call
  25756. * @param i defines the facet index
  25757. * @returns a new Vector3
  25758. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25759. */
  25760. getFacetNormal(i: number): Vector3;
  25761. /**
  25762. * Sets the reference Vector3 with the i-th facet normal in the world system
  25763. * @param i defines the facet index
  25764. * @param ref defines the target vector
  25765. * @returns the current mesh
  25766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25767. */
  25768. getFacetNormalToRef(i: number, ref: Vector3): this;
  25769. /**
  25770. * 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)
  25771. * @param x defines x coordinate
  25772. * @param y defines y coordinate
  25773. * @param z defines z coordinate
  25774. * @returns the array of facet indexes
  25775. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25776. */
  25777. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25778. /**
  25779. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25780. * @param projected sets as the (x,y,z) world projection on the facet
  25781. * @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
  25782. * @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
  25783. * @param x defines x coordinate
  25784. * @param y defines y coordinate
  25785. * @param z defines z coordinate
  25786. * @returns the face index if found (or null instead)
  25787. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25788. */
  25789. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25790. /**
  25791. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25792. * @param projected sets as the (x,y,z) local projection on the facet
  25793. * @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
  25794. * @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
  25795. * @param x defines x coordinate
  25796. * @param y defines y coordinate
  25797. * @param z defines z coordinate
  25798. * @returns the face index if found (or null instead)
  25799. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25800. */
  25801. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25802. /**
  25803. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25804. * @returns the parameters
  25805. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25806. */
  25807. getFacetDataParameters(): any;
  25808. /**
  25809. * Disables the feature FacetData and frees the related memory
  25810. * @returns the current mesh
  25811. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25812. */
  25813. disableFacetData(): AbstractMesh;
  25814. /**
  25815. * Updates the AbstractMesh indices array
  25816. * @param indices defines the data source
  25817. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25818. * @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)
  25819. * @returns the current mesh
  25820. */
  25821. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25822. /**
  25823. * Creates new normals data for the mesh
  25824. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25825. * @returns the current mesh
  25826. */
  25827. createNormals(updatable: boolean): AbstractMesh;
  25828. /**
  25829. * Align the mesh with a normal
  25830. * @param normal defines the normal to use
  25831. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25832. * @returns the current mesh
  25833. */
  25834. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25835. /** @hidden */
  25836. _checkOcclusionQuery(): boolean;
  25837. /**
  25838. * Disables the mesh edge rendering mode
  25839. * @returns the currentAbstractMesh
  25840. */
  25841. disableEdgesRendering(): AbstractMesh;
  25842. /**
  25843. * Enables the edge rendering mode on the mesh.
  25844. * This mode makes the mesh edges visible
  25845. * @param epsilon defines the maximal distance between two angles to detect a face
  25846. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25847. * @returns the currentAbstractMesh
  25848. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25849. */
  25850. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25851. }
  25852. }
  25853. declare module "babylonjs/Actions/actionEvent" {
  25854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25855. import { Nullable } from "babylonjs/types";
  25856. import { Sprite } from "babylonjs/Sprites/sprite";
  25857. import { Scene } from "babylonjs/scene";
  25858. import { Vector2 } from "babylonjs/Maths/math";
  25859. /**
  25860. * Interface used to define ActionEvent
  25861. */
  25862. export interface IActionEvent {
  25863. /** The mesh or sprite that triggered the action */
  25864. source: any;
  25865. /** The X mouse cursor position at the time of the event */
  25866. pointerX: number;
  25867. /** The Y mouse cursor position at the time of the event */
  25868. pointerY: number;
  25869. /** The mesh that is currently pointed at (can be null) */
  25870. meshUnderPointer: Nullable<AbstractMesh>;
  25871. /** the original (browser) event that triggered the ActionEvent */
  25872. sourceEvent?: any;
  25873. /** additional data for the event */
  25874. additionalData?: any;
  25875. }
  25876. /**
  25877. * ActionEvent is the event being sent when an action is triggered.
  25878. */
  25879. export class ActionEvent implements IActionEvent {
  25880. /** The mesh or sprite that triggered the action */
  25881. source: any;
  25882. /** The X mouse cursor position at the time of the event */
  25883. pointerX: number;
  25884. /** The Y mouse cursor position at the time of the event */
  25885. pointerY: number;
  25886. /** The mesh that is currently pointed at (can be null) */
  25887. meshUnderPointer: Nullable<AbstractMesh>;
  25888. /** the original (browser) event that triggered the ActionEvent */
  25889. sourceEvent?: any;
  25890. /** additional data for the event */
  25891. additionalData?: any;
  25892. /**
  25893. * Creates a new ActionEvent
  25894. * @param source The mesh or sprite that triggered the action
  25895. * @param pointerX The X mouse cursor position at the time of the event
  25896. * @param pointerY The Y mouse cursor position at the time of the event
  25897. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25898. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25899. * @param additionalData additional data for the event
  25900. */
  25901. constructor(
  25902. /** The mesh or sprite that triggered the action */
  25903. source: any,
  25904. /** The X mouse cursor position at the time of the event */
  25905. pointerX: number,
  25906. /** The Y mouse cursor position at the time of the event */
  25907. pointerY: number,
  25908. /** The mesh that is currently pointed at (can be null) */
  25909. meshUnderPointer: Nullable<AbstractMesh>,
  25910. /** the original (browser) event that triggered the ActionEvent */
  25911. sourceEvent?: any,
  25912. /** additional data for the event */
  25913. additionalData?: any);
  25914. /**
  25915. * Helper function to auto-create an ActionEvent from a source mesh.
  25916. * @param source The source mesh that triggered the event
  25917. * @param evt The original (browser) event
  25918. * @param additionalData additional data for the event
  25919. * @returns the new ActionEvent
  25920. */
  25921. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25922. /**
  25923. * Helper function to auto-create an ActionEvent from a source sprite
  25924. * @param source The source sprite that triggered the event
  25925. * @param scene Scene associated with the sprite
  25926. * @param evt The original (browser) event
  25927. * @param additionalData additional data for the event
  25928. * @returns the new ActionEvent
  25929. */
  25930. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25931. /**
  25932. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25933. * @param scene the scene where the event occurred
  25934. * @param evt The original (browser) event
  25935. * @returns the new ActionEvent
  25936. */
  25937. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25938. /**
  25939. * Helper function to auto-create an ActionEvent from a primitive
  25940. * @param prim defines the target primitive
  25941. * @param pointerPos defines the pointer position
  25942. * @param evt The original (browser) event
  25943. * @param additionalData additional data for the event
  25944. * @returns the new ActionEvent
  25945. */
  25946. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25947. }
  25948. }
  25949. declare module "babylonjs/Actions/abstractActionManager" {
  25950. import { IDisposable } from "babylonjs/scene";
  25951. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25952. import { IAction } from "babylonjs/Actions/action";
  25953. import { Nullable } from "babylonjs/types";
  25954. /**
  25955. * Abstract class used to decouple action Manager from scene and meshes.
  25956. * Do not instantiate.
  25957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25958. */
  25959. export abstract class AbstractActionManager implements IDisposable {
  25960. /** Gets the list of active triggers */
  25961. static Triggers: {
  25962. [key: string]: number;
  25963. };
  25964. /** Gets the cursor to use when hovering items */
  25965. hoverCursor: string;
  25966. /** Gets the list of actions */
  25967. actions: IAction[];
  25968. /**
  25969. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25970. */
  25971. isRecursive: boolean;
  25972. /**
  25973. * Releases all associated resources
  25974. */
  25975. abstract dispose(): void;
  25976. /**
  25977. * Does this action manager has pointer triggers
  25978. */
  25979. abstract readonly hasPointerTriggers: boolean;
  25980. /**
  25981. * Does this action manager has pick triggers
  25982. */
  25983. abstract readonly hasPickTriggers: boolean;
  25984. /**
  25985. * Process a specific trigger
  25986. * @param trigger defines the trigger to process
  25987. * @param evt defines the event details to be processed
  25988. */
  25989. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25990. /**
  25991. * Does this action manager handles actions of any of the given triggers
  25992. * @param triggers defines the triggers to be tested
  25993. * @return a boolean indicating whether one (or more) of the triggers is handled
  25994. */
  25995. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25996. /**
  25997. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25998. * speed.
  25999. * @param triggerA defines the trigger to be tested
  26000. * @param triggerB defines the trigger to be tested
  26001. * @return a boolean indicating whether one (or more) of the triggers is handled
  26002. */
  26003. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26004. /**
  26005. * Does this action manager handles actions of a given trigger
  26006. * @param trigger defines the trigger to be tested
  26007. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26008. * @return whether the trigger is handled
  26009. */
  26010. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26011. /**
  26012. * Serialize this manager to a JSON object
  26013. * @param name defines the property name to store this manager
  26014. * @returns a JSON representation of this manager
  26015. */
  26016. abstract serialize(name: string): any;
  26017. /**
  26018. * Registers an action to this action manager
  26019. * @param action defines the action to be registered
  26020. * @return the action amended (prepared) after registration
  26021. */
  26022. abstract registerAction(action: IAction): Nullable<IAction>;
  26023. /**
  26024. * Unregisters an action to this action manager
  26025. * @param action defines the action to be unregistered
  26026. * @return a boolean indicating whether the action has been unregistered
  26027. */
  26028. abstract unregisterAction(action: IAction): Boolean;
  26029. /**
  26030. * Does exist one action manager with at least one trigger
  26031. **/
  26032. static readonly HasTriggers: boolean;
  26033. /**
  26034. * Does exist one action manager with at least one pick trigger
  26035. **/
  26036. static readonly HasPickTriggers: boolean;
  26037. /**
  26038. * Does exist one action manager that handles actions of a given trigger
  26039. * @param trigger defines the trigger to be tested
  26040. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26041. **/
  26042. static HasSpecificTrigger(trigger: number): boolean;
  26043. }
  26044. }
  26045. declare module "babylonjs/node" {
  26046. import { Scene } from "babylonjs/scene";
  26047. import { Nullable } from "babylonjs/types";
  26048. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  26049. import { Engine } from "babylonjs/Engines/engine";
  26050. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  26051. import { Observable } from "babylonjs/Misc/observable";
  26052. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26053. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26054. import { Animatable } from "babylonjs/Animations/animatable";
  26055. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26056. import { Animation } from "babylonjs/Animations/animation";
  26057. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26059. /**
  26060. * Defines how a node can be built from a string name.
  26061. */
  26062. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26063. /**
  26064. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26065. */
  26066. export class Node implements IBehaviorAware<Node> {
  26067. /** @hidden */
  26068. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  26069. private static _NodeConstructors;
  26070. /**
  26071. * Add a new node constructor
  26072. * @param type defines the type name of the node to construct
  26073. * @param constructorFunc defines the constructor function
  26074. */
  26075. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26076. /**
  26077. * Returns a node constructor based on type name
  26078. * @param type defines the type name
  26079. * @param name defines the new node name
  26080. * @param scene defines the hosting scene
  26081. * @param options defines optional options to transmit to constructors
  26082. * @returns the new constructor or null
  26083. */
  26084. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26085. /**
  26086. * Gets or sets the name of the node
  26087. */
  26088. name: string;
  26089. /**
  26090. * Gets or sets the id of the node
  26091. */
  26092. id: string;
  26093. /**
  26094. * Gets or sets the unique id of the node
  26095. */
  26096. uniqueId: number;
  26097. /**
  26098. * Gets or sets a string used to store user defined state for the node
  26099. */
  26100. state: string;
  26101. /**
  26102. * Gets or sets an object used to store user defined information for the node
  26103. */
  26104. metadata: any;
  26105. /**
  26106. * For internal use only. Please do not use.
  26107. */
  26108. reservedDataStore: any;
  26109. /**
  26110. * List of inspectable custom properties (used by the Inspector)
  26111. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26112. */
  26113. inspectableCustomProperties: IInspectable[];
  26114. /**
  26115. * Gets or sets a boolean used to define if the node must be serialized
  26116. */
  26117. doNotSerialize: boolean;
  26118. /** @hidden */
  26119. _isDisposed: boolean;
  26120. /**
  26121. * Gets a list of Animations associated with the node
  26122. */
  26123. animations: import("babylonjs/Animations/animation").Animation[];
  26124. protected _ranges: {
  26125. [name: string]: Nullable<AnimationRange>;
  26126. };
  26127. /**
  26128. * Callback raised when the node is ready to be used
  26129. */
  26130. onReady: Nullable<(node: Node) => void>;
  26131. private _isEnabled;
  26132. private _isParentEnabled;
  26133. private _isReady;
  26134. /** @hidden */
  26135. _currentRenderId: number;
  26136. private _parentUpdateId;
  26137. /** @hidden */
  26138. _childUpdateId: number;
  26139. /** @hidden */
  26140. _waitingParentId: Nullable<string>;
  26141. /** @hidden */
  26142. _scene: Scene;
  26143. /** @hidden */
  26144. _cache: any;
  26145. private _parentNode;
  26146. private _children;
  26147. /** @hidden */
  26148. _worldMatrix: Matrix;
  26149. /** @hidden */
  26150. _worldMatrixDeterminant: number;
  26151. /** @hidden */
  26152. _worldMatrixDeterminantIsDirty: boolean;
  26153. /** @hidden */
  26154. private _sceneRootNodesIndex;
  26155. /**
  26156. * Gets a boolean indicating if the node has been disposed
  26157. * @returns true if the node was disposed
  26158. */
  26159. isDisposed(): boolean;
  26160. /**
  26161. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26162. * @see https://doc.babylonjs.com/how_to/parenting
  26163. */
  26164. parent: Nullable<Node>;
  26165. private addToSceneRootNodes;
  26166. private removeFromSceneRootNodes;
  26167. private _animationPropertiesOverride;
  26168. /**
  26169. * Gets or sets the animation properties override
  26170. */
  26171. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26172. /**
  26173. * Gets a string idenfifying the name of the class
  26174. * @returns "Node" string
  26175. */
  26176. getClassName(): string;
  26177. /** @hidden */
  26178. readonly _isNode: boolean;
  26179. /**
  26180. * An event triggered when the mesh is disposed
  26181. */
  26182. onDisposeObservable: Observable<Node>;
  26183. private _onDisposeObserver;
  26184. /**
  26185. * Sets a callback that will be raised when the node will be disposed
  26186. */
  26187. onDispose: () => void;
  26188. /**
  26189. * Creates a new Node
  26190. * @param name the name and id to be given to this node
  26191. * @param scene the scene this node will be added to
  26192. * @param addToRootNodes the node will be added to scene.rootNodes
  26193. */
  26194. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26195. /**
  26196. * Gets the scene of the node
  26197. * @returns a scene
  26198. */
  26199. getScene(): Scene;
  26200. /**
  26201. * Gets the engine of the node
  26202. * @returns a Engine
  26203. */
  26204. getEngine(): Engine;
  26205. private _behaviors;
  26206. /**
  26207. * Attach a behavior to the node
  26208. * @see http://doc.babylonjs.com/features/behaviour
  26209. * @param behavior defines the behavior to attach
  26210. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26211. * @returns the current Node
  26212. */
  26213. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26214. /**
  26215. * Remove an attached behavior
  26216. * @see http://doc.babylonjs.com/features/behaviour
  26217. * @param behavior defines the behavior to attach
  26218. * @returns the current Node
  26219. */
  26220. removeBehavior(behavior: Behavior<Node>): Node;
  26221. /**
  26222. * Gets the list of attached behaviors
  26223. * @see http://doc.babylonjs.com/features/behaviour
  26224. */
  26225. readonly behaviors: Behavior<Node>[];
  26226. /**
  26227. * Gets an attached behavior by name
  26228. * @param name defines the name of the behavior to look for
  26229. * @see http://doc.babylonjs.com/features/behaviour
  26230. * @returns null if behavior was not found else the requested behavior
  26231. */
  26232. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26233. /**
  26234. * Returns the latest update of the World matrix
  26235. * @returns a Matrix
  26236. */
  26237. getWorldMatrix(): Matrix;
  26238. /** @hidden */
  26239. _getWorldMatrixDeterminant(): number;
  26240. /**
  26241. * Returns directly the latest state of the mesh World matrix.
  26242. * A Matrix is returned.
  26243. */
  26244. readonly worldMatrixFromCache: Matrix;
  26245. /** @hidden */
  26246. _initCache(): void;
  26247. /** @hidden */
  26248. updateCache(force?: boolean): void;
  26249. /** @hidden */
  26250. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26251. /** @hidden */
  26252. _updateCache(ignoreParentClass?: boolean): void;
  26253. /** @hidden */
  26254. _isSynchronized(): boolean;
  26255. /** @hidden */
  26256. _markSyncedWithParent(): void;
  26257. /** @hidden */
  26258. isSynchronizedWithParent(): boolean;
  26259. /** @hidden */
  26260. isSynchronized(): boolean;
  26261. /**
  26262. * Is this node ready to be used/rendered
  26263. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26264. * @return true if the node is ready
  26265. */
  26266. isReady(completeCheck?: boolean): boolean;
  26267. /**
  26268. * Is this node enabled?
  26269. * 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
  26270. * @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
  26271. * @return whether this node (and its parent) is enabled
  26272. */
  26273. isEnabled(checkAncestors?: boolean): boolean;
  26274. /** @hidden */
  26275. protected _syncParentEnabledState(): void;
  26276. /**
  26277. * Set the enabled state of this node
  26278. * @param value defines the new enabled state
  26279. */
  26280. setEnabled(value: boolean): void;
  26281. /**
  26282. * Is this node a descendant of the given node?
  26283. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26284. * @param ancestor defines the parent node to inspect
  26285. * @returns a boolean indicating if this node is a descendant of the given node
  26286. */
  26287. isDescendantOf(ancestor: Node): boolean;
  26288. /** @hidden */
  26289. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26290. /**
  26291. * Will return all nodes that have this node as ascendant
  26292. * @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
  26293. * @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
  26294. * @return all children nodes of all types
  26295. */
  26296. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26297. /**
  26298. * Get all child-meshes of this node
  26299. * @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)
  26300. * @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
  26301. * @returns an array of AbstractMesh
  26302. */
  26303. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26304. /**
  26305. * Get all direct children of this node
  26306. * @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
  26307. * @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)
  26308. * @returns an array of Node
  26309. */
  26310. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26311. /** @hidden */
  26312. _setReady(state: boolean): void;
  26313. /**
  26314. * Get an animation by name
  26315. * @param name defines the name of the animation to look for
  26316. * @returns null if not found else the requested animation
  26317. */
  26318. getAnimationByName(name: string): Nullable<Animation>;
  26319. /**
  26320. * Creates an animation range for this node
  26321. * @param name defines the name of the range
  26322. * @param from defines the starting key
  26323. * @param to defines the end key
  26324. */
  26325. createAnimationRange(name: string, from: number, to: number): void;
  26326. /**
  26327. * Delete a specific animation range
  26328. * @param name defines the name of the range to delete
  26329. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26330. */
  26331. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26332. /**
  26333. * Get an animation range by name
  26334. * @param name defines the name of the animation range to look for
  26335. * @returns null if not found else the requested animation range
  26336. */
  26337. getAnimationRange(name: string): Nullable<AnimationRange>;
  26338. /**
  26339. * Gets the list of all animation ranges defined on this node
  26340. * @returns an array
  26341. */
  26342. getAnimationRanges(): Nullable<AnimationRange>[];
  26343. /**
  26344. * Will start the animation sequence
  26345. * @param name defines the range frames for animation sequence
  26346. * @param loop defines if the animation should loop (false by default)
  26347. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26348. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26349. * @returns the object created for this animation. If range does not exist, it will return null
  26350. */
  26351. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26352. /**
  26353. * Serialize animation ranges into a JSON compatible object
  26354. * @returns serialization object
  26355. */
  26356. serializeAnimationRanges(): any;
  26357. /**
  26358. * Computes the world matrix of the node
  26359. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26360. * @returns the world matrix
  26361. */
  26362. computeWorldMatrix(force?: boolean): Matrix;
  26363. /**
  26364. * Releases resources associated with this node.
  26365. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26366. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26367. */
  26368. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26369. /**
  26370. * Parse animation range data from a serialization object and store them into a given node
  26371. * @param node defines where to store the animation ranges
  26372. * @param parsedNode defines the serialization object to read data from
  26373. * @param scene defines the hosting scene
  26374. */
  26375. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26376. /**
  26377. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26378. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26379. * @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
  26380. * @returns the new bounding vectors
  26381. */
  26382. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26383. min: Vector3;
  26384. max: Vector3;
  26385. };
  26386. }
  26387. }
  26388. declare module "babylonjs/Animations/animation" {
  26389. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26390. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26391. import { Nullable } from "babylonjs/types";
  26392. import { Scene } from "babylonjs/scene";
  26393. import { IAnimatable } from "babylonjs/Misc/tools";
  26394. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26395. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26396. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26397. import { Node } from "babylonjs/node";
  26398. import { Animatable } from "babylonjs/Animations/animatable";
  26399. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26400. /**
  26401. * @hidden
  26402. */
  26403. export class _IAnimationState {
  26404. key: number;
  26405. repeatCount: number;
  26406. workValue?: any;
  26407. loopMode?: number;
  26408. offsetValue?: any;
  26409. highLimitValue?: any;
  26410. }
  26411. /**
  26412. * Class used to store any kind of animation
  26413. */
  26414. export class Animation {
  26415. /**Name of the animation */
  26416. name: string;
  26417. /**Property to animate */
  26418. targetProperty: string;
  26419. /**The frames per second of the animation */
  26420. framePerSecond: number;
  26421. /**The data type of the animation */
  26422. dataType: number;
  26423. /**The loop mode of the animation */
  26424. loopMode?: number | undefined;
  26425. /**Specifies if blending should be enabled */
  26426. enableBlending?: boolean | undefined;
  26427. /**
  26428. * Use matrix interpolation instead of using direct key value when animating matrices
  26429. */
  26430. static AllowMatricesInterpolation: boolean;
  26431. /**
  26432. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26433. */
  26434. static AllowMatrixDecomposeForInterpolation: boolean;
  26435. /**
  26436. * Stores the key frames of the animation
  26437. */
  26438. private _keys;
  26439. /**
  26440. * Stores the easing function of the animation
  26441. */
  26442. private _easingFunction;
  26443. /**
  26444. * @hidden Internal use only
  26445. */
  26446. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26447. /**
  26448. * The set of event that will be linked to this animation
  26449. */
  26450. private _events;
  26451. /**
  26452. * Stores an array of target property paths
  26453. */
  26454. targetPropertyPath: string[];
  26455. /**
  26456. * Stores the blending speed of the animation
  26457. */
  26458. blendingSpeed: number;
  26459. /**
  26460. * Stores the animation ranges for the animation
  26461. */
  26462. private _ranges;
  26463. /**
  26464. * @hidden Internal use
  26465. */
  26466. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26467. /**
  26468. * Sets up an animation
  26469. * @param property The property to animate
  26470. * @param animationType The animation type to apply
  26471. * @param framePerSecond The frames per second of the animation
  26472. * @param easingFunction The easing function used in the animation
  26473. * @returns The created animation
  26474. */
  26475. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26476. /**
  26477. * Create and start an animation on a node
  26478. * @param name defines the name of the global animation that will be run on all nodes
  26479. * @param node defines the root node where the animation will take place
  26480. * @param targetProperty defines property to animate
  26481. * @param framePerSecond defines the number of frame per second yo use
  26482. * @param totalFrame defines the number of frames in total
  26483. * @param from defines the initial value
  26484. * @param to defines the final value
  26485. * @param loopMode defines which loop mode you want to use (off by default)
  26486. * @param easingFunction defines the easing function to use (linear by default)
  26487. * @param onAnimationEnd defines the callback to call when animation end
  26488. * @returns the animatable created for this animation
  26489. */
  26490. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26491. /**
  26492. * Create and start an animation on a node and its descendants
  26493. * @param name defines the name of the global animation that will be run on all nodes
  26494. * @param node defines the root node where the animation will take place
  26495. * @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
  26496. * @param targetProperty defines property to animate
  26497. * @param framePerSecond defines the number of frame per second to use
  26498. * @param totalFrame defines the number of frames in total
  26499. * @param from defines the initial value
  26500. * @param to defines the final value
  26501. * @param loopMode defines which loop mode you want to use (off by default)
  26502. * @param easingFunction defines the easing function to use (linear by default)
  26503. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26504. * @returns the list of animatables created for all nodes
  26505. * @example https://www.babylonjs-playground.com/#MH0VLI
  26506. */
  26507. 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[]>;
  26508. /**
  26509. * Creates a new animation, merges it with the existing animations and starts it
  26510. * @param name Name of the animation
  26511. * @param node Node which contains the scene that begins the animations
  26512. * @param targetProperty Specifies which property to animate
  26513. * @param framePerSecond The frames per second of the animation
  26514. * @param totalFrame The total number of frames
  26515. * @param from The frame at the beginning of the animation
  26516. * @param to The frame at the end of the animation
  26517. * @param loopMode Specifies the loop mode of the animation
  26518. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26519. * @param onAnimationEnd Callback to run once the animation is complete
  26520. * @returns Nullable animation
  26521. */
  26522. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26523. /**
  26524. * Transition property of an host to the target Value
  26525. * @param property The property to transition
  26526. * @param targetValue The target Value of the property
  26527. * @param host The object where the property to animate belongs
  26528. * @param scene Scene used to run the animation
  26529. * @param frameRate Framerate (in frame/s) to use
  26530. * @param transition The transition type we want to use
  26531. * @param duration The duration of the animation, in milliseconds
  26532. * @param onAnimationEnd Callback trigger at the end of the animation
  26533. * @returns Nullable animation
  26534. */
  26535. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26536. /**
  26537. * Return the array of runtime animations currently using this animation
  26538. */
  26539. readonly runtimeAnimations: RuntimeAnimation[];
  26540. /**
  26541. * Specifies if any of the runtime animations are currently running
  26542. */
  26543. readonly hasRunningRuntimeAnimations: boolean;
  26544. /**
  26545. * Initializes the animation
  26546. * @param name Name of the animation
  26547. * @param targetProperty Property to animate
  26548. * @param framePerSecond The frames per second of the animation
  26549. * @param dataType The data type of the animation
  26550. * @param loopMode The loop mode of the animation
  26551. * @param enableBlending Specifies if blending should be enabled
  26552. */
  26553. constructor(
  26554. /**Name of the animation */
  26555. name: string,
  26556. /**Property to animate */
  26557. targetProperty: string,
  26558. /**The frames per second of the animation */
  26559. framePerSecond: number,
  26560. /**The data type of the animation */
  26561. dataType: number,
  26562. /**The loop mode of the animation */
  26563. loopMode?: number | undefined,
  26564. /**Specifies if blending should be enabled */
  26565. enableBlending?: boolean | undefined);
  26566. /**
  26567. * Converts the animation to a string
  26568. * @param fullDetails support for multiple levels of logging within scene loading
  26569. * @returns String form of the animation
  26570. */
  26571. toString(fullDetails?: boolean): string;
  26572. /**
  26573. * Add an event to this animation
  26574. * @param event Event to add
  26575. */
  26576. addEvent(event: AnimationEvent): void;
  26577. /**
  26578. * Remove all events found at the given frame
  26579. * @param frame The frame to remove events from
  26580. */
  26581. removeEvents(frame: number): void;
  26582. /**
  26583. * Retrieves all the events from the animation
  26584. * @returns Events from the animation
  26585. */
  26586. getEvents(): AnimationEvent[];
  26587. /**
  26588. * Creates an animation range
  26589. * @param name Name of the animation range
  26590. * @param from Starting frame of the animation range
  26591. * @param to Ending frame of the animation
  26592. */
  26593. createRange(name: string, from: number, to: number): void;
  26594. /**
  26595. * Deletes an animation range by name
  26596. * @param name Name of the animation range to delete
  26597. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26598. */
  26599. deleteRange(name: string, deleteFrames?: boolean): void;
  26600. /**
  26601. * Gets the animation range by name, or null if not defined
  26602. * @param name Name of the animation range
  26603. * @returns Nullable animation range
  26604. */
  26605. getRange(name: string): Nullable<AnimationRange>;
  26606. /**
  26607. * Gets the key frames from the animation
  26608. * @returns The key frames of the animation
  26609. */
  26610. getKeys(): Array<IAnimationKey>;
  26611. /**
  26612. * Gets the highest frame rate of the animation
  26613. * @returns Highest frame rate of the animation
  26614. */
  26615. getHighestFrame(): number;
  26616. /**
  26617. * Gets the easing function of the animation
  26618. * @returns Easing function of the animation
  26619. */
  26620. getEasingFunction(): IEasingFunction;
  26621. /**
  26622. * Sets the easing function of the animation
  26623. * @param easingFunction A custom mathematical formula for animation
  26624. */
  26625. setEasingFunction(easingFunction: EasingFunction): void;
  26626. /**
  26627. * Interpolates a scalar linearly
  26628. * @param startValue Start value of the animation curve
  26629. * @param endValue End value of the animation curve
  26630. * @param gradient Scalar amount to interpolate
  26631. * @returns Interpolated scalar value
  26632. */
  26633. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26634. /**
  26635. * Interpolates a scalar cubically
  26636. * @param startValue Start value of the animation curve
  26637. * @param outTangent End tangent of the animation
  26638. * @param endValue End value of the animation curve
  26639. * @param inTangent Start tangent of the animation curve
  26640. * @param gradient Scalar amount to interpolate
  26641. * @returns Interpolated scalar value
  26642. */
  26643. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26644. /**
  26645. * Interpolates a quaternion using a spherical linear interpolation
  26646. * @param startValue Start value of the animation curve
  26647. * @param endValue End value of the animation curve
  26648. * @param gradient Scalar amount to interpolate
  26649. * @returns Interpolated quaternion value
  26650. */
  26651. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26652. /**
  26653. * Interpolates a quaternion cubically
  26654. * @param startValue Start value of the animation curve
  26655. * @param outTangent End tangent of the animation curve
  26656. * @param endValue End value of the animation curve
  26657. * @param inTangent Start tangent of the animation curve
  26658. * @param gradient Scalar amount to interpolate
  26659. * @returns Interpolated quaternion value
  26660. */
  26661. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26662. /**
  26663. * Interpolates a Vector3 linearl
  26664. * @param startValue Start value of the animation curve
  26665. * @param endValue End value of the animation curve
  26666. * @param gradient Scalar amount to interpolate
  26667. * @returns Interpolated scalar value
  26668. */
  26669. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26670. /**
  26671. * Interpolates a Vector3 cubically
  26672. * @param startValue Start value of the animation curve
  26673. * @param outTangent End tangent of the animation
  26674. * @param endValue End value of the animation curve
  26675. * @param inTangent Start tangent of the animation curve
  26676. * @param gradient Scalar amount to interpolate
  26677. * @returns InterpolatedVector3 value
  26678. */
  26679. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26680. /**
  26681. * Interpolates a Vector2 linearly
  26682. * @param startValue Start value of the animation curve
  26683. * @param endValue End value of the animation curve
  26684. * @param gradient Scalar amount to interpolate
  26685. * @returns Interpolated Vector2 value
  26686. */
  26687. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26688. /**
  26689. * Interpolates a Vector2 cubically
  26690. * @param startValue Start value of the animation curve
  26691. * @param outTangent End tangent of the animation
  26692. * @param endValue End value of the animation curve
  26693. * @param inTangent Start tangent of the animation curve
  26694. * @param gradient Scalar amount to interpolate
  26695. * @returns Interpolated Vector2 value
  26696. */
  26697. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26698. /**
  26699. * Interpolates a size linearly
  26700. * @param startValue Start value of the animation curve
  26701. * @param endValue End value of the animation curve
  26702. * @param gradient Scalar amount to interpolate
  26703. * @returns Interpolated Size value
  26704. */
  26705. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26706. /**
  26707. * Interpolates a Color3 linearly
  26708. * @param startValue Start value of the animation curve
  26709. * @param endValue End value of the animation curve
  26710. * @param gradient Scalar amount to interpolate
  26711. * @returns Interpolated Color3 value
  26712. */
  26713. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26714. /**
  26715. * @hidden Internal use only
  26716. */
  26717. _getKeyValue(value: any): any;
  26718. /**
  26719. * @hidden Internal use only
  26720. */
  26721. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26722. /**
  26723. * Defines the function to use to interpolate matrices
  26724. * @param startValue defines the start matrix
  26725. * @param endValue defines the end matrix
  26726. * @param gradient defines the gradient between both matrices
  26727. * @param result defines an optional target matrix where to store the interpolation
  26728. * @returns the interpolated matrix
  26729. */
  26730. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26731. /**
  26732. * Makes a copy of the animation
  26733. * @returns Cloned animation
  26734. */
  26735. clone(): Animation;
  26736. /**
  26737. * Sets the key frames of the animation
  26738. * @param values The animation key frames to set
  26739. */
  26740. setKeys(values: Array<IAnimationKey>): void;
  26741. /**
  26742. * Serializes the animation to an object
  26743. * @returns Serialized object
  26744. */
  26745. serialize(): any;
  26746. /**
  26747. * Float animation type
  26748. */
  26749. private static _ANIMATIONTYPE_FLOAT;
  26750. /**
  26751. * Vector3 animation type
  26752. */
  26753. private static _ANIMATIONTYPE_VECTOR3;
  26754. /**
  26755. * Quaternion animation type
  26756. */
  26757. private static _ANIMATIONTYPE_QUATERNION;
  26758. /**
  26759. * Matrix animation type
  26760. */
  26761. private static _ANIMATIONTYPE_MATRIX;
  26762. /**
  26763. * Color3 animation type
  26764. */
  26765. private static _ANIMATIONTYPE_COLOR3;
  26766. /**
  26767. * Vector2 animation type
  26768. */
  26769. private static _ANIMATIONTYPE_VECTOR2;
  26770. /**
  26771. * Size animation type
  26772. */
  26773. private static _ANIMATIONTYPE_SIZE;
  26774. /**
  26775. * Relative Loop Mode
  26776. */
  26777. private static _ANIMATIONLOOPMODE_RELATIVE;
  26778. /**
  26779. * Cycle Loop Mode
  26780. */
  26781. private static _ANIMATIONLOOPMODE_CYCLE;
  26782. /**
  26783. * Constant Loop Mode
  26784. */
  26785. private static _ANIMATIONLOOPMODE_CONSTANT;
  26786. /**
  26787. * Get the float animation type
  26788. */
  26789. static readonly ANIMATIONTYPE_FLOAT: number;
  26790. /**
  26791. * Get the Vector3 animation type
  26792. */
  26793. static readonly ANIMATIONTYPE_VECTOR3: number;
  26794. /**
  26795. * Get the Vector2 animation type
  26796. */
  26797. static readonly ANIMATIONTYPE_VECTOR2: number;
  26798. /**
  26799. * Get the Size animation type
  26800. */
  26801. static readonly ANIMATIONTYPE_SIZE: number;
  26802. /**
  26803. * Get the Quaternion animation type
  26804. */
  26805. static readonly ANIMATIONTYPE_QUATERNION: number;
  26806. /**
  26807. * Get the Matrix animation type
  26808. */
  26809. static readonly ANIMATIONTYPE_MATRIX: number;
  26810. /**
  26811. * Get the Color3 animation type
  26812. */
  26813. static readonly ANIMATIONTYPE_COLOR3: number;
  26814. /**
  26815. * Get the Relative Loop Mode
  26816. */
  26817. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26818. /**
  26819. * Get the Cycle Loop Mode
  26820. */
  26821. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26822. /**
  26823. * Get the Constant Loop Mode
  26824. */
  26825. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26826. /** @hidden */
  26827. static _UniversalLerp(left: any, right: any, amount: number): any;
  26828. /**
  26829. * Parses an animation object and creates an animation
  26830. * @param parsedAnimation Parsed animation object
  26831. * @returns Animation object
  26832. */
  26833. static Parse(parsedAnimation: any): Animation;
  26834. /**
  26835. * Appends the serialized animations from the source animations
  26836. * @param source Source containing the animations
  26837. * @param destination Target to store the animations
  26838. */
  26839. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26840. }
  26841. }
  26842. declare module "babylonjs/Materials/Textures/baseTexture" {
  26843. import { Observable } from "babylonjs/Misc/observable";
  26844. import { IAnimatable } from "babylonjs/Misc/tools";
  26845. import { Nullable } from "babylonjs/types";
  26846. import { Scene } from "babylonjs/scene";
  26847. import { Matrix, ISize } from "babylonjs/Maths/math";
  26848. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26849. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26850. /**
  26851. * Base class of all the textures in babylon.
  26852. * It groups all the common properties the materials, post process, lights... might need
  26853. * in order to make a correct use of the texture.
  26854. */
  26855. export class BaseTexture implements IAnimatable {
  26856. /**
  26857. * Default anisotropic filtering level for the application.
  26858. * It is set to 4 as a good tradeoff between perf and quality.
  26859. */
  26860. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26861. /**
  26862. * Gets or sets the unique id of the texture
  26863. */
  26864. uniqueId: number;
  26865. /**
  26866. * Define the name of the texture.
  26867. */
  26868. name: string;
  26869. /**
  26870. * Gets or sets an object used to store user defined information.
  26871. */
  26872. metadata: any;
  26873. /**
  26874. * For internal use only. Please do not use.
  26875. */
  26876. reservedDataStore: any;
  26877. private _hasAlpha;
  26878. /**
  26879. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26880. */
  26881. hasAlpha: boolean;
  26882. /**
  26883. * Defines if the alpha value should be determined via the rgb values.
  26884. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26885. */
  26886. getAlphaFromRGB: boolean;
  26887. /**
  26888. * Intensity or strength of the texture.
  26889. * It is commonly used by materials to fine tune the intensity of the texture
  26890. */
  26891. level: number;
  26892. /**
  26893. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26894. * This is part of the texture as textures usually maps to one uv set.
  26895. */
  26896. coordinatesIndex: number;
  26897. private _coordinatesMode;
  26898. /**
  26899. * How a texture is mapped.
  26900. *
  26901. * | Value | Type | Description |
  26902. * | ----- | ----------------------------------- | ----------- |
  26903. * | 0 | EXPLICIT_MODE | |
  26904. * | 1 | SPHERICAL_MODE | |
  26905. * | 2 | PLANAR_MODE | |
  26906. * | 3 | CUBIC_MODE | |
  26907. * | 4 | PROJECTION_MODE | |
  26908. * | 5 | SKYBOX_MODE | |
  26909. * | 6 | INVCUBIC_MODE | |
  26910. * | 7 | EQUIRECTANGULAR_MODE | |
  26911. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26912. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26913. */
  26914. coordinatesMode: number;
  26915. /**
  26916. * | Value | Type | Description |
  26917. * | ----- | ------------------ | ----------- |
  26918. * | 0 | CLAMP_ADDRESSMODE | |
  26919. * | 1 | WRAP_ADDRESSMODE | |
  26920. * | 2 | MIRROR_ADDRESSMODE | |
  26921. */
  26922. wrapU: number;
  26923. /**
  26924. * | Value | Type | Description |
  26925. * | ----- | ------------------ | ----------- |
  26926. * | 0 | CLAMP_ADDRESSMODE | |
  26927. * | 1 | WRAP_ADDRESSMODE | |
  26928. * | 2 | MIRROR_ADDRESSMODE | |
  26929. */
  26930. wrapV: number;
  26931. /**
  26932. * | Value | Type | Description |
  26933. * | ----- | ------------------ | ----------- |
  26934. * | 0 | CLAMP_ADDRESSMODE | |
  26935. * | 1 | WRAP_ADDRESSMODE | |
  26936. * | 2 | MIRROR_ADDRESSMODE | |
  26937. */
  26938. wrapR: number;
  26939. /**
  26940. * With compliant hardware and browser (supporting anisotropic filtering)
  26941. * this defines the level of anisotropic filtering in the texture.
  26942. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26943. */
  26944. anisotropicFilteringLevel: number;
  26945. /**
  26946. * Define if the texture is a cube texture or if false a 2d texture.
  26947. */
  26948. isCube: boolean;
  26949. /**
  26950. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26951. */
  26952. is3D: boolean;
  26953. /**
  26954. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26955. * HDR texture are usually stored in linear space.
  26956. * This only impacts the PBR and Background materials
  26957. */
  26958. gammaSpace: boolean;
  26959. /**
  26960. * Gets whether or not the texture contains RGBD data.
  26961. */
  26962. readonly isRGBD: boolean;
  26963. /**
  26964. * Is Z inverted in the texture (useful in a cube texture).
  26965. */
  26966. invertZ: boolean;
  26967. /**
  26968. * Are mip maps generated for this texture or not.
  26969. */
  26970. readonly noMipmap: boolean;
  26971. /**
  26972. * @hidden
  26973. */
  26974. lodLevelInAlpha: boolean;
  26975. /**
  26976. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26977. */
  26978. lodGenerationOffset: number;
  26979. /**
  26980. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26981. */
  26982. lodGenerationScale: number;
  26983. /**
  26984. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  26985. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  26986. * average roughness values.
  26987. */
  26988. linearSpecularLOD: boolean;
  26989. /**
  26990. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  26991. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  26992. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  26993. */
  26994. irradianceTexture: Nullable<BaseTexture>;
  26995. /**
  26996. * Define if the texture is a render target.
  26997. */
  26998. isRenderTarget: boolean;
  26999. /**
  27000. * Define the unique id of the texture in the scene.
  27001. */
  27002. readonly uid: string;
  27003. /**
  27004. * Return a string representation of the texture.
  27005. * @returns the texture as a string
  27006. */
  27007. toString(): string;
  27008. /**
  27009. * Get the class name of the texture.
  27010. * @returns "BaseTexture"
  27011. */
  27012. getClassName(): string;
  27013. /**
  27014. * Define the list of animation attached to the texture.
  27015. */
  27016. animations: import("babylonjs/Animations/animation").Animation[];
  27017. /**
  27018. * An event triggered when the texture is disposed.
  27019. */
  27020. onDisposeObservable: Observable<BaseTexture>;
  27021. private _onDisposeObserver;
  27022. /**
  27023. * Callback triggered when the texture has been disposed.
  27024. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27025. */
  27026. onDispose: () => void;
  27027. /**
  27028. * Define the current state of the loading sequence when in delayed load mode.
  27029. */
  27030. delayLoadState: number;
  27031. private _scene;
  27032. /** @hidden */
  27033. _texture: Nullable<InternalTexture>;
  27034. private _uid;
  27035. /**
  27036. * Define if the texture is preventinga material to render or not.
  27037. * If not and the texture is not ready, the engine will use a default black texture instead.
  27038. */
  27039. readonly isBlocking: boolean;
  27040. /**
  27041. * Instantiates a new BaseTexture.
  27042. * Base class of all the textures in babylon.
  27043. * It groups all the common properties the materials, post process, lights... might need
  27044. * in order to make a correct use of the texture.
  27045. * @param scene Define the scene the texture blongs to
  27046. */
  27047. constructor(scene: Nullable<Scene>);
  27048. /**
  27049. * Get the scene the texture belongs to.
  27050. * @returns the scene or null if undefined
  27051. */
  27052. getScene(): Nullable<Scene>;
  27053. /**
  27054. * Get the texture transform matrix used to offset tile the texture for istance.
  27055. * @returns the transformation matrix
  27056. */
  27057. getTextureMatrix(): Matrix;
  27058. /**
  27059. * Get the texture reflection matrix used to rotate/transform the reflection.
  27060. * @returns the reflection matrix
  27061. */
  27062. getReflectionTextureMatrix(): Matrix;
  27063. /**
  27064. * Get the underlying lower level texture from Babylon.
  27065. * @returns the insternal texture
  27066. */
  27067. getInternalTexture(): Nullable<InternalTexture>;
  27068. /**
  27069. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27070. * @returns true if ready or not blocking
  27071. */
  27072. isReadyOrNotBlocking(): boolean;
  27073. /**
  27074. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27075. * @returns true if fully ready
  27076. */
  27077. isReady(): boolean;
  27078. private _cachedSize;
  27079. /**
  27080. * Get the size of the texture.
  27081. * @returns the texture size.
  27082. */
  27083. getSize(): ISize;
  27084. /**
  27085. * Get the base size of the texture.
  27086. * It can be different from the size if the texture has been resized for POT for instance
  27087. * @returns the base size
  27088. */
  27089. getBaseSize(): ISize;
  27090. /**
  27091. * Update the sampling mode of the texture.
  27092. * Default is Trilinear mode.
  27093. *
  27094. * | Value | Type | Description |
  27095. * | ----- | ------------------ | ----------- |
  27096. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27097. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27098. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27099. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27100. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27101. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27102. * | 7 | NEAREST_LINEAR | |
  27103. * | 8 | NEAREST_NEAREST | |
  27104. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27105. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27106. * | 11 | LINEAR_LINEAR | |
  27107. * | 12 | LINEAR_NEAREST | |
  27108. *
  27109. * > _mag_: magnification filter (close to the viewer)
  27110. * > _min_: minification filter (far from the viewer)
  27111. * > _mip_: filter used between mip map levels
  27112. *@param samplingMode Define the new sampling mode of the texture
  27113. */
  27114. updateSamplingMode(samplingMode: number): void;
  27115. /**
  27116. * Scales the texture if is `canRescale()`
  27117. * @param ratio the resize factor we want to use to rescale
  27118. */
  27119. scale(ratio: number): void;
  27120. /**
  27121. * Get if the texture can rescale.
  27122. */
  27123. readonly canRescale: boolean;
  27124. /** @hidden */
  27125. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27126. /** @hidden */
  27127. _rebuild(): void;
  27128. /**
  27129. * Triggers the load sequence in delayed load mode.
  27130. */
  27131. delayLoad(): void;
  27132. /**
  27133. * Clones the texture.
  27134. * @returns the cloned texture
  27135. */
  27136. clone(): Nullable<BaseTexture>;
  27137. /**
  27138. * Get the texture underlying type (INT, FLOAT...)
  27139. */
  27140. readonly textureType: number;
  27141. /**
  27142. * Get the texture underlying format (RGB, RGBA...)
  27143. */
  27144. readonly textureFormat: number;
  27145. /**
  27146. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27147. * This will returns an RGBA array buffer containing either in values (0-255) or
  27148. * float values (0-1) depending of the underlying buffer type.
  27149. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27150. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27151. * @param buffer defines a user defined buffer to fill with data (can be null)
  27152. * @returns The Array buffer containing the pixels data.
  27153. */
  27154. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27155. /**
  27156. * Release and destroy the underlying lower level texture aka internalTexture.
  27157. */
  27158. releaseInternalTexture(): void;
  27159. /**
  27160. * Get the polynomial representation of the texture data.
  27161. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27162. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27163. */
  27164. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27165. /** @hidden */
  27166. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27167. /** @hidden */
  27168. readonly _lodTextureMid: Nullable<BaseTexture>;
  27169. /** @hidden */
  27170. readonly _lodTextureLow: Nullable<BaseTexture>;
  27171. /**
  27172. * Dispose the texture and release its associated resources.
  27173. */
  27174. dispose(): void;
  27175. /**
  27176. * Serialize the texture into a JSON representation that can be parsed later on.
  27177. * @returns the JSON representation of the texture
  27178. */
  27179. serialize(): any;
  27180. /**
  27181. * Helper function to be called back once a list of texture contains only ready textures.
  27182. * @param textures Define the list of textures to wait for
  27183. * @param callback Define the callback triggered once the entire list will be ready
  27184. */
  27185. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27186. }
  27187. }
  27188. declare module "babylonjs/Materials/uniformBuffer" {
  27189. import { Nullable, FloatArray } from "babylonjs/types";
  27190. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27191. import { Engine } from "babylonjs/Engines/engine";
  27192. import { Effect } from "babylonjs/Materials/effect";
  27193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27194. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27195. /**
  27196. * Uniform buffer objects.
  27197. *
  27198. * Handles blocks of uniform on the GPU.
  27199. *
  27200. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27201. *
  27202. * For more information, please refer to :
  27203. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27204. */
  27205. export class UniformBuffer {
  27206. private _engine;
  27207. private _buffer;
  27208. private _data;
  27209. private _bufferData;
  27210. private _dynamic?;
  27211. private _uniformLocations;
  27212. private _uniformSizes;
  27213. private _uniformLocationPointer;
  27214. private _needSync;
  27215. private _noUBO;
  27216. private _currentEffect;
  27217. private static _MAX_UNIFORM_SIZE;
  27218. private static _tempBuffer;
  27219. /**
  27220. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27221. * This is dynamic to allow compat with webgl 1 and 2.
  27222. * You will need to pass the name of the uniform as well as the value.
  27223. */
  27224. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27225. /**
  27226. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27227. * This is dynamic to allow compat with webgl 1 and 2.
  27228. * You will need to pass the name of the uniform as well as the value.
  27229. */
  27230. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27231. /**
  27232. * Lambda to Update a single float in a uniform buffer.
  27233. * This is dynamic to allow compat with webgl 1 and 2.
  27234. * You will need to pass the name of the uniform as well as the value.
  27235. */
  27236. updateFloat: (name: string, x: number) => void;
  27237. /**
  27238. * Lambda to Update a vec2 of float in a uniform buffer.
  27239. * This is dynamic to allow compat with webgl 1 and 2.
  27240. * You will need to pass the name of the uniform as well as the value.
  27241. */
  27242. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27243. /**
  27244. * Lambda to Update a vec3 of float in a uniform buffer.
  27245. * This is dynamic to allow compat with webgl 1 and 2.
  27246. * You will need to pass the name of the uniform as well as the value.
  27247. */
  27248. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27249. /**
  27250. * Lambda to Update a vec4 of float in a uniform buffer.
  27251. * This is dynamic to allow compat with webgl 1 and 2.
  27252. * You will need to pass the name of the uniform as well as the value.
  27253. */
  27254. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27255. /**
  27256. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27257. * This is dynamic to allow compat with webgl 1 and 2.
  27258. * You will need to pass the name of the uniform as well as the value.
  27259. */
  27260. updateMatrix: (name: string, mat: Matrix) => void;
  27261. /**
  27262. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27263. * This is dynamic to allow compat with webgl 1 and 2.
  27264. * You will need to pass the name of the uniform as well as the value.
  27265. */
  27266. updateVector3: (name: string, vector: Vector3) => void;
  27267. /**
  27268. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27269. * This is dynamic to allow compat with webgl 1 and 2.
  27270. * You will need to pass the name of the uniform as well as the value.
  27271. */
  27272. updateVector4: (name: string, vector: Vector4) => void;
  27273. /**
  27274. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27275. * This is dynamic to allow compat with webgl 1 and 2.
  27276. * You will need to pass the name of the uniform as well as the value.
  27277. */
  27278. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27279. /**
  27280. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27281. * This is dynamic to allow compat with webgl 1 and 2.
  27282. * You will need to pass the name of the uniform as well as the value.
  27283. */
  27284. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27285. /**
  27286. * Instantiates a new Uniform buffer objects.
  27287. *
  27288. * Handles blocks of uniform on the GPU.
  27289. *
  27290. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27291. *
  27292. * For more information, please refer to :
  27293. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27294. * @param engine Define the engine the buffer is associated with
  27295. * @param data Define the data contained in the buffer
  27296. * @param dynamic Define if the buffer is updatable
  27297. */
  27298. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27299. /**
  27300. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27301. * or just falling back on setUniformXXX calls.
  27302. */
  27303. readonly useUbo: boolean;
  27304. /**
  27305. * Indicates if the WebGL underlying uniform buffer is in sync
  27306. * with the javascript cache data.
  27307. */
  27308. readonly isSync: boolean;
  27309. /**
  27310. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27311. * Also, a dynamic UniformBuffer will disable cache verification and always
  27312. * update the underlying WebGL uniform buffer to the GPU.
  27313. * @returns if Dynamic, otherwise false
  27314. */
  27315. isDynamic(): boolean;
  27316. /**
  27317. * The data cache on JS side.
  27318. * @returns the underlying data as a float array
  27319. */
  27320. getData(): Float32Array;
  27321. /**
  27322. * The underlying WebGL Uniform buffer.
  27323. * @returns the webgl buffer
  27324. */
  27325. getBuffer(): Nullable<DataBuffer>;
  27326. /**
  27327. * std140 layout specifies how to align data within an UBO structure.
  27328. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27329. * for specs.
  27330. */
  27331. private _fillAlignment;
  27332. /**
  27333. * Adds an uniform in the buffer.
  27334. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27335. * for the layout to be correct !
  27336. * @param name Name of the uniform, as used in the uniform block in the shader.
  27337. * @param size Data size, or data directly.
  27338. */
  27339. addUniform(name: string, size: number | number[]): void;
  27340. /**
  27341. * Adds a Matrix 4x4 to the uniform buffer.
  27342. * @param name Name of the uniform, as used in the uniform block in the shader.
  27343. * @param mat A 4x4 matrix.
  27344. */
  27345. addMatrix(name: string, mat: Matrix): void;
  27346. /**
  27347. * Adds a vec2 to the uniform buffer.
  27348. * @param name Name of the uniform, as used in the uniform block in the shader.
  27349. * @param x Define the x component value of the vec2
  27350. * @param y Define the y component value of the vec2
  27351. */
  27352. addFloat2(name: string, x: number, y: number): void;
  27353. /**
  27354. * Adds a vec3 to the uniform buffer.
  27355. * @param name Name of the uniform, as used in the uniform block in the shader.
  27356. * @param x Define the x component value of the vec3
  27357. * @param y Define the y component value of the vec3
  27358. * @param z Define the z component value of the vec3
  27359. */
  27360. addFloat3(name: string, x: number, y: number, z: number): void;
  27361. /**
  27362. * Adds a vec3 to the uniform buffer.
  27363. * @param name Name of the uniform, as used in the uniform block in the shader.
  27364. * @param color Define the vec3 from a Color
  27365. */
  27366. addColor3(name: string, color: Color3): void;
  27367. /**
  27368. * Adds a vec4 to the uniform buffer.
  27369. * @param name Name of the uniform, as used in the uniform block in the shader.
  27370. * @param color Define the rgb components from a Color
  27371. * @param alpha Define the a component of the vec4
  27372. */
  27373. addColor4(name: string, color: Color3, alpha: number): void;
  27374. /**
  27375. * Adds a vec3 to the uniform buffer.
  27376. * @param name Name of the uniform, as used in the uniform block in the shader.
  27377. * @param vector Define the vec3 components from a Vector
  27378. */
  27379. addVector3(name: string, vector: Vector3): void;
  27380. /**
  27381. * Adds a Matrix 3x3 to the uniform buffer.
  27382. * @param name Name of the uniform, as used in the uniform block in the shader.
  27383. */
  27384. addMatrix3x3(name: string): void;
  27385. /**
  27386. * Adds a Matrix 2x2 to the uniform buffer.
  27387. * @param name Name of the uniform, as used in the uniform block in the shader.
  27388. */
  27389. addMatrix2x2(name: string): void;
  27390. /**
  27391. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27392. */
  27393. create(): void;
  27394. /** @hidden */
  27395. _rebuild(): void;
  27396. /**
  27397. * Updates the WebGL Uniform Buffer on the GPU.
  27398. * If the `dynamic` flag is set to true, no cache comparison is done.
  27399. * Otherwise, the buffer will be updated only if the cache differs.
  27400. */
  27401. update(): void;
  27402. /**
  27403. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27404. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27405. * @param data Define the flattened data
  27406. * @param size Define the size of the data.
  27407. */
  27408. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27409. private _updateMatrix3x3ForUniform;
  27410. private _updateMatrix3x3ForEffect;
  27411. private _updateMatrix2x2ForEffect;
  27412. private _updateMatrix2x2ForUniform;
  27413. private _updateFloatForEffect;
  27414. private _updateFloatForUniform;
  27415. private _updateFloat2ForEffect;
  27416. private _updateFloat2ForUniform;
  27417. private _updateFloat3ForEffect;
  27418. private _updateFloat3ForUniform;
  27419. private _updateFloat4ForEffect;
  27420. private _updateFloat4ForUniform;
  27421. private _updateMatrixForEffect;
  27422. private _updateMatrixForUniform;
  27423. private _updateVector3ForEffect;
  27424. private _updateVector3ForUniform;
  27425. private _updateVector4ForEffect;
  27426. private _updateVector4ForUniform;
  27427. private _updateColor3ForEffect;
  27428. private _updateColor3ForUniform;
  27429. private _updateColor4ForEffect;
  27430. private _updateColor4ForUniform;
  27431. /**
  27432. * Sets a sampler uniform on the effect.
  27433. * @param name Define the name of the sampler.
  27434. * @param texture Define the texture to set in the sampler
  27435. */
  27436. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27437. /**
  27438. * Directly updates the value of the uniform in the cache AND on the GPU.
  27439. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27440. * @param data Define the flattened data
  27441. */
  27442. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27443. /**
  27444. * Binds this uniform buffer to an effect.
  27445. * @param effect Define the effect to bind the buffer to
  27446. * @param name Name of the uniform block in the shader.
  27447. */
  27448. bindToEffect(effect: Effect, name: string): void;
  27449. /**
  27450. * Disposes the uniform buffer.
  27451. */
  27452. dispose(): void;
  27453. }
  27454. }
  27455. declare module "babylonjs/Audio/analyser" {
  27456. import { Scene } from "babylonjs/scene";
  27457. /**
  27458. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27460. */
  27461. export class Analyser {
  27462. /**
  27463. * Gets or sets the smoothing
  27464. * @ignorenaming
  27465. */
  27466. SMOOTHING: number;
  27467. /**
  27468. * Gets or sets the FFT table size
  27469. * @ignorenaming
  27470. */
  27471. FFT_SIZE: number;
  27472. /**
  27473. * Gets or sets the bar graph amplitude
  27474. * @ignorenaming
  27475. */
  27476. BARGRAPHAMPLITUDE: number;
  27477. /**
  27478. * Gets or sets the position of the debug canvas
  27479. * @ignorenaming
  27480. */
  27481. DEBUGCANVASPOS: {
  27482. x: number;
  27483. y: number;
  27484. };
  27485. /**
  27486. * Gets or sets the debug canvas size
  27487. * @ignorenaming
  27488. */
  27489. DEBUGCANVASSIZE: {
  27490. width: number;
  27491. height: number;
  27492. };
  27493. private _byteFreqs;
  27494. private _byteTime;
  27495. private _floatFreqs;
  27496. private _webAudioAnalyser;
  27497. private _debugCanvas;
  27498. private _debugCanvasContext;
  27499. private _scene;
  27500. private _registerFunc;
  27501. private _audioEngine;
  27502. /**
  27503. * Creates a new analyser
  27504. * @param scene defines hosting scene
  27505. */
  27506. constructor(scene: Scene);
  27507. /**
  27508. * Get the number of data values you will have to play with for the visualization
  27509. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27510. * @returns a number
  27511. */
  27512. getFrequencyBinCount(): number;
  27513. /**
  27514. * Gets the current frequency data as a byte array
  27515. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27516. * @returns a Uint8Array
  27517. */
  27518. getByteFrequencyData(): Uint8Array;
  27519. /**
  27520. * Gets the current waveform as a byte array
  27521. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27522. * @returns a Uint8Array
  27523. */
  27524. getByteTimeDomainData(): Uint8Array;
  27525. /**
  27526. * Gets the current frequency data as a float array
  27527. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27528. * @returns a Float32Array
  27529. */
  27530. getFloatFrequencyData(): Float32Array;
  27531. /**
  27532. * Renders the debug canvas
  27533. */
  27534. drawDebugCanvas(): void;
  27535. /**
  27536. * Stops rendering the debug canvas and removes it
  27537. */
  27538. stopDebugCanvas(): void;
  27539. /**
  27540. * Connects two audio nodes
  27541. * @param inputAudioNode defines first node to connect
  27542. * @param outputAudioNode defines second node to connect
  27543. */
  27544. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27545. /**
  27546. * Releases all associated resources
  27547. */
  27548. dispose(): void;
  27549. }
  27550. }
  27551. declare module "babylonjs/Audio/audioEngine" {
  27552. import { IDisposable } from "babylonjs/scene";
  27553. import { Analyser } from "babylonjs/Audio/analyser";
  27554. import { Nullable } from "babylonjs/types";
  27555. import { Observable } from "babylonjs/Misc/observable";
  27556. /**
  27557. * This represents an audio engine and it is responsible
  27558. * to play, synchronize and analyse sounds throughout the application.
  27559. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27560. */
  27561. export interface IAudioEngine extends IDisposable {
  27562. /**
  27563. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27564. */
  27565. readonly canUseWebAudio: boolean;
  27566. /**
  27567. * Gets the current AudioContext if available.
  27568. */
  27569. readonly audioContext: Nullable<AudioContext>;
  27570. /**
  27571. * The master gain node defines the global audio volume of your audio engine.
  27572. */
  27573. readonly masterGain: GainNode;
  27574. /**
  27575. * Gets whether or not mp3 are supported by your browser.
  27576. */
  27577. readonly isMP3supported: boolean;
  27578. /**
  27579. * Gets whether or not ogg are supported by your browser.
  27580. */
  27581. readonly isOGGsupported: boolean;
  27582. /**
  27583. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27584. * @ignoreNaming
  27585. */
  27586. WarnedWebAudioUnsupported: boolean;
  27587. /**
  27588. * Defines if the audio engine relies on a custom unlocked button.
  27589. * In this case, the embedded button will not be displayed.
  27590. */
  27591. useCustomUnlockedButton: boolean;
  27592. /**
  27593. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27594. */
  27595. readonly unlocked: boolean;
  27596. /**
  27597. * Event raised when audio has been unlocked on the browser.
  27598. */
  27599. onAudioUnlockedObservable: Observable<AudioEngine>;
  27600. /**
  27601. * Event raised when audio has been locked on the browser.
  27602. */
  27603. onAudioLockedObservable: Observable<AudioEngine>;
  27604. /**
  27605. * Flags the audio engine in Locked state.
  27606. * This happens due to new browser policies preventing audio to autoplay.
  27607. */
  27608. lock(): void;
  27609. /**
  27610. * Unlocks the audio engine once a user action has been done on the dom.
  27611. * This is helpful to resume play once browser policies have been satisfied.
  27612. */
  27613. unlock(): void;
  27614. }
  27615. /**
  27616. * This represents the default audio engine used in babylon.
  27617. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27619. */
  27620. export class AudioEngine implements IAudioEngine {
  27621. private _audioContext;
  27622. private _audioContextInitialized;
  27623. private _muteButton;
  27624. private _hostElement;
  27625. /**
  27626. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27627. */
  27628. canUseWebAudio: boolean;
  27629. /**
  27630. * The master gain node defines the global audio volume of your audio engine.
  27631. */
  27632. masterGain: GainNode;
  27633. /**
  27634. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27635. * @ignoreNaming
  27636. */
  27637. WarnedWebAudioUnsupported: boolean;
  27638. /**
  27639. * Gets whether or not mp3 are supported by your browser.
  27640. */
  27641. isMP3supported: boolean;
  27642. /**
  27643. * Gets whether or not ogg are supported by your browser.
  27644. */
  27645. isOGGsupported: boolean;
  27646. /**
  27647. * Gets whether audio has been unlocked on the device.
  27648. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27649. * a user interaction has happened.
  27650. */
  27651. unlocked: boolean;
  27652. /**
  27653. * Defines if the audio engine relies on a custom unlocked button.
  27654. * In this case, the embedded button will not be displayed.
  27655. */
  27656. useCustomUnlockedButton: boolean;
  27657. /**
  27658. * Event raised when audio has been unlocked on the browser.
  27659. */
  27660. onAudioUnlockedObservable: Observable<AudioEngine>;
  27661. /**
  27662. * Event raised when audio has been locked on the browser.
  27663. */
  27664. onAudioLockedObservable: Observable<AudioEngine>;
  27665. /**
  27666. * Gets the current AudioContext if available.
  27667. */
  27668. readonly audioContext: Nullable<AudioContext>;
  27669. private _connectedAnalyser;
  27670. /**
  27671. * Instantiates a new audio engine.
  27672. *
  27673. * There should be only one per page as some browsers restrict the number
  27674. * of audio contexts you can create.
  27675. * @param hostElement defines the host element where to display the mute icon if necessary
  27676. */
  27677. constructor(hostElement?: Nullable<HTMLElement>);
  27678. /**
  27679. * Flags the audio engine in Locked state.
  27680. * This happens due to new browser policies preventing audio to autoplay.
  27681. */
  27682. lock(): void;
  27683. /**
  27684. * Unlocks the audio engine once a user action has been done on the dom.
  27685. * This is helpful to resume play once browser policies have been satisfied.
  27686. */
  27687. unlock(): void;
  27688. private _resumeAudioContext;
  27689. private _initializeAudioContext;
  27690. private _tryToRun;
  27691. private _triggerRunningState;
  27692. private _triggerSuspendedState;
  27693. private _displayMuteButton;
  27694. private _moveButtonToTopLeft;
  27695. private _onResize;
  27696. private _hideMuteButton;
  27697. /**
  27698. * Destroy and release the resources associated with the audio ccontext.
  27699. */
  27700. dispose(): void;
  27701. /**
  27702. * Gets the global volume sets on the master gain.
  27703. * @returns the global volume if set or -1 otherwise
  27704. */
  27705. getGlobalVolume(): number;
  27706. /**
  27707. * Sets the global volume of your experience (sets on the master gain).
  27708. * @param newVolume Defines the new global volume of the application
  27709. */
  27710. setGlobalVolume(newVolume: number): void;
  27711. /**
  27712. * Connect the audio engine to an audio analyser allowing some amazing
  27713. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27714. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27715. * @param analyser The analyser to connect to the engine
  27716. */
  27717. connectToAnalyser(analyser: Analyser): void;
  27718. }
  27719. }
  27720. declare module "babylonjs/Loading/loadingScreen" {
  27721. /**
  27722. * Interface used to present a loading screen while loading a scene
  27723. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27724. */
  27725. export interface ILoadingScreen {
  27726. /**
  27727. * Function called to display the loading screen
  27728. */
  27729. displayLoadingUI: () => void;
  27730. /**
  27731. * Function called to hide the loading screen
  27732. */
  27733. hideLoadingUI: () => void;
  27734. /**
  27735. * Gets or sets the color to use for the background
  27736. */
  27737. loadingUIBackgroundColor: string;
  27738. /**
  27739. * Gets or sets the text to display while loading
  27740. */
  27741. loadingUIText: string;
  27742. }
  27743. /**
  27744. * Class used for the default loading screen
  27745. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27746. */
  27747. export class DefaultLoadingScreen implements ILoadingScreen {
  27748. private _renderingCanvas;
  27749. private _loadingText;
  27750. private _loadingDivBackgroundColor;
  27751. private _loadingDiv;
  27752. private _loadingTextDiv;
  27753. /** Gets or sets the logo url to use for the default loading screen */
  27754. static DefaultLogoUrl: string;
  27755. /** Gets or sets the spinner url to use for the default loading screen */
  27756. static DefaultSpinnerUrl: string;
  27757. /**
  27758. * Creates a new default loading screen
  27759. * @param _renderingCanvas defines the canvas used to render the scene
  27760. * @param _loadingText defines the default text to display
  27761. * @param _loadingDivBackgroundColor defines the default background color
  27762. */
  27763. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27764. /**
  27765. * Function called to display the loading screen
  27766. */
  27767. displayLoadingUI(): void;
  27768. /**
  27769. * Function called to hide the loading screen
  27770. */
  27771. hideLoadingUI(): void;
  27772. /**
  27773. * Gets or sets the text to display while loading
  27774. */
  27775. loadingUIText: string;
  27776. /**
  27777. * Gets or sets the color to use for the background
  27778. */
  27779. loadingUIBackgroundColor: string;
  27780. private _resizeLoadingUI;
  27781. }
  27782. }
  27783. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27784. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27785. import { Engine } from "babylonjs/Engines/engine";
  27786. import { Nullable } from "babylonjs/types";
  27787. /** @hidden */
  27788. export class WebGLPipelineContext implements IPipelineContext {
  27789. engine: Engine;
  27790. program: Nullable<WebGLProgram>;
  27791. context?: WebGLRenderingContext;
  27792. vertexShader?: WebGLShader;
  27793. fragmentShader?: WebGLShader;
  27794. isParallelCompiled: boolean;
  27795. onCompiled?: () => void;
  27796. transformFeedback?: WebGLTransformFeedback | null;
  27797. readonly isAsync: boolean;
  27798. readonly isReady: boolean;
  27799. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27800. }
  27801. }
  27802. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27803. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27804. /** @hidden */
  27805. export class WebGLDataBuffer extends DataBuffer {
  27806. private _buffer;
  27807. constructor(resource: WebGLBuffer);
  27808. readonly underlyingResource: any;
  27809. }
  27810. }
  27811. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  27812. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27813. /** @hidden */
  27814. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27815. attributeProcessor(attribute: string): string;
  27816. varyingProcessor(varying: string, isFragment: boolean): string;
  27817. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27818. }
  27819. }
  27820. declare module "babylonjs/Materials/Textures/videoTexture" {
  27821. import { Observable } from "babylonjs/Misc/observable";
  27822. import { Nullable } from "babylonjs/types";
  27823. import { Scene } from "babylonjs/scene";
  27824. import { Texture } from "babylonjs/Materials/Textures/texture";
  27825. /**
  27826. * Settings for finer control over video usage
  27827. */
  27828. export interface VideoTextureSettings {
  27829. /**
  27830. * Applies `autoplay` to video, if specified
  27831. */
  27832. autoPlay?: boolean;
  27833. /**
  27834. * Applies `loop` to video, if specified
  27835. */
  27836. loop?: boolean;
  27837. /**
  27838. * Automatically updates internal texture from video at every frame in the render loop
  27839. */
  27840. autoUpdateTexture: boolean;
  27841. /**
  27842. * Image src displayed during the video loading or until the user interacts with the video.
  27843. */
  27844. poster?: string;
  27845. }
  27846. /**
  27847. * If you want to display a video in your scene, this is the special texture for that.
  27848. * This special texture works similar to other textures, with the exception of a few parameters.
  27849. * @see https://doc.babylonjs.com/how_to/video_texture
  27850. */
  27851. export class VideoTexture extends Texture {
  27852. /**
  27853. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27854. */
  27855. readonly autoUpdateTexture: boolean;
  27856. /**
  27857. * The video instance used by the texture internally
  27858. */
  27859. readonly video: HTMLVideoElement;
  27860. private _onUserActionRequestedObservable;
  27861. /**
  27862. * Event triggerd when a dom action is required by the user to play the video.
  27863. * This happens due to recent changes in browser policies preventing video to auto start.
  27864. */
  27865. readonly onUserActionRequestedObservable: Observable<Texture>;
  27866. private _generateMipMaps;
  27867. private _engine;
  27868. private _stillImageCaptured;
  27869. private _displayingPosterTexture;
  27870. private _settings;
  27871. private _createInternalTextureOnEvent;
  27872. /**
  27873. * Creates a video texture.
  27874. * If you want to display a video in your scene, this is the special texture for that.
  27875. * This special texture works similar to other textures, with the exception of a few parameters.
  27876. * @see https://doc.babylonjs.com/how_to/video_texture
  27877. * @param name optional name, will detect from video source, if not defined
  27878. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27879. * @param scene is obviously the current scene.
  27880. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27881. * @param invertY is false by default but can be used to invert video on Y axis
  27882. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27883. * @param settings allows finer control over video usage
  27884. */
  27885. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27886. private _getName;
  27887. private _getVideo;
  27888. private _createInternalTexture;
  27889. private reset;
  27890. /**
  27891. * @hidden Internal method to initiate `update`.
  27892. */
  27893. _rebuild(): void;
  27894. /**
  27895. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27896. */
  27897. update(): void;
  27898. /**
  27899. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27900. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27901. */
  27902. updateTexture(isVisible: boolean): void;
  27903. protected _updateInternalTexture: () => void;
  27904. /**
  27905. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27906. * @param url New url.
  27907. */
  27908. updateURL(url: string): void;
  27909. /**
  27910. * Dispose the texture and release its associated resources.
  27911. */
  27912. dispose(): void;
  27913. /**
  27914. * Creates a video texture straight from a stream.
  27915. * @param scene Define the scene the texture should be created in
  27916. * @param stream Define the stream the texture should be created from
  27917. * @returns The created video texture as a promise
  27918. */
  27919. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27920. /**
  27921. * Creates a video texture straight from your WebCam video feed.
  27922. * @param scene Define the scene the texture should be created in
  27923. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27924. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27925. * @returns The created video texture as a promise
  27926. */
  27927. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27928. minWidth: number;
  27929. maxWidth: number;
  27930. minHeight: number;
  27931. maxHeight: number;
  27932. deviceId: string;
  27933. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27934. /**
  27935. * Creates a video texture straight from your WebCam video feed.
  27936. * @param scene Define the scene the texture should be created in
  27937. * @param onReady Define a callback to triggered once the texture will be ready
  27938. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27939. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27940. */
  27941. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27942. minWidth: number;
  27943. maxWidth: number;
  27944. minHeight: number;
  27945. maxHeight: number;
  27946. deviceId: string;
  27947. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27948. }
  27949. }
  27950. declare module "babylonjs/Engines/engine" {
  27951. import { Observable } from "babylonjs/Misc/observable";
  27952. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27953. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27954. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27955. import { Camera } from "babylonjs/Cameras/camera";
  27956. import { Scene } from "babylonjs/scene";
  27957. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27958. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27959. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27960. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27961. import { Material } from "babylonjs/Materials/material";
  27962. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27963. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27964. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27965. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27966. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27967. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27968. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27969. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27970. import { WebRequest } from "babylonjs/Misc/webRequest";
  27971. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27972. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27973. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27974. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27975. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27976. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27977. /**
  27978. * Interface for attribute information associated with buffer instanciation
  27979. */
  27980. export class InstancingAttributeInfo {
  27981. /**
  27982. * Index/offset of the attribute in the vertex shader
  27983. */
  27984. index: number;
  27985. /**
  27986. * size of the attribute, 1, 2, 3 or 4
  27987. */
  27988. attributeSize: number;
  27989. /**
  27990. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27991. * default is FLOAT
  27992. */
  27993. attribyteType: number;
  27994. /**
  27995. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27996. */
  27997. normalized: boolean;
  27998. /**
  27999. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28000. */
  28001. offset: number;
  28002. /**
  28003. * Name of the GLSL attribute, for debugging purpose only
  28004. */
  28005. attributeName: string;
  28006. }
  28007. /**
  28008. * Define options used to create a depth texture
  28009. */
  28010. export class DepthTextureCreationOptions {
  28011. /** Specifies whether or not a stencil should be allocated in the texture */
  28012. generateStencil?: boolean;
  28013. /** Specifies whether or not bilinear filtering is enable on the texture */
  28014. bilinearFiltering?: boolean;
  28015. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  28016. comparisonFunction?: number;
  28017. /** Specifies if the created texture is a cube texture */
  28018. isCube?: boolean;
  28019. }
  28020. /**
  28021. * Class used to describe the capabilities of the engine relatively to the current browser
  28022. */
  28023. export class EngineCapabilities {
  28024. /** Maximum textures units per fragment shader */
  28025. maxTexturesImageUnits: number;
  28026. /** Maximum texture units per vertex shader */
  28027. maxVertexTextureImageUnits: number;
  28028. /** Maximum textures units in the entire pipeline */
  28029. maxCombinedTexturesImageUnits: number;
  28030. /** Maximum texture size */
  28031. maxTextureSize: number;
  28032. /** Maximum cube texture size */
  28033. maxCubemapTextureSize: number;
  28034. /** Maximum render texture size */
  28035. maxRenderTextureSize: number;
  28036. /** Maximum number of vertex attributes */
  28037. maxVertexAttribs: number;
  28038. /** Maximum number of varyings */
  28039. maxVaryingVectors: number;
  28040. /** Maximum number of uniforms per vertex shader */
  28041. maxVertexUniformVectors: number;
  28042. /** Maximum number of uniforms per fragment shader */
  28043. maxFragmentUniformVectors: number;
  28044. /** Defines if standard derivates (dx/dy) are supported */
  28045. standardDerivatives: boolean;
  28046. /** Defines if s3tc texture compression is supported */
  28047. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28048. /** Defines if pvrtc texture compression is supported */
  28049. pvrtc: any;
  28050. /** Defines if etc1 texture compression is supported */
  28051. etc1: any;
  28052. /** Defines if etc2 texture compression is supported */
  28053. etc2: any;
  28054. /** Defines if astc texture compression is supported */
  28055. astc: any;
  28056. /** Defines if float textures are supported */
  28057. textureFloat: boolean;
  28058. /** Defines if vertex array objects are supported */
  28059. vertexArrayObject: boolean;
  28060. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28061. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28062. /** Gets the maximum level of anisotropy supported */
  28063. maxAnisotropy: number;
  28064. /** Defines if instancing is supported */
  28065. instancedArrays: boolean;
  28066. /** Defines if 32 bits indices are supported */
  28067. uintIndices: boolean;
  28068. /** Defines if high precision shaders are supported */
  28069. highPrecisionShaderSupported: boolean;
  28070. /** Defines if depth reading in the fragment shader is supported */
  28071. fragmentDepthSupported: boolean;
  28072. /** Defines if float texture linear filtering is supported*/
  28073. textureFloatLinearFiltering: boolean;
  28074. /** Defines if rendering to float textures is supported */
  28075. textureFloatRender: boolean;
  28076. /** Defines if half float textures are supported*/
  28077. textureHalfFloat: boolean;
  28078. /** Defines if half float texture linear filtering is supported*/
  28079. textureHalfFloatLinearFiltering: boolean;
  28080. /** Defines if rendering to half float textures is supported */
  28081. textureHalfFloatRender: boolean;
  28082. /** Defines if textureLOD shader command is supported */
  28083. textureLOD: boolean;
  28084. /** Defines if draw buffers extension is supported */
  28085. drawBuffersExtension: boolean;
  28086. /** Defines if depth textures are supported */
  28087. depthTextureExtension: boolean;
  28088. /** Defines if float color buffer are supported */
  28089. colorBufferFloat: boolean;
  28090. /** Gets disjoint timer query extension (null if not supported) */
  28091. timerQuery: EXT_disjoint_timer_query;
  28092. /** Defines if timestamp can be used with timer query */
  28093. canUseTimestampForTimerQuery: boolean;
  28094. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28095. multiview: any;
  28096. /** Function used to let the system compiles shaders in background */
  28097. parallelShaderCompile: {
  28098. COMPLETION_STATUS_KHR: number;
  28099. };
  28100. }
  28101. /** Interface defining initialization parameters for Engine class */
  28102. export interface EngineOptions extends WebGLContextAttributes {
  28103. /**
  28104. * Defines if the engine should no exceed a specified device ratio
  28105. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28106. */
  28107. limitDeviceRatio?: number;
  28108. /**
  28109. * Defines if webvr should be enabled automatically
  28110. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28111. */
  28112. autoEnableWebVR?: boolean;
  28113. /**
  28114. * Defines if webgl2 should be turned off even if supported
  28115. * @see http://doc.babylonjs.com/features/webgl2
  28116. */
  28117. disableWebGL2Support?: boolean;
  28118. /**
  28119. * Defines if webaudio should be initialized as well
  28120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28121. */
  28122. audioEngine?: boolean;
  28123. /**
  28124. * Defines if animations should run using a deterministic lock step
  28125. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28126. */
  28127. deterministicLockstep?: boolean;
  28128. /** Defines the maximum steps to use with deterministic lock step mode */
  28129. lockstepMaxSteps?: number;
  28130. /**
  28131. * Defines that engine should ignore context lost events
  28132. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28133. */
  28134. doNotHandleContextLost?: boolean;
  28135. /**
  28136. * Defines that engine should ignore modifying touch action attribute and style
  28137. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28138. */
  28139. doNotHandleTouchAction?: boolean;
  28140. /**
  28141. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28142. */
  28143. useHighPrecisionFloats?: boolean;
  28144. }
  28145. /**
  28146. * Defines the interface used by display changed events
  28147. */
  28148. export interface IDisplayChangedEventArgs {
  28149. /** Gets the vrDisplay object (if any) */
  28150. vrDisplay: Nullable<any>;
  28151. /** Gets a boolean indicating if webVR is supported */
  28152. vrSupported: boolean;
  28153. }
  28154. /**
  28155. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28156. */
  28157. export class Engine {
  28158. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28159. static ExceptionList: ({
  28160. key: string;
  28161. capture: string;
  28162. captureConstraint: number;
  28163. targets: string[];
  28164. } | {
  28165. key: string;
  28166. capture: null;
  28167. captureConstraint: null;
  28168. targets: string[];
  28169. })[];
  28170. /** Gets the list of created engines */
  28171. static readonly Instances: Engine[];
  28172. /**
  28173. * Gets the latest created engine
  28174. */
  28175. static readonly LastCreatedEngine: Nullable<Engine>;
  28176. /**
  28177. * Gets the latest created scene
  28178. */
  28179. static readonly LastCreatedScene: Nullable<Scene>;
  28180. /**
  28181. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28182. * @param flag defines which part of the materials must be marked as dirty
  28183. * @param predicate defines a predicate used to filter which materials should be affected
  28184. */
  28185. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28186. /** @hidden */
  28187. static _TextureLoaders: IInternalTextureLoader[];
  28188. /** Defines that alpha blending is disabled */
  28189. static readonly ALPHA_DISABLE: number;
  28190. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28191. static readonly ALPHA_ADD: number;
  28192. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28193. static readonly ALPHA_COMBINE: number;
  28194. /** Defines that alpha blending to DEST - SRC * DEST */
  28195. static readonly ALPHA_SUBTRACT: number;
  28196. /** Defines that alpha blending to SRC * DEST */
  28197. static readonly ALPHA_MULTIPLY: number;
  28198. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28199. static readonly ALPHA_MAXIMIZED: number;
  28200. /** Defines that alpha blending to SRC + DEST */
  28201. static readonly ALPHA_ONEONE: number;
  28202. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28203. static readonly ALPHA_PREMULTIPLIED: number;
  28204. /**
  28205. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28206. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28207. */
  28208. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28209. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28210. static readonly ALPHA_INTERPOLATE: number;
  28211. /**
  28212. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28213. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28214. */
  28215. static readonly ALPHA_SCREENMODE: number;
  28216. /** Defines that the ressource is not delayed*/
  28217. static readonly DELAYLOADSTATE_NONE: number;
  28218. /** Defines that the ressource was successfully delay loaded */
  28219. static readonly DELAYLOADSTATE_LOADED: number;
  28220. /** Defines that the ressource is currently delay loading */
  28221. static readonly DELAYLOADSTATE_LOADING: number;
  28222. /** Defines that the ressource is delayed and has not started loading */
  28223. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28224. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28225. static readonly NEVER: number;
  28226. /** 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 */
  28227. static readonly ALWAYS: number;
  28228. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28229. static readonly LESS: number;
  28230. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28231. static readonly EQUAL: number;
  28232. /** 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 */
  28233. static readonly LEQUAL: number;
  28234. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28235. static readonly GREATER: number;
  28236. /** 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 */
  28237. static readonly GEQUAL: number;
  28238. /** 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 */
  28239. static readonly NOTEQUAL: number;
  28240. /** Passed to stencilOperation to specify that stencil value must be kept */
  28241. static readonly KEEP: number;
  28242. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28243. static readonly REPLACE: number;
  28244. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28245. static readonly INCR: number;
  28246. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28247. static readonly DECR: number;
  28248. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28249. static readonly INVERT: number;
  28250. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28251. static readonly INCR_WRAP: number;
  28252. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28253. static readonly DECR_WRAP: number;
  28254. /** Texture is not repeating outside of 0..1 UVs */
  28255. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28256. /** Texture is repeating outside of 0..1 UVs */
  28257. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28258. /** Texture is repeating and mirrored */
  28259. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28260. /** ALPHA */
  28261. static readonly TEXTUREFORMAT_ALPHA: number;
  28262. /** LUMINANCE */
  28263. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28264. /** LUMINANCE_ALPHA */
  28265. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28266. /** RGB */
  28267. static readonly TEXTUREFORMAT_RGB: number;
  28268. /** RGBA */
  28269. static readonly TEXTUREFORMAT_RGBA: number;
  28270. /** RED */
  28271. static readonly TEXTUREFORMAT_RED: number;
  28272. /** RED (2nd reference) */
  28273. static readonly TEXTUREFORMAT_R: number;
  28274. /** RG */
  28275. static readonly TEXTUREFORMAT_RG: number;
  28276. /** RED_INTEGER */
  28277. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28278. /** RED_INTEGER (2nd reference) */
  28279. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28280. /** RG_INTEGER */
  28281. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28282. /** RGB_INTEGER */
  28283. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28284. /** RGBA_INTEGER */
  28285. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28286. /** UNSIGNED_BYTE */
  28287. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28288. /** UNSIGNED_BYTE (2nd reference) */
  28289. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28290. /** FLOAT */
  28291. static readonly TEXTURETYPE_FLOAT: number;
  28292. /** HALF_FLOAT */
  28293. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28294. /** BYTE */
  28295. static readonly TEXTURETYPE_BYTE: number;
  28296. /** SHORT */
  28297. static readonly TEXTURETYPE_SHORT: number;
  28298. /** UNSIGNED_SHORT */
  28299. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28300. /** INT */
  28301. static readonly TEXTURETYPE_INT: number;
  28302. /** UNSIGNED_INT */
  28303. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28304. /** UNSIGNED_SHORT_4_4_4_4 */
  28305. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28306. /** UNSIGNED_SHORT_5_5_5_1 */
  28307. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28308. /** UNSIGNED_SHORT_5_6_5 */
  28309. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28310. /** UNSIGNED_INT_2_10_10_10_REV */
  28311. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28312. /** UNSIGNED_INT_24_8 */
  28313. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28314. /** UNSIGNED_INT_10F_11F_11F_REV */
  28315. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28316. /** UNSIGNED_INT_5_9_9_9_REV */
  28317. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28318. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28319. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28320. /** nearest is mag = nearest and min = nearest and mip = linear */
  28321. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28322. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28323. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28324. /** Trilinear is mag = linear and min = linear and mip = linear */
  28325. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28326. /** nearest is mag = nearest and min = nearest and mip = linear */
  28327. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28328. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28329. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28330. /** Trilinear is mag = linear and min = linear and mip = linear */
  28331. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28332. /** mag = nearest and min = nearest and mip = nearest */
  28333. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28334. /** mag = nearest and min = linear and mip = nearest */
  28335. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28336. /** mag = nearest and min = linear and mip = linear */
  28337. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28338. /** mag = nearest and min = linear and mip = none */
  28339. static readonly TEXTURE_NEAREST_LINEAR: number;
  28340. /** mag = nearest and min = nearest and mip = none */
  28341. static readonly TEXTURE_NEAREST_NEAREST: number;
  28342. /** mag = linear and min = nearest and mip = nearest */
  28343. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28344. /** mag = linear and min = nearest and mip = linear */
  28345. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28346. /** mag = linear and min = linear and mip = none */
  28347. static readonly TEXTURE_LINEAR_LINEAR: number;
  28348. /** mag = linear and min = nearest and mip = none */
  28349. static readonly TEXTURE_LINEAR_NEAREST: number;
  28350. /** Explicit coordinates mode */
  28351. static readonly TEXTURE_EXPLICIT_MODE: number;
  28352. /** Spherical coordinates mode */
  28353. static readonly TEXTURE_SPHERICAL_MODE: number;
  28354. /** Planar coordinates mode */
  28355. static readonly TEXTURE_PLANAR_MODE: number;
  28356. /** Cubic coordinates mode */
  28357. static readonly TEXTURE_CUBIC_MODE: number;
  28358. /** Projection coordinates mode */
  28359. static readonly TEXTURE_PROJECTION_MODE: number;
  28360. /** Skybox coordinates mode */
  28361. static readonly TEXTURE_SKYBOX_MODE: number;
  28362. /** Inverse Cubic coordinates mode */
  28363. static readonly TEXTURE_INVCUBIC_MODE: number;
  28364. /** Equirectangular coordinates mode */
  28365. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28366. /** Equirectangular Fixed coordinates mode */
  28367. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28368. /** Equirectangular Fixed Mirrored coordinates mode */
  28369. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28370. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28371. static readonly SCALEMODE_FLOOR: number;
  28372. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28373. static readonly SCALEMODE_NEAREST: number;
  28374. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28375. static readonly SCALEMODE_CEILING: number;
  28376. /**
  28377. * Returns the current npm package of the sdk
  28378. */
  28379. static readonly NpmPackage: string;
  28380. /**
  28381. * Returns the current version of the framework
  28382. */
  28383. static readonly Version: string;
  28384. /**
  28385. * Returns a string describing the current engine
  28386. */
  28387. readonly description: string;
  28388. /**
  28389. * Gets or sets the epsilon value used by collision engine
  28390. */
  28391. static CollisionsEpsilon: number;
  28392. /**
  28393. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28394. */
  28395. static ShadersRepository: string;
  28396. /**
  28397. * Method called to create the default loading screen.
  28398. * This can be overriden in your own app.
  28399. * @param canvas The rendering canvas element
  28400. * @returns The loading screen
  28401. */
  28402. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28403. /**
  28404. * Method called to create the default rescale post process on each engine.
  28405. */
  28406. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28407. /** @hidden */
  28408. _shaderProcessor: IShaderProcessor;
  28409. /**
  28410. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28411. */
  28412. forcePOTTextures: boolean;
  28413. /**
  28414. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28415. */
  28416. isFullscreen: boolean;
  28417. /**
  28418. * Gets a boolean indicating if the pointer is currently locked
  28419. */
  28420. isPointerLock: boolean;
  28421. /**
  28422. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28423. */
  28424. cullBackFaces: boolean;
  28425. /**
  28426. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28427. */
  28428. renderEvenInBackground: boolean;
  28429. /**
  28430. * Gets or sets a boolean indicating that cache can be kept between frames
  28431. */
  28432. preventCacheWipeBetweenFrames: boolean;
  28433. /**
  28434. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28435. **/
  28436. enableOfflineSupport: boolean;
  28437. /**
  28438. * 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)
  28439. **/
  28440. disableManifestCheck: boolean;
  28441. /**
  28442. * Gets the list of created scenes
  28443. */
  28444. scenes: Scene[];
  28445. /**
  28446. * Event raised when a new scene is created
  28447. */
  28448. onNewSceneAddedObservable: Observable<Scene>;
  28449. /**
  28450. * Gets the list of created postprocesses
  28451. */
  28452. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28453. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28454. validateShaderPrograms: boolean;
  28455. /**
  28456. * Observable event triggered each time the rendering canvas is resized
  28457. */
  28458. onResizeObservable: Observable<Engine>;
  28459. /**
  28460. * Observable event triggered each time the canvas loses focus
  28461. */
  28462. onCanvasBlurObservable: Observable<Engine>;
  28463. /**
  28464. * Observable event triggered each time the canvas gains focus
  28465. */
  28466. onCanvasFocusObservable: Observable<Engine>;
  28467. /**
  28468. * Observable event triggered each time the canvas receives pointerout event
  28469. */
  28470. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28471. /**
  28472. * Observable event triggered before each texture is initialized
  28473. */
  28474. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28475. /**
  28476. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28477. */
  28478. disableUniformBuffers: boolean;
  28479. /** @hidden */
  28480. _uniformBuffers: UniformBuffer[];
  28481. /**
  28482. * Gets a boolean indicating that the engine supports uniform buffers
  28483. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28484. */
  28485. readonly supportsUniformBuffers: boolean;
  28486. /**
  28487. * Observable raised when the engine begins a new frame
  28488. */
  28489. onBeginFrameObservable: Observable<Engine>;
  28490. /**
  28491. * If set, will be used to request the next animation frame for the render loop
  28492. */
  28493. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28494. /**
  28495. * Observable raised when the engine ends the current frame
  28496. */
  28497. onEndFrameObservable: Observable<Engine>;
  28498. /**
  28499. * Observable raised when the engine is about to compile a shader
  28500. */
  28501. onBeforeShaderCompilationObservable: Observable<Engine>;
  28502. /**
  28503. * Observable raised when the engine has jsut compiled a shader
  28504. */
  28505. onAfterShaderCompilationObservable: Observable<Engine>;
  28506. /** @hidden */
  28507. _gl: WebGLRenderingContext;
  28508. private _renderingCanvas;
  28509. private _windowIsBackground;
  28510. private _webGLVersion;
  28511. protected _highPrecisionShadersAllowed: boolean;
  28512. /** @hidden */
  28513. readonly _shouldUseHighPrecisionShader: boolean;
  28514. /**
  28515. * Gets a boolean indicating that only power of 2 textures are supported
  28516. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28517. */
  28518. readonly needPOTTextures: boolean;
  28519. /** @hidden */
  28520. _badOS: boolean;
  28521. /** @hidden */
  28522. _badDesktopOS: boolean;
  28523. /**
  28524. * Gets the audio engine
  28525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28526. * @ignorenaming
  28527. */
  28528. static audioEngine: IAudioEngine;
  28529. /**
  28530. * Default AudioEngine factory responsible of creating the Audio Engine.
  28531. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28532. */
  28533. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28534. /**
  28535. * Default offline support factory responsible of creating a tool used to store data locally.
  28536. * By default, this will create a Database object if the workload has been embedded.
  28537. */
  28538. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28539. private _onFocus;
  28540. private _onBlur;
  28541. private _onCanvasPointerOut;
  28542. private _onCanvasBlur;
  28543. private _onCanvasFocus;
  28544. private _onFullscreenChange;
  28545. private _onPointerLockChange;
  28546. private _hardwareScalingLevel;
  28547. /** @hidden */
  28548. _caps: EngineCapabilities;
  28549. private _pointerLockRequested;
  28550. private _isStencilEnable;
  28551. private _colorWrite;
  28552. private _loadingScreen;
  28553. /** @hidden */
  28554. _drawCalls: PerfCounter;
  28555. private _glVersion;
  28556. private _glRenderer;
  28557. private _glVendor;
  28558. private _videoTextureSupported;
  28559. private _renderingQueueLaunched;
  28560. private _activeRenderLoops;
  28561. private _deterministicLockstep;
  28562. private _lockstepMaxSteps;
  28563. /**
  28564. * Observable signaled when a context lost event is raised
  28565. */
  28566. onContextLostObservable: Observable<Engine>;
  28567. /**
  28568. * Observable signaled when a context restored event is raised
  28569. */
  28570. onContextRestoredObservable: Observable<Engine>;
  28571. private _onContextLost;
  28572. private _onContextRestored;
  28573. private _contextWasLost;
  28574. /** @hidden */
  28575. _doNotHandleContextLost: boolean;
  28576. /**
  28577. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28578. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28579. */
  28580. doNotHandleContextLost: boolean;
  28581. private _performanceMonitor;
  28582. private _fps;
  28583. private _deltaTime;
  28584. /**
  28585. * Turn this value on if you want to pause FPS computation when in background
  28586. */
  28587. disablePerformanceMonitorInBackground: boolean;
  28588. /**
  28589. * Gets the performance monitor attached to this engine
  28590. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28591. */
  28592. readonly performanceMonitor: PerformanceMonitor;
  28593. /**
  28594. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28595. */
  28596. disableVertexArrayObjects: boolean;
  28597. /** @hidden */
  28598. protected _depthCullingState: _DepthCullingState;
  28599. /** @hidden */
  28600. protected _stencilState: _StencilState;
  28601. /** @hidden */
  28602. protected _alphaState: _AlphaState;
  28603. /** @hidden */
  28604. protected _alphaMode: number;
  28605. /** @hidden */
  28606. _internalTexturesCache: InternalTexture[];
  28607. /** @hidden */
  28608. protected _activeChannel: number;
  28609. private _currentTextureChannel;
  28610. /** @hidden */
  28611. protected _boundTexturesCache: {
  28612. [key: string]: Nullable<InternalTexture>;
  28613. };
  28614. /** @hidden */
  28615. protected _currentEffect: Nullable<Effect>;
  28616. /** @hidden */
  28617. protected _currentProgram: Nullable<WebGLProgram>;
  28618. private _compiledEffects;
  28619. private _vertexAttribArraysEnabled;
  28620. /** @hidden */
  28621. protected _cachedViewport: Nullable<Viewport>;
  28622. private _cachedVertexArrayObject;
  28623. /** @hidden */
  28624. protected _cachedVertexBuffers: any;
  28625. /** @hidden */
  28626. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28627. /** @hidden */
  28628. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28629. /** @hidden */
  28630. _currentRenderTarget: Nullable<InternalTexture>;
  28631. private _uintIndicesCurrentlySet;
  28632. private _currentBoundBuffer;
  28633. /** @hidden */
  28634. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28635. private _currentBufferPointers;
  28636. private _currentInstanceLocations;
  28637. private _currentInstanceBuffers;
  28638. private _textureUnits;
  28639. /** @hidden */
  28640. _workingCanvas: Nullable<HTMLCanvasElement>;
  28641. /** @hidden */
  28642. _workingContext: Nullable<CanvasRenderingContext2D>;
  28643. private _rescalePostProcess;
  28644. private _dummyFramebuffer;
  28645. private _externalData;
  28646. /** @hidden */
  28647. _bindedRenderFunction: any;
  28648. private _vaoRecordInProgress;
  28649. private _mustWipeVertexAttributes;
  28650. private _emptyTexture;
  28651. private _emptyCubeTexture;
  28652. private _emptyTexture3D;
  28653. /** @hidden */
  28654. _frameHandler: number;
  28655. private _nextFreeTextureSlots;
  28656. private _maxSimultaneousTextures;
  28657. private _activeRequests;
  28658. private _texturesSupported;
  28659. /** @hidden */
  28660. _textureFormatInUse: Nullable<string>;
  28661. /**
  28662. * Gets the list of texture formats supported
  28663. */
  28664. readonly texturesSupported: Array<string>;
  28665. /**
  28666. * Gets the list of texture formats in use
  28667. */
  28668. readonly textureFormatInUse: Nullable<string>;
  28669. /**
  28670. * Gets the current viewport
  28671. */
  28672. readonly currentViewport: Nullable<Viewport>;
  28673. /**
  28674. * Gets the default empty texture
  28675. */
  28676. readonly emptyTexture: InternalTexture;
  28677. /**
  28678. * Gets the default empty 3D texture
  28679. */
  28680. readonly emptyTexture3D: InternalTexture;
  28681. /**
  28682. * Gets the default empty cube texture
  28683. */
  28684. readonly emptyCubeTexture: InternalTexture;
  28685. /**
  28686. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28687. */
  28688. readonly premultipliedAlpha: boolean;
  28689. /**
  28690. * Creates a new engine
  28691. * @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
  28692. * @param antialias defines enable antialiasing (default: false)
  28693. * @param options defines further options to be sent to the getContext() function
  28694. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28695. */
  28696. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28697. /**
  28698. * Initializes a webVR display and starts listening to display change events
  28699. * The onVRDisplayChangedObservable will be notified upon these changes
  28700. * @returns The onVRDisplayChangedObservable
  28701. */
  28702. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28703. /** @hidden */
  28704. _prepareVRComponent(): void;
  28705. /** @hidden */
  28706. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28707. /** @hidden */
  28708. _submitVRFrame(): void;
  28709. /**
  28710. * Call this function to leave webVR mode
  28711. * Will do nothing if webVR is not supported or if there is no webVR device
  28712. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28713. */
  28714. disableVR(): void;
  28715. /**
  28716. * Gets a boolean indicating that the system is in VR mode and is presenting
  28717. * @returns true if VR mode is engaged
  28718. */
  28719. isVRPresenting(): boolean;
  28720. /** @hidden */
  28721. _requestVRFrame(): void;
  28722. private _disableTouchAction;
  28723. private _rebuildInternalTextures;
  28724. private _rebuildEffects;
  28725. /**
  28726. * Gets a boolean indicating if all created effects are ready
  28727. * @returns true if all effects are ready
  28728. */
  28729. areAllEffectsReady(): boolean;
  28730. private _rebuildBuffers;
  28731. private _initGLContext;
  28732. /**
  28733. * Gets version of the current webGL context
  28734. */
  28735. readonly webGLVersion: number;
  28736. /**
  28737. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28738. */
  28739. readonly isStencilEnable: boolean;
  28740. /** @hidden */
  28741. _prepareWorkingCanvas(): void;
  28742. /**
  28743. * Reset the texture cache to empty state
  28744. */
  28745. resetTextureCache(): void;
  28746. /**
  28747. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28748. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28749. * @returns true if engine is in deterministic lock step mode
  28750. */
  28751. isDeterministicLockStep(): boolean;
  28752. /**
  28753. * Gets the max steps when engine is running in deterministic lock step
  28754. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28755. * @returns the max steps
  28756. */
  28757. getLockstepMaxSteps(): number;
  28758. /**
  28759. * Gets an object containing information about the current webGL context
  28760. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28761. */
  28762. getGlInfo(): {
  28763. vendor: string;
  28764. renderer: string;
  28765. version: string;
  28766. };
  28767. /**
  28768. * Gets current aspect ratio
  28769. * @param camera defines the camera to use to get the aspect ratio
  28770. * @param useScreen defines if screen size must be used (or the current render target if any)
  28771. * @returns a number defining the aspect ratio
  28772. */
  28773. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28774. /**
  28775. * Gets current screen aspect ratio
  28776. * @returns a number defining the aspect ratio
  28777. */
  28778. getScreenAspectRatio(): number;
  28779. /**
  28780. * Gets the current render width
  28781. * @param useScreen defines if screen size must be used (or the current render target if any)
  28782. * @returns a number defining the current render width
  28783. */
  28784. getRenderWidth(useScreen?: boolean): number;
  28785. /**
  28786. * Gets the current render height
  28787. * @param useScreen defines if screen size must be used (or the current render target if any)
  28788. * @returns a number defining the current render height
  28789. */
  28790. getRenderHeight(useScreen?: boolean): number;
  28791. /**
  28792. * Gets the HTML canvas attached with the current webGL context
  28793. * @returns a HTML canvas
  28794. */
  28795. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28796. /**
  28797. * Gets the client rect of the HTML canvas attached with the current webGL context
  28798. * @returns a client rectanglee
  28799. */
  28800. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28801. /**
  28802. * Defines the hardware scaling level.
  28803. * By default the hardware scaling level is computed from the window device ratio.
  28804. * 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.
  28805. * @param level defines the level to use
  28806. */
  28807. setHardwareScalingLevel(level: number): void;
  28808. /**
  28809. * Gets the current hardware scaling level.
  28810. * By default the hardware scaling level is computed from the window device ratio.
  28811. * 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.
  28812. * @returns a number indicating the current hardware scaling level
  28813. */
  28814. getHardwareScalingLevel(): number;
  28815. /**
  28816. * Gets the list of loaded textures
  28817. * @returns an array containing all loaded textures
  28818. */
  28819. getLoadedTexturesCache(): InternalTexture[];
  28820. /**
  28821. * Gets the object containing all engine capabilities
  28822. * @returns the EngineCapabilities object
  28823. */
  28824. getCaps(): EngineCapabilities;
  28825. /**
  28826. * Gets the current depth function
  28827. * @returns a number defining the depth function
  28828. */
  28829. getDepthFunction(): Nullable<number>;
  28830. /**
  28831. * Sets the current depth function
  28832. * @param depthFunc defines the function to use
  28833. */
  28834. setDepthFunction(depthFunc: number): void;
  28835. /**
  28836. * Sets the current depth function to GREATER
  28837. */
  28838. setDepthFunctionToGreater(): void;
  28839. /**
  28840. * Sets the current depth function to GEQUAL
  28841. */
  28842. setDepthFunctionToGreaterOrEqual(): void;
  28843. /**
  28844. * Sets the current depth function to LESS
  28845. */
  28846. setDepthFunctionToLess(): void;
  28847. private _cachedStencilBuffer;
  28848. private _cachedStencilFunction;
  28849. private _cachedStencilMask;
  28850. private _cachedStencilOperationPass;
  28851. private _cachedStencilOperationFail;
  28852. private _cachedStencilOperationDepthFail;
  28853. private _cachedStencilReference;
  28854. /**
  28855. * Caches the the state of the stencil buffer
  28856. */
  28857. cacheStencilState(): void;
  28858. /**
  28859. * Restores the state of the stencil buffer
  28860. */
  28861. restoreStencilState(): void;
  28862. /**
  28863. * Sets the current depth function to LEQUAL
  28864. */
  28865. setDepthFunctionToLessOrEqual(): void;
  28866. /**
  28867. * Gets a boolean indicating if stencil buffer is enabled
  28868. * @returns the current stencil buffer state
  28869. */
  28870. getStencilBuffer(): boolean;
  28871. /**
  28872. * Enable or disable the stencil buffer
  28873. * @param enable defines if the stencil buffer must be enabled or disabled
  28874. */
  28875. setStencilBuffer(enable: boolean): void;
  28876. /**
  28877. * Gets the current stencil mask
  28878. * @returns a number defining the new stencil mask to use
  28879. */
  28880. getStencilMask(): number;
  28881. /**
  28882. * Sets the current stencil mask
  28883. * @param mask defines the new stencil mask to use
  28884. */
  28885. setStencilMask(mask: number): void;
  28886. /**
  28887. * Gets the current stencil function
  28888. * @returns a number defining the stencil function to use
  28889. */
  28890. getStencilFunction(): number;
  28891. /**
  28892. * Gets the current stencil reference value
  28893. * @returns a number defining the stencil reference value to use
  28894. */
  28895. getStencilFunctionReference(): number;
  28896. /**
  28897. * Gets the current stencil mask
  28898. * @returns a number defining the stencil mask to use
  28899. */
  28900. getStencilFunctionMask(): number;
  28901. /**
  28902. * Sets the current stencil function
  28903. * @param stencilFunc defines the new stencil function to use
  28904. */
  28905. setStencilFunction(stencilFunc: number): void;
  28906. /**
  28907. * Sets the current stencil reference
  28908. * @param reference defines the new stencil reference to use
  28909. */
  28910. setStencilFunctionReference(reference: number): void;
  28911. /**
  28912. * Sets the current stencil mask
  28913. * @param mask defines the new stencil mask to use
  28914. */
  28915. setStencilFunctionMask(mask: number): void;
  28916. /**
  28917. * Gets the current stencil operation when stencil fails
  28918. * @returns a number defining stencil operation to use when stencil fails
  28919. */
  28920. getStencilOperationFail(): number;
  28921. /**
  28922. * Gets the current stencil operation when depth fails
  28923. * @returns a number defining stencil operation to use when depth fails
  28924. */
  28925. getStencilOperationDepthFail(): number;
  28926. /**
  28927. * Gets the current stencil operation when stencil passes
  28928. * @returns a number defining stencil operation to use when stencil passes
  28929. */
  28930. getStencilOperationPass(): number;
  28931. /**
  28932. * Sets the stencil operation to use when stencil fails
  28933. * @param operation defines the stencil operation to use when stencil fails
  28934. */
  28935. setStencilOperationFail(operation: number): void;
  28936. /**
  28937. * Sets the stencil operation to use when depth fails
  28938. * @param operation defines the stencil operation to use when depth fails
  28939. */
  28940. setStencilOperationDepthFail(operation: number): void;
  28941. /**
  28942. * Sets the stencil operation to use when stencil passes
  28943. * @param operation defines the stencil operation to use when stencil passes
  28944. */
  28945. setStencilOperationPass(operation: number): void;
  28946. /**
  28947. * Sets a boolean indicating if the dithering state is enabled or disabled
  28948. * @param value defines the dithering state
  28949. */
  28950. setDitheringState(value: boolean): void;
  28951. /**
  28952. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28953. * @param value defines the rasterizer state
  28954. */
  28955. setRasterizerState(value: boolean): void;
  28956. /**
  28957. * stop executing a render loop function and remove it from the execution array
  28958. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28959. */
  28960. stopRenderLoop(renderFunction?: () => void): void;
  28961. /** @hidden */
  28962. _renderLoop(): void;
  28963. /**
  28964. * Register and execute a render loop. The engine can have more than one render function
  28965. * @param renderFunction defines the function to continuously execute
  28966. */
  28967. runRenderLoop(renderFunction: () => void): void;
  28968. /**
  28969. * Toggle full screen mode
  28970. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28971. */
  28972. switchFullscreen(requestPointerLock: boolean): void;
  28973. /**
  28974. * Enters full screen mode
  28975. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28976. */
  28977. enterFullscreen(requestPointerLock: boolean): void;
  28978. /**
  28979. * Exits full screen mode
  28980. */
  28981. exitFullscreen(): void;
  28982. /**
  28983. * Enters Pointerlock mode
  28984. */
  28985. enterPointerlock(): void;
  28986. /**
  28987. * Exits Pointerlock mode
  28988. */
  28989. exitPointerlock(): void;
  28990. /**
  28991. * Clear the current render buffer or the current render target (if any is set up)
  28992. * @param color defines the color to use
  28993. * @param backBuffer defines if the back buffer must be cleared
  28994. * @param depth defines if the depth buffer must be cleared
  28995. * @param stencil defines if the stencil buffer must be cleared
  28996. */
  28997. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28998. /**
  28999. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29000. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29001. * @param y defines the y-coordinate of the corner of the clear rectangle
  29002. * @param width defines the width of the clear rectangle
  29003. * @param height defines the height of the clear rectangle
  29004. * @param clearColor defines the clear color
  29005. */
  29006. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  29007. /**
  29008. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29009. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29010. * @param y defines the y-coordinate of the corner of the clear rectangle
  29011. * @param width defines the width of the clear rectangle
  29012. * @param height defines the height of the clear rectangle
  29013. */
  29014. enableScissor(x: number, y: number, width: number, height: number): void;
  29015. /**
  29016. * Disable previously set scissor test rectangle
  29017. */
  29018. disableScissor(): void;
  29019. private _viewportCached;
  29020. /** @hidden */
  29021. _viewport(x: number, y: number, width: number, height: number): void;
  29022. /**
  29023. * Set the WebGL's viewport
  29024. * @param viewport defines the viewport element to be used
  29025. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29026. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29027. */
  29028. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  29029. /**
  29030. * Directly set the WebGL Viewport
  29031. * @param x defines the x coordinate of the viewport (in screen space)
  29032. * @param y defines the y coordinate of the viewport (in screen space)
  29033. * @param width defines the width of the viewport (in screen space)
  29034. * @param height defines the height of the viewport (in screen space)
  29035. * @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
  29036. */
  29037. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  29038. /**
  29039. * Begin a new frame
  29040. */
  29041. beginFrame(): void;
  29042. /**
  29043. * Enf the current frame
  29044. */
  29045. endFrame(): void;
  29046. /**
  29047. * Resize the view according to the canvas' size
  29048. */
  29049. resize(): void;
  29050. /**
  29051. * Force a specific size of the canvas
  29052. * @param width defines the new canvas' width
  29053. * @param height defines the new canvas' height
  29054. */
  29055. setSize(width: number, height: number): void;
  29056. /**
  29057. * Binds the frame buffer to the specified texture.
  29058. * @param texture The texture to render to or null for the default canvas
  29059. * @param faceIndex The face of the texture to render to in case of cube texture
  29060. * @param requiredWidth The width of the target to render to
  29061. * @param requiredHeight The height of the target to render to
  29062. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29063. * @param depthStencilTexture The depth stencil texture to use to render
  29064. * @param lodLevel defines le lod level to bind to the frame buffer
  29065. */
  29066. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29067. /** @hidden */
  29068. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29069. /**
  29070. * Unbind the current render target texture from the webGL context
  29071. * @param texture defines the render target texture to unbind
  29072. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29073. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29074. */
  29075. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29076. /**
  29077. * Force the mipmap generation for the given render target texture
  29078. * @param texture defines the render target texture to use
  29079. */
  29080. generateMipMapsForCubemap(texture: InternalTexture): void;
  29081. /**
  29082. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29083. */
  29084. flushFramebuffer(): void;
  29085. /**
  29086. * Unbind the current render target and bind the default framebuffer
  29087. */
  29088. restoreDefaultFramebuffer(): void;
  29089. /**
  29090. * Create an uniform buffer
  29091. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29092. * @param elements defines the content of the uniform buffer
  29093. * @returns the webGL uniform buffer
  29094. */
  29095. createUniformBuffer(elements: FloatArray): DataBuffer;
  29096. /**
  29097. * Create a dynamic uniform buffer
  29098. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29099. * @param elements defines the content of the uniform buffer
  29100. * @returns the webGL uniform buffer
  29101. */
  29102. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29103. /**
  29104. * Update an existing uniform buffer
  29105. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29106. * @param uniformBuffer defines the target uniform buffer
  29107. * @param elements defines the content to update
  29108. * @param offset defines the offset in the uniform buffer where update should start
  29109. * @param count defines the size of the data to update
  29110. */
  29111. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29112. private _resetVertexBufferBinding;
  29113. /**
  29114. * Creates a vertex buffer
  29115. * @param data the data for the vertex buffer
  29116. * @returns the new WebGL static buffer
  29117. */
  29118. createVertexBuffer(data: DataArray): DataBuffer;
  29119. /**
  29120. * Creates a dynamic vertex buffer
  29121. * @param data the data for the dynamic vertex buffer
  29122. * @returns the new WebGL dynamic buffer
  29123. */
  29124. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29125. /**
  29126. * Update a dynamic index buffer
  29127. * @param indexBuffer defines the target index buffer
  29128. * @param indices defines the data to update
  29129. * @param offset defines the offset in the target index buffer where update should start
  29130. */
  29131. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29132. /**
  29133. * Updates a dynamic vertex buffer.
  29134. * @param vertexBuffer the vertex buffer to update
  29135. * @param data the data used to update the vertex buffer
  29136. * @param byteOffset the byte offset of the data
  29137. * @param byteLength the byte length of the data
  29138. */
  29139. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29140. private _resetIndexBufferBinding;
  29141. /**
  29142. * Creates a new index buffer
  29143. * @param indices defines the content of the index buffer
  29144. * @param updatable defines if the index buffer must be updatable
  29145. * @returns a new webGL buffer
  29146. */
  29147. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29148. /**
  29149. * Bind a webGL buffer to the webGL context
  29150. * @param buffer defines the buffer to bind
  29151. */
  29152. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29153. /**
  29154. * Bind an uniform buffer to the current webGL context
  29155. * @param buffer defines the buffer to bind
  29156. */
  29157. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29158. /**
  29159. * Bind a buffer to the current webGL context at a given location
  29160. * @param buffer defines the buffer to bind
  29161. * @param location defines the index where to bind the buffer
  29162. */
  29163. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29164. /**
  29165. * Bind a specific block at a given index in a specific shader program
  29166. * @param pipelineContext defines the pipeline context to use
  29167. * @param blockName defines the block name
  29168. * @param index defines the index where to bind the block
  29169. */
  29170. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29171. private bindIndexBuffer;
  29172. private bindBuffer;
  29173. /**
  29174. * update the bound buffer with the given data
  29175. * @param data defines the data to update
  29176. */
  29177. updateArrayBuffer(data: Float32Array): void;
  29178. private _vertexAttribPointer;
  29179. private _bindIndexBufferWithCache;
  29180. private _bindVertexBuffersAttributes;
  29181. /**
  29182. * Records a vertex array object
  29183. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29184. * @param vertexBuffers defines the list of vertex buffers to store
  29185. * @param indexBuffer defines the index buffer to store
  29186. * @param effect defines the effect to store
  29187. * @returns the new vertex array object
  29188. */
  29189. recordVertexArrayObject(vertexBuffers: {
  29190. [key: string]: VertexBuffer;
  29191. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29192. /**
  29193. * Bind a specific vertex array object
  29194. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29195. * @param vertexArrayObject defines the vertex array object to bind
  29196. * @param indexBuffer defines the index buffer to bind
  29197. */
  29198. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29199. /**
  29200. * Bind webGl buffers directly to the webGL context
  29201. * @param vertexBuffer defines the vertex buffer to bind
  29202. * @param indexBuffer defines the index buffer to bind
  29203. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29204. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29205. * @param effect defines the effect associated with the vertex buffer
  29206. */
  29207. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29208. private _unbindVertexArrayObject;
  29209. /**
  29210. * Bind a list of vertex buffers to the webGL context
  29211. * @param vertexBuffers defines the list of vertex buffers to bind
  29212. * @param indexBuffer defines the index buffer to bind
  29213. * @param effect defines the effect associated with the vertex buffers
  29214. */
  29215. bindBuffers(vertexBuffers: {
  29216. [key: string]: Nullable<VertexBuffer>;
  29217. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29218. /**
  29219. * Unbind all instance attributes
  29220. */
  29221. unbindInstanceAttributes(): void;
  29222. /**
  29223. * Release and free the memory of a vertex array object
  29224. * @param vao defines the vertex array object to delete
  29225. */
  29226. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29227. /** @hidden */
  29228. _releaseBuffer(buffer: DataBuffer): boolean;
  29229. /**
  29230. * Creates a webGL buffer to use with instanciation
  29231. * @param capacity defines the size of the buffer
  29232. * @returns the webGL buffer
  29233. */
  29234. createInstancesBuffer(capacity: number): DataBuffer;
  29235. /**
  29236. * Delete a webGL buffer used with instanciation
  29237. * @param buffer defines the webGL buffer to delete
  29238. */
  29239. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29240. /**
  29241. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29242. * @param instancesBuffer defines the webGL buffer to update and bind
  29243. * @param data defines the data to store in the buffer
  29244. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29245. */
  29246. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29247. /**
  29248. * Apply all cached states (depth, culling, stencil and alpha)
  29249. */
  29250. applyStates(): void;
  29251. /**
  29252. * Send a draw order
  29253. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29254. * @param indexStart defines the starting index
  29255. * @param indexCount defines the number of index to draw
  29256. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29257. */
  29258. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29259. /**
  29260. * Draw a list of points
  29261. * @param verticesStart defines the index of first vertex to draw
  29262. * @param verticesCount defines the count of vertices to draw
  29263. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29264. */
  29265. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29266. /**
  29267. * Draw a list of unindexed primitives
  29268. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29269. * @param verticesStart defines the index of first vertex to draw
  29270. * @param verticesCount defines the count of vertices to draw
  29271. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29272. */
  29273. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29274. /**
  29275. * Draw a list of indexed primitives
  29276. * @param fillMode defines the primitive to use
  29277. * @param indexStart defines the starting index
  29278. * @param indexCount defines the number of index to draw
  29279. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29280. */
  29281. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29282. /**
  29283. * Draw a list of unindexed primitives
  29284. * @param fillMode defines the primitive to use
  29285. * @param verticesStart defines the index of first vertex to draw
  29286. * @param verticesCount defines the count of vertices to draw
  29287. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29288. */
  29289. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29290. private _drawMode;
  29291. /** @hidden */
  29292. _releaseEffect(effect: Effect): void;
  29293. /** @hidden */
  29294. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29295. /**
  29296. * Create a new effect (used to store vertex/fragment shaders)
  29297. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29298. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29299. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29300. * @param samplers defines an array of string used to represent textures
  29301. * @param defines defines the string containing the defines to use to compile the shaders
  29302. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29303. * @param onCompiled defines a function to call when the effect creation is successful
  29304. * @param onError defines a function to call when the effect creation has failed
  29305. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29306. * @returns the new Effect
  29307. */
  29308. 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;
  29309. private _compileShader;
  29310. private _compileRawShader;
  29311. /**
  29312. * Directly creates a webGL program
  29313. * @param pipelineContext defines the pipeline context to attach to
  29314. * @param vertexCode defines the vertex shader code to use
  29315. * @param fragmentCode defines the fragment shader code to use
  29316. * @param context defines the webGL context to use (if not set, the current one will be used)
  29317. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29318. * @returns the new webGL program
  29319. */
  29320. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29321. /**
  29322. * Creates a webGL program
  29323. * @param pipelineContext defines the pipeline context to attach to
  29324. * @param vertexCode defines the vertex shader code to use
  29325. * @param fragmentCode defines the fragment shader code to use
  29326. * @param defines defines the string containing the defines to use to compile the shaders
  29327. * @param context defines the webGL context to use (if not set, the current one will be used)
  29328. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29329. * @returns the new webGL program
  29330. */
  29331. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29332. /**
  29333. * Creates a new pipeline context
  29334. * @returns the new pipeline
  29335. */
  29336. createPipelineContext(): WebGLPipelineContext;
  29337. private _createShaderProgram;
  29338. private _finalizePipelineContext;
  29339. /** @hidden */
  29340. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29341. /** @hidden */
  29342. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29343. /** @hidden */
  29344. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29345. /**
  29346. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29347. * @param pipelineContext defines the pipeline context to use
  29348. * @param uniformsNames defines the list of uniform names
  29349. * @returns an array of webGL uniform locations
  29350. */
  29351. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29352. /**
  29353. * Gets the lsit of active attributes for a given webGL program
  29354. * @param pipelineContext defines the pipeline context to use
  29355. * @param attributesNames defines the list of attribute names to get
  29356. * @returns an array of indices indicating the offset of each attribute
  29357. */
  29358. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29359. /**
  29360. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29361. * @param effect defines the effect to activate
  29362. */
  29363. enableEffect(effect: Nullable<Effect>): void;
  29364. /**
  29365. * Set the value of an uniform to an array of int32
  29366. * @param uniform defines the webGL uniform location where to store the value
  29367. * @param array defines the array of int32 to store
  29368. */
  29369. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29370. /**
  29371. * Set the value of an uniform to an array of int32 (stored as vec2)
  29372. * @param uniform defines the webGL uniform location where to store the value
  29373. * @param array defines the array of int32 to store
  29374. */
  29375. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29376. /**
  29377. * Set the value of an uniform to an array of int32 (stored as vec3)
  29378. * @param uniform defines the webGL uniform location where to store the value
  29379. * @param array defines the array of int32 to store
  29380. */
  29381. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29382. /**
  29383. * Set the value of an uniform to an array of int32 (stored as vec4)
  29384. * @param uniform defines the webGL uniform location where to store the value
  29385. * @param array defines the array of int32 to store
  29386. */
  29387. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29388. /**
  29389. * Set the value of an uniform to an array of float32
  29390. * @param uniform defines the webGL uniform location where to store the value
  29391. * @param array defines the array of float32 to store
  29392. */
  29393. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29394. /**
  29395. * Set the value of an uniform to an array of float32 (stored as vec2)
  29396. * @param uniform defines the webGL uniform location where to store the value
  29397. * @param array defines the array of float32 to store
  29398. */
  29399. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29400. /**
  29401. * Set the value of an uniform to an array of float32 (stored as vec3)
  29402. * @param uniform defines the webGL uniform location where to store the value
  29403. * @param array defines the array of float32 to store
  29404. */
  29405. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29406. /**
  29407. * Set the value of an uniform to an array of float32 (stored as vec4)
  29408. * @param uniform defines the webGL uniform location where to store the value
  29409. * @param array defines the array of float32 to store
  29410. */
  29411. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29412. /**
  29413. * Set the value of an uniform to an array of number
  29414. * @param uniform defines the webGL uniform location where to store the value
  29415. * @param array defines the array of number to store
  29416. */
  29417. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29418. /**
  29419. * Set the value of an uniform to an array of number (stored as vec2)
  29420. * @param uniform defines the webGL uniform location where to store the value
  29421. * @param array defines the array of number to store
  29422. */
  29423. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29424. /**
  29425. * Set the value of an uniform to an array of number (stored as vec3)
  29426. * @param uniform defines the webGL uniform location where to store the value
  29427. * @param array defines the array of number to store
  29428. */
  29429. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29430. /**
  29431. * Set the value of an uniform to an array of number (stored as vec4)
  29432. * @param uniform defines the webGL uniform location where to store the value
  29433. * @param array defines the array of number to store
  29434. */
  29435. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29436. /**
  29437. * Set the value of an uniform to an array of float32 (stored as matrices)
  29438. * @param uniform defines the webGL uniform location where to store the value
  29439. * @param matrices defines the array of float32 to store
  29440. */
  29441. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29442. /**
  29443. * Set the value of an uniform to a matrix
  29444. * @param uniform defines the webGL uniform location where to store the value
  29445. * @param matrix defines the matrix to store
  29446. */
  29447. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29448. /**
  29449. * Set the value of an uniform to a matrix (3x3)
  29450. * @param uniform defines the webGL uniform location where to store the value
  29451. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29452. */
  29453. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29454. /**
  29455. * Set the value of an uniform to a matrix (2x2)
  29456. * @param uniform defines the webGL uniform location where to store the value
  29457. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29458. */
  29459. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29460. /**
  29461. * Set the value of an uniform to a number (int)
  29462. * @param uniform defines the webGL uniform location where to store the value
  29463. * @param value defines the int number to store
  29464. */
  29465. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29466. /**
  29467. * Set the value of an uniform to a number (float)
  29468. * @param uniform defines the webGL uniform location where to store the value
  29469. * @param value defines the float number to store
  29470. */
  29471. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29472. /**
  29473. * Set the value of an uniform to a vec2
  29474. * @param uniform defines the webGL uniform location where to store the value
  29475. * @param x defines the 1st component of the value
  29476. * @param y defines the 2nd component of the value
  29477. */
  29478. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29479. /**
  29480. * Set the value of an uniform to a vec3
  29481. * @param uniform defines the webGL uniform location where to store the value
  29482. * @param x defines the 1st component of the value
  29483. * @param y defines the 2nd component of the value
  29484. * @param z defines the 3rd component of the value
  29485. */
  29486. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29487. /**
  29488. * Set the value of an uniform to a boolean
  29489. * @param uniform defines the webGL uniform location where to store the value
  29490. * @param bool defines the boolean to store
  29491. */
  29492. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29493. /**
  29494. * Set the value of an uniform to a vec4
  29495. * @param uniform defines the webGL uniform location where to store the value
  29496. * @param x defines the 1st component of the value
  29497. * @param y defines the 2nd component of the value
  29498. * @param z defines the 3rd component of the value
  29499. * @param w defines the 4th component of the value
  29500. */
  29501. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29502. /**
  29503. * Set the value of an uniform to a Color3
  29504. * @param uniform defines the webGL uniform location where to store the value
  29505. * @param color3 defines the color to store
  29506. */
  29507. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29508. /**
  29509. * Set the value of an uniform to a Color3 and an alpha value
  29510. * @param uniform defines the webGL uniform location where to store the value
  29511. * @param color3 defines the color to store
  29512. * @param alpha defines the alpha component to store
  29513. */
  29514. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29515. /**
  29516. * Sets a Color4 on a uniform variable
  29517. * @param uniform defines the uniform location
  29518. * @param color4 defines the value to be set
  29519. */
  29520. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29521. /**
  29522. * Set various states to the webGL context
  29523. * @param culling defines backface culling state
  29524. * @param zOffset defines the value to apply to zOffset (0 by default)
  29525. * @param force defines if states must be applied even if cache is up to date
  29526. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29527. */
  29528. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29529. /**
  29530. * Set the z offset to apply to current rendering
  29531. * @param value defines the offset to apply
  29532. */
  29533. setZOffset(value: number): void;
  29534. /**
  29535. * Gets the current value of the zOffset
  29536. * @returns the current zOffset state
  29537. */
  29538. getZOffset(): number;
  29539. /**
  29540. * Enable or disable depth buffering
  29541. * @param enable defines the state to set
  29542. */
  29543. setDepthBuffer(enable: boolean): void;
  29544. /**
  29545. * Gets a boolean indicating if depth writing is enabled
  29546. * @returns the current depth writing state
  29547. */
  29548. getDepthWrite(): boolean;
  29549. /**
  29550. * Enable or disable depth writing
  29551. * @param enable defines the state to set
  29552. */
  29553. setDepthWrite(enable: boolean): void;
  29554. /**
  29555. * Enable or disable color writing
  29556. * @param enable defines the state to set
  29557. */
  29558. setColorWrite(enable: boolean): void;
  29559. /**
  29560. * Gets a boolean indicating if color writing is enabled
  29561. * @returns the current color writing state
  29562. */
  29563. getColorWrite(): boolean;
  29564. /**
  29565. * Sets alpha constants used by some alpha blending modes
  29566. * @param r defines the red component
  29567. * @param g defines the green component
  29568. * @param b defines the blue component
  29569. * @param a defines the alpha component
  29570. */
  29571. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29572. /**
  29573. * Sets the current alpha mode
  29574. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29575. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29576. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29577. */
  29578. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29579. /**
  29580. * Gets the current alpha mode
  29581. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29582. * @returns the current alpha mode
  29583. */
  29584. getAlphaMode(): number;
  29585. /**
  29586. * Clears the list of texture accessible through engine.
  29587. * This can help preventing texture load conflict due to name collision.
  29588. */
  29589. clearInternalTexturesCache(): void;
  29590. /**
  29591. * Force the entire cache to be cleared
  29592. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29593. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29594. */
  29595. wipeCaches(bruteForce?: boolean): void;
  29596. /**
  29597. * Set the compressed texture format to use, based on the formats you have, and the formats
  29598. * supported by the hardware / browser.
  29599. *
  29600. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29601. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29602. * to API arguments needed to compressed textures. This puts the burden on the container
  29603. * generator to house the arcane code for determining these for current & future formats.
  29604. *
  29605. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29606. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29607. *
  29608. * Note: The result of this call is not taken into account when a texture is base64.
  29609. *
  29610. * @param formatsAvailable defines the list of those format families you have created
  29611. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29612. *
  29613. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29614. * @returns The extension selected.
  29615. */
  29616. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29617. /** @hidden */
  29618. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29619. min: number;
  29620. mag: number;
  29621. };
  29622. /** @hidden */
  29623. _createTexture(): WebGLTexture;
  29624. /**
  29625. * Usually called from Texture.ts.
  29626. * Passed information to create a WebGLTexture
  29627. * @param urlArg defines a value which contains one of the following:
  29628. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29629. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29630. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29631. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29632. * @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)
  29633. * @param scene needed for loading to the correct scene
  29634. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29635. * @param onLoad optional callback to be called upon successful completion
  29636. * @param onError optional callback to be called upon failure
  29637. * @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
  29638. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29639. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29640. * @param forcedExtension defines the extension to use to pick the right loader
  29641. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29642. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29643. */
  29644. 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;
  29645. private _rescaleTexture;
  29646. private _unpackFlipYCached;
  29647. /**
  29648. * In case you are sharing the context with other applications, it might
  29649. * be interested to not cache the unpack flip y state to ensure a consistent
  29650. * value would be set.
  29651. */
  29652. enableUnpackFlipYCached: boolean;
  29653. /** @hidden */
  29654. _unpackFlipY(value: boolean): void;
  29655. /** @hidden */
  29656. _getUnpackAlignement(): number;
  29657. /**
  29658. * Creates a dynamic texture
  29659. * @param width defines the width of the texture
  29660. * @param height defines the height of the texture
  29661. * @param generateMipMaps defines if the engine should generate the mip levels
  29662. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29663. * @returns the dynamic texture inside an InternalTexture
  29664. */
  29665. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29666. /**
  29667. * Update the sampling mode of a given texture
  29668. * @param samplingMode defines the required sampling mode
  29669. * @param texture defines the texture to update
  29670. */
  29671. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29672. /**
  29673. * Update the content of a dynamic texture
  29674. * @param texture defines the texture to update
  29675. * @param canvas defines the canvas containing the source
  29676. * @param invertY defines if data must be stored with Y axis inverted
  29677. * @param premulAlpha defines if alpha is stored as premultiplied
  29678. * @param format defines the format of the data
  29679. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29680. */
  29681. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29682. /**
  29683. * Update a video texture
  29684. * @param texture defines the texture to update
  29685. * @param video defines the video element to use
  29686. * @param invertY defines if data must be stored with Y axis inverted
  29687. */
  29688. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29689. /**
  29690. * Updates a depth texture Comparison Mode and Function.
  29691. * If the comparison Function is equal to 0, the mode will be set to none.
  29692. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29693. * @param texture The texture to set the comparison function for
  29694. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29695. */
  29696. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29697. /** @hidden */
  29698. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29699. width: number;
  29700. height: number;
  29701. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29702. /**
  29703. * Creates a depth stencil texture.
  29704. * This is only available in WebGL 2 or with the depth texture extension available.
  29705. * @param size The size of face edge in the texture.
  29706. * @param options The options defining the texture.
  29707. * @returns The texture
  29708. */
  29709. createDepthStencilTexture(size: number | {
  29710. width: number;
  29711. height: number;
  29712. }, options: DepthTextureCreationOptions): InternalTexture;
  29713. /**
  29714. * Creates a depth stencil texture.
  29715. * This is only available in WebGL 2 or with the depth texture extension available.
  29716. * @param size The size of face edge in the texture.
  29717. * @param options The options defining the texture.
  29718. * @returns The texture
  29719. */
  29720. private _createDepthStencilTexture;
  29721. /**
  29722. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29723. * @param renderTarget The render target to set the frame buffer for
  29724. */
  29725. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29726. /**
  29727. * Creates a new render target texture
  29728. * @param size defines the size of the texture
  29729. * @param options defines the options used to create the texture
  29730. * @returns a new render target texture stored in an InternalTexture
  29731. */
  29732. createRenderTargetTexture(size: number | {
  29733. width: number;
  29734. height: number;
  29735. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29736. /** @hidden */
  29737. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29738. /**
  29739. * Updates the sample count of a render target texture
  29740. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29741. * @param texture defines the texture to update
  29742. * @param samples defines the sample count to set
  29743. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29744. */
  29745. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29746. /** @hidden */
  29747. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29748. /** @hidden */
  29749. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29750. /** @hidden */
  29751. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29752. /** @hidden */
  29753. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29754. /**
  29755. * @hidden
  29756. */
  29757. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29758. private _prepareWebGLTextureContinuation;
  29759. private _prepareWebGLTexture;
  29760. /** @hidden */
  29761. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29762. /** @hidden */
  29763. _releaseFramebufferObjects(texture: InternalTexture): void;
  29764. /** @hidden */
  29765. _releaseTexture(texture: InternalTexture): void;
  29766. private setProgram;
  29767. private _boundUniforms;
  29768. /**
  29769. * Binds an effect to the webGL context
  29770. * @param effect defines the effect to bind
  29771. */
  29772. bindSamplers(effect: Effect): void;
  29773. private _activateCurrentTexture;
  29774. /** @hidden */
  29775. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29776. /** @hidden */
  29777. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29778. /**
  29779. * Sets a texture to the webGL context from a postprocess
  29780. * @param channel defines the channel to use
  29781. * @param postProcess defines the source postprocess
  29782. */
  29783. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29784. /**
  29785. * Binds the output of the passed in post process to the texture channel specified
  29786. * @param channel The channel the texture should be bound to
  29787. * @param postProcess The post process which's output should be bound
  29788. */
  29789. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29790. /**
  29791. * Unbind all textures from the webGL context
  29792. */
  29793. unbindAllTextures(): void;
  29794. /**
  29795. * Sets a texture to the according uniform.
  29796. * @param channel The texture channel
  29797. * @param uniform The uniform to set
  29798. * @param texture The texture to apply
  29799. */
  29800. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29801. /**
  29802. * Sets a depth stencil texture from a render target to the according uniform.
  29803. * @param channel The texture channel
  29804. * @param uniform The uniform to set
  29805. * @param texture The render target texture containing the depth stencil texture to apply
  29806. */
  29807. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29808. private _bindSamplerUniformToChannel;
  29809. private _getTextureWrapMode;
  29810. private _setTexture;
  29811. /**
  29812. * Sets an array of texture to the webGL context
  29813. * @param channel defines the channel where the texture array must be set
  29814. * @param uniform defines the associated uniform location
  29815. * @param textures defines the array of textures to bind
  29816. */
  29817. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29818. /** @hidden */
  29819. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29820. private _setTextureParameterFloat;
  29821. private _setTextureParameterInteger;
  29822. /**
  29823. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29824. * @param x defines the x coordinate of the rectangle where pixels must be read
  29825. * @param y defines the y coordinate of the rectangle where pixels must be read
  29826. * @param width defines the width of the rectangle where pixels must be read
  29827. * @param height defines the height of the rectangle where pixels must be read
  29828. * @returns a Uint8Array containing RGBA colors
  29829. */
  29830. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29831. /**
  29832. * Add an externaly attached data from its key.
  29833. * This method call will fail and return false, if such key already exists.
  29834. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29835. * @param key the unique key that identifies the data
  29836. * @param data the data object to associate to the key for this Engine instance
  29837. * @return true if no such key were already present and the data was added successfully, false otherwise
  29838. */
  29839. addExternalData<T>(key: string, data: T): boolean;
  29840. /**
  29841. * Get an externaly attached data from its key
  29842. * @param key the unique key that identifies the data
  29843. * @return the associated data, if present (can be null), or undefined if not present
  29844. */
  29845. getExternalData<T>(key: string): T;
  29846. /**
  29847. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29848. * @param key the unique key that identifies the data
  29849. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29850. * @return the associated data, can be null if the factory returned null.
  29851. */
  29852. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29853. /**
  29854. * Remove an externaly attached data from the Engine instance
  29855. * @param key the unique key that identifies the data
  29856. * @return true if the data was successfully removed, false if it doesn't exist
  29857. */
  29858. removeExternalData(key: string): boolean;
  29859. /**
  29860. * Unbind all vertex attributes from the webGL context
  29861. */
  29862. unbindAllAttributes(): void;
  29863. /**
  29864. * 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
  29865. */
  29866. releaseEffects(): void;
  29867. /**
  29868. * Dispose and release all associated resources
  29869. */
  29870. dispose(): void;
  29871. /**
  29872. * Display the loading screen
  29873. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29874. */
  29875. displayLoadingUI(): void;
  29876. /**
  29877. * Hide the loading screen
  29878. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29879. */
  29880. hideLoadingUI(): void;
  29881. /**
  29882. * Gets the current loading screen object
  29883. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29884. */
  29885. /**
  29886. * Sets the current loading screen object
  29887. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29888. */
  29889. loadingScreen: ILoadingScreen;
  29890. /**
  29891. * Sets the current loading screen text
  29892. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29893. */
  29894. loadingUIText: string;
  29895. /**
  29896. * Sets the current loading screen background color
  29897. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29898. */
  29899. loadingUIBackgroundColor: string;
  29900. /**
  29901. * Attach a new callback raised when context lost event is fired
  29902. * @param callback defines the callback to call
  29903. */
  29904. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29905. /**
  29906. * Attach a new callback raised when context restored event is fired
  29907. * @param callback defines the callback to call
  29908. */
  29909. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29910. /**
  29911. * Gets the source code of the vertex shader associated with a specific webGL program
  29912. * @param program defines the program to use
  29913. * @returns a string containing the source code of the vertex shader associated with the program
  29914. */
  29915. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29916. /**
  29917. * Gets the source code of the fragment shader associated with a specific webGL program
  29918. * @param program defines the program to use
  29919. * @returns a string containing the source code of the fragment shader associated with the program
  29920. */
  29921. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29922. /**
  29923. * Get the current error code of the webGL context
  29924. * @returns the error code
  29925. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29926. */
  29927. getError(): number;
  29928. /**
  29929. * Gets the current framerate
  29930. * @returns a number representing the framerate
  29931. */
  29932. getFps(): number;
  29933. /**
  29934. * Gets the time spent between current and previous frame
  29935. * @returns a number representing the delta time in ms
  29936. */
  29937. getDeltaTime(): number;
  29938. private _measureFps;
  29939. /** @hidden */
  29940. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29941. private _canRenderToFloatFramebuffer;
  29942. private _canRenderToHalfFloatFramebuffer;
  29943. private _canRenderToFramebuffer;
  29944. /** @hidden */
  29945. _getWebGLTextureType(type: number): number;
  29946. /** @hidden */
  29947. _getInternalFormat(format: number): number;
  29948. /** @hidden */
  29949. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29950. /** @hidden */
  29951. _getRGBAMultiSampleBufferFormat(type: number): number;
  29952. /** @hidden */
  29953. _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;
  29954. /** @hidden */
  29955. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29956. /**
  29957. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29958. * @returns true if the engine can be created
  29959. * @ignorenaming
  29960. */
  29961. static isSupported(): boolean;
  29962. }
  29963. }
  29964. declare module "babylonjs/Materials/effect" {
  29965. import { Observable } from "babylonjs/Misc/observable";
  29966. import { Nullable } from "babylonjs/types";
  29967. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29968. import { IDisposable } from "babylonjs/scene";
  29969. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29970. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29971. import { Engine } from "babylonjs/Engines/engine";
  29972. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29973. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29974. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29975. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29977. /**
  29978. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29979. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29980. */
  29981. export class EffectFallbacks {
  29982. private _defines;
  29983. private _currentRank;
  29984. private _maxRank;
  29985. private _mesh;
  29986. /**
  29987. * Removes the fallback from the bound mesh.
  29988. */
  29989. unBindMesh(): void;
  29990. /**
  29991. * Adds a fallback on the specified property.
  29992. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29993. * @param define The name of the define in the shader
  29994. */
  29995. addFallback(rank: number, define: string): void;
  29996. /**
  29997. * Sets the mesh to use CPU skinning when needing to fallback.
  29998. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29999. * @param mesh The mesh to use the fallbacks.
  30000. */
  30001. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  30002. /**
  30003. * Checks to see if more fallbacks are still availible.
  30004. */
  30005. readonly isMoreFallbacks: boolean;
  30006. /**
  30007. * Removes the defines that should be removed when falling back.
  30008. * @param currentDefines defines the current define statements for the shader.
  30009. * @param effect defines the current effect we try to compile
  30010. * @returns The resulting defines with defines of the current rank removed.
  30011. */
  30012. reduce(currentDefines: string, effect: Effect): string;
  30013. }
  30014. /**
  30015. * Options to be used when creating an effect.
  30016. */
  30017. export class EffectCreationOptions {
  30018. /**
  30019. * Atrributes that will be used in the shader.
  30020. */
  30021. attributes: string[];
  30022. /**
  30023. * Uniform varible names that will be set in the shader.
  30024. */
  30025. uniformsNames: string[];
  30026. /**
  30027. * Uniform buffer varible names that will be set in the shader.
  30028. */
  30029. uniformBuffersNames: string[];
  30030. /**
  30031. * Sampler texture variable names that will be set in the shader.
  30032. */
  30033. samplers: string[];
  30034. /**
  30035. * Define statements that will be set in the shader.
  30036. */
  30037. defines: any;
  30038. /**
  30039. * Possible fallbacks for this effect to improve performance when needed.
  30040. */
  30041. fallbacks: Nullable<EffectFallbacks>;
  30042. /**
  30043. * Callback that will be called when the shader is compiled.
  30044. */
  30045. onCompiled: Nullable<(effect: Effect) => void>;
  30046. /**
  30047. * Callback that will be called if an error occurs during shader compilation.
  30048. */
  30049. onError: Nullable<(effect: Effect, errors: string) => void>;
  30050. /**
  30051. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30052. */
  30053. indexParameters: any;
  30054. /**
  30055. * Max number of lights that can be used in the shader.
  30056. */
  30057. maxSimultaneousLights: number;
  30058. /**
  30059. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30060. */
  30061. transformFeedbackVaryings: Nullable<string[]>;
  30062. }
  30063. /**
  30064. * Effect containing vertex and fragment shader that can be executed on an object.
  30065. */
  30066. export class Effect implements IDisposable {
  30067. /**
  30068. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30069. */
  30070. static ShadersRepository: string;
  30071. /**
  30072. * Name of the effect.
  30073. */
  30074. name: any;
  30075. /**
  30076. * String container all the define statements that should be set on the shader.
  30077. */
  30078. defines: string;
  30079. /**
  30080. * Callback that will be called when the shader is compiled.
  30081. */
  30082. onCompiled: Nullable<(effect: Effect) => void>;
  30083. /**
  30084. * Callback that will be called if an error occurs during shader compilation.
  30085. */
  30086. onError: Nullable<(effect: Effect, errors: string) => void>;
  30087. /**
  30088. * Callback that will be called when effect is bound.
  30089. */
  30090. onBind: Nullable<(effect: Effect) => void>;
  30091. /**
  30092. * Unique ID of the effect.
  30093. */
  30094. uniqueId: number;
  30095. /**
  30096. * Observable that will be called when the shader is compiled.
  30097. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30098. */
  30099. onCompileObservable: Observable<Effect>;
  30100. /**
  30101. * Observable that will be called if an error occurs during shader compilation.
  30102. */
  30103. onErrorObservable: Observable<Effect>;
  30104. /** @hidden */
  30105. _onBindObservable: Nullable<Observable<Effect>>;
  30106. /**
  30107. * Observable that will be called when effect is bound.
  30108. */
  30109. readonly onBindObservable: Observable<Effect>;
  30110. /** @hidden */
  30111. _bonesComputationForcedToCPU: boolean;
  30112. private static _uniqueIdSeed;
  30113. private _engine;
  30114. private _uniformBuffersNames;
  30115. private _uniformsNames;
  30116. private _samplerList;
  30117. private _samplers;
  30118. private _isReady;
  30119. private _compilationError;
  30120. private _attributesNames;
  30121. private _attributes;
  30122. private _uniforms;
  30123. /**
  30124. * Key for the effect.
  30125. * @hidden
  30126. */
  30127. _key: string;
  30128. private _indexParameters;
  30129. private _fallbacks;
  30130. private _vertexSourceCode;
  30131. private _fragmentSourceCode;
  30132. private _vertexSourceCodeOverride;
  30133. private _fragmentSourceCodeOverride;
  30134. private _transformFeedbackVaryings;
  30135. /**
  30136. * Compiled shader to webGL program.
  30137. * @hidden
  30138. */
  30139. _pipelineContext: Nullable<IPipelineContext>;
  30140. private _valueCache;
  30141. private static _baseCache;
  30142. /**
  30143. * Instantiates an effect.
  30144. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30145. * @param baseName Name of the effect.
  30146. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30147. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30148. * @param samplers List of sampler variables that will be passed to the shader.
  30149. * @param engine Engine to be used to render the effect
  30150. * @param defines Define statements to be added to the shader.
  30151. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30152. * @param onCompiled Callback that will be called when the shader is compiled.
  30153. * @param onError Callback that will be called if an error occurs during shader compilation.
  30154. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30155. */
  30156. 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);
  30157. private _useFinalCode;
  30158. /**
  30159. * Unique key for this effect
  30160. */
  30161. readonly key: string;
  30162. /**
  30163. * If the effect has been compiled and prepared.
  30164. * @returns if the effect is compiled and prepared.
  30165. */
  30166. isReady(): boolean;
  30167. /**
  30168. * The engine the effect was initialized with.
  30169. * @returns the engine.
  30170. */
  30171. getEngine(): Engine;
  30172. /**
  30173. * The pipeline context for this effect
  30174. * @returns the associated pipeline context
  30175. */
  30176. getPipelineContext(): Nullable<IPipelineContext>;
  30177. /**
  30178. * The set of names of attribute variables for the shader.
  30179. * @returns An array of attribute names.
  30180. */
  30181. getAttributesNames(): string[];
  30182. /**
  30183. * Returns the attribute at the given index.
  30184. * @param index The index of the attribute.
  30185. * @returns The location of the attribute.
  30186. */
  30187. getAttributeLocation(index: number): number;
  30188. /**
  30189. * Returns the attribute based on the name of the variable.
  30190. * @param name of the attribute to look up.
  30191. * @returns the attribute location.
  30192. */
  30193. getAttributeLocationByName(name: string): number;
  30194. /**
  30195. * The number of attributes.
  30196. * @returns the numnber of attributes.
  30197. */
  30198. getAttributesCount(): number;
  30199. /**
  30200. * Gets the index of a uniform variable.
  30201. * @param uniformName of the uniform to look up.
  30202. * @returns the index.
  30203. */
  30204. getUniformIndex(uniformName: string): number;
  30205. /**
  30206. * Returns the attribute based on the name of the variable.
  30207. * @param uniformName of the uniform to look up.
  30208. * @returns the location of the uniform.
  30209. */
  30210. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30211. /**
  30212. * Returns an array of sampler variable names
  30213. * @returns The array of sampler variable neames.
  30214. */
  30215. getSamplers(): string[];
  30216. /**
  30217. * The error from the last compilation.
  30218. * @returns the error string.
  30219. */
  30220. getCompilationError(): string;
  30221. /**
  30222. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30223. * @param func The callback to be used.
  30224. */
  30225. executeWhenCompiled(func: (effect: Effect) => void): void;
  30226. private _checkIsReady;
  30227. /** @hidden */
  30228. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30229. /** @hidden */
  30230. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30231. /** @hidden */
  30232. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30233. /**
  30234. * Recompiles the webGL program
  30235. * @param vertexSourceCode The source code for the vertex shader.
  30236. * @param fragmentSourceCode The source code for the fragment shader.
  30237. * @param onCompiled Callback called when completed.
  30238. * @param onError Callback called on error.
  30239. * @hidden
  30240. */
  30241. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30242. /**
  30243. * Prepares the effect
  30244. * @hidden
  30245. */
  30246. _prepareEffect(): void;
  30247. /**
  30248. * Checks if the effect is supported. (Must be called after compilation)
  30249. */
  30250. readonly isSupported: boolean;
  30251. /**
  30252. * Binds a texture to the engine to be used as output of the shader.
  30253. * @param channel Name of the output variable.
  30254. * @param texture Texture to bind.
  30255. * @hidden
  30256. */
  30257. _bindTexture(channel: string, texture: InternalTexture): void;
  30258. /**
  30259. * Sets a texture on the engine to be used in the shader.
  30260. * @param channel Name of the sampler variable.
  30261. * @param texture Texture to set.
  30262. */
  30263. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30264. /**
  30265. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30266. * @param channel Name of the sampler variable.
  30267. * @param texture Texture to set.
  30268. */
  30269. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30270. /**
  30271. * Sets an array of textures on the engine to be used in the shader.
  30272. * @param channel Name of the variable.
  30273. * @param textures Textures to set.
  30274. */
  30275. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30276. /**
  30277. * 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)
  30278. * @param channel Name of the sampler variable.
  30279. * @param postProcess Post process to get the input texture from.
  30280. */
  30281. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30282. /**
  30283. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30284. * 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)
  30285. * @param channel Name of the sampler variable.
  30286. * @param postProcess Post process to get the output texture from.
  30287. */
  30288. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30289. /** @hidden */
  30290. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30291. /** @hidden */
  30292. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30293. /** @hidden */
  30294. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30295. /** @hidden */
  30296. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30297. /**
  30298. * Binds a buffer to a uniform.
  30299. * @param buffer Buffer to bind.
  30300. * @param name Name of the uniform variable to bind to.
  30301. */
  30302. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30303. /**
  30304. * Binds block to a uniform.
  30305. * @param blockName Name of the block to bind.
  30306. * @param index Index to bind.
  30307. */
  30308. bindUniformBlock(blockName: string, index: number): void;
  30309. /**
  30310. * Sets an interger value on a uniform variable.
  30311. * @param uniformName Name of the variable.
  30312. * @param value Value to be set.
  30313. * @returns this effect.
  30314. */
  30315. setInt(uniformName: string, value: number): Effect;
  30316. /**
  30317. * Sets an int array on a uniform variable.
  30318. * @param uniformName Name of the variable.
  30319. * @param array array to be set.
  30320. * @returns this effect.
  30321. */
  30322. setIntArray(uniformName: string, array: Int32Array): Effect;
  30323. /**
  30324. * 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)
  30325. * @param uniformName Name of the variable.
  30326. * @param array array to be set.
  30327. * @returns this effect.
  30328. */
  30329. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30330. /**
  30331. * 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)
  30332. * @param uniformName Name of the variable.
  30333. * @param array array to be set.
  30334. * @returns this effect.
  30335. */
  30336. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30337. /**
  30338. * 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)
  30339. * @param uniformName Name of the variable.
  30340. * @param array array to be set.
  30341. * @returns this effect.
  30342. */
  30343. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30344. /**
  30345. * Sets an float array on a uniform variable.
  30346. * @param uniformName Name of the variable.
  30347. * @param array array to be set.
  30348. * @returns this effect.
  30349. */
  30350. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30351. /**
  30352. * 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)
  30353. * @param uniformName Name of the variable.
  30354. * @param array array to be set.
  30355. * @returns this effect.
  30356. */
  30357. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30358. /**
  30359. * 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)
  30360. * @param uniformName Name of the variable.
  30361. * @param array array to be set.
  30362. * @returns this effect.
  30363. */
  30364. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30365. /**
  30366. * 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)
  30367. * @param uniformName Name of the variable.
  30368. * @param array array to be set.
  30369. * @returns this effect.
  30370. */
  30371. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30372. /**
  30373. * Sets an array on a uniform variable.
  30374. * @param uniformName Name of the variable.
  30375. * @param array array to be set.
  30376. * @returns this effect.
  30377. */
  30378. setArray(uniformName: string, array: number[]): Effect;
  30379. /**
  30380. * 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)
  30381. * @param uniformName Name of the variable.
  30382. * @param array array to be set.
  30383. * @returns this effect.
  30384. */
  30385. setArray2(uniformName: string, array: number[]): Effect;
  30386. /**
  30387. * 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)
  30388. * @param uniformName Name of the variable.
  30389. * @param array array to be set.
  30390. * @returns this effect.
  30391. */
  30392. setArray3(uniformName: string, array: number[]): Effect;
  30393. /**
  30394. * 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)
  30395. * @param uniformName Name of the variable.
  30396. * @param array array to be set.
  30397. * @returns this effect.
  30398. */
  30399. setArray4(uniformName: string, array: number[]): Effect;
  30400. /**
  30401. * Sets matrices on a uniform variable.
  30402. * @param uniformName Name of the variable.
  30403. * @param matrices matrices to be set.
  30404. * @returns this effect.
  30405. */
  30406. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30407. /**
  30408. * Sets matrix on a uniform variable.
  30409. * @param uniformName Name of the variable.
  30410. * @param matrix matrix to be set.
  30411. * @returns this effect.
  30412. */
  30413. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30414. /**
  30415. * 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)
  30416. * @param uniformName Name of the variable.
  30417. * @param matrix matrix to be set.
  30418. * @returns this effect.
  30419. */
  30420. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30421. /**
  30422. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30423. * @param uniformName Name of the variable.
  30424. * @param matrix matrix to be set.
  30425. * @returns this effect.
  30426. */
  30427. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30428. /**
  30429. * Sets a float on a uniform variable.
  30430. * @param uniformName Name of the variable.
  30431. * @param value value to be set.
  30432. * @returns this effect.
  30433. */
  30434. setFloat(uniformName: string, value: number): Effect;
  30435. /**
  30436. * Sets a boolean on a uniform variable.
  30437. * @param uniformName Name of the variable.
  30438. * @param bool value to be set.
  30439. * @returns this effect.
  30440. */
  30441. setBool(uniformName: string, bool: boolean): Effect;
  30442. /**
  30443. * Sets a Vector2 on a uniform variable.
  30444. * @param uniformName Name of the variable.
  30445. * @param vector2 vector2 to be set.
  30446. * @returns this effect.
  30447. */
  30448. setVector2(uniformName: string, vector2: Vector2): Effect;
  30449. /**
  30450. * Sets a float2 on a uniform variable.
  30451. * @param uniformName Name of the variable.
  30452. * @param x First float in float2.
  30453. * @param y Second float in float2.
  30454. * @returns this effect.
  30455. */
  30456. setFloat2(uniformName: string, x: number, y: number): Effect;
  30457. /**
  30458. * Sets a Vector3 on a uniform variable.
  30459. * @param uniformName Name of the variable.
  30460. * @param vector3 Value to be set.
  30461. * @returns this effect.
  30462. */
  30463. setVector3(uniformName: string, vector3: Vector3): Effect;
  30464. /**
  30465. * Sets a float3 on a uniform variable.
  30466. * @param uniformName Name of the variable.
  30467. * @param x First float in float3.
  30468. * @param y Second float in float3.
  30469. * @param z Third float in float3.
  30470. * @returns this effect.
  30471. */
  30472. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30473. /**
  30474. * Sets a Vector4 on a uniform variable.
  30475. * @param uniformName Name of the variable.
  30476. * @param vector4 Value to be set.
  30477. * @returns this effect.
  30478. */
  30479. setVector4(uniformName: string, vector4: Vector4): Effect;
  30480. /**
  30481. * Sets a float4 on a uniform variable.
  30482. * @param uniformName Name of the variable.
  30483. * @param x First float in float4.
  30484. * @param y Second float in float4.
  30485. * @param z Third float in float4.
  30486. * @param w Fourth float in float4.
  30487. * @returns this effect.
  30488. */
  30489. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30490. /**
  30491. * Sets a Color3 on a uniform variable.
  30492. * @param uniformName Name of the variable.
  30493. * @param color3 Value to be set.
  30494. * @returns this effect.
  30495. */
  30496. setColor3(uniformName: string, color3: Color3): Effect;
  30497. /**
  30498. * Sets a Color4 on a uniform variable.
  30499. * @param uniformName Name of the variable.
  30500. * @param color3 Value to be set.
  30501. * @param alpha Alpha value to be set.
  30502. * @returns this effect.
  30503. */
  30504. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30505. /**
  30506. * Sets a Color4 on a uniform variable
  30507. * @param uniformName defines the name of the variable
  30508. * @param color4 defines the value to be set
  30509. * @returns this effect.
  30510. */
  30511. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30512. /** Release all associated resources */
  30513. dispose(): void;
  30514. /**
  30515. * This function will add a new shader to the shader store
  30516. * @param name the name of the shader
  30517. * @param pixelShader optional pixel shader content
  30518. * @param vertexShader optional vertex shader content
  30519. */
  30520. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30521. /**
  30522. * Store of each shader (The can be looked up using effect.key)
  30523. */
  30524. static ShadersStore: {
  30525. [key: string]: string;
  30526. };
  30527. /**
  30528. * Store of each included file for a shader (The can be looked up using effect.key)
  30529. */
  30530. static IncludesShadersStore: {
  30531. [key: string]: string;
  30532. };
  30533. /**
  30534. * Resets the cache of effects.
  30535. */
  30536. static ResetCache(): void;
  30537. }
  30538. }
  30539. declare module "babylonjs/Materials/colorCurves" {
  30540. import { Effect } from "babylonjs/Materials/effect";
  30541. /**
  30542. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30543. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30544. * 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;
  30545. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30546. */
  30547. export class ColorCurves {
  30548. private _dirty;
  30549. private _tempColor;
  30550. private _globalCurve;
  30551. private _highlightsCurve;
  30552. private _midtonesCurve;
  30553. private _shadowsCurve;
  30554. private _positiveCurve;
  30555. private _negativeCurve;
  30556. private _globalHue;
  30557. private _globalDensity;
  30558. private _globalSaturation;
  30559. private _globalExposure;
  30560. /**
  30561. * Gets the global Hue value.
  30562. * 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).
  30563. */
  30564. /**
  30565. * Sets the global Hue value.
  30566. * 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).
  30567. */
  30568. globalHue: number;
  30569. /**
  30570. * Gets the global Density value.
  30571. * 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.
  30572. * Values less than zero provide a filter of opposite hue.
  30573. */
  30574. /**
  30575. * Sets the global Density value.
  30576. * 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.
  30577. * Values less than zero provide a filter of opposite hue.
  30578. */
  30579. globalDensity: number;
  30580. /**
  30581. * Gets the global Saturation value.
  30582. * 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.
  30583. */
  30584. /**
  30585. * Sets the global Saturation value.
  30586. * 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.
  30587. */
  30588. globalSaturation: number;
  30589. /**
  30590. * Gets the global Exposure value.
  30591. * 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.
  30592. */
  30593. /**
  30594. * Sets the global Exposure value.
  30595. * 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.
  30596. */
  30597. globalExposure: number;
  30598. private _highlightsHue;
  30599. private _highlightsDensity;
  30600. private _highlightsSaturation;
  30601. private _highlightsExposure;
  30602. /**
  30603. * Gets the highlights Hue value.
  30604. * 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).
  30605. */
  30606. /**
  30607. * Sets the highlights Hue value.
  30608. * 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).
  30609. */
  30610. highlightsHue: number;
  30611. /**
  30612. * Gets the highlights Density value.
  30613. * 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.
  30614. * Values less than zero provide a filter of opposite hue.
  30615. */
  30616. /**
  30617. * Sets the highlights Density value.
  30618. * 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.
  30619. * Values less than zero provide a filter of opposite hue.
  30620. */
  30621. highlightsDensity: number;
  30622. /**
  30623. * Gets the highlights Saturation value.
  30624. * 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.
  30625. */
  30626. /**
  30627. * Sets the highlights Saturation value.
  30628. * 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.
  30629. */
  30630. highlightsSaturation: number;
  30631. /**
  30632. * Gets the highlights Exposure value.
  30633. * 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.
  30634. */
  30635. /**
  30636. * Sets the highlights Exposure value.
  30637. * 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.
  30638. */
  30639. highlightsExposure: number;
  30640. private _midtonesHue;
  30641. private _midtonesDensity;
  30642. private _midtonesSaturation;
  30643. private _midtonesExposure;
  30644. /**
  30645. * Gets the midtones Hue value.
  30646. * 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).
  30647. */
  30648. /**
  30649. * Sets the midtones Hue value.
  30650. * 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).
  30651. */
  30652. midtonesHue: number;
  30653. /**
  30654. * Gets the midtones Density value.
  30655. * 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.
  30656. * Values less than zero provide a filter of opposite hue.
  30657. */
  30658. /**
  30659. * Sets the midtones Density value.
  30660. * 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.
  30661. * Values less than zero provide a filter of opposite hue.
  30662. */
  30663. midtonesDensity: number;
  30664. /**
  30665. * Gets the midtones Saturation value.
  30666. * 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.
  30667. */
  30668. /**
  30669. * Sets the midtones Saturation value.
  30670. * 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.
  30671. */
  30672. midtonesSaturation: number;
  30673. /**
  30674. * Gets the midtones Exposure value.
  30675. * 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.
  30676. */
  30677. /**
  30678. * Sets the midtones Exposure value.
  30679. * 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.
  30680. */
  30681. midtonesExposure: number;
  30682. private _shadowsHue;
  30683. private _shadowsDensity;
  30684. private _shadowsSaturation;
  30685. private _shadowsExposure;
  30686. /**
  30687. * Gets the shadows Hue value.
  30688. * 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).
  30689. */
  30690. /**
  30691. * Sets the shadows Hue value.
  30692. * 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).
  30693. */
  30694. shadowsHue: number;
  30695. /**
  30696. * Gets the shadows Density value.
  30697. * 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.
  30698. * Values less than zero provide a filter of opposite hue.
  30699. */
  30700. /**
  30701. * Sets the shadows Density value.
  30702. * 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.
  30703. * Values less than zero provide a filter of opposite hue.
  30704. */
  30705. shadowsDensity: number;
  30706. /**
  30707. * Gets the shadows Saturation value.
  30708. * 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.
  30709. */
  30710. /**
  30711. * Sets the shadows Saturation value.
  30712. * 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.
  30713. */
  30714. shadowsSaturation: number;
  30715. /**
  30716. * Gets the shadows Exposure value.
  30717. * 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.
  30718. */
  30719. /**
  30720. * Sets the shadows Exposure value.
  30721. * 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.
  30722. */
  30723. shadowsExposure: number;
  30724. /**
  30725. * Returns the class name
  30726. * @returns The class name
  30727. */
  30728. getClassName(): string;
  30729. /**
  30730. * Binds the color curves to the shader.
  30731. * @param colorCurves The color curve to bind
  30732. * @param effect The effect to bind to
  30733. * @param positiveUniform The positive uniform shader parameter
  30734. * @param neutralUniform The neutral uniform shader parameter
  30735. * @param negativeUniform The negative uniform shader parameter
  30736. */
  30737. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30738. /**
  30739. * Prepare the list of uniforms associated with the ColorCurves effects.
  30740. * @param uniformsList The list of uniforms used in the effect
  30741. */
  30742. static PrepareUniforms(uniformsList: string[]): void;
  30743. /**
  30744. * Returns color grading data based on a hue, density, saturation and exposure value.
  30745. * @param filterHue The hue of the color filter.
  30746. * @param filterDensity The density of the color filter.
  30747. * @param saturation The saturation.
  30748. * @param exposure The exposure.
  30749. * @param result The result data container.
  30750. */
  30751. private getColorGradingDataToRef;
  30752. /**
  30753. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30754. * @param value The input slider value in range [-100,100].
  30755. * @returns Adjusted value.
  30756. */
  30757. private static applyColorGradingSliderNonlinear;
  30758. /**
  30759. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30760. * @param hue The hue (H) input.
  30761. * @param saturation The saturation (S) input.
  30762. * @param brightness The brightness (B) input.
  30763. * @result An RGBA color represented as Vector4.
  30764. */
  30765. private static fromHSBToRef;
  30766. /**
  30767. * Returns a value clamped between min and max
  30768. * @param value The value to clamp
  30769. * @param min The minimum of value
  30770. * @param max The maximum of value
  30771. * @returns The clamped value.
  30772. */
  30773. private static clamp;
  30774. /**
  30775. * Clones the current color curve instance.
  30776. * @return The cloned curves
  30777. */
  30778. clone(): ColorCurves;
  30779. /**
  30780. * Serializes the current color curve instance to a json representation.
  30781. * @return a JSON representation
  30782. */
  30783. serialize(): any;
  30784. /**
  30785. * Parses the color curve from a json representation.
  30786. * @param source the JSON source to parse
  30787. * @return The parsed curves
  30788. */
  30789. static Parse(source: any): ColorCurves;
  30790. }
  30791. }
  30792. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30793. import { Observable } from "babylonjs/Misc/observable";
  30794. import { Nullable } from "babylonjs/types";
  30795. import { Color4 } from "babylonjs/Maths/math";
  30796. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30797. import { Effect } from "babylonjs/Materials/effect";
  30798. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30799. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30800. /**
  30801. * Interface to follow in your material defines to integrate easily the
  30802. * Image proccessing functions.
  30803. * @hidden
  30804. */
  30805. export interface IImageProcessingConfigurationDefines {
  30806. IMAGEPROCESSING: boolean;
  30807. VIGNETTE: boolean;
  30808. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30809. VIGNETTEBLENDMODEOPAQUE: boolean;
  30810. TONEMAPPING: boolean;
  30811. TONEMAPPING_ACES: boolean;
  30812. CONTRAST: boolean;
  30813. EXPOSURE: boolean;
  30814. COLORCURVES: boolean;
  30815. COLORGRADING: boolean;
  30816. COLORGRADING3D: boolean;
  30817. SAMPLER3DGREENDEPTH: boolean;
  30818. SAMPLER3DBGRMAP: boolean;
  30819. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30820. }
  30821. /**
  30822. * @hidden
  30823. */
  30824. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30825. IMAGEPROCESSING: boolean;
  30826. VIGNETTE: boolean;
  30827. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30828. VIGNETTEBLENDMODEOPAQUE: boolean;
  30829. TONEMAPPING: boolean;
  30830. TONEMAPPING_ACES: boolean;
  30831. CONTRAST: boolean;
  30832. COLORCURVES: boolean;
  30833. COLORGRADING: boolean;
  30834. COLORGRADING3D: boolean;
  30835. SAMPLER3DGREENDEPTH: boolean;
  30836. SAMPLER3DBGRMAP: boolean;
  30837. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30838. EXPOSURE: boolean;
  30839. constructor();
  30840. }
  30841. /**
  30842. * This groups together the common properties used for image processing either in direct forward pass
  30843. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30844. * or not.
  30845. */
  30846. export class ImageProcessingConfiguration {
  30847. /**
  30848. * Default tone mapping applied in BabylonJS.
  30849. */
  30850. static readonly TONEMAPPING_STANDARD: number;
  30851. /**
  30852. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30853. * to other engines rendering to increase portability.
  30854. */
  30855. static readonly TONEMAPPING_ACES: number;
  30856. /**
  30857. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30858. */
  30859. colorCurves: Nullable<ColorCurves>;
  30860. private _colorCurvesEnabled;
  30861. /**
  30862. * Gets wether the color curves effect is enabled.
  30863. */
  30864. /**
  30865. * Sets wether the color curves effect is enabled.
  30866. */
  30867. colorCurvesEnabled: boolean;
  30868. private _colorGradingTexture;
  30869. /**
  30870. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30871. */
  30872. /**
  30873. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30874. */
  30875. colorGradingTexture: Nullable<BaseTexture>;
  30876. private _colorGradingEnabled;
  30877. /**
  30878. * Gets wether the color grading effect is enabled.
  30879. */
  30880. /**
  30881. * Sets wether the color grading effect is enabled.
  30882. */
  30883. colorGradingEnabled: boolean;
  30884. private _colorGradingWithGreenDepth;
  30885. /**
  30886. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30887. */
  30888. /**
  30889. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30890. */
  30891. colorGradingWithGreenDepth: boolean;
  30892. private _colorGradingBGR;
  30893. /**
  30894. * Gets wether the color grading texture contains BGR values.
  30895. */
  30896. /**
  30897. * Sets wether the color grading texture contains BGR values.
  30898. */
  30899. colorGradingBGR: boolean;
  30900. /** @hidden */
  30901. _exposure: number;
  30902. /**
  30903. * Gets the Exposure used in the effect.
  30904. */
  30905. /**
  30906. * Sets the Exposure used in the effect.
  30907. */
  30908. exposure: number;
  30909. private _toneMappingEnabled;
  30910. /**
  30911. * Gets wether the tone mapping effect is enabled.
  30912. */
  30913. /**
  30914. * Sets wether the tone mapping effect is enabled.
  30915. */
  30916. toneMappingEnabled: boolean;
  30917. private _toneMappingType;
  30918. /**
  30919. * Gets the type of tone mapping effect.
  30920. */
  30921. /**
  30922. * Sets the type of tone mapping effect used in BabylonJS.
  30923. */
  30924. toneMappingType: number;
  30925. protected _contrast: number;
  30926. /**
  30927. * Gets the contrast used in the effect.
  30928. */
  30929. /**
  30930. * Sets the contrast used in the effect.
  30931. */
  30932. contrast: number;
  30933. /**
  30934. * Vignette stretch size.
  30935. */
  30936. vignetteStretch: number;
  30937. /**
  30938. * Vignette centre X Offset.
  30939. */
  30940. vignetteCentreX: number;
  30941. /**
  30942. * Vignette centre Y Offset.
  30943. */
  30944. vignetteCentreY: number;
  30945. /**
  30946. * Vignette weight or intensity of the vignette effect.
  30947. */
  30948. vignetteWeight: number;
  30949. /**
  30950. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30951. * if vignetteEnabled is set to true.
  30952. */
  30953. vignetteColor: Color4;
  30954. /**
  30955. * Camera field of view used by the Vignette effect.
  30956. */
  30957. vignetteCameraFov: number;
  30958. private _vignetteBlendMode;
  30959. /**
  30960. * Gets the vignette blend mode allowing different kind of effect.
  30961. */
  30962. /**
  30963. * Sets the vignette blend mode allowing different kind of effect.
  30964. */
  30965. vignetteBlendMode: number;
  30966. private _vignetteEnabled;
  30967. /**
  30968. * Gets wether the vignette effect is enabled.
  30969. */
  30970. /**
  30971. * Sets wether the vignette effect is enabled.
  30972. */
  30973. vignetteEnabled: boolean;
  30974. private _applyByPostProcess;
  30975. /**
  30976. * Gets wether the image processing is applied through a post process or not.
  30977. */
  30978. /**
  30979. * Sets wether the image processing is applied through a post process or not.
  30980. */
  30981. applyByPostProcess: boolean;
  30982. private _isEnabled;
  30983. /**
  30984. * Gets wether the image processing is enabled or not.
  30985. */
  30986. /**
  30987. * Sets wether the image processing is enabled or not.
  30988. */
  30989. isEnabled: boolean;
  30990. /**
  30991. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30992. */
  30993. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30994. /**
  30995. * Method called each time the image processing information changes requires to recompile the effect.
  30996. */
  30997. protected _updateParameters(): void;
  30998. /**
  30999. * Gets the current class name.
  31000. * @return "ImageProcessingConfiguration"
  31001. */
  31002. getClassName(): string;
  31003. /**
  31004. * Prepare the list of uniforms associated with the Image Processing effects.
  31005. * @param uniforms The list of uniforms used in the effect
  31006. * @param defines the list of defines currently in use
  31007. */
  31008. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31009. /**
  31010. * Prepare the list of samplers associated with the Image Processing effects.
  31011. * @param samplersList The list of uniforms used in the effect
  31012. * @param defines the list of defines currently in use
  31013. */
  31014. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31015. /**
  31016. * Prepare the list of defines associated to the shader.
  31017. * @param defines the list of defines to complete
  31018. * @param forPostProcess Define if we are currently in post process mode or not
  31019. */
  31020. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31021. /**
  31022. * Returns true if all the image processing information are ready.
  31023. * @returns True if ready, otherwise, false
  31024. */
  31025. isReady(): boolean;
  31026. /**
  31027. * Binds the image processing to the shader.
  31028. * @param effect The effect to bind to
  31029. * @param aspectRatio Define the current aspect ratio of the effect
  31030. */
  31031. bind(effect: Effect, aspectRatio?: number): void;
  31032. /**
  31033. * Clones the current image processing instance.
  31034. * @return The cloned image processing
  31035. */
  31036. clone(): ImageProcessingConfiguration;
  31037. /**
  31038. * Serializes the current image processing instance to a json representation.
  31039. * @return a JSON representation
  31040. */
  31041. serialize(): any;
  31042. /**
  31043. * Parses the image processing from a json representation.
  31044. * @param source the JSON source to parse
  31045. * @return The parsed image processing
  31046. */
  31047. static Parse(source: any): ImageProcessingConfiguration;
  31048. private static _VIGNETTEMODE_MULTIPLY;
  31049. private static _VIGNETTEMODE_OPAQUE;
  31050. /**
  31051. * Used to apply the vignette as a mix with the pixel color.
  31052. */
  31053. static readonly VIGNETTEMODE_MULTIPLY: number;
  31054. /**
  31055. * Used to apply the vignette as a replacement of the pixel color.
  31056. */
  31057. static readonly VIGNETTEMODE_OPAQUE: number;
  31058. }
  31059. }
  31060. declare module "babylonjs/Materials/fresnelParameters" {
  31061. import { Color3 } from "babylonjs/Maths/math";
  31062. /**
  31063. * This represents all the required information to add a fresnel effect on a material:
  31064. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31065. */
  31066. export class FresnelParameters {
  31067. private _isEnabled;
  31068. /**
  31069. * Define if the fresnel effect is enable or not.
  31070. */
  31071. isEnabled: boolean;
  31072. /**
  31073. * Define the color used on edges (grazing angle)
  31074. */
  31075. leftColor: Color3;
  31076. /**
  31077. * Define the color used on center
  31078. */
  31079. rightColor: Color3;
  31080. /**
  31081. * Define bias applied to computed fresnel term
  31082. */
  31083. bias: number;
  31084. /**
  31085. * Defined the power exponent applied to fresnel term
  31086. */
  31087. power: number;
  31088. /**
  31089. * Clones the current fresnel and its valuues
  31090. * @returns a clone fresnel configuration
  31091. */
  31092. clone(): FresnelParameters;
  31093. /**
  31094. * Serializes the current fresnel parameters to a JSON representation.
  31095. * @return the JSON serialization
  31096. */
  31097. serialize(): any;
  31098. /**
  31099. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31100. * @param parsedFresnelParameters Define the JSON representation
  31101. * @returns the parsed parameters
  31102. */
  31103. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31104. }
  31105. }
  31106. declare module "babylonjs/Misc/decorators" {
  31107. import { Nullable } from "babylonjs/types";
  31108. import { Scene } from "babylonjs/scene";
  31109. import { IAnimatable } from "babylonjs/Misc/tools";
  31110. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31111. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31112. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31113. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31114. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31115. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31116. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31117. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31118. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31119. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31120. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31121. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31122. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31123. /**
  31124. * Decorator used to define property that can be serialized as reference to a camera
  31125. * @param sourceName defines the name of the property to decorate
  31126. */
  31127. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31128. /**
  31129. * Class used to help serialization objects
  31130. */
  31131. export class SerializationHelper {
  31132. /** @hidden */
  31133. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31134. /** @hidden */
  31135. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31136. /** @hidden */
  31137. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31138. /** @hidden */
  31139. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31140. /**
  31141. * Appends the serialized animations from the source animations
  31142. * @param source Source containing the animations
  31143. * @param destination Target to store the animations
  31144. */
  31145. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31146. /**
  31147. * Static function used to serialized a specific entity
  31148. * @param entity defines the entity to serialize
  31149. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31150. * @returns a JSON compatible object representing the serialization of the entity
  31151. */
  31152. static Serialize<T>(entity: T, serializationObject?: any): any;
  31153. /**
  31154. * Creates a new entity from a serialization data object
  31155. * @param creationFunction defines a function used to instanciated the new entity
  31156. * @param source defines the source serialization data
  31157. * @param scene defines the hosting scene
  31158. * @param rootUrl defines the root url for resources
  31159. * @returns a new entity
  31160. */
  31161. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31162. /**
  31163. * Clones an object
  31164. * @param creationFunction defines the function used to instanciate the new object
  31165. * @param source defines the source object
  31166. * @returns the cloned object
  31167. */
  31168. static Clone<T>(creationFunction: () => T, source: T): T;
  31169. /**
  31170. * Instanciates a new object based on a source one (some data will be shared between both object)
  31171. * @param creationFunction defines the function used to instanciate the new object
  31172. * @param source defines the source object
  31173. * @returns the new object
  31174. */
  31175. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31176. }
  31177. }
  31178. declare module "babylonjs/Cameras/camera" {
  31179. import { SmartArray } from "babylonjs/Misc/smartArray";
  31180. import { Observable } from "babylonjs/Misc/observable";
  31181. import { Nullable } from "babylonjs/types";
  31182. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31183. import { Scene } from "babylonjs/scene";
  31184. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31185. import { Node } from "babylonjs/node";
  31186. import { Mesh } from "babylonjs/Meshes/mesh";
  31187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31188. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31189. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31190. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31191. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31192. import { Ray } from "babylonjs/Culling/ray";
  31193. /**
  31194. * This is the base class of all the camera used in the application.
  31195. * @see http://doc.babylonjs.com/features/cameras
  31196. */
  31197. export class Camera extends Node {
  31198. /** @hidden */
  31199. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31200. /**
  31201. * This is the default projection mode used by the cameras.
  31202. * It helps recreating a feeling of perspective and better appreciate depth.
  31203. * This is the best way to simulate real life cameras.
  31204. */
  31205. static readonly PERSPECTIVE_CAMERA: number;
  31206. /**
  31207. * This helps creating camera with an orthographic mode.
  31208. * 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.
  31209. */
  31210. static readonly ORTHOGRAPHIC_CAMERA: number;
  31211. /**
  31212. * This is the default FOV mode for perspective cameras.
  31213. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31214. */
  31215. static readonly FOVMODE_VERTICAL_FIXED: number;
  31216. /**
  31217. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31218. */
  31219. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31220. /**
  31221. * This specifies ther is no need for a camera rig.
  31222. * Basically only one eye is rendered corresponding to the camera.
  31223. */
  31224. static readonly RIG_MODE_NONE: number;
  31225. /**
  31226. * Simulates a camera Rig with one blue eye and one red eye.
  31227. * This can be use with 3d blue and red glasses.
  31228. */
  31229. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31230. /**
  31231. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31232. */
  31233. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31234. /**
  31235. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31236. */
  31237. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31238. /**
  31239. * Defines that both eyes of the camera will be rendered over under each other.
  31240. */
  31241. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31242. /**
  31243. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31244. */
  31245. static readonly RIG_MODE_VR: number;
  31246. /**
  31247. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31248. */
  31249. static readonly RIG_MODE_WEBVR: number;
  31250. /**
  31251. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31252. */
  31253. static readonly RIG_MODE_CUSTOM: number;
  31254. /**
  31255. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31256. */
  31257. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31258. /**
  31259. * Define the input manager associated with the camera.
  31260. */
  31261. inputs: CameraInputsManager<Camera>;
  31262. /** @hidden */
  31263. _position: Vector3;
  31264. /**
  31265. * Define the current local position of the camera in the scene
  31266. */
  31267. position: Vector3;
  31268. /**
  31269. * The vector the camera should consider as up.
  31270. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31271. */
  31272. upVector: Vector3;
  31273. /**
  31274. * Define the current limit on the left side for an orthographic camera
  31275. * In scene unit
  31276. */
  31277. orthoLeft: Nullable<number>;
  31278. /**
  31279. * Define the current limit on the right side for an orthographic camera
  31280. * In scene unit
  31281. */
  31282. orthoRight: Nullable<number>;
  31283. /**
  31284. * Define the current limit on the bottom side for an orthographic camera
  31285. * In scene unit
  31286. */
  31287. orthoBottom: Nullable<number>;
  31288. /**
  31289. * Define the current limit on the top side for an orthographic camera
  31290. * In scene unit
  31291. */
  31292. orthoTop: Nullable<number>;
  31293. /**
  31294. * Field Of View is set in Radians. (default is 0.8)
  31295. */
  31296. fov: number;
  31297. /**
  31298. * Define the minimum distance the camera can see from.
  31299. * This is important to note that the depth buffer are not infinite and the closer it starts
  31300. * the more your scene might encounter depth fighting issue.
  31301. */
  31302. minZ: number;
  31303. /**
  31304. * Define the maximum distance the camera can see to.
  31305. * This is important to note that the depth buffer are not infinite and the further it end
  31306. * the more your scene might encounter depth fighting issue.
  31307. */
  31308. maxZ: number;
  31309. /**
  31310. * Define the default inertia of the camera.
  31311. * This helps giving a smooth feeling to the camera movement.
  31312. */
  31313. inertia: number;
  31314. /**
  31315. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31316. */
  31317. mode: number;
  31318. /**
  31319. * Define wether the camera is intermediate.
  31320. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31321. */
  31322. isIntermediate: boolean;
  31323. /**
  31324. * Define the viewport of the camera.
  31325. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31326. */
  31327. viewport: Viewport;
  31328. /**
  31329. * Restricts the camera to viewing objects with the same layerMask.
  31330. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31331. */
  31332. layerMask: number;
  31333. /**
  31334. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31335. */
  31336. fovMode: number;
  31337. /**
  31338. * Rig mode of the camera.
  31339. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31340. * This is normally controlled byt the camera themselves as internal use.
  31341. */
  31342. cameraRigMode: number;
  31343. /**
  31344. * Defines the distance between both "eyes" in case of a RIG
  31345. */
  31346. interaxialDistance: number;
  31347. /**
  31348. * Defines if stereoscopic rendering is done side by side or over under.
  31349. */
  31350. isStereoscopicSideBySide: boolean;
  31351. /**
  31352. * 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
  31353. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31354. * else in the scene.
  31355. */
  31356. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31357. /**
  31358. * When set, the camera will render to this render target instead of the default canvas
  31359. */
  31360. outputRenderTarget: Nullable<RenderTargetTexture>;
  31361. /**
  31362. * Observable triggered when the camera view matrix has changed.
  31363. */
  31364. onViewMatrixChangedObservable: Observable<Camera>;
  31365. /**
  31366. * Observable triggered when the camera Projection matrix has changed.
  31367. */
  31368. onProjectionMatrixChangedObservable: Observable<Camera>;
  31369. /**
  31370. * Observable triggered when the inputs have been processed.
  31371. */
  31372. onAfterCheckInputsObservable: Observable<Camera>;
  31373. /**
  31374. * Observable triggered when reset has been called and applied to the camera.
  31375. */
  31376. onRestoreStateObservable: Observable<Camera>;
  31377. /** @hidden */
  31378. _cameraRigParams: any;
  31379. /** @hidden */
  31380. _rigCameras: Camera[];
  31381. /** @hidden */
  31382. _rigPostProcess: Nullable<PostProcess>;
  31383. protected _webvrViewMatrix: Matrix;
  31384. /** @hidden */
  31385. _skipRendering: boolean;
  31386. /** @hidden */
  31387. _projectionMatrix: Matrix;
  31388. /** @hidden */
  31389. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31390. /** @hidden */
  31391. _activeMeshes: SmartArray<AbstractMesh>;
  31392. protected _globalPosition: Vector3;
  31393. /** @hidden */
  31394. _computedViewMatrix: Matrix;
  31395. private _doNotComputeProjectionMatrix;
  31396. private _transformMatrix;
  31397. private _frustumPlanes;
  31398. private _refreshFrustumPlanes;
  31399. private _storedFov;
  31400. private _stateStored;
  31401. /**
  31402. * Instantiates a new camera object.
  31403. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31404. * @see http://doc.babylonjs.com/features/cameras
  31405. * @param name Defines the name of the camera in the scene
  31406. * @param position Defines the position of the camera
  31407. * @param scene Defines the scene the camera belongs too
  31408. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31409. */
  31410. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31411. /**
  31412. * Store current camera state (fov, position, etc..)
  31413. * @returns the camera
  31414. */
  31415. storeState(): Camera;
  31416. /**
  31417. * Restores the camera state values if it has been stored. You must call storeState() first
  31418. */
  31419. protected _restoreStateValues(): boolean;
  31420. /**
  31421. * Restored camera state. You must call storeState() first.
  31422. * @returns true if restored and false otherwise
  31423. */
  31424. restoreState(): boolean;
  31425. /**
  31426. * Gets the class name of the camera.
  31427. * @returns the class name
  31428. */
  31429. getClassName(): string;
  31430. /** @hidden */
  31431. readonly _isCamera: boolean;
  31432. /**
  31433. * Gets a string representation of the camera useful for debug purpose.
  31434. * @param fullDetails Defines that a more verboe level of logging is required
  31435. * @returns the string representation
  31436. */
  31437. toString(fullDetails?: boolean): string;
  31438. /**
  31439. * Gets the current world space position of the camera.
  31440. */
  31441. readonly globalPosition: Vector3;
  31442. /**
  31443. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31444. * @returns the active meshe list
  31445. */
  31446. getActiveMeshes(): SmartArray<AbstractMesh>;
  31447. /**
  31448. * Check wether a mesh is part of the current active mesh list of the camera
  31449. * @param mesh Defines the mesh to check
  31450. * @returns true if active, false otherwise
  31451. */
  31452. isActiveMesh(mesh: Mesh): boolean;
  31453. /**
  31454. * Is this camera ready to be used/rendered
  31455. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31456. * @return true if the camera is ready
  31457. */
  31458. isReady(completeCheck?: boolean): boolean;
  31459. /** @hidden */
  31460. _initCache(): void;
  31461. /** @hidden */
  31462. _updateCache(ignoreParentClass?: boolean): void;
  31463. /** @hidden */
  31464. _isSynchronized(): boolean;
  31465. /** @hidden */
  31466. _isSynchronizedViewMatrix(): boolean;
  31467. /** @hidden */
  31468. _isSynchronizedProjectionMatrix(): boolean;
  31469. /**
  31470. * Attach the input controls to a specific dom element to get the input from.
  31471. * @param element Defines the element the controls should be listened from
  31472. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31473. */
  31474. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31475. /**
  31476. * Detach the current controls from the specified dom element.
  31477. * @param element Defines the element to stop listening the inputs from
  31478. */
  31479. detachControl(element: HTMLElement): void;
  31480. /**
  31481. * Update the camera state according to the different inputs gathered during the frame.
  31482. */
  31483. update(): void;
  31484. /** @hidden */
  31485. _checkInputs(): void;
  31486. /** @hidden */
  31487. readonly rigCameras: Camera[];
  31488. /**
  31489. * Gets the post process used by the rig cameras
  31490. */
  31491. readonly rigPostProcess: Nullable<PostProcess>;
  31492. /**
  31493. * Internal, gets the first post proces.
  31494. * @returns the first post process to be run on this camera.
  31495. */
  31496. _getFirstPostProcess(): Nullable<PostProcess>;
  31497. private _cascadePostProcessesToRigCams;
  31498. /**
  31499. * Attach a post process to the camera.
  31500. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31501. * @param postProcess The post process to attach to the camera
  31502. * @param insertAt The position of the post process in case several of them are in use in the scene
  31503. * @returns the position the post process has been inserted at
  31504. */
  31505. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31506. /**
  31507. * Detach a post process to the camera.
  31508. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31509. * @param postProcess The post process to detach from the camera
  31510. */
  31511. detachPostProcess(postProcess: PostProcess): void;
  31512. /**
  31513. * Gets the current world matrix of the camera
  31514. */
  31515. getWorldMatrix(): Matrix;
  31516. /** @hidden */
  31517. _getViewMatrix(): Matrix;
  31518. /**
  31519. * Gets the current view matrix of the camera.
  31520. * @param force forces the camera to recompute the matrix without looking at the cached state
  31521. * @returns the view matrix
  31522. */
  31523. getViewMatrix(force?: boolean): Matrix;
  31524. /**
  31525. * Freeze the projection matrix.
  31526. * It will prevent the cache check of the camera projection compute and can speed up perf
  31527. * if no parameter of the camera are meant to change
  31528. * @param projection Defines manually a projection if necessary
  31529. */
  31530. freezeProjectionMatrix(projection?: Matrix): void;
  31531. /**
  31532. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31533. */
  31534. unfreezeProjectionMatrix(): void;
  31535. /**
  31536. * Gets the current projection matrix of the camera.
  31537. * @param force forces the camera to recompute the matrix without looking at the cached state
  31538. * @returns the projection matrix
  31539. */
  31540. getProjectionMatrix(force?: boolean): Matrix;
  31541. /**
  31542. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31543. * @returns a Matrix
  31544. */
  31545. getTransformationMatrix(): Matrix;
  31546. private _updateFrustumPlanes;
  31547. /**
  31548. * Checks if a cullable object (mesh...) is in the camera frustum
  31549. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31550. * @param target The object to check
  31551. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31552. * @returns true if the object is in frustum otherwise false
  31553. */
  31554. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31555. /**
  31556. * Checks if a cullable object (mesh...) is in the camera frustum
  31557. * Unlike isInFrustum this cheks the full bounding box
  31558. * @param target The object to check
  31559. * @returns true if the object is in frustum otherwise false
  31560. */
  31561. isCompletelyInFrustum(target: ICullable): boolean;
  31562. /**
  31563. * Gets a ray in the forward direction from the camera.
  31564. * @param length Defines the length of the ray to create
  31565. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31566. * @param origin Defines the start point of the ray which defaults to the camera position
  31567. * @returns the forward ray
  31568. */
  31569. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31570. /**
  31571. * Releases resources associated with this node.
  31572. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31573. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31574. */
  31575. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31576. /** @hidden */
  31577. _isLeftCamera: boolean;
  31578. /**
  31579. * Gets the left camera of a rig setup in case of Rigged Camera
  31580. */
  31581. readonly isLeftCamera: boolean;
  31582. /** @hidden */
  31583. _isRightCamera: boolean;
  31584. /**
  31585. * Gets the right camera of a rig setup in case of Rigged Camera
  31586. */
  31587. readonly isRightCamera: boolean;
  31588. /**
  31589. * Gets the left camera of a rig setup in case of Rigged Camera
  31590. */
  31591. readonly leftCamera: Nullable<FreeCamera>;
  31592. /**
  31593. * Gets the right camera of a rig setup in case of Rigged Camera
  31594. */
  31595. readonly rightCamera: Nullable<FreeCamera>;
  31596. /**
  31597. * Gets the left camera target of a rig setup in case of Rigged Camera
  31598. * @returns the target position
  31599. */
  31600. getLeftTarget(): Nullable<Vector3>;
  31601. /**
  31602. * Gets the right camera target of a rig setup in case of Rigged Camera
  31603. * @returns the target position
  31604. */
  31605. getRightTarget(): Nullable<Vector3>;
  31606. /**
  31607. * @hidden
  31608. */
  31609. setCameraRigMode(mode: number, rigParams: any): void;
  31610. /** @hidden */
  31611. static _setStereoscopicRigMode(camera: Camera): void;
  31612. /** @hidden */
  31613. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31614. /** @hidden */
  31615. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31616. /** @hidden */
  31617. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31618. /** @hidden */
  31619. _getVRProjectionMatrix(): Matrix;
  31620. protected _updateCameraRotationMatrix(): void;
  31621. protected _updateWebVRCameraRotationMatrix(): void;
  31622. /**
  31623. * This function MUST be overwritten by the different WebVR cameras available.
  31624. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31625. * @hidden
  31626. */
  31627. _getWebVRProjectionMatrix(): Matrix;
  31628. /**
  31629. * This function MUST be overwritten by the different WebVR cameras available.
  31630. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31631. * @hidden
  31632. */
  31633. _getWebVRViewMatrix(): Matrix;
  31634. /** @hidden */
  31635. setCameraRigParameter(name: string, value: any): void;
  31636. /**
  31637. * needs to be overridden by children so sub has required properties to be copied
  31638. * @hidden
  31639. */
  31640. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31641. /**
  31642. * May need to be overridden by children
  31643. * @hidden
  31644. */
  31645. _updateRigCameras(): void;
  31646. /** @hidden */
  31647. _setupInputs(): void;
  31648. /**
  31649. * Serialiaze the camera setup to a json represention
  31650. * @returns the JSON representation
  31651. */
  31652. serialize(): any;
  31653. /**
  31654. * Clones the current camera.
  31655. * @param name The cloned camera name
  31656. * @returns the cloned camera
  31657. */
  31658. clone(name: string): Camera;
  31659. /**
  31660. * Gets the direction of the camera relative to a given local axis.
  31661. * @param localAxis Defines the reference axis to provide a relative direction.
  31662. * @return the direction
  31663. */
  31664. getDirection(localAxis: Vector3): Vector3;
  31665. /**
  31666. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31667. * @param localAxis Defines the reference axis to provide a relative direction.
  31668. * @param result Defines the vector to store the result in
  31669. */
  31670. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31671. /**
  31672. * Gets a camera constructor for a given camera type
  31673. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31674. * @param name The name of the camera the result will be able to instantiate
  31675. * @param scene The scene the result will construct the camera in
  31676. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31677. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31678. * @returns a factory method to construc the camera
  31679. */
  31680. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31681. /**
  31682. * Compute the world matrix of the camera.
  31683. * @returns the camera workd matrix
  31684. */
  31685. computeWorldMatrix(): Matrix;
  31686. /**
  31687. * Parse a JSON and creates the camera from the parsed information
  31688. * @param parsedCamera The JSON to parse
  31689. * @param scene The scene to instantiate the camera in
  31690. * @returns the newly constructed camera
  31691. */
  31692. static Parse(parsedCamera: any, scene: Scene): Camera;
  31693. }
  31694. }
  31695. declare module "babylonjs/Misc/tools" {
  31696. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31697. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31698. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31699. import { Observable } from "babylonjs/Misc/observable";
  31700. import { DomManagement } from "babylonjs/Misc/domManagement";
  31701. import { WebRequest } from "babylonjs/Misc/webRequest";
  31702. import { Camera } from "babylonjs/Cameras/camera";
  31703. import { Engine } from "babylonjs/Engines/engine";
  31704. import { Animation } from "babylonjs/Animations/animation";
  31705. /**
  31706. * Interface for any object that can request an animation frame
  31707. */
  31708. export interface ICustomAnimationFrameRequester {
  31709. /**
  31710. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31711. */
  31712. renderFunction?: Function;
  31713. /**
  31714. * Called to request the next frame to render to
  31715. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31716. */
  31717. requestAnimationFrame: Function;
  31718. /**
  31719. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31720. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31721. */
  31722. requestID?: number;
  31723. }
  31724. /**
  31725. * Interface containing an array of animations
  31726. */
  31727. export interface IAnimatable {
  31728. /**
  31729. * Array of animations
  31730. */
  31731. animations: Nullable<Array<Animation>>;
  31732. }
  31733. /** Interface used by value gradients (color, factor, ...) */
  31734. export interface IValueGradient {
  31735. /**
  31736. * Gets or sets the gradient value (between 0 and 1)
  31737. */
  31738. gradient: number;
  31739. }
  31740. /** Class used to store color4 gradient */
  31741. export class ColorGradient implements IValueGradient {
  31742. /**
  31743. * Gets or sets the gradient value (between 0 and 1)
  31744. */
  31745. gradient: number;
  31746. /**
  31747. * Gets or sets first associated color
  31748. */
  31749. color1: Color4;
  31750. /**
  31751. * Gets or sets second associated color
  31752. */
  31753. color2?: Color4;
  31754. /**
  31755. * Will get a color picked randomly between color1 and color2.
  31756. * If color2 is undefined then color1 will be used
  31757. * @param result defines the target Color4 to store the result in
  31758. */
  31759. getColorToRef(result: Color4): void;
  31760. }
  31761. /** Class used to store color 3 gradient */
  31762. export class Color3Gradient implements IValueGradient {
  31763. /**
  31764. * Gets or sets the gradient value (between 0 and 1)
  31765. */
  31766. gradient: number;
  31767. /**
  31768. * Gets or sets the associated color
  31769. */
  31770. color: Color3;
  31771. }
  31772. /** Class used to store factor gradient */
  31773. export class FactorGradient implements IValueGradient {
  31774. /**
  31775. * Gets or sets the gradient value (between 0 and 1)
  31776. */
  31777. gradient: number;
  31778. /**
  31779. * Gets or sets first associated factor
  31780. */
  31781. factor1: number;
  31782. /**
  31783. * Gets or sets second associated factor
  31784. */
  31785. factor2?: number;
  31786. /**
  31787. * Will get a number picked randomly between factor1 and factor2.
  31788. * If factor2 is undefined then factor1 will be used
  31789. * @returns the picked number
  31790. */
  31791. getFactor(): number;
  31792. }
  31793. /**
  31794. * @ignore
  31795. * Application error to support additional information when loading a file
  31796. */
  31797. export class LoadFileError extends Error {
  31798. /** defines the optional web request */
  31799. request?: WebRequest | undefined;
  31800. private static _setPrototypeOf;
  31801. /**
  31802. * Creates a new LoadFileError
  31803. * @param message defines the message of the error
  31804. * @param request defines the optional web request
  31805. */
  31806. constructor(message: string,
  31807. /** defines the optional web request */
  31808. request?: WebRequest | undefined);
  31809. }
  31810. /**
  31811. * Class used to define a retry strategy when error happens while loading assets
  31812. */
  31813. export class RetryStrategy {
  31814. /**
  31815. * Function used to defines an exponential back off strategy
  31816. * @param maxRetries defines the maximum number of retries (3 by default)
  31817. * @param baseInterval defines the interval between retries
  31818. * @returns the strategy function to use
  31819. */
  31820. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31821. }
  31822. /**
  31823. * File request interface
  31824. */
  31825. export interface IFileRequest {
  31826. /**
  31827. * Raised when the request is complete (success or error).
  31828. */
  31829. onCompleteObservable: Observable<IFileRequest>;
  31830. /**
  31831. * Aborts the request for a file.
  31832. */
  31833. abort: () => void;
  31834. }
  31835. /**
  31836. * Class containing a set of static utilities functions
  31837. */
  31838. export class Tools {
  31839. /**
  31840. * Gets or sets the base URL to use to load assets
  31841. */
  31842. static BaseUrl: string;
  31843. /**
  31844. * Enable/Disable Custom HTTP Request Headers globally.
  31845. * default = false
  31846. * @see CustomRequestHeaders
  31847. */
  31848. static UseCustomRequestHeaders: boolean;
  31849. /**
  31850. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31851. * i.e. when loading files, where the server/service expects an Authorization header
  31852. */
  31853. static CustomRequestHeaders: {
  31854. [key: string]: string;
  31855. };
  31856. /**
  31857. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31858. */
  31859. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31860. /**
  31861. * Default behaviour for cors in the application.
  31862. * It can be a string if the expected behavior is identical in the entire app.
  31863. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31864. */
  31865. static CorsBehavior: string | ((url: string | string[]) => string);
  31866. /**
  31867. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31868. * @ignorenaming
  31869. */
  31870. static UseFallbackTexture: boolean;
  31871. /**
  31872. * Use this object to register external classes like custom textures or material
  31873. * to allow the laoders to instantiate them
  31874. */
  31875. static RegisteredExternalClasses: {
  31876. [key: string]: Object;
  31877. };
  31878. /**
  31879. * Texture content used if a texture cannot loaded
  31880. * @ignorenaming
  31881. */
  31882. static fallbackTexture: string;
  31883. /**
  31884. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31885. * @param u defines the coordinate on X axis
  31886. * @param v defines the coordinate on Y axis
  31887. * @param width defines the width of the source data
  31888. * @param height defines the height of the source data
  31889. * @param pixels defines the source byte array
  31890. * @param color defines the output color
  31891. */
  31892. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31893. /**
  31894. * Interpolates between a and b via alpha
  31895. * @param a The lower value (returned when alpha = 0)
  31896. * @param b The upper value (returned when alpha = 1)
  31897. * @param alpha The interpolation-factor
  31898. * @return The mixed value
  31899. */
  31900. static Mix(a: number, b: number, alpha: number): number;
  31901. /**
  31902. * Tries to instantiate a new object from a given class name
  31903. * @param className defines the class name to instantiate
  31904. * @returns the new object or null if the system was not able to do the instantiation
  31905. */
  31906. static Instantiate(className: string): any;
  31907. /**
  31908. * Provides a slice function that will work even on IE
  31909. * @param data defines the array to slice
  31910. * @param start defines the start of the data (optional)
  31911. * @param end defines the end of the data (optional)
  31912. * @returns the new sliced array
  31913. */
  31914. static Slice<T>(data: T, start?: number, end?: number): T;
  31915. /**
  31916. * Polyfill for setImmediate
  31917. * @param action defines the action to execute after the current execution block
  31918. */
  31919. static SetImmediate(action: () => void): void;
  31920. /**
  31921. * Function indicating if a number is an exponent of 2
  31922. * @param value defines the value to test
  31923. * @returns true if the value is an exponent of 2
  31924. */
  31925. static IsExponentOfTwo(value: number): boolean;
  31926. private static _tmpFloatArray;
  31927. /**
  31928. * Returns the nearest 32-bit single precision float representation of a Number
  31929. * @param value A Number. If the parameter is of a different type, it will get converted
  31930. * to a number or to NaN if it cannot be converted
  31931. * @returns number
  31932. */
  31933. static FloatRound(value: number): number;
  31934. /**
  31935. * Find the next highest power of two.
  31936. * @param x Number to start search from.
  31937. * @return Next highest power of two.
  31938. */
  31939. static CeilingPOT(x: number): number;
  31940. /**
  31941. * Find the next lowest power of two.
  31942. * @param x Number to start search from.
  31943. * @return Next lowest power of two.
  31944. */
  31945. static FloorPOT(x: number): number;
  31946. /**
  31947. * Find the nearest power of two.
  31948. * @param x Number to start search from.
  31949. * @return Next nearest power of two.
  31950. */
  31951. static NearestPOT(x: number): number;
  31952. /**
  31953. * Get the closest exponent of two
  31954. * @param value defines the value to approximate
  31955. * @param max defines the maximum value to return
  31956. * @param mode defines how to define the closest value
  31957. * @returns closest exponent of two of the given value
  31958. */
  31959. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31960. /**
  31961. * Extracts the filename from a path
  31962. * @param path defines the path to use
  31963. * @returns the filename
  31964. */
  31965. static GetFilename(path: string): string;
  31966. /**
  31967. * Extracts the "folder" part of a path (everything before the filename).
  31968. * @param uri The URI to extract the info from
  31969. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31970. * @returns The "folder" part of the path
  31971. */
  31972. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31973. /**
  31974. * Extracts text content from a DOM element hierarchy
  31975. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31976. */
  31977. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31978. /**
  31979. * Convert an angle in radians to degrees
  31980. * @param angle defines the angle to convert
  31981. * @returns the angle in degrees
  31982. */
  31983. static ToDegrees(angle: number): number;
  31984. /**
  31985. * Convert an angle in degrees to radians
  31986. * @param angle defines the angle to convert
  31987. * @returns the angle in radians
  31988. */
  31989. static ToRadians(angle: number): number;
  31990. /**
  31991. * Encode a buffer to a base64 string
  31992. * @param buffer defines the buffer to encode
  31993. * @returns the encoded string
  31994. */
  31995. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31996. /**
  31997. * Extracts minimum and maximum values from a list of indexed positions
  31998. * @param positions defines the positions to use
  31999. * @param indices defines the indices to the positions
  32000. * @param indexStart defines the start index
  32001. * @param indexCount defines the end index
  32002. * @param bias defines bias value to add to the result
  32003. * @return minimum and maximum values
  32004. */
  32005. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32006. minimum: Vector3;
  32007. maximum: Vector3;
  32008. };
  32009. /**
  32010. * Extracts minimum and maximum values from a list of positions
  32011. * @param positions defines the positions to use
  32012. * @param start defines the start index in the positions array
  32013. * @param count defines the number of positions to handle
  32014. * @param bias defines bias value to add to the result
  32015. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32016. * @return minimum and maximum values
  32017. */
  32018. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32019. minimum: Vector3;
  32020. maximum: Vector3;
  32021. };
  32022. /**
  32023. * Returns an array if obj is not an array
  32024. * @param obj defines the object to evaluate as an array
  32025. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32026. * @returns either obj directly if obj is an array or a new array containing obj
  32027. */
  32028. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32029. /**
  32030. * Gets the pointer prefix to use
  32031. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32032. */
  32033. static GetPointerPrefix(): string;
  32034. /**
  32035. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32036. * @param func - the function to be called
  32037. * @param requester - the object that will request the next frame. Falls back to window.
  32038. * @returns frame number
  32039. */
  32040. static QueueNewFrame(func: () => void, requester?: any): number;
  32041. /**
  32042. * Ask the browser to promote the current element to fullscreen rendering mode
  32043. * @param element defines the DOM element to promote
  32044. */
  32045. static RequestFullscreen(element: HTMLElement): void;
  32046. /**
  32047. * Asks the browser to exit fullscreen mode
  32048. */
  32049. static ExitFullscreen(): void;
  32050. /**
  32051. * Ask the browser to promote the current element to pointerlock mode
  32052. * @param element defines the DOM element to promote
  32053. */
  32054. static RequestPointerlock(element: HTMLElement): void;
  32055. /**
  32056. * Asks the browser to exit pointerlock mode
  32057. */
  32058. static ExitPointerlock(): void;
  32059. /**
  32060. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32061. * @param url define the url we are trying
  32062. * @param element define the dom element where to configure the cors policy
  32063. */
  32064. static SetCorsBehavior(url: string | string[], element: {
  32065. crossOrigin: string | null;
  32066. }): void;
  32067. /**
  32068. * Removes unwanted characters from an url
  32069. * @param url defines the url to clean
  32070. * @returns the cleaned url
  32071. */
  32072. static CleanUrl(url: string): string;
  32073. /**
  32074. * Gets or sets a function used to pre-process url before using them to load assets
  32075. */
  32076. static PreprocessUrl: (url: string) => string;
  32077. /**
  32078. * Loads an image as an HTMLImageElement.
  32079. * @param input url string, ArrayBuffer, or Blob to load
  32080. * @param onLoad callback called when the image successfully loads
  32081. * @param onError callback called when the image fails to load
  32082. * @param offlineProvider offline provider for caching
  32083. * @returns the HTMLImageElement of the loaded image
  32084. */
  32085. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32086. /**
  32087. * Loads a file
  32088. * @param url url string, ArrayBuffer, or Blob to load
  32089. * @param onSuccess callback called when the file successfully loads
  32090. * @param onProgress callback called while file is loading (if the server supports this mode)
  32091. * @param offlineProvider defines the offline provider for caching
  32092. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32093. * @param onError callback called when the file fails to load
  32094. * @returns a file request object
  32095. */
  32096. 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;
  32097. /**
  32098. * Load a script (identified by an url). When the url returns, the
  32099. * content of this file is added into a new script element, attached to the DOM (body element)
  32100. * @param scriptUrl defines the url of the script to laod
  32101. * @param onSuccess defines the callback called when the script is loaded
  32102. * @param onError defines the callback to call if an error occurs
  32103. * @param scriptId defines the id of the script element
  32104. */
  32105. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32106. /**
  32107. * Load an asynchronous script (identified by an url). When the url returns, the
  32108. * content of this file is added into a new script element, attached to the DOM (body element)
  32109. * @param scriptUrl defines the url of the script to laod
  32110. * @param scriptId defines the id of the script element
  32111. * @returns a promise request object
  32112. */
  32113. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  32114. /**
  32115. * Loads a file from a blob
  32116. * @param fileToLoad defines the blob to use
  32117. * @param callback defines the callback to call when data is loaded
  32118. * @param progressCallback defines the callback to call during loading process
  32119. * @returns a file request object
  32120. */
  32121. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32122. /**
  32123. * Loads a file
  32124. * @param fileToLoad defines the file to load
  32125. * @param callback defines the callback to call when data is loaded
  32126. * @param progressCallBack defines the callback to call during loading process
  32127. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32128. * @returns a file request object
  32129. */
  32130. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32131. /**
  32132. * Creates a data url from a given string content
  32133. * @param content defines the content to convert
  32134. * @returns the new data url link
  32135. */
  32136. static FileAsURL(content: string): string;
  32137. /**
  32138. * Format the given number to a specific decimal format
  32139. * @param value defines the number to format
  32140. * @param decimals defines the number of decimals to use
  32141. * @returns the formatted string
  32142. */
  32143. static Format(value: number, decimals?: number): string;
  32144. /**
  32145. * Checks if a given vector is inside a specific range
  32146. * @param v defines the vector to test
  32147. * @param min defines the minimum range
  32148. * @param max defines the maximum range
  32149. */
  32150. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32151. /**
  32152. * Tries to copy an object by duplicating every property
  32153. * @param source defines the source object
  32154. * @param destination defines the target object
  32155. * @param doNotCopyList defines a list of properties to avoid
  32156. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32157. */
  32158. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32159. /**
  32160. * Gets a boolean indicating if the given object has no own property
  32161. * @param obj defines the object to test
  32162. * @returns true if object has no own property
  32163. */
  32164. static IsEmpty(obj: any): boolean;
  32165. /**
  32166. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  32167. * @param str Source string
  32168. * @param suffix Suffix to search for in the source string
  32169. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32170. */
  32171. static EndsWith(str: string, suffix: string): boolean;
  32172. /**
  32173. * Function used to register events at window level
  32174. * @param events defines the events to register
  32175. */
  32176. static RegisterTopRootEvents(events: {
  32177. name: string;
  32178. handler: Nullable<(e: FocusEvent) => any>;
  32179. }[]): void;
  32180. /**
  32181. * Function used to unregister events from window level
  32182. * @param events defines the events to unregister
  32183. */
  32184. static UnregisterTopRootEvents(events: {
  32185. name: string;
  32186. handler: Nullable<(e: FocusEvent) => any>;
  32187. }[]): void;
  32188. /**
  32189. * @ignore
  32190. */
  32191. static _ScreenshotCanvas: HTMLCanvasElement;
  32192. /**
  32193. * Dumps the current bound framebuffer
  32194. * @param width defines the rendering width
  32195. * @param height defines the rendering height
  32196. * @param engine defines the hosting engine
  32197. * @param successCallback defines the callback triggered once the data are available
  32198. * @param mimeType defines the mime type of the result
  32199. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32200. */
  32201. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32202. /**
  32203. * Converts the canvas data to blob.
  32204. * This acts as a polyfill for browsers not supporting the to blob function.
  32205. * @param canvas Defines the canvas to extract the data from
  32206. * @param successCallback Defines the callback triggered once the data are available
  32207. * @param mimeType Defines the mime type of the result
  32208. */
  32209. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32210. /**
  32211. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32212. * @param successCallback defines the callback triggered once the data are available
  32213. * @param mimeType defines the mime type of the result
  32214. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32215. */
  32216. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32217. /**
  32218. * Downloads a blob in the browser
  32219. * @param blob defines the blob to download
  32220. * @param fileName defines the name of the downloaded file
  32221. */
  32222. static Download(blob: Blob, fileName: string): void;
  32223. /**
  32224. * Captures a screenshot of the current rendering
  32225. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32226. * @param engine defines the rendering engine
  32227. * @param camera defines the source camera
  32228. * @param size This parameter can be set to a single number or to an object with the
  32229. * following (optional) properties: precision, width, height. If a single number is passed,
  32230. * it will be used for both width and height. If an object is passed, the screenshot size
  32231. * will be derived from the parameters. The precision property is a multiplier allowing
  32232. * rendering at a higher or lower resolution
  32233. * @param successCallback defines the callback receives a single parameter which contains the
  32234. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32235. * src parameter of an <img> to display it
  32236. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32237. * Check your browser for supported MIME types
  32238. */
  32239. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32240. /**
  32241. * Generates an image screenshot from the specified camera.
  32242. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32243. * @param engine The engine to use for rendering
  32244. * @param camera The camera to use for rendering
  32245. * @param size This parameter can be set to a single number or to an object with the
  32246. * following (optional) properties: precision, width, height. If a single number is passed,
  32247. * it will be used for both width and height. If an object is passed, the screenshot size
  32248. * will be derived from the parameters. The precision property is a multiplier allowing
  32249. * rendering at a higher or lower resolution
  32250. * @param successCallback The callback receives a single parameter which contains the
  32251. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32252. * src parameter of an <img> to display it
  32253. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32254. * Check your browser for supported MIME types
  32255. * @param samples Texture samples (default: 1)
  32256. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32257. * @param fileName A name for for the downloaded file.
  32258. */
  32259. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32260. /**
  32261. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32262. * Be aware Math.random() could cause collisions, but:
  32263. * "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"
  32264. * @returns a pseudo random id
  32265. */
  32266. static RandomId(): string;
  32267. /**
  32268. * Test if the given uri is a base64 string
  32269. * @param uri The uri to test
  32270. * @return True if the uri is a base64 string or false otherwise
  32271. */
  32272. static IsBase64(uri: string): boolean;
  32273. /**
  32274. * Decode the given base64 uri.
  32275. * @param uri The uri to decode
  32276. * @return The decoded base64 data.
  32277. */
  32278. static DecodeBase64(uri: string): ArrayBuffer;
  32279. /**
  32280. * Gets the absolute url.
  32281. * @param url the input url
  32282. * @return the absolute url
  32283. */
  32284. static GetAbsoluteUrl(url: string): string;
  32285. /**
  32286. * No log
  32287. */
  32288. static readonly NoneLogLevel: number;
  32289. /**
  32290. * Only message logs
  32291. */
  32292. static readonly MessageLogLevel: number;
  32293. /**
  32294. * Only warning logs
  32295. */
  32296. static readonly WarningLogLevel: number;
  32297. /**
  32298. * Only error logs
  32299. */
  32300. static readonly ErrorLogLevel: number;
  32301. /**
  32302. * All logs
  32303. */
  32304. static readonly AllLogLevel: number;
  32305. /**
  32306. * Gets a value indicating the number of loading errors
  32307. * @ignorenaming
  32308. */
  32309. static readonly errorsCount: number;
  32310. /**
  32311. * Callback called when a new log is added
  32312. */
  32313. static OnNewCacheEntry: (entry: string) => void;
  32314. /**
  32315. * Log a message to the console
  32316. * @param message defines the message to log
  32317. */
  32318. static Log(message: string): void;
  32319. /**
  32320. * Write a warning message to the console
  32321. * @param message defines the message to log
  32322. */
  32323. static Warn(message: string): void;
  32324. /**
  32325. * Write an error message to the console
  32326. * @param message defines the message to log
  32327. */
  32328. static Error(message: string): void;
  32329. /**
  32330. * Gets current log cache (list of logs)
  32331. */
  32332. static readonly LogCache: string;
  32333. /**
  32334. * Clears the log cache
  32335. */
  32336. static ClearLogCache(): void;
  32337. /**
  32338. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32339. */
  32340. static LogLevels: number;
  32341. /**
  32342. * Checks if the loaded document was accessed via `file:`-Protocol.
  32343. * @returns boolean
  32344. */
  32345. static IsFileURL(): boolean;
  32346. /**
  32347. * Checks if the window object exists
  32348. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32349. */
  32350. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32351. /**
  32352. * No performance log
  32353. */
  32354. static readonly PerformanceNoneLogLevel: number;
  32355. /**
  32356. * Use user marks to log performance
  32357. */
  32358. static readonly PerformanceUserMarkLogLevel: number;
  32359. /**
  32360. * Log performance to the console
  32361. */
  32362. static readonly PerformanceConsoleLogLevel: number;
  32363. private static _performance;
  32364. /**
  32365. * Sets the current performance log level
  32366. */
  32367. static PerformanceLogLevel: number;
  32368. private static _StartPerformanceCounterDisabled;
  32369. private static _EndPerformanceCounterDisabled;
  32370. private static _StartUserMark;
  32371. private static _EndUserMark;
  32372. private static _StartPerformanceConsole;
  32373. private static _EndPerformanceConsole;
  32374. /**
  32375. * Starts a performance counter
  32376. */
  32377. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32378. /**
  32379. * Ends a specific performance coutner
  32380. */
  32381. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32382. /**
  32383. * Gets either window.performance.now() if supported or Date.now() else
  32384. */
  32385. static readonly Now: number;
  32386. /**
  32387. * This method will return the name of the class used to create the instance of the given object.
  32388. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32389. * @param object the object to get the class name from
  32390. * @param isType defines if the object is actually a type
  32391. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32392. */
  32393. static GetClassName(object: any, isType?: boolean): string;
  32394. /**
  32395. * Gets the first element of an array satisfying a given predicate
  32396. * @param array defines the array to browse
  32397. * @param predicate defines the predicate to use
  32398. * @returns null if not found or the element
  32399. */
  32400. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32401. /**
  32402. * This method will return the name of the full name of the class, including its owning module (if any).
  32403. * 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).
  32404. * @param object the object to get the class name from
  32405. * @param isType defines if the object is actually a type
  32406. * @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.
  32407. * @ignorenaming
  32408. */
  32409. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32410. /**
  32411. * Returns a promise that resolves after the given amount of time.
  32412. * @param delay Number of milliseconds to delay
  32413. * @returns Promise that resolves after the given amount of time
  32414. */
  32415. static DelayAsync(delay: number): Promise<void>;
  32416. /**
  32417. * Gets the current gradient from an array of IValueGradient
  32418. * @param ratio defines the current ratio to get
  32419. * @param gradients defines the array of IValueGradient
  32420. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32421. */
  32422. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32423. }
  32424. /**
  32425. * This class is used to track a performance counter which is number based.
  32426. * The user has access to many properties which give statistics of different nature.
  32427. *
  32428. * The implementer can track two kinds of Performance Counter: time and count.
  32429. * 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.
  32430. * 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.
  32431. */
  32432. export class PerfCounter {
  32433. /**
  32434. * Gets or sets a global boolean to turn on and off all the counters
  32435. */
  32436. static Enabled: boolean;
  32437. /**
  32438. * Returns the smallest value ever
  32439. */
  32440. readonly min: number;
  32441. /**
  32442. * Returns the biggest value ever
  32443. */
  32444. readonly max: number;
  32445. /**
  32446. * Returns the average value since the performance counter is running
  32447. */
  32448. readonly average: number;
  32449. /**
  32450. * Returns the average value of the last second the counter was monitored
  32451. */
  32452. readonly lastSecAverage: number;
  32453. /**
  32454. * Returns the current value
  32455. */
  32456. readonly current: number;
  32457. /**
  32458. * Gets the accumulated total
  32459. */
  32460. readonly total: number;
  32461. /**
  32462. * Gets the total value count
  32463. */
  32464. readonly count: number;
  32465. /**
  32466. * Creates a new counter
  32467. */
  32468. constructor();
  32469. /**
  32470. * Call this method to start monitoring a new frame.
  32471. * 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.
  32472. */
  32473. fetchNewFrame(): void;
  32474. /**
  32475. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32476. * @param newCount the count value to add to the monitored count
  32477. * @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.
  32478. */
  32479. addCount(newCount: number, fetchResult: boolean): void;
  32480. /**
  32481. * Start monitoring this performance counter
  32482. */
  32483. beginMonitoring(): void;
  32484. /**
  32485. * Compute the time lapsed since the previous beginMonitoring() call.
  32486. * @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
  32487. */
  32488. endMonitoring(newFrame?: boolean): void;
  32489. private _fetchResult;
  32490. private _startMonitoringTime;
  32491. private _min;
  32492. private _max;
  32493. private _average;
  32494. private _current;
  32495. private _totalValueCount;
  32496. private _totalAccumulated;
  32497. private _lastSecAverage;
  32498. private _lastSecAccumulated;
  32499. private _lastSecTime;
  32500. private _lastSecValueCount;
  32501. }
  32502. /**
  32503. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32504. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32505. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32506. * @param name The name of the class, case should be preserved
  32507. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32508. */
  32509. export function className(name: string, module?: string): (target: Object) => void;
  32510. /**
  32511. * An implementation of a loop for asynchronous functions.
  32512. */
  32513. export class AsyncLoop {
  32514. /**
  32515. * Defines the number of iterations for the loop
  32516. */
  32517. iterations: number;
  32518. /**
  32519. * Defines the current index of the loop.
  32520. */
  32521. index: number;
  32522. private _done;
  32523. private _fn;
  32524. private _successCallback;
  32525. /**
  32526. * Constructor.
  32527. * @param iterations the number of iterations.
  32528. * @param func the function to run each iteration
  32529. * @param successCallback the callback that will be called upon succesful execution
  32530. * @param offset starting offset.
  32531. */
  32532. constructor(
  32533. /**
  32534. * Defines the number of iterations for the loop
  32535. */
  32536. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32537. /**
  32538. * Execute the next iteration. Must be called after the last iteration was finished.
  32539. */
  32540. executeNext(): void;
  32541. /**
  32542. * Break the loop and run the success callback.
  32543. */
  32544. breakLoop(): void;
  32545. /**
  32546. * Create and run an async loop.
  32547. * @param iterations the number of iterations.
  32548. * @param fn the function to run each iteration
  32549. * @param successCallback the callback that will be called upon succesful execution
  32550. * @param offset starting offset.
  32551. * @returns the created async loop object
  32552. */
  32553. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32554. /**
  32555. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32556. * @param iterations total number of iterations
  32557. * @param syncedIterations number of synchronous iterations in each async iteration.
  32558. * @param fn the function to call each iteration.
  32559. * @param callback a success call back that will be called when iterating stops.
  32560. * @param breakFunction a break condition (optional)
  32561. * @param timeout timeout settings for the setTimeout function. default - 0.
  32562. * @returns the created async loop object
  32563. */
  32564. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32565. }
  32566. }
  32567. declare module "babylonjs/Collisions/collisionCoordinator" {
  32568. import { Nullable } from "babylonjs/types";
  32569. import { Scene } from "babylonjs/scene";
  32570. import { Vector3 } from "babylonjs/Maths/math";
  32571. import { Collider } from "babylonjs/Collisions/collider";
  32572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32573. /** @hidden */
  32574. export interface ICollisionCoordinator {
  32575. createCollider(): Collider;
  32576. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32577. init(scene: Scene): void;
  32578. }
  32579. /** @hidden */
  32580. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32581. private _scene;
  32582. private _scaledPosition;
  32583. private _scaledVelocity;
  32584. private _finalPosition;
  32585. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32586. createCollider(): Collider;
  32587. init(scene: Scene): void;
  32588. private _collideWithWorld;
  32589. }
  32590. }
  32591. declare module "babylonjs/Inputs/scene.inputManager" {
  32592. import { Nullable } from "babylonjs/types";
  32593. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32594. import { Vector2 } from "babylonjs/Maths/math";
  32595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32596. import { Scene } from "babylonjs/scene";
  32597. /**
  32598. * Class used to manage all inputs for the scene.
  32599. */
  32600. export class InputManager {
  32601. /** The distance in pixel that you have to move to prevent some events */
  32602. static DragMovementThreshold: number;
  32603. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32604. static LongPressDelay: number;
  32605. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32606. static DoubleClickDelay: number;
  32607. /** If you need to check double click without raising a single click at first click, enable this flag */
  32608. static ExclusiveDoubleClickMode: boolean;
  32609. private _wheelEventName;
  32610. private _onPointerMove;
  32611. private _onPointerDown;
  32612. private _onPointerUp;
  32613. private _initClickEvent;
  32614. private _initActionManager;
  32615. private _delayedSimpleClick;
  32616. private _delayedSimpleClickTimeout;
  32617. private _previousDelayedSimpleClickTimeout;
  32618. private _meshPickProceed;
  32619. private _previousButtonPressed;
  32620. private _currentPickResult;
  32621. private _previousPickResult;
  32622. private _totalPointersPressed;
  32623. private _doubleClickOccured;
  32624. private _pointerOverMesh;
  32625. private _pickedDownMesh;
  32626. private _pickedUpMesh;
  32627. private _pointerX;
  32628. private _pointerY;
  32629. private _unTranslatedPointerX;
  32630. private _unTranslatedPointerY;
  32631. private _startingPointerPosition;
  32632. private _previousStartingPointerPosition;
  32633. private _startingPointerTime;
  32634. private _previousStartingPointerTime;
  32635. private _pointerCaptures;
  32636. private _onKeyDown;
  32637. private _onKeyUp;
  32638. private _onCanvasFocusObserver;
  32639. private _onCanvasBlurObserver;
  32640. private _scene;
  32641. /**
  32642. * Creates a new InputManager
  32643. * @param scene defines the hosting scene
  32644. */
  32645. constructor(scene: Scene);
  32646. /**
  32647. * Gets the mesh that is currently under the pointer
  32648. */
  32649. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32650. /**
  32651. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32652. */
  32653. readonly unTranslatedPointer: Vector2;
  32654. /**
  32655. * Gets or sets the current on-screen X position of the pointer
  32656. */
  32657. pointerX: number;
  32658. /**
  32659. * Gets or sets the current on-screen Y position of the pointer
  32660. */
  32661. pointerY: number;
  32662. private _updatePointerPosition;
  32663. private _processPointerMove;
  32664. private _setRayOnPointerInfo;
  32665. private _checkPrePointerObservable;
  32666. /**
  32667. * Use this method to simulate a pointer move on a mesh
  32668. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32669. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32670. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32671. */
  32672. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32673. /**
  32674. * Use this method to simulate a pointer down on a mesh
  32675. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32676. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32677. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32678. */
  32679. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32680. private _processPointerDown;
  32681. /** @hidden */
  32682. _isPointerSwiping(): boolean;
  32683. /**
  32684. * Use this method to simulate a pointer up on a mesh
  32685. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32686. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32687. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32688. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32689. */
  32690. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32691. private _processPointerUp;
  32692. /**
  32693. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32694. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32695. * @returns true if the pointer was captured
  32696. */
  32697. isPointerCaptured(pointerId?: number): boolean;
  32698. /**
  32699. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32700. * @param attachUp defines if you want to attach events to pointerup
  32701. * @param attachDown defines if you want to attach events to pointerdown
  32702. * @param attachMove defines if you want to attach events to pointermove
  32703. */
  32704. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32705. /**
  32706. * Detaches all event handlers
  32707. */
  32708. detachControl(): void;
  32709. /**
  32710. * Force the value of meshUnderPointer
  32711. * @param mesh defines the mesh to use
  32712. */
  32713. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32714. /**
  32715. * Gets the mesh under the pointer
  32716. * @returns a Mesh or null if no mesh is under the pointer
  32717. */
  32718. getPointerOverMesh(): Nullable<AbstractMesh>;
  32719. }
  32720. }
  32721. declare module "babylonjs/Animations/animationGroup" {
  32722. import { Animatable } from "babylonjs/Animations/animatable";
  32723. import { Animation } from "babylonjs/Animations/animation";
  32724. import { Scene, IDisposable } from "babylonjs/scene";
  32725. import { Observable } from "babylonjs/Misc/observable";
  32726. import { Nullable } from "babylonjs/types";
  32727. import "babylonjs/Animations/animatable";
  32728. /**
  32729. * This class defines the direct association between an animation and a target
  32730. */
  32731. export class TargetedAnimation {
  32732. /**
  32733. * Animation to perform
  32734. */
  32735. animation: Animation;
  32736. /**
  32737. * Target to animate
  32738. */
  32739. target: any;
  32740. /**
  32741. * Serialize the object
  32742. * @returns the JSON object representing the current entity
  32743. */
  32744. serialize(): any;
  32745. }
  32746. /**
  32747. * Use this class to create coordinated animations on multiple targets
  32748. */
  32749. export class AnimationGroup implements IDisposable {
  32750. /** The name of the animation group */
  32751. name: string;
  32752. private _scene;
  32753. private _targetedAnimations;
  32754. private _animatables;
  32755. private _from;
  32756. private _to;
  32757. private _isStarted;
  32758. private _isPaused;
  32759. private _speedRatio;
  32760. private _loopAnimation;
  32761. /**
  32762. * Gets or sets the unique id of the node
  32763. */
  32764. uniqueId: number;
  32765. /**
  32766. * This observable will notify when one animation have ended
  32767. */
  32768. onAnimationEndObservable: Observable<TargetedAnimation>;
  32769. /**
  32770. * Observer raised when one animation loops
  32771. */
  32772. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32773. /**
  32774. * This observable will notify when all animations have ended.
  32775. */
  32776. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32777. /**
  32778. * This observable will notify when all animations have paused.
  32779. */
  32780. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32781. /**
  32782. * This observable will notify when all animations are playing.
  32783. */
  32784. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32785. /**
  32786. * Gets the first frame
  32787. */
  32788. readonly from: number;
  32789. /**
  32790. * Gets the last frame
  32791. */
  32792. readonly to: number;
  32793. /**
  32794. * Define if the animations are started
  32795. */
  32796. readonly isStarted: boolean;
  32797. /**
  32798. * Gets a value indicating that the current group is playing
  32799. */
  32800. readonly isPlaying: boolean;
  32801. /**
  32802. * Gets or sets the speed ratio to use for all animations
  32803. */
  32804. /**
  32805. * Gets or sets the speed ratio to use for all animations
  32806. */
  32807. speedRatio: number;
  32808. /**
  32809. * Gets or sets if all animations should loop or not
  32810. */
  32811. loopAnimation: boolean;
  32812. /**
  32813. * Gets the targeted animations for this animation group
  32814. */
  32815. readonly targetedAnimations: Array<TargetedAnimation>;
  32816. /**
  32817. * returning the list of animatables controlled by this animation group.
  32818. */
  32819. readonly animatables: Array<Animatable>;
  32820. /**
  32821. * Instantiates a new Animation Group.
  32822. * This helps managing several animations at once.
  32823. * @see http://doc.babylonjs.com/how_to/group
  32824. * @param name Defines the name of the group
  32825. * @param scene Defines the scene the group belongs to
  32826. */
  32827. constructor(
  32828. /** The name of the animation group */
  32829. name: string, scene?: Nullable<Scene>);
  32830. /**
  32831. * Add an animation (with its target) in the group
  32832. * @param animation defines the animation we want to add
  32833. * @param target defines the target of the animation
  32834. * @returns the TargetedAnimation object
  32835. */
  32836. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32837. /**
  32838. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32839. * It can add constant keys at begin or end
  32840. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32841. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32842. * @returns the animation group
  32843. */
  32844. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32845. /**
  32846. * Start all animations on given targets
  32847. * @param loop defines if animations must loop
  32848. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32849. * @param from defines the from key (optional)
  32850. * @param to defines the to key (optional)
  32851. * @returns the current animation group
  32852. */
  32853. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32854. /**
  32855. * Pause all animations
  32856. * @returns the animation group
  32857. */
  32858. pause(): AnimationGroup;
  32859. /**
  32860. * Play all animations to initial state
  32861. * This function will start() the animations if they were not started or will restart() them if they were paused
  32862. * @param loop defines if animations must loop
  32863. * @returns the animation group
  32864. */
  32865. play(loop?: boolean): AnimationGroup;
  32866. /**
  32867. * Reset all animations to initial state
  32868. * @returns the animation group
  32869. */
  32870. reset(): AnimationGroup;
  32871. /**
  32872. * Restart animations from key 0
  32873. * @returns the animation group
  32874. */
  32875. restart(): AnimationGroup;
  32876. /**
  32877. * Stop all animations
  32878. * @returns the animation group
  32879. */
  32880. stop(): AnimationGroup;
  32881. /**
  32882. * Set animation weight for all animatables
  32883. * @param weight defines the weight to use
  32884. * @return the animationGroup
  32885. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32886. */
  32887. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32888. /**
  32889. * Synchronize and normalize all animatables with a source animatable
  32890. * @param root defines the root animatable to synchronize with
  32891. * @return the animationGroup
  32892. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32893. */
  32894. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32895. /**
  32896. * Goes to a specific frame in this animation group
  32897. * @param frame the frame number to go to
  32898. * @return the animationGroup
  32899. */
  32900. goToFrame(frame: number): AnimationGroup;
  32901. /**
  32902. * Dispose all associated resources
  32903. */
  32904. dispose(): void;
  32905. private _checkAnimationGroupEnded;
  32906. /**
  32907. * Clone the current animation group and returns a copy
  32908. * @param newName defines the name of the new group
  32909. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32910. * @returns the new aniamtion group
  32911. */
  32912. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32913. /**
  32914. * Serializes the animationGroup to an object
  32915. * @returns Serialized object
  32916. */
  32917. serialize(): any;
  32918. /**
  32919. * Returns a new AnimationGroup object parsed from the source provided.
  32920. * @param parsedAnimationGroup defines the source
  32921. * @param scene defines the scene that will receive the animationGroup
  32922. * @returns a new AnimationGroup
  32923. */
  32924. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32925. /**
  32926. * Returns the string "AnimationGroup"
  32927. * @returns "AnimationGroup"
  32928. */
  32929. getClassName(): string;
  32930. /**
  32931. * Creates a detailled string about the object
  32932. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32933. * @returns a string representing the object
  32934. */
  32935. toString(fullDetails?: boolean): string;
  32936. }
  32937. }
  32938. declare module "babylonjs/scene" {
  32939. import { Nullable } from "babylonjs/types";
  32940. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32941. import { Observable } from "babylonjs/Misc/observable";
  32942. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32943. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32944. import { Geometry } from "babylonjs/Meshes/geometry";
  32945. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32946. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32948. import { Mesh } from "babylonjs/Meshes/mesh";
  32949. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32950. import { Bone } from "babylonjs/Bones/bone";
  32951. import { Skeleton } from "babylonjs/Bones/skeleton";
  32952. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32953. import { Camera } from "babylonjs/Cameras/camera";
  32954. import { AbstractScene } from "babylonjs/abstractScene";
  32955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32956. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32957. import { Material } from "babylonjs/Materials/material";
  32958. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32959. import { Effect } from "babylonjs/Materials/effect";
  32960. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32961. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32962. import { Light } from "babylonjs/Lights/light";
  32963. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32964. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32965. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32966. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32967. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32968. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32969. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32970. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32971. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32972. import { Engine } from "babylonjs/Engines/engine";
  32973. import { Node } from "babylonjs/node";
  32974. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32975. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32976. import { WebRequest } from "babylonjs/Misc/webRequest";
  32977. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  32978. import { Ray } from "babylonjs/Culling/ray";
  32979. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32980. import { Animation } from "babylonjs/Animations/animation";
  32981. import { Animatable } from "babylonjs/Animations/animatable";
  32982. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32983. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32984. import { Collider } from "babylonjs/Collisions/collider";
  32985. /**
  32986. * Define an interface for all classes that will hold resources
  32987. */
  32988. export interface IDisposable {
  32989. /**
  32990. * Releases all held resources
  32991. */
  32992. dispose(): void;
  32993. }
  32994. /** Interface defining initialization parameters for Scene class */
  32995. export interface SceneOptions {
  32996. /**
  32997. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32998. * It will improve performance when the number of geometries becomes important.
  32999. */
  33000. useGeometryUniqueIdsMap?: boolean;
  33001. /**
  33002. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33003. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33004. */
  33005. useMaterialMeshMap?: boolean;
  33006. /**
  33007. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33008. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33009. */
  33010. useClonedMeshhMap?: boolean;
  33011. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33012. virtual?: boolean;
  33013. }
  33014. /**
  33015. * Represents a scene to be rendered by the engine.
  33016. * @see http://doc.babylonjs.com/features/scene
  33017. */
  33018. export class Scene extends AbstractScene implements IAnimatable {
  33019. private static _uniqueIdCounter;
  33020. /** The fog is deactivated */
  33021. static readonly FOGMODE_NONE: number;
  33022. /** The fog density is following an exponential function */
  33023. static readonly FOGMODE_EXP: number;
  33024. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33025. static readonly FOGMODE_EXP2: number;
  33026. /** The fog density is following a linear function. */
  33027. static readonly FOGMODE_LINEAR: number;
  33028. /**
  33029. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33030. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33031. */
  33032. static MinDeltaTime: number;
  33033. /**
  33034. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33035. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33036. */
  33037. static MaxDeltaTime: number;
  33038. /**
  33039. * Factory used to create the default material.
  33040. * @param name The name of the material to create
  33041. * @param scene The scene to create the material for
  33042. * @returns The default material
  33043. */
  33044. static DefaultMaterialFactory(scene: Scene): Material;
  33045. /**
  33046. * Factory used to create the a collision coordinator.
  33047. * @returns The collision coordinator
  33048. */
  33049. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33050. /** @hidden */
  33051. _inputManager: InputManager;
  33052. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33053. cameraToUseForPointers: Nullable<Camera>;
  33054. /** @hidden */
  33055. readonly _isScene: boolean;
  33056. /**
  33057. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33058. */
  33059. autoClear: boolean;
  33060. /**
  33061. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33062. */
  33063. autoClearDepthAndStencil: boolean;
  33064. /**
  33065. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33066. */
  33067. clearColor: Color4;
  33068. /**
  33069. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33070. */
  33071. ambientColor: Color3;
  33072. /**
  33073. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33074. * It should only be one of the following (if not the default embedded one):
  33075. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33076. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33077. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33078. * The material properties need to be setup according to the type of texture in use.
  33079. */
  33080. environmentBRDFTexture: BaseTexture;
  33081. /** @hidden */
  33082. protected _environmentTexture: Nullable<BaseTexture>;
  33083. /**
  33084. * Texture used in all pbr material as the reflection texture.
  33085. * As in the majority of the scene they are the same (exception for multi room and so on),
  33086. * this is easier to reference from here than from all the materials.
  33087. */
  33088. /**
  33089. * Texture used in all pbr material as the reflection texture.
  33090. * As in the majority of the scene they are the same (exception for multi room and so on),
  33091. * this is easier to set here than in all the materials.
  33092. */
  33093. environmentTexture: Nullable<BaseTexture>;
  33094. /** @hidden */
  33095. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33096. /**
  33097. * Default image processing configuration used either in the rendering
  33098. * Forward main pass or through the imageProcessingPostProcess if present.
  33099. * As in the majority of the scene they are the same (exception for multi camera),
  33100. * this is easier to reference from here than from all the materials and post process.
  33101. *
  33102. * No setter as we it is a shared configuration, you can set the values instead.
  33103. */
  33104. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33105. private _forceWireframe;
  33106. /**
  33107. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33108. */
  33109. forceWireframe: boolean;
  33110. private _forcePointsCloud;
  33111. /**
  33112. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33113. */
  33114. forcePointsCloud: boolean;
  33115. /**
  33116. * Gets or sets the active clipplane 1
  33117. */
  33118. clipPlane: Nullable<Plane>;
  33119. /**
  33120. * Gets or sets the active clipplane 2
  33121. */
  33122. clipPlane2: Nullable<Plane>;
  33123. /**
  33124. * Gets or sets the active clipplane 3
  33125. */
  33126. clipPlane3: Nullable<Plane>;
  33127. /**
  33128. * Gets or sets the active clipplane 4
  33129. */
  33130. clipPlane4: Nullable<Plane>;
  33131. /**
  33132. * Gets or sets a boolean indicating if animations are enabled
  33133. */
  33134. animationsEnabled: boolean;
  33135. private _animationPropertiesOverride;
  33136. /**
  33137. * Gets or sets the animation properties override
  33138. */
  33139. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33140. /**
  33141. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33142. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33143. */
  33144. useConstantAnimationDeltaTime: boolean;
  33145. /**
  33146. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33147. * Please note that it requires to run a ray cast through the scene on every frame
  33148. */
  33149. constantlyUpdateMeshUnderPointer: boolean;
  33150. /**
  33151. * Defines the HTML cursor to use when hovering over interactive elements
  33152. */
  33153. hoverCursor: string;
  33154. /**
  33155. * Defines the HTML default cursor to use (empty by default)
  33156. */
  33157. defaultCursor: string;
  33158. /**
  33159. * This is used to call preventDefault() on pointer down
  33160. * in order to block unwanted artifacts like system double clicks
  33161. */
  33162. preventDefaultOnPointerDown: boolean;
  33163. /**
  33164. * This is used to call preventDefault() on pointer up
  33165. * in order to block unwanted artifacts like system double clicks
  33166. */
  33167. preventDefaultOnPointerUp: boolean;
  33168. /**
  33169. * Gets or sets user defined metadata
  33170. */
  33171. metadata: any;
  33172. /**
  33173. * For internal use only. Please do not use.
  33174. */
  33175. reservedDataStore: any;
  33176. /**
  33177. * Gets the name of the plugin used to load this scene (null by default)
  33178. */
  33179. loadingPluginName: string;
  33180. /**
  33181. * Use this array to add regular expressions used to disable offline support for specific urls
  33182. */
  33183. disableOfflineSupportExceptionRules: RegExp[];
  33184. /**
  33185. * An event triggered when the scene is disposed.
  33186. */
  33187. onDisposeObservable: Observable<Scene>;
  33188. private _onDisposeObserver;
  33189. /** Sets a function to be executed when this scene is disposed. */
  33190. onDispose: () => void;
  33191. /**
  33192. * An event triggered before rendering the scene (right after animations and physics)
  33193. */
  33194. onBeforeRenderObservable: Observable<Scene>;
  33195. private _onBeforeRenderObserver;
  33196. /** Sets a function to be executed before rendering this scene */
  33197. beforeRender: Nullable<() => void>;
  33198. /**
  33199. * An event triggered after rendering the scene
  33200. */
  33201. onAfterRenderObservable: Observable<Scene>;
  33202. private _onAfterRenderObserver;
  33203. /** Sets a function to be executed after rendering this scene */
  33204. afterRender: Nullable<() => void>;
  33205. /**
  33206. * An event triggered before animating the scene
  33207. */
  33208. onBeforeAnimationsObservable: Observable<Scene>;
  33209. /**
  33210. * An event triggered after animations processing
  33211. */
  33212. onAfterAnimationsObservable: Observable<Scene>;
  33213. /**
  33214. * An event triggered before draw calls are ready to be sent
  33215. */
  33216. onBeforeDrawPhaseObservable: Observable<Scene>;
  33217. /**
  33218. * An event triggered after draw calls have been sent
  33219. */
  33220. onAfterDrawPhaseObservable: Observable<Scene>;
  33221. /**
  33222. * An event triggered when the scene is ready
  33223. */
  33224. onReadyObservable: Observable<Scene>;
  33225. /**
  33226. * An event triggered before rendering a camera
  33227. */
  33228. onBeforeCameraRenderObservable: Observable<Camera>;
  33229. private _onBeforeCameraRenderObserver;
  33230. /** Sets a function to be executed before rendering a camera*/
  33231. beforeCameraRender: () => void;
  33232. /**
  33233. * An event triggered after rendering a camera
  33234. */
  33235. onAfterCameraRenderObservable: Observable<Camera>;
  33236. private _onAfterCameraRenderObserver;
  33237. /** Sets a function to be executed after rendering a camera*/
  33238. afterCameraRender: () => void;
  33239. /**
  33240. * An event triggered when active meshes evaluation is about to start
  33241. */
  33242. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33243. /**
  33244. * An event triggered when active meshes evaluation is done
  33245. */
  33246. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33247. /**
  33248. * An event triggered when particles rendering is about to start
  33249. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33250. */
  33251. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33252. /**
  33253. * An event triggered when particles rendering is done
  33254. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33255. */
  33256. onAfterParticlesRenderingObservable: Observable<Scene>;
  33257. /**
  33258. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33259. */
  33260. onDataLoadedObservable: Observable<Scene>;
  33261. /**
  33262. * An event triggered when a camera is created
  33263. */
  33264. onNewCameraAddedObservable: Observable<Camera>;
  33265. /**
  33266. * An event triggered when a camera is removed
  33267. */
  33268. onCameraRemovedObservable: Observable<Camera>;
  33269. /**
  33270. * An event triggered when a light is created
  33271. */
  33272. onNewLightAddedObservable: Observable<Light>;
  33273. /**
  33274. * An event triggered when a light is removed
  33275. */
  33276. onLightRemovedObservable: Observable<Light>;
  33277. /**
  33278. * An event triggered when a geometry is created
  33279. */
  33280. onNewGeometryAddedObservable: Observable<Geometry>;
  33281. /**
  33282. * An event triggered when a geometry is removed
  33283. */
  33284. onGeometryRemovedObservable: Observable<Geometry>;
  33285. /**
  33286. * An event triggered when a transform node is created
  33287. */
  33288. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33289. /**
  33290. * An event triggered when a transform node is removed
  33291. */
  33292. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33293. /**
  33294. * An event triggered when a mesh is created
  33295. */
  33296. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33297. /**
  33298. * An event triggered when a mesh is removed
  33299. */
  33300. onMeshRemovedObservable: Observable<AbstractMesh>;
  33301. /**
  33302. * An event triggered when a skeleton is created
  33303. */
  33304. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33305. /**
  33306. * An event triggered when a skeleton is removed
  33307. */
  33308. onSkeletonRemovedObservable: Observable<Skeleton>;
  33309. /**
  33310. * An event triggered when a material is created
  33311. */
  33312. onNewMaterialAddedObservable: Observable<Material>;
  33313. /**
  33314. * An event triggered when a material is removed
  33315. */
  33316. onMaterialRemovedObservable: Observable<Material>;
  33317. /**
  33318. * An event triggered when a texture is created
  33319. */
  33320. onNewTextureAddedObservable: Observable<BaseTexture>;
  33321. /**
  33322. * An event triggered when a texture is removed
  33323. */
  33324. onTextureRemovedObservable: Observable<BaseTexture>;
  33325. /**
  33326. * An event triggered when render targets are about to be rendered
  33327. * Can happen multiple times per frame.
  33328. */
  33329. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33330. /**
  33331. * An event triggered when render targets were rendered.
  33332. * Can happen multiple times per frame.
  33333. */
  33334. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33335. /**
  33336. * An event triggered before calculating deterministic simulation step
  33337. */
  33338. onBeforeStepObservable: Observable<Scene>;
  33339. /**
  33340. * An event triggered after calculating deterministic simulation step
  33341. */
  33342. onAfterStepObservable: Observable<Scene>;
  33343. /**
  33344. * An event triggered when the activeCamera property is updated
  33345. */
  33346. onActiveCameraChanged: Observable<Scene>;
  33347. /**
  33348. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33349. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33350. * 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)
  33351. */
  33352. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33353. /**
  33354. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33355. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33356. * 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)
  33357. */
  33358. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33359. /**
  33360. * This Observable will when a mesh has been imported into the scene.
  33361. */
  33362. onMeshImportedObservable: Observable<AbstractMesh>;
  33363. /**
  33364. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33365. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33366. */
  33367. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33368. /** @hidden */
  33369. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33370. /**
  33371. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33372. */
  33373. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33374. /**
  33375. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33376. */
  33377. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33378. /**
  33379. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33380. */
  33381. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33382. /** Callback called when a pointer move is detected */
  33383. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33384. /** Callback called when a pointer down is detected */
  33385. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33386. /** Callback called when a pointer up is detected */
  33387. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33388. /** Callback called when a pointer pick is detected */
  33389. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33390. /**
  33391. * 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).
  33392. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33393. */
  33394. onPrePointerObservable: Observable<PointerInfoPre>;
  33395. /**
  33396. * Observable event triggered each time an input event is received from the rendering canvas
  33397. */
  33398. onPointerObservable: Observable<PointerInfo>;
  33399. /**
  33400. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33401. */
  33402. readonly unTranslatedPointer: Vector2;
  33403. /**
  33404. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33405. */
  33406. static DragMovementThreshold: number;
  33407. /**
  33408. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33409. */
  33410. static LongPressDelay: number;
  33411. /**
  33412. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33413. */
  33414. static DoubleClickDelay: number;
  33415. /** If you need to check double click without raising a single click at first click, enable this flag */
  33416. static ExclusiveDoubleClickMode: boolean;
  33417. /** @hidden */
  33418. _mirroredCameraPosition: Nullable<Vector3>;
  33419. /**
  33420. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33421. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33422. */
  33423. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33424. /**
  33425. * Observable event triggered each time an keyboard event is received from the hosting window
  33426. */
  33427. onKeyboardObservable: Observable<KeyboardInfo>;
  33428. private _useRightHandedSystem;
  33429. /**
  33430. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33431. */
  33432. useRightHandedSystem: boolean;
  33433. private _timeAccumulator;
  33434. private _currentStepId;
  33435. private _currentInternalStep;
  33436. /**
  33437. * Sets the step Id used by deterministic lock step
  33438. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33439. * @param newStepId defines the step Id
  33440. */
  33441. setStepId(newStepId: number): void;
  33442. /**
  33443. * Gets the step Id used by deterministic lock step
  33444. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33445. * @returns the step Id
  33446. */
  33447. getStepId(): number;
  33448. /**
  33449. * Gets the internal step used by deterministic lock step
  33450. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33451. * @returns the internal step
  33452. */
  33453. getInternalStep(): number;
  33454. private _fogEnabled;
  33455. /**
  33456. * Gets or sets a boolean indicating if fog is enabled on this scene
  33457. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33458. * (Default is true)
  33459. */
  33460. fogEnabled: boolean;
  33461. private _fogMode;
  33462. /**
  33463. * Gets or sets the fog mode to use
  33464. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33465. * | mode | value |
  33466. * | --- | --- |
  33467. * | FOGMODE_NONE | 0 |
  33468. * | FOGMODE_EXP | 1 |
  33469. * | FOGMODE_EXP2 | 2 |
  33470. * | FOGMODE_LINEAR | 3 |
  33471. */
  33472. fogMode: number;
  33473. /**
  33474. * Gets or sets the fog color to use
  33475. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33476. * (Default is Color3(0.2, 0.2, 0.3))
  33477. */
  33478. fogColor: Color3;
  33479. /**
  33480. * Gets or sets the fog density to use
  33481. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33482. * (Default is 0.1)
  33483. */
  33484. fogDensity: number;
  33485. /**
  33486. * Gets or sets the fog start distance to use
  33487. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33488. * (Default is 0)
  33489. */
  33490. fogStart: number;
  33491. /**
  33492. * Gets or sets the fog end distance to use
  33493. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33494. * (Default is 1000)
  33495. */
  33496. fogEnd: number;
  33497. private _shadowsEnabled;
  33498. /**
  33499. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33500. */
  33501. shadowsEnabled: boolean;
  33502. private _lightsEnabled;
  33503. /**
  33504. * Gets or sets a boolean indicating if lights are enabled on this scene
  33505. */
  33506. lightsEnabled: boolean;
  33507. /** All of the active cameras added to this scene. */
  33508. activeCameras: Camera[];
  33509. /** @hidden */
  33510. _activeCamera: Nullable<Camera>;
  33511. /** Gets or sets the current active camera */
  33512. activeCamera: Nullable<Camera>;
  33513. private _defaultMaterial;
  33514. /** The default material used on meshes when no material is affected */
  33515. /** The default material used on meshes when no material is affected */
  33516. defaultMaterial: Material;
  33517. private _texturesEnabled;
  33518. /**
  33519. * Gets or sets a boolean indicating if textures are enabled on this scene
  33520. */
  33521. texturesEnabled: boolean;
  33522. /**
  33523. * Gets or sets a boolean indicating if particles are enabled on this scene
  33524. */
  33525. particlesEnabled: boolean;
  33526. /**
  33527. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33528. */
  33529. spritesEnabled: boolean;
  33530. private _skeletonsEnabled;
  33531. /**
  33532. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33533. */
  33534. skeletonsEnabled: boolean;
  33535. /**
  33536. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33537. */
  33538. lensFlaresEnabled: boolean;
  33539. /**
  33540. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33541. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33542. */
  33543. collisionsEnabled: boolean;
  33544. private _collisionCoordinator;
  33545. /** @hidden */
  33546. readonly collisionCoordinator: ICollisionCoordinator;
  33547. /**
  33548. * Defines the gravity applied to this scene (used only for collisions)
  33549. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33550. */
  33551. gravity: Vector3;
  33552. /**
  33553. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33554. */
  33555. postProcessesEnabled: boolean;
  33556. /**
  33557. * The list of postprocesses added to the scene
  33558. */
  33559. postProcesses: PostProcess[];
  33560. /**
  33561. * Gets the current postprocess manager
  33562. */
  33563. postProcessManager: PostProcessManager;
  33564. /**
  33565. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33566. */
  33567. renderTargetsEnabled: boolean;
  33568. /**
  33569. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33570. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33571. */
  33572. dumpNextRenderTargets: boolean;
  33573. /**
  33574. * The list of user defined render targets added to the scene
  33575. */
  33576. customRenderTargets: RenderTargetTexture[];
  33577. /**
  33578. * Defines if texture loading must be delayed
  33579. * If true, textures will only be loaded when they need to be rendered
  33580. */
  33581. useDelayedTextureLoading: boolean;
  33582. /**
  33583. * Gets the list of meshes imported to the scene through SceneLoader
  33584. */
  33585. importedMeshesFiles: String[];
  33586. /**
  33587. * Gets or sets a boolean indicating if probes are enabled on this scene
  33588. */
  33589. probesEnabled: boolean;
  33590. /**
  33591. * Gets or sets the current offline provider to use to store scene data
  33592. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33593. */
  33594. offlineProvider: IOfflineProvider;
  33595. /**
  33596. * Gets or sets the action manager associated with the scene
  33597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33598. */
  33599. actionManager: AbstractActionManager;
  33600. private _meshesForIntersections;
  33601. /**
  33602. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33603. */
  33604. proceduralTexturesEnabled: boolean;
  33605. private _engine;
  33606. private _totalVertices;
  33607. /** @hidden */
  33608. _activeIndices: PerfCounter;
  33609. /** @hidden */
  33610. _activeParticles: PerfCounter;
  33611. /** @hidden */
  33612. _activeBones: PerfCounter;
  33613. private _animationRatio;
  33614. /** @hidden */
  33615. _animationTimeLast: number;
  33616. /** @hidden */
  33617. _animationTime: number;
  33618. /**
  33619. * Gets or sets a general scale for animation speed
  33620. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33621. */
  33622. animationTimeScale: number;
  33623. /** @hidden */
  33624. _cachedMaterial: Nullable<Material>;
  33625. /** @hidden */
  33626. _cachedEffect: Nullable<Effect>;
  33627. /** @hidden */
  33628. _cachedVisibility: Nullable<number>;
  33629. private _renderId;
  33630. private _frameId;
  33631. private _executeWhenReadyTimeoutId;
  33632. private _intermediateRendering;
  33633. private _viewUpdateFlag;
  33634. private _projectionUpdateFlag;
  33635. /** @hidden */
  33636. _toBeDisposed: Nullable<IDisposable>[];
  33637. private _activeRequests;
  33638. /** @hidden */
  33639. _pendingData: any[];
  33640. private _isDisposed;
  33641. /**
  33642. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33643. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33644. */
  33645. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33646. private _activeMeshes;
  33647. private _processedMaterials;
  33648. private _renderTargets;
  33649. /** @hidden */
  33650. _activeParticleSystems: SmartArray<IParticleSystem>;
  33651. private _activeSkeletons;
  33652. private _softwareSkinnedMeshes;
  33653. private _renderingManager;
  33654. /** @hidden */
  33655. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33656. private _transformMatrix;
  33657. private _sceneUbo;
  33658. /** @hidden */
  33659. _viewMatrix: Matrix;
  33660. private _projectionMatrix;
  33661. /** @hidden */
  33662. _forcedViewPosition: Nullable<Vector3>;
  33663. /** @hidden */
  33664. _frustumPlanes: Plane[];
  33665. /**
  33666. * Gets the list of frustum planes (built from the active camera)
  33667. */
  33668. readonly frustumPlanes: Plane[];
  33669. /**
  33670. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33671. * This is useful if there are more lights that the maximum simulteanous authorized
  33672. */
  33673. requireLightSorting: boolean;
  33674. /** @hidden */
  33675. readonly useMaterialMeshMap: boolean;
  33676. /** @hidden */
  33677. readonly useClonedMeshhMap: boolean;
  33678. private _externalData;
  33679. private _uid;
  33680. /**
  33681. * @hidden
  33682. * Backing store of defined scene components.
  33683. */
  33684. _components: ISceneComponent[];
  33685. /**
  33686. * @hidden
  33687. * Backing store of defined scene components.
  33688. */
  33689. _serializableComponents: ISceneSerializableComponent[];
  33690. /**
  33691. * List of components to register on the next registration step.
  33692. */
  33693. private _transientComponents;
  33694. /**
  33695. * Registers the transient components if needed.
  33696. */
  33697. private _registerTransientComponents;
  33698. /**
  33699. * @hidden
  33700. * Add a component to the scene.
  33701. * Note that the ccomponent could be registered on th next frame if this is called after
  33702. * the register component stage.
  33703. * @param component Defines the component to add to the scene
  33704. */
  33705. _addComponent(component: ISceneComponent): void;
  33706. /**
  33707. * @hidden
  33708. * Gets a component from the scene.
  33709. * @param name defines the name of the component to retrieve
  33710. * @returns the component or null if not present
  33711. */
  33712. _getComponent(name: string): Nullable<ISceneComponent>;
  33713. /**
  33714. * @hidden
  33715. * Defines the actions happening before camera updates.
  33716. */
  33717. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33718. /**
  33719. * @hidden
  33720. * Defines the actions happening before clear the canvas.
  33721. */
  33722. _beforeClearStage: Stage<SimpleStageAction>;
  33723. /**
  33724. * @hidden
  33725. * Defines the actions when collecting render targets for the frame.
  33726. */
  33727. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33728. /**
  33729. * @hidden
  33730. * Defines the actions happening for one camera in the frame.
  33731. */
  33732. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33733. /**
  33734. * @hidden
  33735. * Defines the actions happening during the per mesh ready checks.
  33736. */
  33737. _isReadyForMeshStage: Stage<MeshStageAction>;
  33738. /**
  33739. * @hidden
  33740. * Defines the actions happening before evaluate active mesh checks.
  33741. */
  33742. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33743. /**
  33744. * @hidden
  33745. * Defines the actions happening during the evaluate sub mesh checks.
  33746. */
  33747. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33748. /**
  33749. * @hidden
  33750. * Defines the actions happening during the active mesh stage.
  33751. */
  33752. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33753. /**
  33754. * @hidden
  33755. * Defines the actions happening during the per camera render target step.
  33756. */
  33757. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33758. /**
  33759. * @hidden
  33760. * Defines the actions happening just before the active camera is drawing.
  33761. */
  33762. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33763. /**
  33764. * @hidden
  33765. * Defines the actions happening just before a render target is drawing.
  33766. */
  33767. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33768. /**
  33769. * @hidden
  33770. * Defines the actions happening just before a rendering group is drawing.
  33771. */
  33772. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33773. /**
  33774. * @hidden
  33775. * Defines the actions happening just before a mesh is drawing.
  33776. */
  33777. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33778. /**
  33779. * @hidden
  33780. * Defines the actions happening just after a mesh has been drawn.
  33781. */
  33782. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33783. /**
  33784. * @hidden
  33785. * Defines the actions happening just after a rendering group has been drawn.
  33786. */
  33787. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33788. /**
  33789. * @hidden
  33790. * Defines the actions happening just after the active camera has been drawn.
  33791. */
  33792. _afterCameraDrawStage: Stage<CameraStageAction>;
  33793. /**
  33794. * @hidden
  33795. * Defines the actions happening just after a render target has been drawn.
  33796. */
  33797. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33798. /**
  33799. * @hidden
  33800. * Defines the actions happening just after rendering all cameras and computing intersections.
  33801. */
  33802. _afterRenderStage: Stage<SimpleStageAction>;
  33803. /**
  33804. * @hidden
  33805. * Defines the actions happening when a pointer move event happens.
  33806. */
  33807. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33808. /**
  33809. * @hidden
  33810. * Defines the actions happening when a pointer down event happens.
  33811. */
  33812. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33813. /**
  33814. * @hidden
  33815. * Defines the actions happening when a pointer up event happens.
  33816. */
  33817. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33818. /**
  33819. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33820. */
  33821. private geometriesByUniqueId;
  33822. /**
  33823. * Creates a new Scene
  33824. * @param engine defines the engine to use to render this scene
  33825. * @param options defines the scene options
  33826. */
  33827. constructor(engine: Engine, options?: SceneOptions);
  33828. /**
  33829. * Gets a string idenfifying the name of the class
  33830. * @returns "Scene" string
  33831. */
  33832. getClassName(): string;
  33833. private _defaultMeshCandidates;
  33834. /**
  33835. * @hidden
  33836. */
  33837. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33838. private _defaultSubMeshCandidates;
  33839. /**
  33840. * @hidden
  33841. */
  33842. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33843. /**
  33844. * Sets the default candidate providers for the scene.
  33845. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33846. * and getCollidingSubMeshCandidates to their default function
  33847. */
  33848. setDefaultCandidateProviders(): void;
  33849. /**
  33850. * Gets the mesh that is currently under the pointer
  33851. */
  33852. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33853. /**
  33854. * Gets or sets the current on-screen X position of the pointer
  33855. */
  33856. pointerX: number;
  33857. /**
  33858. * Gets or sets the current on-screen Y position of the pointer
  33859. */
  33860. pointerY: number;
  33861. /**
  33862. * Gets the cached material (ie. the latest rendered one)
  33863. * @returns the cached material
  33864. */
  33865. getCachedMaterial(): Nullable<Material>;
  33866. /**
  33867. * Gets the cached effect (ie. the latest rendered one)
  33868. * @returns the cached effect
  33869. */
  33870. getCachedEffect(): Nullable<Effect>;
  33871. /**
  33872. * Gets the cached visibility state (ie. the latest rendered one)
  33873. * @returns the cached visibility state
  33874. */
  33875. getCachedVisibility(): Nullable<number>;
  33876. /**
  33877. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33878. * @param material defines the current material
  33879. * @param effect defines the current effect
  33880. * @param visibility defines the current visibility state
  33881. * @returns true if one parameter is not cached
  33882. */
  33883. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33884. /**
  33885. * Gets the engine associated with the scene
  33886. * @returns an Engine
  33887. */
  33888. getEngine(): Engine;
  33889. /**
  33890. * Gets the total number of vertices rendered per frame
  33891. * @returns the total number of vertices rendered per frame
  33892. */
  33893. getTotalVertices(): number;
  33894. /**
  33895. * Gets the performance counter for total vertices
  33896. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33897. */
  33898. readonly totalVerticesPerfCounter: PerfCounter;
  33899. /**
  33900. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33901. * @returns the total number of active indices rendered per frame
  33902. */
  33903. getActiveIndices(): number;
  33904. /**
  33905. * Gets the performance counter for active indices
  33906. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33907. */
  33908. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33909. /**
  33910. * Gets the total number of active particles rendered per frame
  33911. * @returns the total number of active particles rendered per frame
  33912. */
  33913. getActiveParticles(): number;
  33914. /**
  33915. * Gets the performance counter for active particles
  33916. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33917. */
  33918. readonly activeParticlesPerfCounter: PerfCounter;
  33919. /**
  33920. * Gets the total number of active bones rendered per frame
  33921. * @returns the total number of active bones rendered per frame
  33922. */
  33923. getActiveBones(): number;
  33924. /**
  33925. * Gets the performance counter for active bones
  33926. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33927. */
  33928. readonly activeBonesPerfCounter: PerfCounter;
  33929. /**
  33930. * Gets the array of active meshes
  33931. * @returns an array of AbstractMesh
  33932. */
  33933. getActiveMeshes(): SmartArray<AbstractMesh>;
  33934. /**
  33935. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33936. * @returns a number
  33937. */
  33938. getAnimationRatio(): number;
  33939. /**
  33940. * Gets an unique Id for the current render phase
  33941. * @returns a number
  33942. */
  33943. getRenderId(): number;
  33944. /**
  33945. * Gets an unique Id for the current frame
  33946. * @returns a number
  33947. */
  33948. getFrameId(): number;
  33949. /** Call this function if you want to manually increment the render Id*/
  33950. incrementRenderId(): void;
  33951. private _createUbo;
  33952. /**
  33953. * Use this method to simulate a pointer move on a mesh
  33954. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33955. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33956. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33957. * @returns the current scene
  33958. */
  33959. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33960. /**
  33961. * Use this method to simulate a pointer down on a mesh
  33962. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33963. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33964. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33965. * @returns the current scene
  33966. */
  33967. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33968. /**
  33969. * Use this method to simulate a pointer up on a mesh
  33970. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33971. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33972. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33973. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33974. * @returns the current scene
  33975. */
  33976. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33977. /**
  33978. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33979. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33980. * @returns true if the pointer was captured
  33981. */
  33982. isPointerCaptured(pointerId?: number): boolean;
  33983. /**
  33984. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33985. * @param attachUp defines if you want to attach events to pointerup
  33986. * @param attachDown defines if you want to attach events to pointerdown
  33987. * @param attachMove defines if you want to attach events to pointermove
  33988. */
  33989. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33990. /** Detaches all event handlers*/
  33991. detachControl(): void;
  33992. /**
  33993. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33994. * Delay loaded resources are not taking in account
  33995. * @return true if all required resources are ready
  33996. */
  33997. isReady(): boolean;
  33998. /** Resets all cached information relative to material (including effect and visibility) */
  33999. resetCachedMaterial(): void;
  34000. /**
  34001. * Registers a function to be called before every frame render
  34002. * @param func defines the function to register
  34003. */
  34004. registerBeforeRender(func: () => void): void;
  34005. /**
  34006. * Unregisters a function called before every frame render
  34007. * @param func defines the function to unregister
  34008. */
  34009. unregisterBeforeRender(func: () => void): void;
  34010. /**
  34011. * Registers a function to be called after every frame render
  34012. * @param func defines the function to register
  34013. */
  34014. registerAfterRender(func: () => void): void;
  34015. /**
  34016. * Unregisters a function called after every frame render
  34017. * @param func defines the function to unregister
  34018. */
  34019. unregisterAfterRender(func: () => void): void;
  34020. private _executeOnceBeforeRender;
  34021. /**
  34022. * The provided function will run before render once and will be disposed afterwards.
  34023. * A timeout delay can be provided so that the function will be executed in N ms.
  34024. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34025. * @param func The function to be executed.
  34026. * @param timeout optional delay in ms
  34027. */
  34028. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34029. /** @hidden */
  34030. _addPendingData(data: any): void;
  34031. /** @hidden */
  34032. _removePendingData(data: any): void;
  34033. /**
  34034. * Returns the number of items waiting to be loaded
  34035. * @returns the number of items waiting to be loaded
  34036. */
  34037. getWaitingItemsCount(): number;
  34038. /**
  34039. * Returns a boolean indicating if the scene is still loading data
  34040. */
  34041. readonly isLoading: boolean;
  34042. /**
  34043. * Registers a function to be executed when the scene is ready
  34044. * @param {Function} func - the function to be executed
  34045. */
  34046. executeWhenReady(func: () => void): void;
  34047. /**
  34048. * Returns a promise that resolves when the scene is ready
  34049. * @returns A promise that resolves when the scene is ready
  34050. */
  34051. whenReadyAsync(): Promise<void>;
  34052. /** @hidden */
  34053. _checkIsReady(): void;
  34054. /**
  34055. * Gets all animatable attached to the scene
  34056. */
  34057. readonly animatables: Animatable[];
  34058. /**
  34059. * Resets the last animation time frame.
  34060. * Useful to override when animations start running when loading a scene for the first time.
  34061. */
  34062. resetLastAnimationTimeFrame(): void;
  34063. /**
  34064. * Gets the current view matrix
  34065. * @returns a Matrix
  34066. */
  34067. getViewMatrix(): Matrix;
  34068. /**
  34069. * Gets the current projection matrix
  34070. * @returns a Matrix
  34071. */
  34072. getProjectionMatrix(): Matrix;
  34073. /**
  34074. * Gets the current transform matrix
  34075. * @returns a Matrix made of View * Projection
  34076. */
  34077. getTransformMatrix(): Matrix;
  34078. /**
  34079. * Sets the current transform matrix
  34080. * @param viewL defines the View matrix to use
  34081. * @param projectionL defines the Projection matrix to use
  34082. * @param viewR defines the right View matrix to use (if provided)
  34083. * @param projectionR defines the right Projection matrix to use (if provided)
  34084. */
  34085. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34086. /**
  34087. * Gets the uniform buffer used to store scene data
  34088. * @returns a UniformBuffer
  34089. */
  34090. getSceneUniformBuffer(): UniformBuffer;
  34091. /**
  34092. * Gets an unique (relatively to the current scene) Id
  34093. * @returns an unique number for the scene
  34094. */
  34095. getUniqueId(): number;
  34096. /**
  34097. * Add a mesh to the list of scene's meshes
  34098. * @param newMesh defines the mesh to add
  34099. * @param recursive if all child meshes should also be added to the scene
  34100. */
  34101. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34102. /**
  34103. * Remove a mesh for the list of scene's meshes
  34104. * @param toRemove defines the mesh to remove
  34105. * @param recursive if all child meshes should also be removed from the scene
  34106. * @returns the index where the mesh was in the mesh list
  34107. */
  34108. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34109. /**
  34110. * Add a transform node to the list of scene's transform nodes
  34111. * @param newTransformNode defines the transform node to add
  34112. */
  34113. addTransformNode(newTransformNode: TransformNode): void;
  34114. /**
  34115. * Remove a transform node for the list of scene's transform nodes
  34116. * @param toRemove defines the transform node to remove
  34117. * @returns the index where the transform node was in the transform node list
  34118. */
  34119. removeTransformNode(toRemove: TransformNode): number;
  34120. /**
  34121. * Remove a skeleton for the list of scene's skeletons
  34122. * @param toRemove defines the skeleton to remove
  34123. * @returns the index where the skeleton was in the skeleton list
  34124. */
  34125. removeSkeleton(toRemove: Skeleton): number;
  34126. /**
  34127. * Remove a morph target for the list of scene's morph targets
  34128. * @param toRemove defines the morph target to remove
  34129. * @returns the index where the morph target was in the morph target list
  34130. */
  34131. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34132. /**
  34133. * Remove a light for the list of scene's lights
  34134. * @param toRemove defines the light to remove
  34135. * @returns the index where the light was in the light list
  34136. */
  34137. removeLight(toRemove: Light): number;
  34138. /**
  34139. * Remove a camera for the list of scene's cameras
  34140. * @param toRemove defines the camera to remove
  34141. * @returns the index where the camera was in the camera list
  34142. */
  34143. removeCamera(toRemove: Camera): number;
  34144. /**
  34145. * Remove a particle system for the list of scene's particle systems
  34146. * @param toRemove defines the particle system to remove
  34147. * @returns the index where the particle system was in the particle system list
  34148. */
  34149. removeParticleSystem(toRemove: IParticleSystem): number;
  34150. /**
  34151. * Remove a animation for the list of scene's animations
  34152. * @param toRemove defines the animation to remove
  34153. * @returns the index where the animation was in the animation list
  34154. */
  34155. removeAnimation(toRemove: Animation): number;
  34156. /**
  34157. * Will stop the animation of the given target
  34158. * @param target - the target
  34159. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34160. * @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)
  34161. */
  34162. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34163. /**
  34164. * Removes the given animation group from this scene.
  34165. * @param toRemove The animation group to remove
  34166. * @returns The index of the removed animation group
  34167. */
  34168. removeAnimationGroup(toRemove: AnimationGroup): number;
  34169. /**
  34170. * Removes the given multi-material from this scene.
  34171. * @param toRemove The multi-material to remove
  34172. * @returns The index of the removed multi-material
  34173. */
  34174. removeMultiMaterial(toRemove: MultiMaterial): number;
  34175. /**
  34176. * Removes the given material from this scene.
  34177. * @param toRemove The material to remove
  34178. * @returns The index of the removed material
  34179. */
  34180. removeMaterial(toRemove: Material): number;
  34181. /**
  34182. * Removes the given action manager from this scene.
  34183. * @param toRemove The action manager to remove
  34184. * @returns The index of the removed action manager
  34185. */
  34186. removeActionManager(toRemove: AbstractActionManager): number;
  34187. /**
  34188. * Removes the given texture from this scene.
  34189. * @param toRemove The texture to remove
  34190. * @returns The index of the removed texture
  34191. */
  34192. removeTexture(toRemove: BaseTexture): number;
  34193. /**
  34194. * Adds the given light to this scene
  34195. * @param newLight The light to add
  34196. */
  34197. addLight(newLight: Light): void;
  34198. /**
  34199. * Sorts the list list based on light priorities
  34200. */
  34201. sortLightsByPriority(): void;
  34202. /**
  34203. * Adds the given camera to this scene
  34204. * @param newCamera The camera to add
  34205. */
  34206. addCamera(newCamera: Camera): void;
  34207. /**
  34208. * Adds the given skeleton to this scene
  34209. * @param newSkeleton The skeleton to add
  34210. */
  34211. addSkeleton(newSkeleton: Skeleton): void;
  34212. /**
  34213. * Adds the given particle system to this scene
  34214. * @param newParticleSystem The particle system to add
  34215. */
  34216. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34217. /**
  34218. * Adds the given animation to this scene
  34219. * @param newAnimation The animation to add
  34220. */
  34221. addAnimation(newAnimation: Animation): void;
  34222. /**
  34223. * Adds the given animation group to this scene.
  34224. * @param newAnimationGroup The animation group to add
  34225. */
  34226. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34227. /**
  34228. * Adds the given multi-material to this scene
  34229. * @param newMultiMaterial The multi-material to add
  34230. */
  34231. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34232. /**
  34233. * Adds the given material to this scene
  34234. * @param newMaterial The material to add
  34235. */
  34236. addMaterial(newMaterial: Material): void;
  34237. /**
  34238. * Adds the given morph target to this scene
  34239. * @param newMorphTargetManager The morph target to add
  34240. */
  34241. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34242. /**
  34243. * Adds the given geometry to this scene
  34244. * @param newGeometry The geometry to add
  34245. */
  34246. addGeometry(newGeometry: Geometry): void;
  34247. /**
  34248. * Adds the given action manager to this scene
  34249. * @param newActionManager The action manager to add
  34250. */
  34251. addActionManager(newActionManager: AbstractActionManager): void;
  34252. /**
  34253. * Adds the given texture to this scene.
  34254. * @param newTexture The texture to add
  34255. */
  34256. addTexture(newTexture: BaseTexture): void;
  34257. /**
  34258. * Switch active camera
  34259. * @param newCamera defines the new active camera
  34260. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34261. */
  34262. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34263. /**
  34264. * sets the active camera of the scene using its ID
  34265. * @param id defines the camera's ID
  34266. * @return the new active camera or null if none found.
  34267. */
  34268. setActiveCameraByID(id: string): Nullable<Camera>;
  34269. /**
  34270. * sets the active camera of the scene using its name
  34271. * @param name defines the camera's name
  34272. * @returns the new active camera or null if none found.
  34273. */
  34274. setActiveCameraByName(name: string): Nullable<Camera>;
  34275. /**
  34276. * get an animation group using its name
  34277. * @param name defines the material's name
  34278. * @return the animation group or null if none found.
  34279. */
  34280. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34281. /**
  34282. * Get a material using its unique id
  34283. * @param uniqueId defines the material's unique id
  34284. * @return the material or null if none found.
  34285. */
  34286. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34287. /**
  34288. * get a material using its id
  34289. * @param id defines the material's ID
  34290. * @return the material or null if none found.
  34291. */
  34292. getMaterialByID(id: string): Nullable<Material>;
  34293. /**
  34294. * Gets a material using its name
  34295. * @param name defines the material's name
  34296. * @return the material or null if none found.
  34297. */
  34298. getMaterialByName(name: string): Nullable<Material>;
  34299. /**
  34300. * Gets a camera using its id
  34301. * @param id defines the id to look for
  34302. * @returns the camera or null if not found
  34303. */
  34304. getCameraByID(id: string): Nullable<Camera>;
  34305. /**
  34306. * Gets a camera using its unique id
  34307. * @param uniqueId defines the unique id to look for
  34308. * @returns the camera or null if not found
  34309. */
  34310. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34311. /**
  34312. * Gets a camera using its name
  34313. * @param name defines the camera's name
  34314. * @return the camera or null if none found.
  34315. */
  34316. getCameraByName(name: string): Nullable<Camera>;
  34317. /**
  34318. * Gets a bone using its id
  34319. * @param id defines the bone's id
  34320. * @return the bone or null if not found
  34321. */
  34322. getBoneByID(id: string): Nullable<Bone>;
  34323. /**
  34324. * Gets a bone using its id
  34325. * @param name defines the bone's name
  34326. * @return the bone or null if not found
  34327. */
  34328. getBoneByName(name: string): Nullable<Bone>;
  34329. /**
  34330. * Gets a light node using its name
  34331. * @param name defines the the light's name
  34332. * @return the light or null if none found.
  34333. */
  34334. getLightByName(name: string): Nullable<Light>;
  34335. /**
  34336. * Gets a light node using its id
  34337. * @param id defines the light's id
  34338. * @return the light or null if none found.
  34339. */
  34340. getLightByID(id: string): Nullable<Light>;
  34341. /**
  34342. * Gets a light node using its scene-generated unique ID
  34343. * @param uniqueId defines the light's unique id
  34344. * @return the light or null if none found.
  34345. */
  34346. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34347. /**
  34348. * Gets a particle system by id
  34349. * @param id defines the particle system id
  34350. * @return the corresponding system or null if none found
  34351. */
  34352. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34353. /**
  34354. * Gets a geometry using its ID
  34355. * @param id defines the geometry's id
  34356. * @return the geometry or null if none found.
  34357. */
  34358. getGeometryByID(id: string): Nullable<Geometry>;
  34359. private _getGeometryByUniqueID;
  34360. /**
  34361. * Add a new geometry to this scene
  34362. * @param geometry defines the geometry to be added to the scene.
  34363. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34364. * @return a boolean defining if the geometry was added or not
  34365. */
  34366. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34367. /**
  34368. * Removes an existing geometry
  34369. * @param geometry defines the geometry to be removed from the scene
  34370. * @return a boolean defining if the geometry was removed or not
  34371. */
  34372. removeGeometry(geometry: Geometry): boolean;
  34373. /**
  34374. * Gets the list of geometries attached to the scene
  34375. * @returns an array of Geometry
  34376. */
  34377. getGeometries(): Geometry[];
  34378. /**
  34379. * Gets the first added mesh found of a given ID
  34380. * @param id defines the id to search for
  34381. * @return the mesh found or null if not found at all
  34382. */
  34383. getMeshByID(id: string): Nullable<AbstractMesh>;
  34384. /**
  34385. * Gets a list of meshes using their id
  34386. * @param id defines the id to search for
  34387. * @returns a list of meshes
  34388. */
  34389. getMeshesByID(id: string): Array<AbstractMesh>;
  34390. /**
  34391. * Gets the first added transform node found of a given ID
  34392. * @param id defines the id to search for
  34393. * @return the found transform node or null if not found at all.
  34394. */
  34395. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34396. /**
  34397. * Gets a transform node with its auto-generated unique id
  34398. * @param uniqueId efines the unique id to search for
  34399. * @return the found transform node or null if not found at all.
  34400. */
  34401. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34402. /**
  34403. * Gets a list of transform nodes using their id
  34404. * @param id defines the id to search for
  34405. * @returns a list of transform nodes
  34406. */
  34407. getTransformNodesByID(id: string): Array<TransformNode>;
  34408. /**
  34409. * Gets a mesh with its auto-generated unique id
  34410. * @param uniqueId defines the unique id to search for
  34411. * @return the found mesh or null if not found at all.
  34412. */
  34413. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34414. /**
  34415. * Gets a the last added mesh using a given id
  34416. * @param id defines the id to search for
  34417. * @return the found mesh or null if not found at all.
  34418. */
  34419. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34420. /**
  34421. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34422. * @param id defines the id to search for
  34423. * @return the found node or null if not found at all
  34424. */
  34425. getLastEntryByID(id: string): Nullable<Node>;
  34426. /**
  34427. * Gets a node (Mesh, Camera, Light) using a given id
  34428. * @param id defines the id to search for
  34429. * @return the found node or null if not found at all
  34430. */
  34431. getNodeByID(id: string): Nullable<Node>;
  34432. /**
  34433. * Gets a node (Mesh, Camera, Light) using a given name
  34434. * @param name defines the name to search for
  34435. * @return the found node or null if not found at all.
  34436. */
  34437. getNodeByName(name: string): Nullable<Node>;
  34438. /**
  34439. * Gets a mesh using a given name
  34440. * @param name defines the name to search for
  34441. * @return the found mesh or null if not found at all.
  34442. */
  34443. getMeshByName(name: string): Nullable<AbstractMesh>;
  34444. /**
  34445. * Gets a transform node using a given name
  34446. * @param name defines the name to search for
  34447. * @return the found transform node or null if not found at all.
  34448. */
  34449. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34450. /**
  34451. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34452. * @param id defines the id to search for
  34453. * @return the found skeleton or null if not found at all.
  34454. */
  34455. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34456. /**
  34457. * Gets a skeleton using a given auto generated unique id
  34458. * @param uniqueId defines the unique id to search for
  34459. * @return the found skeleton or null if not found at all.
  34460. */
  34461. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34462. /**
  34463. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34464. * @param id defines the id to search for
  34465. * @return the found skeleton or null if not found at all.
  34466. */
  34467. getSkeletonById(id: string): Nullable<Skeleton>;
  34468. /**
  34469. * Gets a skeleton using a given name
  34470. * @param name defines the name to search for
  34471. * @return the found skeleton or null if not found at all.
  34472. */
  34473. getSkeletonByName(name: string): Nullable<Skeleton>;
  34474. /**
  34475. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34476. * @param id defines the id to search for
  34477. * @return the found morph target manager or null if not found at all.
  34478. */
  34479. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34480. /**
  34481. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34482. * @param id defines the id to search for
  34483. * @return the found morph target or null if not found at all.
  34484. */
  34485. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34486. /**
  34487. * Gets a boolean indicating if the given mesh is active
  34488. * @param mesh defines the mesh to look for
  34489. * @returns true if the mesh is in the active list
  34490. */
  34491. isActiveMesh(mesh: AbstractMesh): boolean;
  34492. /**
  34493. * Return a unique id as a string which can serve as an identifier for the scene
  34494. */
  34495. readonly uid: string;
  34496. /**
  34497. * Add an externaly attached data from its key.
  34498. * This method call will fail and return false, if such key already exists.
  34499. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34500. * @param key the unique key that identifies the data
  34501. * @param data the data object to associate to the key for this Engine instance
  34502. * @return true if no such key were already present and the data was added successfully, false otherwise
  34503. */
  34504. addExternalData<T>(key: string, data: T): boolean;
  34505. /**
  34506. * Get an externaly attached data from its key
  34507. * @param key the unique key that identifies the data
  34508. * @return the associated data, if present (can be null), or undefined if not present
  34509. */
  34510. getExternalData<T>(key: string): Nullable<T>;
  34511. /**
  34512. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34513. * @param key the unique key that identifies the data
  34514. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34515. * @return the associated data, can be null if the factory returned null.
  34516. */
  34517. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34518. /**
  34519. * Remove an externaly attached data from the Engine instance
  34520. * @param key the unique key that identifies the data
  34521. * @return true if the data was successfully removed, false if it doesn't exist
  34522. */
  34523. removeExternalData(key: string): boolean;
  34524. private _evaluateSubMesh;
  34525. /**
  34526. * Clear the processed materials smart array preventing retention point in material dispose.
  34527. */
  34528. freeProcessedMaterials(): void;
  34529. private _preventFreeActiveMeshesAndRenderingGroups;
  34530. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34531. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34532. * when disposing several meshes in a row or a hierarchy of meshes.
  34533. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34534. */
  34535. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34536. /**
  34537. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34538. */
  34539. freeActiveMeshes(): void;
  34540. /**
  34541. * Clear the info related to rendering groups preventing retention points during dispose.
  34542. */
  34543. freeRenderingGroups(): void;
  34544. /** @hidden */
  34545. _isInIntermediateRendering(): boolean;
  34546. /**
  34547. * Lambda returning the list of potentially active meshes.
  34548. */
  34549. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34550. /**
  34551. * Lambda returning the list of potentially active sub meshes.
  34552. */
  34553. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34554. /**
  34555. * Lambda returning the list of potentially intersecting sub meshes.
  34556. */
  34557. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34558. /**
  34559. * Lambda returning the list of potentially colliding sub meshes.
  34560. */
  34561. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34562. private _activeMeshesFrozen;
  34563. /**
  34564. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34565. * @returns the current scene
  34566. */
  34567. freezeActiveMeshes(): Scene;
  34568. /**
  34569. * Use this function to restart evaluating active meshes on every frame
  34570. * @returns the current scene
  34571. */
  34572. unfreezeActiveMeshes(): Scene;
  34573. private _evaluateActiveMeshes;
  34574. private _activeMesh;
  34575. /**
  34576. * Update the transform matrix to update from the current active camera
  34577. * @param force defines a boolean used to force the update even if cache is up to date
  34578. */
  34579. updateTransformMatrix(force?: boolean): void;
  34580. private _bindFrameBuffer;
  34581. /** @hidden */
  34582. _allowPostProcessClearColor: boolean;
  34583. /** @hidden */
  34584. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34585. private _processSubCameras;
  34586. private _checkIntersections;
  34587. /** @hidden */
  34588. _advancePhysicsEngineStep(step: number): void;
  34589. /**
  34590. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34591. */
  34592. getDeterministicFrameTime: () => number;
  34593. /** @hidden */
  34594. _animate(): void;
  34595. /** Execute all animations (for a frame) */
  34596. animate(): void;
  34597. /**
  34598. * Render the scene
  34599. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34600. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34601. */
  34602. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34603. /**
  34604. * Freeze all materials
  34605. * A frozen material will not be updatable but should be faster to render
  34606. */
  34607. freezeMaterials(): void;
  34608. /**
  34609. * Unfreeze all materials
  34610. * A frozen material will not be updatable but should be faster to render
  34611. */
  34612. unfreezeMaterials(): void;
  34613. /**
  34614. * Releases all held ressources
  34615. */
  34616. dispose(): void;
  34617. /**
  34618. * Gets if the scene is already disposed
  34619. */
  34620. readonly isDisposed: boolean;
  34621. /**
  34622. * Call this function to reduce memory footprint of the scene.
  34623. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34624. */
  34625. clearCachedVertexData(): void;
  34626. /**
  34627. * This function will remove the local cached buffer data from texture.
  34628. * It will save memory but will prevent the texture from being rebuilt
  34629. */
  34630. cleanCachedTextureBuffer(): void;
  34631. /**
  34632. * Get the world extend vectors with an optional filter
  34633. *
  34634. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34635. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34636. */
  34637. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34638. min: Vector3;
  34639. max: Vector3;
  34640. };
  34641. /**
  34642. * Creates a ray that can be used to pick in the scene
  34643. * @param x defines the x coordinate of the origin (on-screen)
  34644. * @param y defines the y coordinate of the origin (on-screen)
  34645. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34646. * @param camera defines the camera to use for the picking
  34647. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34648. * @returns a Ray
  34649. */
  34650. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34651. /**
  34652. * Creates a ray that can be used to pick in the scene
  34653. * @param x defines the x coordinate of the origin (on-screen)
  34654. * @param y defines the y coordinate of the origin (on-screen)
  34655. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34656. * @param result defines the ray where to store the picking ray
  34657. * @param camera defines the camera to use for the picking
  34658. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34659. * @returns the current scene
  34660. */
  34661. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34662. /**
  34663. * Creates a ray that can be used to pick in the scene
  34664. * @param x defines the x coordinate of the origin (on-screen)
  34665. * @param y defines the y coordinate of the origin (on-screen)
  34666. * @param camera defines the camera to use for the picking
  34667. * @returns a Ray
  34668. */
  34669. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34670. /**
  34671. * Creates a ray that can be used to pick in the scene
  34672. * @param x defines the x coordinate of the origin (on-screen)
  34673. * @param y defines the y coordinate of the origin (on-screen)
  34674. * @param result defines the ray where to store the picking ray
  34675. * @param camera defines the camera to use for the picking
  34676. * @returns the current scene
  34677. */
  34678. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34679. /** Launch a ray to try to pick a mesh in the scene
  34680. * @param x position on screen
  34681. * @param y position on screen
  34682. * @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
  34683. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34684. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34685. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34686. * @returns a PickingInfo
  34687. */
  34688. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34689. /** Use the given ray to pick a mesh in the scene
  34690. * @param ray The ray to use to pick meshes
  34691. * @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
  34692. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34693. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34694. * @returns a PickingInfo
  34695. */
  34696. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34697. /**
  34698. * Launch a ray to try to pick a mesh in the scene
  34699. * @param x X position on screen
  34700. * @param y Y position on screen
  34701. * @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
  34702. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34703. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34704. * @returns an array of PickingInfo
  34705. */
  34706. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34707. /**
  34708. * Launch a ray to try to pick a mesh in the scene
  34709. * @param ray Ray to use
  34710. * @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
  34711. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34712. * @returns an array of PickingInfo
  34713. */
  34714. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34715. /**
  34716. * Force the value of meshUnderPointer
  34717. * @param mesh defines the mesh to use
  34718. */
  34719. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34720. /**
  34721. * Gets the mesh under the pointer
  34722. * @returns a Mesh or null if no mesh is under the pointer
  34723. */
  34724. getPointerOverMesh(): Nullable<AbstractMesh>;
  34725. /** @hidden */
  34726. _rebuildGeometries(): void;
  34727. /** @hidden */
  34728. _rebuildTextures(): void;
  34729. private _getByTags;
  34730. /**
  34731. * Get a list of meshes by tags
  34732. * @param tagsQuery defines the tags query to use
  34733. * @param forEach defines a predicate used to filter results
  34734. * @returns an array of Mesh
  34735. */
  34736. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34737. /**
  34738. * Get a list of cameras by tags
  34739. * @param tagsQuery defines the tags query to use
  34740. * @param forEach defines a predicate used to filter results
  34741. * @returns an array of Camera
  34742. */
  34743. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34744. /**
  34745. * Get a list of lights by tags
  34746. * @param tagsQuery defines the tags query to use
  34747. * @param forEach defines a predicate used to filter results
  34748. * @returns an array of Light
  34749. */
  34750. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34751. /**
  34752. * Get a list of materials by tags
  34753. * @param tagsQuery defines the tags query to use
  34754. * @param forEach defines a predicate used to filter results
  34755. * @returns an array of Material
  34756. */
  34757. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34758. /**
  34759. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34760. * This allowed control for front to back rendering or reversly depending of the special needs.
  34761. *
  34762. * @param renderingGroupId The rendering group id corresponding to its index
  34763. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34764. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34765. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34766. */
  34767. 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;
  34768. /**
  34769. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34770. *
  34771. * @param renderingGroupId The rendering group id corresponding to its index
  34772. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34773. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34774. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34775. */
  34776. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34777. /**
  34778. * Gets the current auto clear configuration for one rendering group of the rendering
  34779. * manager.
  34780. * @param index the rendering group index to get the information for
  34781. * @returns The auto clear setup for the requested rendering group
  34782. */
  34783. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34784. private _blockMaterialDirtyMechanism;
  34785. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34786. blockMaterialDirtyMechanism: boolean;
  34787. /**
  34788. * Will flag all materials as dirty to trigger new shader compilation
  34789. * @param flag defines the flag used to specify which material part must be marked as dirty
  34790. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34791. */
  34792. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34793. /** @hidden */
  34794. _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;
  34795. /** @hidden */
  34796. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34797. }
  34798. }
  34799. declare module "babylonjs/assetContainer" {
  34800. import { AbstractScene } from "babylonjs/abstractScene";
  34801. import { Scene } from "babylonjs/scene";
  34802. import { Mesh } from "babylonjs/Meshes/mesh";
  34803. /**
  34804. * Set of assets to keep when moving a scene into an asset container.
  34805. */
  34806. export class KeepAssets extends AbstractScene {
  34807. }
  34808. /**
  34809. * Container with a set of assets that can be added or removed from a scene.
  34810. */
  34811. export class AssetContainer extends AbstractScene {
  34812. /**
  34813. * The scene the AssetContainer belongs to.
  34814. */
  34815. scene: Scene;
  34816. /**
  34817. * Instantiates an AssetContainer.
  34818. * @param scene The scene the AssetContainer belongs to.
  34819. */
  34820. constructor(scene: Scene);
  34821. /**
  34822. * Adds all the assets from the container to the scene.
  34823. */
  34824. addAllToScene(): void;
  34825. /**
  34826. * Removes all the assets in the container from the scene
  34827. */
  34828. removeAllFromScene(): void;
  34829. /**
  34830. * Disposes all the assets in the container
  34831. */
  34832. dispose(): void;
  34833. private _moveAssets;
  34834. /**
  34835. * Removes all the assets contained in the scene and adds them to the container.
  34836. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34837. */
  34838. moveAllFromScene(keepAssets?: KeepAssets): void;
  34839. /**
  34840. * 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.
  34841. * @returns the root mesh
  34842. */
  34843. createRootMesh(): Mesh;
  34844. }
  34845. }
  34846. declare module "babylonjs/abstractScene" {
  34847. import { Scene } from "babylonjs/scene";
  34848. import { Nullable } from "babylonjs/types";
  34849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34850. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34851. import { Geometry } from "babylonjs/Meshes/geometry";
  34852. import { Skeleton } from "babylonjs/Bones/skeleton";
  34853. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34854. import { AssetContainer } from "babylonjs/assetContainer";
  34855. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34856. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34857. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34858. import { Material } from "babylonjs/Materials/material";
  34859. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34860. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34861. import { Camera } from "babylonjs/Cameras/camera";
  34862. import { Light } from "babylonjs/Lights/light";
  34863. import { Node } from "babylonjs/node";
  34864. import { Animation } from "babylonjs/Animations/animation";
  34865. /**
  34866. * Defines how the parser contract is defined.
  34867. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34868. */
  34869. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34870. /**
  34871. * Defines how the individual parser contract is defined.
  34872. * These parser can parse an individual asset
  34873. */
  34874. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34875. /**
  34876. * Base class of the scene acting as a container for the different elements composing a scene.
  34877. * This class is dynamically extended by the different components of the scene increasing
  34878. * flexibility and reducing coupling
  34879. */
  34880. export abstract class AbstractScene {
  34881. /**
  34882. * Stores the list of available parsers in the application.
  34883. */
  34884. private static _BabylonFileParsers;
  34885. /**
  34886. * Stores the list of available individual parsers in the application.
  34887. */
  34888. private static _IndividualBabylonFileParsers;
  34889. /**
  34890. * Adds a parser in the list of available ones
  34891. * @param name Defines the name of the parser
  34892. * @param parser Defines the parser to add
  34893. */
  34894. static AddParser(name: string, parser: BabylonFileParser): void;
  34895. /**
  34896. * Gets a general parser from the list of avaialble ones
  34897. * @param name Defines the name of the parser
  34898. * @returns the requested parser or null
  34899. */
  34900. static GetParser(name: string): Nullable<BabylonFileParser>;
  34901. /**
  34902. * Adds n individual parser in the list of available ones
  34903. * @param name Defines the name of the parser
  34904. * @param parser Defines the parser to add
  34905. */
  34906. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34907. /**
  34908. * Gets an individual parser from the list of avaialble ones
  34909. * @param name Defines the name of the parser
  34910. * @returns the requested parser or null
  34911. */
  34912. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34913. /**
  34914. * Parser json data and populate both a scene and its associated container object
  34915. * @param jsonData Defines the data to parse
  34916. * @param scene Defines the scene to parse the data for
  34917. * @param container Defines the container attached to the parsing sequence
  34918. * @param rootUrl Defines the root url of the data
  34919. */
  34920. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34921. /**
  34922. * Gets the list of root nodes (ie. nodes with no parent)
  34923. */
  34924. rootNodes: Node[];
  34925. /** All of the cameras added to this scene
  34926. * @see http://doc.babylonjs.com/babylon101/cameras
  34927. */
  34928. cameras: Camera[];
  34929. /**
  34930. * All of the lights added to this scene
  34931. * @see http://doc.babylonjs.com/babylon101/lights
  34932. */
  34933. lights: Light[];
  34934. /**
  34935. * All of the (abstract) meshes added to this scene
  34936. */
  34937. meshes: AbstractMesh[];
  34938. /**
  34939. * The list of skeletons added to the scene
  34940. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34941. */
  34942. skeletons: Skeleton[];
  34943. /**
  34944. * All of the particle systems added to this scene
  34945. * @see http://doc.babylonjs.com/babylon101/particles
  34946. */
  34947. particleSystems: IParticleSystem[];
  34948. /**
  34949. * Gets a list of Animations associated with the scene
  34950. */
  34951. animations: Animation[];
  34952. /**
  34953. * All of the animation groups added to this scene
  34954. * @see http://doc.babylonjs.com/how_to/group
  34955. */
  34956. animationGroups: AnimationGroup[];
  34957. /**
  34958. * All of the multi-materials added to this scene
  34959. * @see http://doc.babylonjs.com/how_to/multi_materials
  34960. */
  34961. multiMaterials: MultiMaterial[];
  34962. /**
  34963. * All of the materials added to this scene
  34964. * In the context of a Scene, it is not supposed to be modified manually.
  34965. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34966. * Note also that the order of the Material wihin the array is not significant and might change.
  34967. * @see http://doc.babylonjs.com/babylon101/materials
  34968. */
  34969. materials: Material[];
  34970. /**
  34971. * The list of morph target managers added to the scene
  34972. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34973. */
  34974. morphTargetManagers: MorphTargetManager[];
  34975. /**
  34976. * The list of geometries used in the scene.
  34977. */
  34978. geometries: Geometry[];
  34979. /**
  34980. * All of the tranform nodes added to this scene
  34981. * In the context of a Scene, it is not supposed to be modified manually.
  34982. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34983. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34984. * @see http://doc.babylonjs.com/how_to/transformnode
  34985. */
  34986. transformNodes: TransformNode[];
  34987. /**
  34988. * ActionManagers available on the scene.
  34989. */
  34990. actionManagers: AbstractActionManager[];
  34991. /**
  34992. * Textures to keep.
  34993. */
  34994. textures: BaseTexture[];
  34995. /**
  34996. * Environment texture for the scene
  34997. */
  34998. environmentTexture: Nullable<BaseTexture>;
  34999. }
  35000. }
  35001. declare module "babylonjs/Audio/sound" {
  35002. import { Observable } from "babylonjs/Misc/observable";
  35003. import { Vector3 } from "babylonjs/Maths/math";
  35004. import { Nullable } from "babylonjs/types";
  35005. import { Scene } from "babylonjs/scene";
  35006. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35007. /**
  35008. * Defines a sound that can be played in the application.
  35009. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35010. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35011. */
  35012. export class Sound {
  35013. /**
  35014. * The name of the sound in the scene.
  35015. */
  35016. name: string;
  35017. /**
  35018. * Does the sound autoplay once loaded.
  35019. */
  35020. autoplay: boolean;
  35021. /**
  35022. * Does the sound loop after it finishes playing once.
  35023. */
  35024. loop: boolean;
  35025. /**
  35026. * Does the sound use a custom attenuation curve to simulate the falloff
  35027. * happening when the source gets further away from the camera.
  35028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35029. */
  35030. useCustomAttenuation: boolean;
  35031. /**
  35032. * The sound track id this sound belongs to.
  35033. */
  35034. soundTrackId: number;
  35035. /**
  35036. * Is this sound currently played.
  35037. */
  35038. isPlaying: boolean;
  35039. /**
  35040. * Is this sound currently paused.
  35041. */
  35042. isPaused: boolean;
  35043. /**
  35044. * Does this sound enables spatial sound.
  35045. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35046. */
  35047. spatialSound: boolean;
  35048. /**
  35049. * Define the reference distance the sound should be heard perfectly.
  35050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35051. */
  35052. refDistance: number;
  35053. /**
  35054. * Define the roll off factor of spatial sounds.
  35055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35056. */
  35057. rolloffFactor: number;
  35058. /**
  35059. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35061. */
  35062. maxDistance: number;
  35063. /**
  35064. * Define the distance attenuation model the sound will follow.
  35065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35066. */
  35067. distanceModel: string;
  35068. /**
  35069. * @hidden
  35070. * Back Compat
  35071. **/
  35072. onended: () => any;
  35073. /**
  35074. * Observable event when the current playing sound finishes.
  35075. */
  35076. onEndedObservable: Observable<Sound>;
  35077. private _panningModel;
  35078. private _playbackRate;
  35079. private _streaming;
  35080. private _startTime;
  35081. private _startOffset;
  35082. private _position;
  35083. /** @hidden */
  35084. _positionInEmitterSpace: boolean;
  35085. private _localDirection;
  35086. private _volume;
  35087. private _isReadyToPlay;
  35088. private _isDirectional;
  35089. private _readyToPlayCallback;
  35090. private _audioBuffer;
  35091. private _soundSource;
  35092. private _streamingSource;
  35093. private _soundPanner;
  35094. private _soundGain;
  35095. private _inputAudioNode;
  35096. private _outputAudioNode;
  35097. private _coneInnerAngle;
  35098. private _coneOuterAngle;
  35099. private _coneOuterGain;
  35100. private _scene;
  35101. private _connectedTransformNode;
  35102. private _customAttenuationFunction;
  35103. private _registerFunc;
  35104. private _isOutputConnected;
  35105. private _htmlAudioElement;
  35106. private _urlType;
  35107. /** @hidden */
  35108. static _SceneComponentInitialization: (scene: Scene) => void;
  35109. /**
  35110. * Create a sound and attach it to a scene
  35111. * @param name Name of your sound
  35112. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35113. * @param scene defines the scene the sound belongs to
  35114. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35115. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35116. */
  35117. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  35118. /**
  35119. * Release the sound and its associated resources
  35120. */
  35121. dispose(): void;
  35122. /**
  35123. * Gets if the sounds is ready to be played or not.
  35124. * @returns true if ready, otherwise false
  35125. */
  35126. isReady(): boolean;
  35127. private _soundLoaded;
  35128. /**
  35129. * Sets the data of the sound from an audiobuffer
  35130. * @param audioBuffer The audioBuffer containing the data
  35131. */
  35132. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35133. /**
  35134. * Updates the current sounds options such as maxdistance, loop...
  35135. * @param options A JSON object containing values named as the object properties
  35136. */
  35137. updateOptions(options: any): void;
  35138. private _createSpatialParameters;
  35139. private _updateSpatialParameters;
  35140. /**
  35141. * Switch the panning model to HRTF:
  35142. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35144. */
  35145. switchPanningModelToHRTF(): void;
  35146. /**
  35147. * Switch the panning model to Equal Power:
  35148. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35149. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35150. */
  35151. switchPanningModelToEqualPower(): void;
  35152. private _switchPanningModel;
  35153. /**
  35154. * Connect this sound to a sound track audio node like gain...
  35155. * @param soundTrackAudioNode the sound track audio node to connect to
  35156. */
  35157. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35158. /**
  35159. * Transform this sound into a directional source
  35160. * @param coneInnerAngle Size of the inner cone in degree
  35161. * @param coneOuterAngle Size of the outer cone in degree
  35162. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35163. */
  35164. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35165. /**
  35166. * Gets or sets the inner angle for the directional cone.
  35167. */
  35168. /**
  35169. * Gets or sets the inner angle for the directional cone.
  35170. */
  35171. directionalConeInnerAngle: number;
  35172. /**
  35173. * Gets or sets the outer angle for the directional cone.
  35174. */
  35175. /**
  35176. * Gets or sets the outer angle for the directional cone.
  35177. */
  35178. directionalConeOuterAngle: number;
  35179. /**
  35180. * Sets the position of the emitter if spatial sound is enabled
  35181. * @param newPosition Defines the new posisiton
  35182. */
  35183. setPosition(newPosition: Vector3): void;
  35184. /**
  35185. * Sets the local direction of the emitter if spatial sound is enabled
  35186. * @param newLocalDirection Defines the new local direction
  35187. */
  35188. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35189. private _updateDirection;
  35190. /** @hidden */
  35191. updateDistanceFromListener(): void;
  35192. /**
  35193. * Sets a new custom attenuation function for the sound.
  35194. * @param callback Defines the function used for the attenuation
  35195. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35196. */
  35197. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35198. /**
  35199. * Play the sound
  35200. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35201. * @param offset (optional) Start the sound setting it at a specific time
  35202. */
  35203. play(time?: number, offset?: number): void;
  35204. private _onended;
  35205. /**
  35206. * Stop the sound
  35207. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35208. */
  35209. stop(time?: number): void;
  35210. /**
  35211. * Put the sound in pause
  35212. */
  35213. pause(): void;
  35214. /**
  35215. * Sets a dedicated volume for this sounds
  35216. * @param newVolume Define the new volume of the sound
  35217. * @param time Define in how long the sound should be at this value
  35218. */
  35219. setVolume(newVolume: number, time?: number): void;
  35220. /**
  35221. * Set the sound play back rate
  35222. * @param newPlaybackRate Define the playback rate the sound should be played at
  35223. */
  35224. setPlaybackRate(newPlaybackRate: number): void;
  35225. /**
  35226. * Gets the volume of the sound.
  35227. * @returns the volume of the sound
  35228. */
  35229. getVolume(): number;
  35230. /**
  35231. * Attach the sound to a dedicated mesh
  35232. * @param transformNode The transform node to connect the sound with
  35233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35234. */
  35235. attachToMesh(transformNode: TransformNode): void;
  35236. /**
  35237. * Detach the sound from the previously attached mesh
  35238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35239. */
  35240. detachFromMesh(): void;
  35241. private _onRegisterAfterWorldMatrixUpdate;
  35242. /**
  35243. * Clone the current sound in the scene.
  35244. * @returns the new sound clone
  35245. */
  35246. clone(): Nullable<Sound>;
  35247. /**
  35248. * Gets the current underlying audio buffer containing the data
  35249. * @returns the audio buffer
  35250. */
  35251. getAudioBuffer(): Nullable<AudioBuffer>;
  35252. /**
  35253. * Serializes the Sound in a JSON representation
  35254. * @returns the JSON representation of the sound
  35255. */
  35256. serialize(): any;
  35257. /**
  35258. * Parse a JSON representation of a sound to innstantiate in a given scene
  35259. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35260. * @param scene Define the scene the new parsed sound should be created in
  35261. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35262. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35263. * @returns the newly parsed sound
  35264. */
  35265. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35266. }
  35267. }
  35268. declare module "babylonjs/Actions/directAudioActions" {
  35269. import { Action } from "babylonjs/Actions/action";
  35270. import { Condition } from "babylonjs/Actions/condition";
  35271. import { Sound } from "babylonjs/Audio/sound";
  35272. /**
  35273. * This defines an action helpful to play a defined sound on a triggered action.
  35274. */
  35275. export class PlaySoundAction extends Action {
  35276. private _sound;
  35277. /**
  35278. * Instantiate the action
  35279. * @param triggerOptions defines the trigger options
  35280. * @param sound defines the sound to play
  35281. * @param condition defines the trigger related conditions
  35282. */
  35283. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35284. /** @hidden */
  35285. _prepare(): void;
  35286. /**
  35287. * Execute the action and play the sound.
  35288. */
  35289. execute(): void;
  35290. /**
  35291. * Serializes the actions and its related information.
  35292. * @param parent defines the object to serialize in
  35293. * @returns the serialized object
  35294. */
  35295. serialize(parent: any): any;
  35296. }
  35297. /**
  35298. * This defines an action helpful to stop a defined sound on a triggered action.
  35299. */
  35300. export class StopSoundAction extends Action {
  35301. private _sound;
  35302. /**
  35303. * Instantiate the action
  35304. * @param triggerOptions defines the trigger options
  35305. * @param sound defines the sound to stop
  35306. * @param condition defines the trigger related conditions
  35307. */
  35308. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35309. /** @hidden */
  35310. _prepare(): void;
  35311. /**
  35312. * Execute the action and stop the sound.
  35313. */
  35314. execute(): void;
  35315. /**
  35316. * Serializes the actions and its related information.
  35317. * @param parent defines the object to serialize in
  35318. * @returns the serialized object
  35319. */
  35320. serialize(parent: any): any;
  35321. }
  35322. }
  35323. declare module "babylonjs/Actions/interpolateValueAction" {
  35324. import { Action } from "babylonjs/Actions/action";
  35325. import { Condition } from "babylonjs/Actions/condition";
  35326. import { Observable } from "babylonjs/Misc/observable";
  35327. /**
  35328. * This defines an action responsible to change the value of a property
  35329. * by interpolating between its current value and the newly set one once triggered.
  35330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35331. */
  35332. export class InterpolateValueAction extends Action {
  35333. /**
  35334. * Defines the path of the property where the value should be interpolated
  35335. */
  35336. propertyPath: string;
  35337. /**
  35338. * Defines the target value at the end of the interpolation.
  35339. */
  35340. value: any;
  35341. /**
  35342. * Defines the time it will take for the property to interpolate to the value.
  35343. */
  35344. duration: number;
  35345. /**
  35346. * Defines if the other scene animations should be stopped when the action has been triggered
  35347. */
  35348. stopOtherAnimations?: boolean;
  35349. /**
  35350. * Defines a callback raised once the interpolation animation has been done.
  35351. */
  35352. onInterpolationDone?: () => void;
  35353. /**
  35354. * Observable triggered once the interpolation animation has been done.
  35355. */
  35356. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35357. private _target;
  35358. private _effectiveTarget;
  35359. private _property;
  35360. /**
  35361. * Instantiate the action
  35362. * @param triggerOptions defines the trigger options
  35363. * @param target defines the object containing the value to interpolate
  35364. * @param propertyPath defines the path to the property in the target object
  35365. * @param value defines the target value at the end of the interpolation
  35366. * @param duration deines the time it will take for the property to interpolate to the value.
  35367. * @param condition defines the trigger related conditions
  35368. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35369. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35370. */
  35371. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35372. /** @hidden */
  35373. _prepare(): void;
  35374. /**
  35375. * Execute the action starts the value interpolation.
  35376. */
  35377. execute(): void;
  35378. /**
  35379. * Serializes the actions and its related information.
  35380. * @param parent defines the object to serialize in
  35381. * @returns the serialized object
  35382. */
  35383. serialize(parent: any): any;
  35384. }
  35385. }
  35386. declare module "babylonjs/Actions/index" {
  35387. export * from "babylonjs/Actions/action";
  35388. export * from "babylonjs/Actions/actionEvent";
  35389. export * from "babylonjs/Actions/actionManager";
  35390. export * from "babylonjs/Actions/condition";
  35391. export * from "babylonjs/Actions/directActions";
  35392. export * from "babylonjs/Actions/directAudioActions";
  35393. export * from "babylonjs/Actions/interpolateValueAction";
  35394. }
  35395. declare module "babylonjs/Animations/index" {
  35396. export * from "babylonjs/Animations/animatable";
  35397. export * from "babylonjs/Animations/animation";
  35398. export * from "babylonjs/Animations/animationGroup";
  35399. export * from "babylonjs/Animations/animationPropertiesOverride";
  35400. export * from "babylonjs/Animations/easing";
  35401. export * from "babylonjs/Animations/runtimeAnimation";
  35402. export * from "babylonjs/Animations/animationEvent";
  35403. export * from "babylonjs/Animations/animationGroup";
  35404. export * from "babylonjs/Animations/animationKey";
  35405. export * from "babylonjs/Animations/animationRange";
  35406. }
  35407. declare module "babylonjs/Audio/soundTrack" {
  35408. import { Sound } from "babylonjs/Audio/sound";
  35409. import { Analyser } from "babylonjs/Audio/analyser";
  35410. import { Scene } from "babylonjs/scene";
  35411. /**
  35412. * Options allowed during the creation of a sound track.
  35413. */
  35414. export interface ISoundTrackOptions {
  35415. /**
  35416. * The volume the sound track should take during creation
  35417. */
  35418. volume?: number;
  35419. /**
  35420. * Define if the sound track is the main sound track of the scene
  35421. */
  35422. mainTrack?: boolean;
  35423. }
  35424. /**
  35425. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35426. * It will be also used in a future release to apply effects on a specific track.
  35427. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35428. */
  35429. export class SoundTrack {
  35430. /**
  35431. * The unique identifier of the sound track in the scene.
  35432. */
  35433. id: number;
  35434. /**
  35435. * The list of sounds included in the sound track.
  35436. */
  35437. soundCollection: Array<Sound>;
  35438. private _outputAudioNode;
  35439. private _scene;
  35440. private _isMainTrack;
  35441. private _connectedAnalyser;
  35442. private _options;
  35443. private _isInitialized;
  35444. /**
  35445. * Creates a new sound track.
  35446. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35447. * @param scene Define the scene the sound track belongs to
  35448. * @param options
  35449. */
  35450. constructor(scene: Scene, options?: ISoundTrackOptions);
  35451. private _initializeSoundTrackAudioGraph;
  35452. /**
  35453. * Release the sound track and its associated resources
  35454. */
  35455. dispose(): void;
  35456. /**
  35457. * Adds a sound to this sound track
  35458. * @param sound define the cound to add
  35459. * @ignoreNaming
  35460. */
  35461. AddSound(sound: Sound): void;
  35462. /**
  35463. * Removes a sound to this sound track
  35464. * @param sound define the cound to remove
  35465. * @ignoreNaming
  35466. */
  35467. RemoveSound(sound: Sound): void;
  35468. /**
  35469. * Set a global volume for the full sound track.
  35470. * @param newVolume Define the new volume of the sound track
  35471. */
  35472. setVolume(newVolume: number): void;
  35473. /**
  35474. * Switch the panning model to HRTF:
  35475. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35477. */
  35478. switchPanningModelToHRTF(): void;
  35479. /**
  35480. * Switch the panning model to Equal Power:
  35481. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35482. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35483. */
  35484. switchPanningModelToEqualPower(): void;
  35485. /**
  35486. * Connect the sound track to an audio analyser allowing some amazing
  35487. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35489. * @param analyser The analyser to connect to the engine
  35490. */
  35491. connectToAnalyser(analyser: Analyser): void;
  35492. }
  35493. }
  35494. declare module "babylonjs/Audio/audioSceneComponent" {
  35495. import { Sound } from "babylonjs/Audio/sound";
  35496. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35497. import { Nullable } from "babylonjs/types";
  35498. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35499. import { Scene } from "babylonjs/scene";
  35500. import { AbstractScene } from "babylonjs/abstractScene";
  35501. module "babylonjs/abstractScene" {
  35502. interface AbstractScene {
  35503. /**
  35504. * The list of sounds used in the scene.
  35505. */
  35506. sounds: Nullable<Array<Sound>>;
  35507. }
  35508. }
  35509. module "babylonjs/scene" {
  35510. interface Scene {
  35511. /**
  35512. * @hidden
  35513. * Backing field
  35514. */
  35515. _mainSoundTrack: SoundTrack;
  35516. /**
  35517. * The main sound track played by the scene.
  35518. * It cotains your primary collection of sounds.
  35519. */
  35520. mainSoundTrack: SoundTrack;
  35521. /**
  35522. * The list of sound tracks added to the scene
  35523. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35524. */
  35525. soundTracks: Nullable<Array<SoundTrack>>;
  35526. /**
  35527. * Gets a sound using a given name
  35528. * @param name defines the name to search for
  35529. * @return the found sound or null if not found at all.
  35530. */
  35531. getSoundByName(name: string): Nullable<Sound>;
  35532. /**
  35533. * Gets or sets if audio support is enabled
  35534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35535. */
  35536. audioEnabled: boolean;
  35537. /**
  35538. * Gets or sets if audio will be output to headphones
  35539. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35540. */
  35541. headphone: boolean;
  35542. }
  35543. }
  35544. /**
  35545. * Defines the sound scene component responsible to manage any sounds
  35546. * in a given scene.
  35547. */
  35548. export class AudioSceneComponent implements ISceneSerializableComponent {
  35549. /**
  35550. * The component name helpfull to identify the component in the list of scene components.
  35551. */
  35552. readonly name: string;
  35553. /**
  35554. * The scene the component belongs to.
  35555. */
  35556. scene: Scene;
  35557. private _audioEnabled;
  35558. /**
  35559. * Gets whether audio is enabled or not.
  35560. * Please use related enable/disable method to switch state.
  35561. */
  35562. readonly audioEnabled: boolean;
  35563. private _headphone;
  35564. /**
  35565. * Gets whether audio is outputing to headphone or not.
  35566. * Please use the according Switch methods to change output.
  35567. */
  35568. readonly headphone: boolean;
  35569. /**
  35570. * Creates a new instance of the component for the given scene
  35571. * @param scene Defines the scene to register the component in
  35572. */
  35573. constructor(scene: Scene);
  35574. /**
  35575. * Registers the component in a given scene
  35576. */
  35577. register(): void;
  35578. /**
  35579. * Rebuilds the elements related to this component in case of
  35580. * context lost for instance.
  35581. */
  35582. rebuild(): void;
  35583. /**
  35584. * Serializes the component data to the specified json object
  35585. * @param serializationObject The object to serialize to
  35586. */
  35587. serialize(serializationObject: any): void;
  35588. /**
  35589. * Adds all the elements from the container to the scene
  35590. * @param container the container holding the elements
  35591. */
  35592. addFromContainer(container: AbstractScene): void;
  35593. /**
  35594. * Removes all the elements in the container from the scene
  35595. * @param container contains the elements to remove
  35596. * @param dispose if the removed element should be disposed (default: false)
  35597. */
  35598. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35599. /**
  35600. * Disposes the component and the associated ressources.
  35601. */
  35602. dispose(): void;
  35603. /**
  35604. * Disables audio in the associated scene.
  35605. */
  35606. disableAudio(): void;
  35607. /**
  35608. * Enables audio in the associated scene.
  35609. */
  35610. enableAudio(): void;
  35611. /**
  35612. * Switch audio to headphone output.
  35613. */
  35614. switchAudioModeForHeadphones(): void;
  35615. /**
  35616. * Switch audio to normal speakers.
  35617. */
  35618. switchAudioModeForNormalSpeakers(): void;
  35619. private _afterRender;
  35620. }
  35621. }
  35622. declare module "babylonjs/Audio/weightedsound" {
  35623. import { Sound } from "babylonjs/Audio/sound";
  35624. /**
  35625. * Wraps one or more Sound objects and selects one with random weight for playback.
  35626. */
  35627. export class WeightedSound {
  35628. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35629. loop: boolean;
  35630. private _coneInnerAngle;
  35631. private _coneOuterAngle;
  35632. private _volume;
  35633. /** A Sound is currently playing. */
  35634. isPlaying: boolean;
  35635. /** A Sound is currently paused. */
  35636. isPaused: boolean;
  35637. private _sounds;
  35638. private _weights;
  35639. private _currentIndex?;
  35640. /**
  35641. * Creates a new WeightedSound from the list of sounds given.
  35642. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35643. * @param sounds Array of Sounds that will be selected from.
  35644. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35645. */
  35646. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35647. /**
  35648. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35649. */
  35650. /**
  35651. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35652. */
  35653. directionalConeInnerAngle: number;
  35654. /**
  35655. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35656. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35657. */
  35658. /**
  35659. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35660. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35661. */
  35662. directionalConeOuterAngle: number;
  35663. /**
  35664. * Playback volume.
  35665. */
  35666. /**
  35667. * Playback volume.
  35668. */
  35669. volume: number;
  35670. private _onended;
  35671. /**
  35672. * Suspend playback
  35673. */
  35674. pause(): void;
  35675. /**
  35676. * Stop playback
  35677. */
  35678. stop(): void;
  35679. /**
  35680. * Start playback.
  35681. * @param startOffset Position the clip head at a specific time in seconds.
  35682. */
  35683. play(startOffset?: number): void;
  35684. }
  35685. }
  35686. declare module "babylonjs/Audio/index" {
  35687. export * from "babylonjs/Audio/analyser";
  35688. export * from "babylonjs/Audio/audioEngine";
  35689. export * from "babylonjs/Audio/audioSceneComponent";
  35690. export * from "babylonjs/Audio/sound";
  35691. export * from "babylonjs/Audio/soundTrack";
  35692. export * from "babylonjs/Audio/weightedsound";
  35693. }
  35694. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35695. import { Behavior } from "babylonjs/Behaviors/behavior";
  35696. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35697. import { BackEase } from "babylonjs/Animations/easing";
  35698. /**
  35699. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35700. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35701. */
  35702. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35703. /**
  35704. * Gets the name of the behavior.
  35705. */
  35706. readonly name: string;
  35707. /**
  35708. * The easing function used by animations
  35709. */
  35710. static EasingFunction: BackEase;
  35711. /**
  35712. * The easing mode used by animations
  35713. */
  35714. static EasingMode: number;
  35715. /**
  35716. * The duration of the animation, in milliseconds
  35717. */
  35718. transitionDuration: number;
  35719. /**
  35720. * Length of the distance animated by the transition when lower radius is reached
  35721. */
  35722. lowerRadiusTransitionRange: number;
  35723. /**
  35724. * Length of the distance animated by the transition when upper radius is reached
  35725. */
  35726. upperRadiusTransitionRange: number;
  35727. private _autoTransitionRange;
  35728. /**
  35729. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35730. */
  35731. /**
  35732. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35733. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35734. */
  35735. autoTransitionRange: boolean;
  35736. private _attachedCamera;
  35737. private _onAfterCheckInputsObserver;
  35738. private _onMeshTargetChangedObserver;
  35739. /**
  35740. * Initializes the behavior.
  35741. */
  35742. init(): void;
  35743. /**
  35744. * Attaches the behavior to its arc rotate camera.
  35745. * @param camera Defines the camera to attach the behavior to
  35746. */
  35747. attach(camera: ArcRotateCamera): void;
  35748. /**
  35749. * Detaches the behavior from its current arc rotate camera.
  35750. */
  35751. detach(): void;
  35752. private _radiusIsAnimating;
  35753. private _radiusBounceTransition;
  35754. private _animatables;
  35755. private _cachedWheelPrecision;
  35756. /**
  35757. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35758. * @param radiusLimit The limit to check against.
  35759. * @return Bool to indicate if at limit.
  35760. */
  35761. private _isRadiusAtLimit;
  35762. /**
  35763. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35764. * @param radiusDelta The delta by which to animate to. Can be negative.
  35765. */
  35766. private _applyBoundRadiusAnimation;
  35767. /**
  35768. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35769. */
  35770. protected _clearAnimationLocks(): void;
  35771. /**
  35772. * Stops and removes all animations that have been applied to the camera
  35773. */
  35774. stopAllAnimations(): void;
  35775. }
  35776. }
  35777. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35778. import { Behavior } from "babylonjs/Behaviors/behavior";
  35779. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35780. import { ExponentialEase } from "babylonjs/Animations/easing";
  35781. import { Nullable } from "babylonjs/types";
  35782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35783. import { Vector3 } from "babylonjs/Maths/math";
  35784. /**
  35785. * 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.
  35786. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35787. */
  35788. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35789. /**
  35790. * Gets the name of the behavior.
  35791. */
  35792. readonly name: string;
  35793. private _mode;
  35794. private _radiusScale;
  35795. private _positionScale;
  35796. private _defaultElevation;
  35797. private _elevationReturnTime;
  35798. private _elevationReturnWaitTime;
  35799. private _zoomStopsAnimation;
  35800. private _framingTime;
  35801. /**
  35802. * The easing function used by animations
  35803. */
  35804. static EasingFunction: ExponentialEase;
  35805. /**
  35806. * The easing mode used by animations
  35807. */
  35808. static EasingMode: number;
  35809. /**
  35810. * Sets the current mode used by the behavior
  35811. */
  35812. /**
  35813. * Gets current mode used by the behavior.
  35814. */
  35815. mode: number;
  35816. /**
  35817. * Sets the scale applied to the radius (1 by default)
  35818. */
  35819. /**
  35820. * Gets the scale applied to the radius
  35821. */
  35822. radiusScale: number;
  35823. /**
  35824. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35825. */
  35826. /**
  35827. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35828. */
  35829. positionScale: number;
  35830. /**
  35831. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35832. * behaviour is triggered, in radians.
  35833. */
  35834. /**
  35835. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35836. * behaviour is triggered, in radians.
  35837. */
  35838. defaultElevation: number;
  35839. /**
  35840. * Sets the time (in milliseconds) taken to return to the default beta position.
  35841. * Negative value indicates camera should not return to default.
  35842. */
  35843. /**
  35844. * Gets the time (in milliseconds) taken to return to the default beta position.
  35845. * Negative value indicates camera should not return to default.
  35846. */
  35847. elevationReturnTime: number;
  35848. /**
  35849. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35850. */
  35851. /**
  35852. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35853. */
  35854. elevationReturnWaitTime: number;
  35855. /**
  35856. * Sets the flag that indicates if user zooming should stop animation.
  35857. */
  35858. /**
  35859. * Gets the flag that indicates if user zooming should stop animation.
  35860. */
  35861. zoomStopsAnimation: boolean;
  35862. /**
  35863. * Sets the transition time when framing the mesh, in milliseconds
  35864. */
  35865. /**
  35866. * Gets the transition time when framing the mesh, in milliseconds
  35867. */
  35868. framingTime: number;
  35869. /**
  35870. * Define if the behavior should automatically change the configured
  35871. * camera limits and sensibilities.
  35872. */
  35873. autoCorrectCameraLimitsAndSensibility: boolean;
  35874. private _onPrePointerObservableObserver;
  35875. private _onAfterCheckInputsObserver;
  35876. private _onMeshTargetChangedObserver;
  35877. private _attachedCamera;
  35878. private _isPointerDown;
  35879. private _lastInteractionTime;
  35880. /**
  35881. * Initializes the behavior.
  35882. */
  35883. init(): void;
  35884. /**
  35885. * Attaches the behavior to its arc rotate camera.
  35886. * @param camera Defines the camera to attach the behavior to
  35887. */
  35888. attach(camera: ArcRotateCamera): void;
  35889. /**
  35890. * Detaches the behavior from its current arc rotate camera.
  35891. */
  35892. detach(): void;
  35893. private _animatables;
  35894. private _betaIsAnimating;
  35895. private _betaTransition;
  35896. private _radiusTransition;
  35897. private _vectorTransition;
  35898. /**
  35899. * Targets the given mesh and updates zoom level accordingly.
  35900. * @param mesh The mesh to target.
  35901. * @param radius Optional. If a cached radius position already exists, overrides default.
  35902. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35903. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35904. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35905. */
  35906. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35907. /**
  35908. * Targets the given mesh with its children and updates zoom level accordingly.
  35909. * @param mesh The mesh to target.
  35910. * @param radius Optional. If a cached radius position already exists, overrides default.
  35911. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35912. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35913. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35914. */
  35915. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35916. /**
  35917. * Targets the given meshes with their children and updates zoom level accordingly.
  35918. * @param meshes The mesh to target.
  35919. * @param radius Optional. If a cached radius position already exists, overrides default.
  35920. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35921. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35922. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35923. */
  35924. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35925. /**
  35926. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35927. * @param minimumWorld Determines the smaller position of the bounding box extend
  35928. * @param maximumWorld Determines the bigger position of the bounding box extend
  35929. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35930. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35931. */
  35932. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35933. /**
  35934. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35935. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35936. * frustum width.
  35937. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35938. * to fully enclose the mesh in the viewing frustum.
  35939. */
  35940. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35941. /**
  35942. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35943. * is automatically returned to its default position (expected to be above ground plane).
  35944. */
  35945. private _maintainCameraAboveGround;
  35946. /**
  35947. * Returns the frustum slope based on the canvas ratio and camera FOV
  35948. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35949. */
  35950. private _getFrustumSlope;
  35951. /**
  35952. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35953. */
  35954. private _clearAnimationLocks;
  35955. /**
  35956. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35957. */
  35958. private _applyUserInteraction;
  35959. /**
  35960. * Stops and removes all animations that have been applied to the camera
  35961. */
  35962. stopAllAnimations(): void;
  35963. /**
  35964. * Gets a value indicating if the user is moving the camera
  35965. */
  35966. readonly isUserIsMoving: boolean;
  35967. /**
  35968. * The camera can move all the way towards the mesh.
  35969. */
  35970. static IgnoreBoundsSizeMode: number;
  35971. /**
  35972. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35973. */
  35974. static FitFrustumSidesMode: number;
  35975. }
  35976. }
  35977. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35978. import { Nullable } from "babylonjs/types";
  35979. import { Camera } from "babylonjs/Cameras/camera";
  35980. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35981. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35982. /**
  35983. * Base class for Camera Pointer Inputs.
  35984. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35985. * for example usage.
  35986. */
  35987. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35988. /**
  35989. * Defines the camera the input is attached to.
  35990. */
  35991. abstract camera: Camera;
  35992. /**
  35993. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35994. */
  35995. protected _altKey: boolean;
  35996. protected _ctrlKey: boolean;
  35997. protected _metaKey: boolean;
  35998. protected _shiftKey: boolean;
  35999. /**
  36000. * Which mouse buttons were pressed at time of last mouse event.
  36001. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36002. */
  36003. protected _buttonsPressed: number;
  36004. /**
  36005. * Defines the buttons associated with the input to handle camera move.
  36006. */
  36007. buttons: number[];
  36008. /**
  36009. * Attach the input controls to a specific dom element to get the input from.
  36010. * @param element Defines the element the controls should be listened from
  36011. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36012. */
  36013. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36014. /**
  36015. * Detach the current controls from the specified dom element.
  36016. * @param element Defines the element to stop listening the inputs from
  36017. */
  36018. detachControl(element: Nullable<HTMLElement>): void;
  36019. /**
  36020. * Gets the class name of the current input.
  36021. * @returns the class name
  36022. */
  36023. getClassName(): string;
  36024. /**
  36025. * Get the friendly name associated with the input class.
  36026. * @returns the input friendly name
  36027. */
  36028. getSimpleName(): string;
  36029. /**
  36030. * Called on pointer POINTERDOUBLETAP event.
  36031. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36032. */
  36033. protected onDoubleTap(type: string): void;
  36034. /**
  36035. * Called on pointer POINTERMOVE event if only a single touch is active.
  36036. * Override this method to provide functionality.
  36037. */
  36038. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36039. /**
  36040. * Called on pointer POINTERMOVE event if multiple touches are active.
  36041. * Override this method to provide functionality.
  36042. */
  36043. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36044. /**
  36045. * Called on JS contextmenu event.
  36046. * Override this method to provide functionality.
  36047. */
  36048. protected onContextMenu(evt: PointerEvent): void;
  36049. /**
  36050. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36051. * press.
  36052. * Override this method to provide functionality.
  36053. */
  36054. protected onButtonDown(evt: PointerEvent): void;
  36055. /**
  36056. * Called each time a new POINTERUP event occurs. Ie, for each button
  36057. * release.
  36058. * Override this method to provide functionality.
  36059. */
  36060. protected onButtonUp(evt: PointerEvent): void;
  36061. /**
  36062. * Called when window becomes inactive.
  36063. * Override this method to provide functionality.
  36064. */
  36065. protected onLostFocus(): void;
  36066. private _pointerInput;
  36067. private _observer;
  36068. private _onLostFocus;
  36069. private pointA;
  36070. private pointB;
  36071. }
  36072. }
  36073. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36074. import { Nullable } from "babylonjs/types";
  36075. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36076. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36077. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36078. /**
  36079. * Manage the pointers inputs to control an arc rotate camera.
  36080. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36081. */
  36082. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36083. /**
  36084. * Defines the camera the input is attached to.
  36085. */
  36086. camera: ArcRotateCamera;
  36087. /**
  36088. * Gets the class name of the current input.
  36089. * @returns the class name
  36090. */
  36091. getClassName(): string;
  36092. /**
  36093. * Defines the buttons associated with the input to handle camera move.
  36094. */
  36095. buttons: number[];
  36096. /**
  36097. * Defines the pointer angular sensibility along the X axis or how fast is
  36098. * the camera rotating.
  36099. */
  36100. angularSensibilityX: number;
  36101. /**
  36102. * Defines the pointer angular sensibility along the Y axis or how fast is
  36103. * the camera rotating.
  36104. */
  36105. angularSensibilityY: number;
  36106. /**
  36107. * Defines the pointer pinch precision or how fast is the camera zooming.
  36108. */
  36109. pinchPrecision: number;
  36110. /**
  36111. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36112. * from 0.
  36113. * It defines the percentage of current camera.radius to use as delta when
  36114. * pinch zoom is used.
  36115. */
  36116. pinchDeltaPercentage: number;
  36117. /**
  36118. * Defines the pointer panning sensibility or how fast is the camera moving.
  36119. */
  36120. panningSensibility: number;
  36121. /**
  36122. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36123. */
  36124. multiTouchPanning: boolean;
  36125. /**
  36126. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36127. * zoom (pinch) through multitouch.
  36128. */
  36129. multiTouchPanAndZoom: boolean;
  36130. /**
  36131. * Revers pinch action direction.
  36132. */
  36133. pinchInwards: boolean;
  36134. private _isPanClick;
  36135. private _twoFingerActivityCount;
  36136. private _isPinching;
  36137. /**
  36138. * Called on pointer POINTERMOVE event if only a single touch is active.
  36139. */
  36140. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36141. /**
  36142. * Called on pointer POINTERDOUBLETAP event.
  36143. */
  36144. protected onDoubleTap(type: string): void;
  36145. /**
  36146. * Called on pointer POINTERMOVE event if multiple touches are active.
  36147. */
  36148. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36149. /**
  36150. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36151. * press.
  36152. */
  36153. protected onButtonDown(evt: PointerEvent): void;
  36154. /**
  36155. * Called each time a new POINTERUP event occurs. Ie, for each button
  36156. * release.
  36157. */
  36158. protected onButtonUp(evt: PointerEvent): void;
  36159. /**
  36160. * Called when window becomes inactive.
  36161. */
  36162. protected onLostFocus(): void;
  36163. }
  36164. }
  36165. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36166. import { Nullable } from "babylonjs/types";
  36167. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36168. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36169. /**
  36170. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36172. */
  36173. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36174. /**
  36175. * Defines the camera the input is attached to.
  36176. */
  36177. camera: ArcRotateCamera;
  36178. /**
  36179. * Defines the list of key codes associated with the up action (increase alpha)
  36180. */
  36181. keysUp: number[];
  36182. /**
  36183. * Defines the list of key codes associated with the down action (decrease alpha)
  36184. */
  36185. keysDown: number[];
  36186. /**
  36187. * Defines the list of key codes associated with the left action (increase beta)
  36188. */
  36189. keysLeft: number[];
  36190. /**
  36191. * Defines the list of key codes associated with the right action (decrease beta)
  36192. */
  36193. keysRight: number[];
  36194. /**
  36195. * Defines the list of key codes associated with the reset action.
  36196. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36197. */
  36198. keysReset: number[];
  36199. /**
  36200. * Defines the panning sensibility of the inputs.
  36201. * (How fast is the camera paning)
  36202. */
  36203. panningSensibility: number;
  36204. /**
  36205. * Defines the zooming sensibility of the inputs.
  36206. * (How fast is the camera zooming)
  36207. */
  36208. zoomingSensibility: number;
  36209. /**
  36210. * Defines wether maintaining the alt key down switch the movement mode from
  36211. * orientation to zoom.
  36212. */
  36213. useAltToZoom: boolean;
  36214. /**
  36215. * Rotation speed of the camera
  36216. */
  36217. angularSpeed: number;
  36218. private _keys;
  36219. private _ctrlPressed;
  36220. private _altPressed;
  36221. private _onCanvasBlurObserver;
  36222. private _onKeyboardObserver;
  36223. private _engine;
  36224. private _scene;
  36225. /**
  36226. * Attach the input controls to a specific dom element to get the input from.
  36227. * @param element Defines the element the controls should be listened from
  36228. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36229. */
  36230. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36231. /**
  36232. * Detach the current controls from the specified dom element.
  36233. * @param element Defines the element to stop listening the inputs from
  36234. */
  36235. detachControl(element: Nullable<HTMLElement>): void;
  36236. /**
  36237. * Update the current camera state depending on the inputs that have been used this frame.
  36238. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36239. */
  36240. checkInputs(): void;
  36241. /**
  36242. * Gets the class name of the current intput.
  36243. * @returns the class name
  36244. */
  36245. getClassName(): string;
  36246. /**
  36247. * Get the friendly name associated with the input class.
  36248. * @returns the input friendly name
  36249. */
  36250. getSimpleName(): string;
  36251. }
  36252. }
  36253. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36254. import { Nullable } from "babylonjs/types";
  36255. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36256. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36257. /**
  36258. * Manage the mouse wheel inputs to control an arc rotate camera.
  36259. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36260. */
  36261. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36262. /**
  36263. * Defines the camera the input is attached to.
  36264. */
  36265. camera: ArcRotateCamera;
  36266. /**
  36267. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36268. */
  36269. wheelPrecision: number;
  36270. /**
  36271. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36272. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36273. */
  36274. wheelDeltaPercentage: number;
  36275. private _wheel;
  36276. private _observer;
  36277. private computeDeltaFromMouseWheelLegacyEvent;
  36278. /**
  36279. * Attach the input controls to a specific dom element to get the input from.
  36280. * @param element Defines the element the controls should be listened from
  36281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36282. */
  36283. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36284. /**
  36285. * Detach the current controls from the specified dom element.
  36286. * @param element Defines the element to stop listening the inputs from
  36287. */
  36288. detachControl(element: Nullable<HTMLElement>): void;
  36289. /**
  36290. * Gets the class name of the current intput.
  36291. * @returns the class name
  36292. */
  36293. getClassName(): string;
  36294. /**
  36295. * Get the friendly name associated with the input class.
  36296. * @returns the input friendly name
  36297. */
  36298. getSimpleName(): string;
  36299. }
  36300. }
  36301. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36302. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36303. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36304. /**
  36305. * Default Inputs manager for the ArcRotateCamera.
  36306. * It groups all the default supported inputs for ease of use.
  36307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36308. */
  36309. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36310. /**
  36311. * Instantiates a new ArcRotateCameraInputsManager.
  36312. * @param camera Defines the camera the inputs belong to
  36313. */
  36314. constructor(camera: ArcRotateCamera);
  36315. /**
  36316. * Add mouse wheel input support to the input manager.
  36317. * @returns the current input manager
  36318. */
  36319. addMouseWheel(): ArcRotateCameraInputsManager;
  36320. /**
  36321. * Add pointers input support to the input manager.
  36322. * @returns the current input manager
  36323. */
  36324. addPointers(): ArcRotateCameraInputsManager;
  36325. /**
  36326. * Add keyboard input support to the input manager.
  36327. * @returns the current input manager
  36328. */
  36329. addKeyboard(): ArcRotateCameraInputsManager;
  36330. }
  36331. }
  36332. declare module "babylonjs/Cameras/arcRotateCamera" {
  36333. import { Observable } from "babylonjs/Misc/observable";
  36334. import { Nullable } from "babylonjs/types";
  36335. import { Scene } from "babylonjs/scene";
  36336. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36338. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36339. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36340. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36341. import { Camera } from "babylonjs/Cameras/camera";
  36342. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36343. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36344. import { Collider } from "babylonjs/Collisions/collider";
  36345. /**
  36346. * This represents an orbital type of camera.
  36347. *
  36348. * 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.
  36349. * 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.
  36350. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36351. */
  36352. export class ArcRotateCamera extends TargetCamera {
  36353. /**
  36354. * Defines the rotation angle of the camera along the longitudinal axis.
  36355. */
  36356. alpha: number;
  36357. /**
  36358. * Defines the rotation angle of the camera along the latitudinal axis.
  36359. */
  36360. beta: number;
  36361. /**
  36362. * Defines the radius of the camera from it s target point.
  36363. */
  36364. radius: number;
  36365. protected _target: Vector3;
  36366. protected _targetHost: Nullable<AbstractMesh>;
  36367. /**
  36368. * Defines the target point of the camera.
  36369. * The camera looks towards it form the radius distance.
  36370. */
  36371. target: Vector3;
  36372. /**
  36373. * Define the current local position of the camera in the scene
  36374. */
  36375. position: Vector3;
  36376. protected _upVector: Vector3;
  36377. protected _upToYMatrix: Matrix;
  36378. protected _YToUpMatrix: Matrix;
  36379. /**
  36380. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36381. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36382. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36383. */
  36384. upVector: Vector3;
  36385. /**
  36386. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36387. */
  36388. setMatUp(): void;
  36389. /**
  36390. * Current inertia value on the longitudinal axis.
  36391. * The bigger this number the longer it will take for the camera to stop.
  36392. */
  36393. inertialAlphaOffset: number;
  36394. /**
  36395. * Current inertia value on the latitudinal axis.
  36396. * The bigger this number the longer it will take for the camera to stop.
  36397. */
  36398. inertialBetaOffset: number;
  36399. /**
  36400. * Current inertia value on the radius axis.
  36401. * The bigger this number the longer it will take for the camera to stop.
  36402. */
  36403. inertialRadiusOffset: number;
  36404. /**
  36405. * Minimum allowed angle on the longitudinal axis.
  36406. * This can help limiting how the Camera is able to move in the scene.
  36407. */
  36408. lowerAlphaLimit: Nullable<number>;
  36409. /**
  36410. * Maximum allowed angle on the longitudinal axis.
  36411. * This can help limiting how the Camera is able to move in the scene.
  36412. */
  36413. upperAlphaLimit: Nullable<number>;
  36414. /**
  36415. * Minimum allowed angle on the latitudinal axis.
  36416. * This can help limiting how the Camera is able to move in the scene.
  36417. */
  36418. lowerBetaLimit: number;
  36419. /**
  36420. * Maximum allowed angle on the latitudinal axis.
  36421. * This can help limiting how the Camera is able to move in the scene.
  36422. */
  36423. upperBetaLimit: number;
  36424. /**
  36425. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36426. * This can help limiting how the Camera is able to move in the scene.
  36427. */
  36428. lowerRadiusLimit: Nullable<number>;
  36429. /**
  36430. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36431. * This can help limiting how the Camera is able to move in the scene.
  36432. */
  36433. upperRadiusLimit: Nullable<number>;
  36434. /**
  36435. * Defines the current inertia value used during panning of the camera along the X axis.
  36436. */
  36437. inertialPanningX: number;
  36438. /**
  36439. * Defines the current inertia value used during panning of the camera along the Y axis.
  36440. */
  36441. inertialPanningY: number;
  36442. /**
  36443. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36444. * Basically if your fingers moves away from more than this distance you will be considered
  36445. * in pinch mode.
  36446. */
  36447. pinchToPanMaxDistance: number;
  36448. /**
  36449. * Defines the maximum distance the camera can pan.
  36450. * This could help keeping the cammera always in your scene.
  36451. */
  36452. panningDistanceLimit: Nullable<number>;
  36453. /**
  36454. * Defines the target of the camera before paning.
  36455. */
  36456. panningOriginTarget: Vector3;
  36457. /**
  36458. * Defines the value of the inertia used during panning.
  36459. * 0 would mean stop inertia and one would mean no decelleration at all.
  36460. */
  36461. panningInertia: number;
  36462. /**
  36463. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36464. */
  36465. angularSensibilityX: number;
  36466. /**
  36467. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36468. */
  36469. angularSensibilityY: number;
  36470. /**
  36471. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36472. */
  36473. pinchPrecision: number;
  36474. /**
  36475. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36476. * It will be used instead of pinchDeltaPrecision if different from 0.
  36477. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36478. */
  36479. pinchDeltaPercentage: number;
  36480. /**
  36481. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36482. */
  36483. panningSensibility: number;
  36484. /**
  36485. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36486. */
  36487. keysUp: number[];
  36488. /**
  36489. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36490. */
  36491. keysDown: number[];
  36492. /**
  36493. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36494. */
  36495. keysLeft: number[];
  36496. /**
  36497. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36498. */
  36499. keysRight: number[];
  36500. /**
  36501. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36502. */
  36503. wheelPrecision: number;
  36504. /**
  36505. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36506. * It will be used instead of pinchDeltaPrecision if different from 0.
  36507. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36508. */
  36509. wheelDeltaPercentage: number;
  36510. /**
  36511. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36512. */
  36513. zoomOnFactor: number;
  36514. /**
  36515. * Defines a screen offset for the camera position.
  36516. */
  36517. targetScreenOffset: Vector2;
  36518. /**
  36519. * Allows the camera to be completely reversed.
  36520. * If false the camera can not arrive upside down.
  36521. */
  36522. allowUpsideDown: boolean;
  36523. /**
  36524. * Define if double tap/click is used to restore the previously saved state of the camera.
  36525. */
  36526. useInputToRestoreState: boolean;
  36527. /** @hidden */
  36528. _viewMatrix: Matrix;
  36529. /** @hidden */
  36530. _useCtrlForPanning: boolean;
  36531. /** @hidden */
  36532. _panningMouseButton: number;
  36533. /**
  36534. * Defines the input associated to the camera.
  36535. */
  36536. inputs: ArcRotateCameraInputsManager;
  36537. /** @hidden */
  36538. _reset: () => void;
  36539. /**
  36540. * Defines the allowed panning axis.
  36541. */
  36542. panningAxis: Vector3;
  36543. protected _localDirection: Vector3;
  36544. protected _transformedDirection: Vector3;
  36545. private _bouncingBehavior;
  36546. /**
  36547. * Gets the bouncing behavior of the camera if it has been enabled.
  36548. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36549. */
  36550. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36551. /**
  36552. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36553. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36554. */
  36555. useBouncingBehavior: boolean;
  36556. private _framingBehavior;
  36557. /**
  36558. * Gets the framing behavior of the camera if it has been enabled.
  36559. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36560. */
  36561. readonly framingBehavior: Nullable<FramingBehavior>;
  36562. /**
  36563. * Defines if the framing behavior of the camera is enabled on the camera.
  36564. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36565. */
  36566. useFramingBehavior: boolean;
  36567. private _autoRotationBehavior;
  36568. /**
  36569. * Gets the auto rotation behavior of the camera if it has been enabled.
  36570. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36571. */
  36572. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36573. /**
  36574. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36575. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36576. */
  36577. useAutoRotationBehavior: boolean;
  36578. /**
  36579. * Observable triggered when the mesh target has been changed on the camera.
  36580. */
  36581. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36582. /**
  36583. * Event raised when the camera is colliding with a mesh.
  36584. */
  36585. onCollide: (collidedMesh: AbstractMesh) => void;
  36586. /**
  36587. * Defines whether the camera should check collision with the objects oh the scene.
  36588. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36589. */
  36590. checkCollisions: boolean;
  36591. /**
  36592. * Defines the collision radius of the camera.
  36593. * This simulates a sphere around the camera.
  36594. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36595. */
  36596. collisionRadius: Vector3;
  36597. protected _collider: Collider;
  36598. protected _previousPosition: Vector3;
  36599. protected _collisionVelocity: Vector3;
  36600. protected _newPosition: Vector3;
  36601. protected _previousAlpha: number;
  36602. protected _previousBeta: number;
  36603. protected _previousRadius: number;
  36604. protected _collisionTriggered: boolean;
  36605. protected _targetBoundingCenter: Nullable<Vector3>;
  36606. private _computationVector;
  36607. /**
  36608. * Instantiates a new ArcRotateCamera in a given scene
  36609. * @param name Defines the name of the camera
  36610. * @param alpha Defines the camera rotation along the logitudinal axis
  36611. * @param beta Defines the camera rotation along the latitudinal axis
  36612. * @param radius Defines the camera distance from its target
  36613. * @param target Defines the camera target
  36614. * @param scene Defines the scene the camera belongs to
  36615. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36616. */
  36617. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36618. /** @hidden */
  36619. _initCache(): void;
  36620. /** @hidden */
  36621. _updateCache(ignoreParentClass?: boolean): void;
  36622. protected _getTargetPosition(): Vector3;
  36623. private _storedAlpha;
  36624. private _storedBeta;
  36625. private _storedRadius;
  36626. private _storedTarget;
  36627. /**
  36628. * Stores the current state of the camera (alpha, beta, radius and target)
  36629. * @returns the camera itself
  36630. */
  36631. storeState(): Camera;
  36632. /**
  36633. * @hidden
  36634. * Restored camera state. You must call storeState() first
  36635. */
  36636. _restoreStateValues(): boolean;
  36637. /** @hidden */
  36638. _isSynchronizedViewMatrix(): boolean;
  36639. /**
  36640. * Attached controls to the current camera.
  36641. * @param element Defines the element the controls should be listened from
  36642. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36643. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36644. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36645. */
  36646. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36647. /**
  36648. * Detach the current controls from the camera.
  36649. * The camera will stop reacting to inputs.
  36650. * @param element Defines the element to stop listening the inputs from
  36651. */
  36652. detachControl(element: HTMLElement): void;
  36653. /** @hidden */
  36654. _checkInputs(): void;
  36655. protected _checkLimits(): void;
  36656. /**
  36657. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36658. */
  36659. rebuildAnglesAndRadius(): void;
  36660. /**
  36661. * Use a position to define the current camera related information like aplha, beta and radius
  36662. * @param position Defines the position to set the camera at
  36663. */
  36664. setPosition(position: Vector3): void;
  36665. /**
  36666. * Defines the target the camera should look at.
  36667. * This will automatically adapt alpha beta and radius to fit within the new target.
  36668. * @param target Defines the new target as a Vector or a mesh
  36669. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36670. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36671. */
  36672. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36673. /** @hidden */
  36674. _getViewMatrix(): Matrix;
  36675. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36676. /**
  36677. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36678. * @param meshes Defines the mesh to zoom on
  36679. * @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)
  36680. */
  36681. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36682. /**
  36683. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36684. * The target will be changed but the radius
  36685. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36686. * @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)
  36687. */
  36688. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36689. min: Vector3;
  36690. max: Vector3;
  36691. distance: number;
  36692. }, doNotUpdateMaxZ?: boolean): void;
  36693. /**
  36694. * @override
  36695. * Override Camera.createRigCamera
  36696. */
  36697. createRigCamera(name: string, cameraIndex: number): Camera;
  36698. /**
  36699. * @hidden
  36700. * @override
  36701. * Override Camera._updateRigCameras
  36702. */
  36703. _updateRigCameras(): void;
  36704. /**
  36705. * Destroy the camera and release the current resources hold by it.
  36706. */
  36707. dispose(): void;
  36708. /**
  36709. * Gets the current object class name.
  36710. * @return the class name
  36711. */
  36712. getClassName(): string;
  36713. }
  36714. }
  36715. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36716. import { Behavior } from "babylonjs/Behaviors/behavior";
  36717. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36718. /**
  36719. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36720. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36721. */
  36722. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36723. /**
  36724. * Gets the name of the behavior.
  36725. */
  36726. readonly name: string;
  36727. private _zoomStopsAnimation;
  36728. private _idleRotationSpeed;
  36729. private _idleRotationWaitTime;
  36730. private _idleRotationSpinupTime;
  36731. /**
  36732. * Sets the flag that indicates if user zooming should stop animation.
  36733. */
  36734. /**
  36735. * Gets the flag that indicates if user zooming should stop animation.
  36736. */
  36737. zoomStopsAnimation: boolean;
  36738. /**
  36739. * Sets the default speed at which the camera rotates around the model.
  36740. */
  36741. /**
  36742. * Gets the default speed at which the camera rotates around the model.
  36743. */
  36744. idleRotationSpeed: number;
  36745. /**
  36746. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36747. */
  36748. /**
  36749. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36750. */
  36751. idleRotationWaitTime: number;
  36752. /**
  36753. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36754. */
  36755. /**
  36756. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36757. */
  36758. idleRotationSpinupTime: number;
  36759. /**
  36760. * Gets a value indicating if the camera is currently rotating because of this behavior
  36761. */
  36762. readonly rotationInProgress: boolean;
  36763. private _onPrePointerObservableObserver;
  36764. private _onAfterCheckInputsObserver;
  36765. private _attachedCamera;
  36766. private _isPointerDown;
  36767. private _lastFrameTime;
  36768. private _lastInteractionTime;
  36769. private _cameraRotationSpeed;
  36770. /**
  36771. * Initializes the behavior.
  36772. */
  36773. init(): void;
  36774. /**
  36775. * Attaches the behavior to its arc rotate camera.
  36776. * @param camera Defines the camera to attach the behavior to
  36777. */
  36778. attach(camera: ArcRotateCamera): void;
  36779. /**
  36780. * Detaches the behavior from its current arc rotate camera.
  36781. */
  36782. detach(): void;
  36783. /**
  36784. * Returns true if user is scrolling.
  36785. * @return true if user is scrolling.
  36786. */
  36787. private _userIsZooming;
  36788. private _lastFrameRadius;
  36789. private _shouldAnimationStopForInteraction;
  36790. /**
  36791. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36792. */
  36793. private _applyUserInteraction;
  36794. private _userIsMoving;
  36795. }
  36796. }
  36797. declare module "babylonjs/Behaviors/Cameras/index" {
  36798. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36799. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36800. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36801. }
  36802. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36803. import { Mesh } from "babylonjs/Meshes/mesh";
  36804. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36805. import { Behavior } from "babylonjs/Behaviors/behavior";
  36806. /**
  36807. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36808. */
  36809. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36810. private ui;
  36811. /**
  36812. * The name of the behavior
  36813. */
  36814. name: string;
  36815. /**
  36816. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36817. */
  36818. distanceAwayFromFace: number;
  36819. /**
  36820. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36821. */
  36822. distanceAwayFromBottomOfFace: number;
  36823. private _faceVectors;
  36824. private _target;
  36825. private _scene;
  36826. private _onRenderObserver;
  36827. private _tmpMatrix;
  36828. private _tmpVector;
  36829. /**
  36830. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36831. * @param ui The transform node that should be attched to the mesh
  36832. */
  36833. constructor(ui: TransformNode);
  36834. /**
  36835. * Initializes the behavior
  36836. */
  36837. init(): void;
  36838. private _closestFace;
  36839. private _zeroVector;
  36840. private _lookAtTmpMatrix;
  36841. private _lookAtToRef;
  36842. /**
  36843. * Attaches the AttachToBoxBehavior to the passed in mesh
  36844. * @param target The mesh that the specified node will be attached to
  36845. */
  36846. attach(target: Mesh): void;
  36847. /**
  36848. * Detaches the behavior from the mesh
  36849. */
  36850. detach(): void;
  36851. }
  36852. }
  36853. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36854. import { Behavior } from "babylonjs/Behaviors/behavior";
  36855. import { Mesh } from "babylonjs/Meshes/mesh";
  36856. /**
  36857. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36858. */
  36859. export class FadeInOutBehavior implements Behavior<Mesh> {
  36860. /**
  36861. * Time in milliseconds to delay before fading in (Default: 0)
  36862. */
  36863. delay: number;
  36864. /**
  36865. * Time in milliseconds for the mesh to fade in (Default: 300)
  36866. */
  36867. fadeInTime: number;
  36868. private _millisecondsPerFrame;
  36869. private _hovered;
  36870. private _hoverValue;
  36871. private _ownerNode;
  36872. /**
  36873. * Instatiates the FadeInOutBehavior
  36874. */
  36875. constructor();
  36876. /**
  36877. * The name of the behavior
  36878. */
  36879. readonly name: string;
  36880. /**
  36881. * Initializes the behavior
  36882. */
  36883. init(): void;
  36884. /**
  36885. * Attaches the fade behavior on the passed in mesh
  36886. * @param ownerNode The mesh that will be faded in/out once attached
  36887. */
  36888. attach(ownerNode: Mesh): void;
  36889. /**
  36890. * Detaches the behavior from the mesh
  36891. */
  36892. detach(): void;
  36893. /**
  36894. * Triggers the mesh to begin fading in or out
  36895. * @param value if the object should fade in or out (true to fade in)
  36896. */
  36897. fadeIn(value: boolean): void;
  36898. private _update;
  36899. private _setAllVisibility;
  36900. }
  36901. }
  36902. declare module "babylonjs/Misc/pivotTools" {
  36903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36904. /**
  36905. * Class containing a set of static utilities functions for managing Pivots
  36906. * @hidden
  36907. */
  36908. export class PivotTools {
  36909. private static _PivotCached;
  36910. private static _OldPivotPoint;
  36911. private static _PivotTranslation;
  36912. private static _PivotTmpVector;
  36913. /** @hidden */
  36914. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36915. /** @hidden */
  36916. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36917. }
  36918. }
  36919. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36920. import { Scene } from "babylonjs/scene";
  36921. import { Vector4, Plane } from "babylonjs/Maths/math";
  36922. import { Mesh } from "babylonjs/Meshes/mesh";
  36923. import { Nullable } from "babylonjs/types";
  36924. /**
  36925. * Class containing static functions to help procedurally build meshes
  36926. */
  36927. export class PlaneBuilder {
  36928. /**
  36929. * Creates a plane mesh
  36930. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36931. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36932. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36934. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36936. * @param name defines the name of the mesh
  36937. * @param options defines the options used to create the mesh
  36938. * @param scene defines the hosting scene
  36939. * @returns the plane mesh
  36940. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36941. */
  36942. static CreatePlane(name: string, options: {
  36943. size?: number;
  36944. width?: number;
  36945. height?: number;
  36946. sideOrientation?: number;
  36947. frontUVs?: Vector4;
  36948. backUVs?: Vector4;
  36949. updatable?: boolean;
  36950. sourcePlane?: Plane;
  36951. }, scene?: Nullable<Scene>): Mesh;
  36952. }
  36953. }
  36954. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36955. import { Behavior } from "babylonjs/Behaviors/behavior";
  36956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36957. import { Observable } from "babylonjs/Misc/observable";
  36958. import { Vector3 } from "babylonjs/Maths/math";
  36959. import { Ray } from "babylonjs/Culling/ray";
  36960. import "babylonjs/Meshes/Builders/planeBuilder";
  36961. /**
  36962. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36963. */
  36964. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36965. private static _AnyMouseID;
  36966. /**
  36967. * Abstract mesh the behavior is set on
  36968. */
  36969. attachedNode: AbstractMesh;
  36970. private _dragPlane;
  36971. private _scene;
  36972. private _pointerObserver;
  36973. private _beforeRenderObserver;
  36974. private static _planeScene;
  36975. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36976. /**
  36977. * 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)
  36978. */
  36979. maxDragAngle: number;
  36980. /**
  36981. * @hidden
  36982. */
  36983. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36984. /**
  36985. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36986. */
  36987. currentDraggingPointerID: number;
  36988. /**
  36989. * The last position where the pointer hit the drag plane in world space
  36990. */
  36991. lastDragPosition: Vector3;
  36992. /**
  36993. * If the behavior is currently in a dragging state
  36994. */
  36995. dragging: boolean;
  36996. /**
  36997. * 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)
  36998. */
  36999. dragDeltaRatio: number;
  37000. /**
  37001. * If the drag plane orientation should be updated during the dragging (Default: true)
  37002. */
  37003. updateDragPlane: boolean;
  37004. private _debugMode;
  37005. private _moving;
  37006. /**
  37007. * Fires each time the attached mesh is dragged with the pointer
  37008. * * delta between last drag position and current drag position in world space
  37009. * * dragDistance along the drag axis
  37010. * * dragPlaneNormal normal of the current drag plane used during the drag
  37011. * * dragPlanePoint in world space where the drag intersects the drag plane
  37012. */
  37013. onDragObservable: Observable<{
  37014. delta: Vector3;
  37015. dragPlanePoint: Vector3;
  37016. dragPlaneNormal: Vector3;
  37017. dragDistance: number;
  37018. pointerId: number;
  37019. }>;
  37020. /**
  37021. * Fires each time a drag begins (eg. mouse down on mesh)
  37022. */
  37023. onDragStartObservable: Observable<{
  37024. dragPlanePoint: Vector3;
  37025. pointerId: number;
  37026. }>;
  37027. /**
  37028. * Fires each time a drag ends (eg. mouse release after drag)
  37029. */
  37030. onDragEndObservable: Observable<{
  37031. dragPlanePoint: Vector3;
  37032. pointerId: number;
  37033. }>;
  37034. /**
  37035. * If the attached mesh should be moved when dragged
  37036. */
  37037. moveAttached: boolean;
  37038. /**
  37039. * If the drag behavior will react to drag events (Default: true)
  37040. */
  37041. enabled: boolean;
  37042. /**
  37043. * If camera controls should be detached during the drag
  37044. */
  37045. detachCameraControls: boolean;
  37046. /**
  37047. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37048. */
  37049. useObjectOrienationForDragging: boolean;
  37050. private _options;
  37051. /**
  37052. * Creates a pointer drag behavior that can be attached to a mesh
  37053. * @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)
  37054. */
  37055. constructor(options?: {
  37056. dragAxis?: Vector3;
  37057. dragPlaneNormal?: Vector3;
  37058. });
  37059. /**
  37060. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37061. */
  37062. validateDrag: (targetPosition: Vector3) => boolean;
  37063. /**
  37064. * The name of the behavior
  37065. */
  37066. readonly name: string;
  37067. /**
  37068. * Initializes the behavior
  37069. */
  37070. init(): void;
  37071. private _tmpVector;
  37072. private _alternatePickedPoint;
  37073. private _worldDragAxis;
  37074. private _targetPosition;
  37075. private _attachedElement;
  37076. /**
  37077. * Attaches the drag behavior the passed in mesh
  37078. * @param ownerNode The mesh that will be dragged around once attached
  37079. */
  37080. attach(ownerNode: AbstractMesh): void;
  37081. /**
  37082. * Force relase the drag action by code.
  37083. */
  37084. releaseDrag(): void;
  37085. private _startDragRay;
  37086. private _lastPointerRay;
  37087. /**
  37088. * Simulates the start of a pointer drag event on the behavior
  37089. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37090. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37091. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37092. */
  37093. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37094. private _startDrag;
  37095. private _dragDelta;
  37096. private _moveDrag;
  37097. private _pickWithRayOnDragPlane;
  37098. private _pointA;
  37099. private _pointB;
  37100. private _pointC;
  37101. private _lineA;
  37102. private _lineB;
  37103. private _localAxis;
  37104. private _lookAt;
  37105. private _updateDragPlanePosition;
  37106. /**
  37107. * Detaches the behavior from the mesh
  37108. */
  37109. detach(): void;
  37110. }
  37111. }
  37112. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37113. import { Mesh } from "babylonjs/Meshes/mesh";
  37114. import { Behavior } from "babylonjs/Behaviors/behavior";
  37115. /**
  37116. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37117. */
  37118. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37119. private _dragBehaviorA;
  37120. private _dragBehaviorB;
  37121. private _startDistance;
  37122. private _initialScale;
  37123. private _targetScale;
  37124. private _ownerNode;
  37125. private _sceneRenderObserver;
  37126. /**
  37127. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37128. */
  37129. constructor();
  37130. /**
  37131. * The name of the behavior
  37132. */
  37133. readonly name: string;
  37134. /**
  37135. * Initializes the behavior
  37136. */
  37137. init(): void;
  37138. private _getCurrentDistance;
  37139. /**
  37140. * Attaches the scale behavior the passed in mesh
  37141. * @param ownerNode The mesh that will be scaled around once attached
  37142. */
  37143. attach(ownerNode: Mesh): void;
  37144. /**
  37145. * Detaches the behavior from the mesh
  37146. */
  37147. detach(): void;
  37148. }
  37149. }
  37150. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37151. import { Behavior } from "babylonjs/Behaviors/behavior";
  37152. import { Mesh } from "babylonjs/Meshes/mesh";
  37153. import { Observable } from "babylonjs/Misc/observable";
  37154. /**
  37155. * 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
  37156. */
  37157. export class SixDofDragBehavior implements Behavior<Mesh> {
  37158. private static _virtualScene;
  37159. private _ownerNode;
  37160. private _sceneRenderObserver;
  37161. private _scene;
  37162. private _targetPosition;
  37163. private _virtualOriginMesh;
  37164. private _virtualDragMesh;
  37165. private _pointerObserver;
  37166. private _moving;
  37167. private _startingOrientation;
  37168. /**
  37169. * 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)
  37170. */
  37171. private zDragFactor;
  37172. /**
  37173. * If the object should rotate to face the drag origin
  37174. */
  37175. rotateDraggedObject: boolean;
  37176. /**
  37177. * If the behavior is currently in a dragging state
  37178. */
  37179. dragging: boolean;
  37180. /**
  37181. * 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)
  37182. */
  37183. dragDeltaRatio: number;
  37184. /**
  37185. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37186. */
  37187. currentDraggingPointerID: number;
  37188. /**
  37189. * If camera controls should be detached during the drag
  37190. */
  37191. detachCameraControls: boolean;
  37192. /**
  37193. * Fires each time a drag starts
  37194. */
  37195. onDragStartObservable: Observable<{}>;
  37196. /**
  37197. * Fires each time a drag ends (eg. mouse release after drag)
  37198. */
  37199. onDragEndObservable: Observable<{}>;
  37200. /**
  37201. * 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
  37202. */
  37203. constructor();
  37204. /**
  37205. * The name of the behavior
  37206. */
  37207. readonly name: string;
  37208. /**
  37209. * Initializes the behavior
  37210. */
  37211. init(): void;
  37212. /**
  37213. * Attaches the scale behavior the passed in mesh
  37214. * @param ownerNode The mesh that will be scaled around once attached
  37215. */
  37216. attach(ownerNode: Mesh): void;
  37217. /**
  37218. * Detaches the behavior from the mesh
  37219. */
  37220. detach(): void;
  37221. }
  37222. }
  37223. declare module "babylonjs/Behaviors/Meshes/index" {
  37224. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37225. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37226. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37227. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37228. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37229. }
  37230. declare module "babylonjs/Behaviors/index" {
  37231. export * from "babylonjs/Behaviors/behavior";
  37232. export * from "babylonjs/Behaviors/Cameras/index";
  37233. export * from "babylonjs/Behaviors/Meshes/index";
  37234. }
  37235. declare module "babylonjs/Bones/boneIKController" {
  37236. import { Bone } from "babylonjs/Bones/bone";
  37237. import { Vector3 } from "babylonjs/Maths/math";
  37238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37239. import { Nullable } from "babylonjs/types";
  37240. /**
  37241. * Class used to apply inverse kinematics to bones
  37242. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37243. */
  37244. export class BoneIKController {
  37245. private static _tmpVecs;
  37246. private static _tmpQuat;
  37247. private static _tmpMats;
  37248. /**
  37249. * Gets or sets the target mesh
  37250. */
  37251. targetMesh: AbstractMesh;
  37252. /** Gets or sets the mesh used as pole */
  37253. poleTargetMesh: AbstractMesh;
  37254. /**
  37255. * Gets or sets the bone used as pole
  37256. */
  37257. poleTargetBone: Nullable<Bone>;
  37258. /**
  37259. * Gets or sets the target position
  37260. */
  37261. targetPosition: Vector3;
  37262. /**
  37263. * Gets or sets the pole target position
  37264. */
  37265. poleTargetPosition: Vector3;
  37266. /**
  37267. * Gets or sets the pole target local offset
  37268. */
  37269. poleTargetLocalOffset: Vector3;
  37270. /**
  37271. * Gets or sets the pole angle
  37272. */
  37273. poleAngle: number;
  37274. /**
  37275. * Gets or sets the mesh associated with the controller
  37276. */
  37277. mesh: AbstractMesh;
  37278. /**
  37279. * 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)
  37280. */
  37281. slerpAmount: number;
  37282. private _bone1Quat;
  37283. private _bone1Mat;
  37284. private _bone2Ang;
  37285. private _bone1;
  37286. private _bone2;
  37287. private _bone1Length;
  37288. private _bone2Length;
  37289. private _maxAngle;
  37290. private _maxReach;
  37291. private _rightHandedSystem;
  37292. private _bendAxis;
  37293. private _slerping;
  37294. private _adjustRoll;
  37295. /**
  37296. * Gets or sets maximum allowed angle
  37297. */
  37298. maxAngle: number;
  37299. /**
  37300. * Creates a new BoneIKController
  37301. * @param mesh defines the mesh to control
  37302. * @param bone defines the bone to control
  37303. * @param options defines options to set up the controller
  37304. */
  37305. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37306. targetMesh?: AbstractMesh;
  37307. poleTargetMesh?: AbstractMesh;
  37308. poleTargetBone?: Bone;
  37309. poleTargetLocalOffset?: Vector3;
  37310. poleAngle?: number;
  37311. bendAxis?: Vector3;
  37312. maxAngle?: number;
  37313. slerpAmount?: number;
  37314. });
  37315. private _setMaxAngle;
  37316. /**
  37317. * Force the controller to update the bones
  37318. */
  37319. update(): void;
  37320. }
  37321. }
  37322. declare module "babylonjs/Bones/boneLookController" {
  37323. import { Vector3, Space } from "babylonjs/Maths/math";
  37324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37325. import { Bone } from "babylonjs/Bones/bone";
  37326. /**
  37327. * Class used to make a bone look toward a point in space
  37328. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37329. */
  37330. export class BoneLookController {
  37331. private static _tmpVecs;
  37332. private static _tmpQuat;
  37333. private static _tmpMats;
  37334. /**
  37335. * The target Vector3 that the bone will look at
  37336. */
  37337. target: Vector3;
  37338. /**
  37339. * The mesh that the bone is attached to
  37340. */
  37341. mesh: AbstractMesh;
  37342. /**
  37343. * The bone that will be looking to the target
  37344. */
  37345. bone: Bone;
  37346. /**
  37347. * The up axis of the coordinate system that is used when the bone is rotated
  37348. */
  37349. upAxis: Vector3;
  37350. /**
  37351. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37352. */
  37353. upAxisSpace: Space;
  37354. /**
  37355. * Used to make an adjustment to the yaw of the bone
  37356. */
  37357. adjustYaw: number;
  37358. /**
  37359. * Used to make an adjustment to the pitch of the bone
  37360. */
  37361. adjustPitch: number;
  37362. /**
  37363. * Used to make an adjustment to the roll of the bone
  37364. */
  37365. adjustRoll: number;
  37366. /**
  37367. * 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)
  37368. */
  37369. slerpAmount: number;
  37370. private _minYaw;
  37371. private _maxYaw;
  37372. private _minPitch;
  37373. private _maxPitch;
  37374. private _minYawSin;
  37375. private _minYawCos;
  37376. private _maxYawSin;
  37377. private _maxYawCos;
  37378. private _midYawConstraint;
  37379. private _minPitchTan;
  37380. private _maxPitchTan;
  37381. private _boneQuat;
  37382. private _slerping;
  37383. private _transformYawPitch;
  37384. private _transformYawPitchInv;
  37385. private _firstFrameSkipped;
  37386. private _yawRange;
  37387. private _fowardAxis;
  37388. /**
  37389. * Gets or sets the minimum yaw angle that the bone can look to
  37390. */
  37391. minYaw: number;
  37392. /**
  37393. * Gets or sets the maximum yaw angle that the bone can look to
  37394. */
  37395. maxYaw: number;
  37396. /**
  37397. * Gets or sets the minimum pitch angle that the bone can look to
  37398. */
  37399. minPitch: number;
  37400. /**
  37401. * Gets or sets the maximum pitch angle that the bone can look to
  37402. */
  37403. maxPitch: number;
  37404. /**
  37405. * Create a BoneLookController
  37406. * @param mesh the mesh that the bone belongs to
  37407. * @param bone the bone that will be looking to the target
  37408. * @param target the target Vector3 to look at
  37409. * @param options optional settings:
  37410. * * maxYaw: the maximum angle the bone will yaw to
  37411. * * minYaw: the minimum angle the bone will yaw to
  37412. * * maxPitch: the maximum angle the bone will pitch to
  37413. * * minPitch: the minimum angle the bone will yaw to
  37414. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37415. * * upAxis: the up axis of the coordinate system
  37416. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37417. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37418. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37419. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37420. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37421. * * adjustRoll: used to make an adjustment to the roll of the bone
  37422. **/
  37423. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37424. maxYaw?: number;
  37425. minYaw?: number;
  37426. maxPitch?: number;
  37427. minPitch?: number;
  37428. slerpAmount?: number;
  37429. upAxis?: Vector3;
  37430. upAxisSpace?: Space;
  37431. yawAxis?: Vector3;
  37432. pitchAxis?: Vector3;
  37433. adjustYaw?: number;
  37434. adjustPitch?: number;
  37435. adjustRoll?: number;
  37436. });
  37437. /**
  37438. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37439. */
  37440. update(): void;
  37441. private _getAngleDiff;
  37442. private _getAngleBetween;
  37443. private _isAngleBetween;
  37444. }
  37445. }
  37446. declare module "babylonjs/Bones/index" {
  37447. export * from "babylonjs/Bones/bone";
  37448. export * from "babylonjs/Bones/boneIKController";
  37449. export * from "babylonjs/Bones/boneLookController";
  37450. export * from "babylonjs/Bones/skeleton";
  37451. }
  37452. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37453. import { Nullable } from "babylonjs/types";
  37454. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37455. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37456. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37457. /**
  37458. * Manage the gamepad inputs to control an arc rotate camera.
  37459. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37460. */
  37461. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37462. /**
  37463. * Defines the camera the input is attached to.
  37464. */
  37465. camera: ArcRotateCamera;
  37466. /**
  37467. * Defines the gamepad the input is gathering event from.
  37468. */
  37469. gamepad: Nullable<Gamepad>;
  37470. /**
  37471. * Defines the gamepad rotation sensiblity.
  37472. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37473. */
  37474. gamepadRotationSensibility: number;
  37475. /**
  37476. * Defines the gamepad move sensiblity.
  37477. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37478. */
  37479. gamepadMoveSensibility: number;
  37480. private _onGamepadConnectedObserver;
  37481. private _onGamepadDisconnectedObserver;
  37482. /**
  37483. * Attach the input controls to a specific dom element to get the input from.
  37484. * @param element Defines the element the controls should be listened from
  37485. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37486. */
  37487. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37488. /**
  37489. * Detach the current controls from the specified dom element.
  37490. * @param element Defines the element to stop listening the inputs from
  37491. */
  37492. detachControl(element: Nullable<HTMLElement>): void;
  37493. /**
  37494. * Update the current camera state depending on the inputs that have been used this frame.
  37495. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37496. */
  37497. checkInputs(): void;
  37498. /**
  37499. * Gets the class name of the current intput.
  37500. * @returns the class name
  37501. */
  37502. getClassName(): string;
  37503. /**
  37504. * Get the friendly name associated with the input class.
  37505. * @returns the input friendly name
  37506. */
  37507. getSimpleName(): string;
  37508. }
  37509. }
  37510. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37511. import { Nullable } from "babylonjs/types";
  37512. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37513. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37514. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37515. interface ArcRotateCameraInputsManager {
  37516. /**
  37517. * Add orientation input support to the input manager.
  37518. * @returns the current input manager
  37519. */
  37520. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37521. }
  37522. }
  37523. /**
  37524. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37525. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37526. */
  37527. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37528. /**
  37529. * Defines the camera the input is attached to.
  37530. */
  37531. camera: ArcRotateCamera;
  37532. /**
  37533. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37534. */
  37535. alphaCorrection: number;
  37536. /**
  37537. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37538. */
  37539. gammaCorrection: number;
  37540. private _alpha;
  37541. private _gamma;
  37542. private _dirty;
  37543. private _deviceOrientationHandler;
  37544. /**
  37545. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37546. */
  37547. constructor();
  37548. /**
  37549. * Attach the input controls to a specific dom element to get the input from.
  37550. * @param element Defines the element the controls should be listened from
  37551. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37552. */
  37553. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37554. /** @hidden */
  37555. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37556. /**
  37557. * Update the current camera state depending on the inputs that have been used this frame.
  37558. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37559. */
  37560. checkInputs(): void;
  37561. /**
  37562. * Detach the current controls from the specified dom element.
  37563. * @param element Defines the element to stop listening the inputs from
  37564. */
  37565. detachControl(element: Nullable<HTMLElement>): void;
  37566. /**
  37567. * Gets the class name of the current intput.
  37568. * @returns the class name
  37569. */
  37570. getClassName(): string;
  37571. /**
  37572. * Get the friendly name associated with the input class.
  37573. * @returns the input friendly name
  37574. */
  37575. getSimpleName(): string;
  37576. }
  37577. }
  37578. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37579. import { Nullable } from "babylonjs/types";
  37580. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37581. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37582. /**
  37583. * Listen to mouse events to control the camera.
  37584. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37585. */
  37586. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37587. /**
  37588. * Defines the camera the input is attached to.
  37589. */
  37590. camera: FlyCamera;
  37591. /**
  37592. * Defines if touch is enabled. (Default is true.)
  37593. */
  37594. touchEnabled: boolean;
  37595. /**
  37596. * Defines the buttons associated with the input to handle camera rotation.
  37597. */
  37598. buttons: number[];
  37599. /**
  37600. * Assign buttons for Yaw control.
  37601. */
  37602. buttonsYaw: number[];
  37603. /**
  37604. * Assign buttons for Pitch control.
  37605. */
  37606. buttonsPitch: number[];
  37607. /**
  37608. * Assign buttons for Roll control.
  37609. */
  37610. buttonsRoll: number[];
  37611. /**
  37612. * Detect if any button is being pressed while mouse is moved.
  37613. * -1 = Mouse locked.
  37614. * 0 = Left button.
  37615. * 1 = Middle Button.
  37616. * 2 = Right Button.
  37617. */
  37618. activeButton: number;
  37619. /**
  37620. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37621. * Higher values reduce its sensitivity.
  37622. */
  37623. angularSensibility: number;
  37624. private _mousemoveCallback;
  37625. private _observer;
  37626. private _rollObserver;
  37627. private previousPosition;
  37628. private noPreventDefault;
  37629. private element;
  37630. /**
  37631. * Listen to mouse events to control the camera.
  37632. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37634. */
  37635. constructor(touchEnabled?: boolean);
  37636. /**
  37637. * Attach the mouse control to the HTML DOM element.
  37638. * @param element Defines the element that listens to the input events.
  37639. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37640. */
  37641. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37642. /**
  37643. * Detach the current controls from the specified dom element.
  37644. * @param element Defines the element to stop listening the inputs from
  37645. */
  37646. detachControl(element: Nullable<HTMLElement>): void;
  37647. /**
  37648. * Gets the class name of the current input.
  37649. * @returns the class name.
  37650. */
  37651. getClassName(): string;
  37652. /**
  37653. * Get the friendly name associated with the input class.
  37654. * @returns the input's friendly name.
  37655. */
  37656. getSimpleName(): string;
  37657. private _pointerInput;
  37658. private _onMouseMove;
  37659. /**
  37660. * Rotate camera by mouse offset.
  37661. */
  37662. private rotateCamera;
  37663. }
  37664. }
  37665. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37666. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37667. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37668. /**
  37669. * Default Inputs manager for the FlyCamera.
  37670. * It groups all the default supported inputs for ease of use.
  37671. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37672. */
  37673. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37674. /**
  37675. * Instantiates a new FlyCameraInputsManager.
  37676. * @param camera Defines the camera the inputs belong to.
  37677. */
  37678. constructor(camera: FlyCamera);
  37679. /**
  37680. * Add keyboard input support to the input manager.
  37681. * @returns the new FlyCameraKeyboardMoveInput().
  37682. */
  37683. addKeyboard(): FlyCameraInputsManager;
  37684. /**
  37685. * Add mouse input support to the input manager.
  37686. * @param touchEnabled Enable touch screen support.
  37687. * @returns the new FlyCameraMouseInput().
  37688. */
  37689. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37690. }
  37691. }
  37692. declare module "babylonjs/Cameras/flyCamera" {
  37693. import { Scene } from "babylonjs/scene";
  37694. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37696. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37697. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37698. /**
  37699. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37700. * such as in a 3D Space Shooter or a Flight Simulator.
  37701. */
  37702. export class FlyCamera extends TargetCamera {
  37703. /**
  37704. * Define the collision ellipsoid of the camera.
  37705. * This is helpful for simulating a camera body, like a player's body.
  37706. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37707. */
  37708. ellipsoid: Vector3;
  37709. /**
  37710. * Define an offset for the position of the ellipsoid around the camera.
  37711. * This can be helpful if the camera is attached away from the player's body center,
  37712. * such as at its head.
  37713. */
  37714. ellipsoidOffset: Vector3;
  37715. /**
  37716. * Enable or disable collisions of the camera with the rest of the scene objects.
  37717. */
  37718. checkCollisions: boolean;
  37719. /**
  37720. * Enable or disable gravity on the camera.
  37721. */
  37722. applyGravity: boolean;
  37723. /**
  37724. * Define the current direction the camera is moving to.
  37725. */
  37726. cameraDirection: Vector3;
  37727. /**
  37728. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37729. * This overrides and empties cameraRotation.
  37730. */
  37731. rotationQuaternion: Quaternion;
  37732. /**
  37733. * Track Roll to maintain the wanted Rolling when looking around.
  37734. */
  37735. _trackRoll: number;
  37736. /**
  37737. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37738. */
  37739. rollCorrect: number;
  37740. /**
  37741. * Mimic a banked turn, Rolling the camera when Yawing.
  37742. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37743. */
  37744. bankedTurn: boolean;
  37745. /**
  37746. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37747. */
  37748. bankedTurnLimit: number;
  37749. /**
  37750. * Value of 0 disables the banked Roll.
  37751. * Value of 1 is equal to the Yaw angle in radians.
  37752. */
  37753. bankedTurnMultiplier: number;
  37754. /**
  37755. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37756. */
  37757. inputs: FlyCameraInputsManager;
  37758. /**
  37759. * Gets the input sensibility for mouse input.
  37760. * Higher values reduce sensitivity.
  37761. */
  37762. /**
  37763. * Sets the input sensibility for a mouse input.
  37764. * Higher values reduce sensitivity.
  37765. */
  37766. angularSensibility: number;
  37767. /**
  37768. * Get the keys for camera movement forward.
  37769. */
  37770. /**
  37771. * Set the keys for camera movement forward.
  37772. */
  37773. keysForward: number[];
  37774. /**
  37775. * Get the keys for camera movement backward.
  37776. */
  37777. keysBackward: number[];
  37778. /**
  37779. * Get the keys for camera movement up.
  37780. */
  37781. /**
  37782. * Set the keys for camera movement up.
  37783. */
  37784. keysUp: number[];
  37785. /**
  37786. * Get the keys for camera movement down.
  37787. */
  37788. /**
  37789. * Set the keys for camera movement down.
  37790. */
  37791. keysDown: number[];
  37792. /**
  37793. * Get the keys for camera movement left.
  37794. */
  37795. /**
  37796. * Set the keys for camera movement left.
  37797. */
  37798. keysLeft: number[];
  37799. /**
  37800. * Set the keys for camera movement right.
  37801. */
  37802. /**
  37803. * Set the keys for camera movement right.
  37804. */
  37805. keysRight: number[];
  37806. /**
  37807. * Event raised when the camera collides with a mesh in the scene.
  37808. */
  37809. onCollide: (collidedMesh: AbstractMesh) => void;
  37810. private _collider;
  37811. private _needMoveForGravity;
  37812. private _oldPosition;
  37813. private _diffPosition;
  37814. private _newPosition;
  37815. /** @hidden */
  37816. _localDirection: Vector3;
  37817. /** @hidden */
  37818. _transformedDirection: Vector3;
  37819. /**
  37820. * Instantiates a FlyCamera.
  37821. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37822. * such as in a 3D Space Shooter or a Flight Simulator.
  37823. * @param name Define the name of the camera in the scene.
  37824. * @param position Define the starting position of the camera in the scene.
  37825. * @param scene Define the scene the camera belongs to.
  37826. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37827. */
  37828. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37829. /**
  37830. * Attach a control to the HTML DOM element.
  37831. * @param element Defines the element that listens to the input events.
  37832. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37833. */
  37834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37835. /**
  37836. * Detach a control from the HTML DOM element.
  37837. * The camera will stop reacting to that input.
  37838. * @param element Defines the element that listens to the input events.
  37839. */
  37840. detachControl(element: HTMLElement): void;
  37841. private _collisionMask;
  37842. /**
  37843. * Get the mask that the camera ignores in collision events.
  37844. */
  37845. /**
  37846. * Set the mask that the camera ignores in collision events.
  37847. */
  37848. collisionMask: number;
  37849. /** @hidden */
  37850. _collideWithWorld(displacement: Vector3): void;
  37851. /** @hidden */
  37852. private _onCollisionPositionChange;
  37853. /** @hidden */
  37854. _checkInputs(): void;
  37855. /** @hidden */
  37856. _decideIfNeedsToMove(): boolean;
  37857. /** @hidden */
  37858. _updatePosition(): void;
  37859. /**
  37860. * Restore the Roll to its target value at the rate specified.
  37861. * @param rate - Higher means slower restoring.
  37862. * @hidden
  37863. */
  37864. restoreRoll(rate: number): void;
  37865. /**
  37866. * Destroy the camera and release the current resources held by it.
  37867. */
  37868. dispose(): void;
  37869. /**
  37870. * Get the current object class name.
  37871. * @returns the class name.
  37872. */
  37873. getClassName(): string;
  37874. }
  37875. }
  37876. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37877. import { Nullable } from "babylonjs/types";
  37878. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37879. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37880. /**
  37881. * Listen to keyboard events to control the camera.
  37882. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37883. */
  37884. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37885. /**
  37886. * Defines the camera the input is attached to.
  37887. */
  37888. camera: FlyCamera;
  37889. /**
  37890. * The list of keyboard keys used to control the forward move of the camera.
  37891. */
  37892. keysForward: number[];
  37893. /**
  37894. * The list of keyboard keys used to control the backward move of the camera.
  37895. */
  37896. keysBackward: number[];
  37897. /**
  37898. * The list of keyboard keys used to control the forward move of the camera.
  37899. */
  37900. keysUp: number[];
  37901. /**
  37902. * The list of keyboard keys used to control the backward move of the camera.
  37903. */
  37904. keysDown: number[];
  37905. /**
  37906. * The list of keyboard keys used to control the right strafe move of the camera.
  37907. */
  37908. keysRight: number[];
  37909. /**
  37910. * The list of keyboard keys used to control the left strafe move of the camera.
  37911. */
  37912. keysLeft: number[];
  37913. private _keys;
  37914. private _onCanvasBlurObserver;
  37915. private _onKeyboardObserver;
  37916. private _engine;
  37917. private _scene;
  37918. /**
  37919. * Attach the input controls to a specific dom element to get the input from.
  37920. * @param element Defines the element the controls should be listened from
  37921. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37922. */
  37923. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37924. /**
  37925. * Detach the current controls from the specified dom element.
  37926. * @param element Defines the element to stop listening the inputs from
  37927. */
  37928. detachControl(element: Nullable<HTMLElement>): void;
  37929. /**
  37930. * Gets the class name of the current intput.
  37931. * @returns the class name
  37932. */
  37933. getClassName(): string;
  37934. /** @hidden */
  37935. _onLostFocus(e: FocusEvent): void;
  37936. /**
  37937. * Get the friendly name associated with the input class.
  37938. * @returns the input friendly name
  37939. */
  37940. getSimpleName(): string;
  37941. /**
  37942. * Update the current camera state depending on the inputs that have been used this frame.
  37943. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37944. */
  37945. checkInputs(): void;
  37946. }
  37947. }
  37948. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37949. import { Nullable } from "babylonjs/types";
  37950. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37951. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37952. /**
  37953. * Manage the mouse wheel inputs to control a follow camera.
  37954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37955. */
  37956. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37957. /**
  37958. * Defines the camera the input is attached to.
  37959. */
  37960. camera: FollowCamera;
  37961. /**
  37962. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37963. */
  37964. axisControlRadius: boolean;
  37965. /**
  37966. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37967. */
  37968. axisControlHeight: boolean;
  37969. /**
  37970. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37971. */
  37972. axisControlRotation: boolean;
  37973. /**
  37974. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37975. * relation to mouseWheel events.
  37976. */
  37977. wheelPrecision: number;
  37978. /**
  37979. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37980. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37981. */
  37982. wheelDeltaPercentage: number;
  37983. private _wheel;
  37984. private _observer;
  37985. /**
  37986. * Attach the input controls to a specific dom element to get the input from.
  37987. * @param element Defines the element the controls should be listened from
  37988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37989. */
  37990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37991. /**
  37992. * Detach the current controls from the specified dom element.
  37993. * @param element Defines the element to stop listening the inputs from
  37994. */
  37995. detachControl(element: Nullable<HTMLElement>): void;
  37996. /**
  37997. * Gets the class name of the current intput.
  37998. * @returns the class name
  37999. */
  38000. getClassName(): string;
  38001. /**
  38002. * Get the friendly name associated with the input class.
  38003. * @returns the input friendly name
  38004. */
  38005. getSimpleName(): string;
  38006. }
  38007. }
  38008. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38009. import { Nullable } from "babylonjs/types";
  38010. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38011. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38012. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38013. /**
  38014. * Manage the pointers inputs to control an follow camera.
  38015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38016. */
  38017. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38018. /**
  38019. * Defines the camera the input is attached to.
  38020. */
  38021. camera: FollowCamera;
  38022. /**
  38023. * Gets the class name of the current input.
  38024. * @returns the class name
  38025. */
  38026. getClassName(): string;
  38027. /**
  38028. * Defines the pointer angular sensibility along the X axis or how fast is
  38029. * the camera rotating.
  38030. * A negative number will reverse the axis direction.
  38031. */
  38032. angularSensibilityX: number;
  38033. /**
  38034. * Defines the pointer angular sensibility along the Y axis or how fast is
  38035. * the camera rotating.
  38036. * A negative number will reverse the axis direction.
  38037. */
  38038. angularSensibilityY: number;
  38039. /**
  38040. * Defines the pointer pinch precision or how fast is the camera zooming.
  38041. * A negative number will reverse the axis direction.
  38042. */
  38043. pinchPrecision: number;
  38044. /**
  38045. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38046. * from 0.
  38047. * It defines the percentage of current camera.radius to use as delta when
  38048. * pinch zoom is used.
  38049. */
  38050. pinchDeltaPercentage: number;
  38051. /**
  38052. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38053. */
  38054. axisXControlRadius: boolean;
  38055. /**
  38056. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38057. */
  38058. axisXControlHeight: boolean;
  38059. /**
  38060. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38061. */
  38062. axisXControlRotation: boolean;
  38063. /**
  38064. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38065. */
  38066. axisYControlRadius: boolean;
  38067. /**
  38068. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38069. */
  38070. axisYControlHeight: boolean;
  38071. /**
  38072. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38073. */
  38074. axisYControlRotation: boolean;
  38075. /**
  38076. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38077. */
  38078. axisPinchControlRadius: boolean;
  38079. /**
  38080. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38081. */
  38082. axisPinchControlHeight: boolean;
  38083. /**
  38084. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38085. */
  38086. axisPinchControlRotation: boolean;
  38087. /**
  38088. * Log error messages if basic misconfiguration has occurred.
  38089. */
  38090. warningEnable: boolean;
  38091. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38092. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38093. private _warningCounter;
  38094. private _warning;
  38095. }
  38096. }
  38097. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38098. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38099. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38100. /**
  38101. * Default Inputs manager for the FollowCamera.
  38102. * It groups all the default supported inputs for ease of use.
  38103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38104. */
  38105. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38106. /**
  38107. * Instantiates a new FollowCameraInputsManager.
  38108. * @param camera Defines the camera the inputs belong to
  38109. */
  38110. constructor(camera: FollowCamera);
  38111. /**
  38112. * Add keyboard input support to the input manager.
  38113. * @returns the current input manager
  38114. */
  38115. addKeyboard(): FollowCameraInputsManager;
  38116. /**
  38117. * Add mouse wheel input support to the input manager.
  38118. * @returns the current input manager
  38119. */
  38120. addMouseWheel(): FollowCameraInputsManager;
  38121. /**
  38122. * Add pointers input support to the input manager.
  38123. * @returns the current input manager
  38124. */
  38125. addPointers(): FollowCameraInputsManager;
  38126. /**
  38127. * Add orientation input support to the input manager.
  38128. * @returns the current input manager
  38129. */
  38130. addVRDeviceOrientation(): FollowCameraInputsManager;
  38131. }
  38132. }
  38133. declare module "babylonjs/Cameras/followCamera" {
  38134. import { Nullable } from "babylonjs/types";
  38135. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38136. import { Scene } from "babylonjs/scene";
  38137. import { Vector3 } from "babylonjs/Maths/math";
  38138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38139. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38140. /**
  38141. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38142. * an arc rotate version arcFollowCamera are available.
  38143. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38144. */
  38145. export class FollowCamera extends TargetCamera {
  38146. /**
  38147. * Distance the follow camera should follow an object at
  38148. */
  38149. radius: number;
  38150. /**
  38151. * Minimum allowed distance of the camera to the axis of rotation
  38152. * (The camera can not get closer).
  38153. * This can help limiting how the Camera is able to move in the scene.
  38154. */
  38155. lowerRadiusLimit: Nullable<number>;
  38156. /**
  38157. * Maximum allowed distance of the camera to the axis of rotation
  38158. * (The camera can not get further).
  38159. * This can help limiting how the Camera is able to move in the scene.
  38160. */
  38161. upperRadiusLimit: Nullable<number>;
  38162. /**
  38163. * Define a rotation offset between the camera and the object it follows
  38164. */
  38165. rotationOffset: number;
  38166. /**
  38167. * Minimum allowed angle to camera position relative to target object.
  38168. * This can help limiting how the Camera is able to move in the scene.
  38169. */
  38170. lowerRotationOffsetLimit: Nullable<number>;
  38171. /**
  38172. * Maximum allowed angle to camera position relative to target object.
  38173. * This can help limiting how the Camera is able to move in the scene.
  38174. */
  38175. upperRotationOffsetLimit: Nullable<number>;
  38176. /**
  38177. * Define a height offset between the camera and the object it follows.
  38178. * It can help following an object from the top (like a car chaing a plane)
  38179. */
  38180. heightOffset: number;
  38181. /**
  38182. * Minimum allowed height of camera position relative to target object.
  38183. * This can help limiting how the Camera is able to move in the scene.
  38184. */
  38185. lowerHeightOffsetLimit: Nullable<number>;
  38186. /**
  38187. * Maximum allowed height of camera position relative to target object.
  38188. * This can help limiting how the Camera is able to move in the scene.
  38189. */
  38190. upperHeightOffsetLimit: Nullable<number>;
  38191. /**
  38192. * Define how fast the camera can accelerate to follow it s target.
  38193. */
  38194. cameraAcceleration: number;
  38195. /**
  38196. * Define the speed limit of the camera following an object.
  38197. */
  38198. maxCameraSpeed: number;
  38199. /**
  38200. * Define the target of the camera.
  38201. */
  38202. lockedTarget: Nullable<AbstractMesh>;
  38203. /**
  38204. * Defines the input associated with the camera.
  38205. */
  38206. inputs: FollowCameraInputsManager;
  38207. /**
  38208. * Instantiates the follow camera.
  38209. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38210. * @param name Define the name of the camera in the scene
  38211. * @param position Define the position of the camera
  38212. * @param scene Define the scene the camera belong to
  38213. * @param lockedTarget Define the target of the camera
  38214. */
  38215. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38216. private _follow;
  38217. /**
  38218. * Attached controls to the current camera.
  38219. * @param element Defines the element the controls should be listened from
  38220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38221. */
  38222. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38223. /**
  38224. * Detach the current controls from the camera.
  38225. * The camera will stop reacting to inputs.
  38226. * @param element Defines the element to stop listening the inputs from
  38227. */
  38228. detachControl(element: HTMLElement): void;
  38229. /** @hidden */
  38230. _checkInputs(): void;
  38231. private _checkLimits;
  38232. /**
  38233. * Gets the camera class name.
  38234. * @returns the class name
  38235. */
  38236. getClassName(): string;
  38237. }
  38238. /**
  38239. * Arc Rotate version of the follow camera.
  38240. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38241. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38242. */
  38243. export class ArcFollowCamera extends TargetCamera {
  38244. /** The longitudinal angle of the camera */
  38245. alpha: number;
  38246. /** The latitudinal angle of the camera */
  38247. beta: number;
  38248. /** The radius of the camera from its target */
  38249. radius: number;
  38250. /** Define the camera target (the messh it should follow) */
  38251. target: Nullable<AbstractMesh>;
  38252. private _cartesianCoordinates;
  38253. /**
  38254. * Instantiates a new ArcFollowCamera
  38255. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38256. * @param name Define the name of the camera
  38257. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38258. * @param beta Define the rotation angle of the camera around the elevation axis
  38259. * @param radius Define the radius of the camera from its target point
  38260. * @param target Define the target of the camera
  38261. * @param scene Define the scene the camera belongs to
  38262. */
  38263. constructor(name: string,
  38264. /** The longitudinal angle of the camera */
  38265. alpha: number,
  38266. /** The latitudinal angle of the camera */
  38267. beta: number,
  38268. /** The radius of the camera from its target */
  38269. radius: number,
  38270. /** Define the camera target (the messh it should follow) */
  38271. target: Nullable<AbstractMesh>, scene: Scene);
  38272. private _follow;
  38273. /** @hidden */
  38274. _checkInputs(): void;
  38275. /**
  38276. * Returns the class name of the object.
  38277. * It is mostly used internally for serialization purposes.
  38278. */
  38279. getClassName(): string;
  38280. }
  38281. }
  38282. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38283. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38284. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38285. import { Nullable } from "babylonjs/types";
  38286. /**
  38287. * Manage the keyboard inputs to control the movement of a follow camera.
  38288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38289. */
  38290. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38291. /**
  38292. * Defines the camera the input is attached to.
  38293. */
  38294. camera: FollowCamera;
  38295. /**
  38296. * Defines the list of key codes associated with the up action (increase heightOffset)
  38297. */
  38298. keysHeightOffsetIncr: number[];
  38299. /**
  38300. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38301. */
  38302. keysHeightOffsetDecr: number[];
  38303. /**
  38304. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38305. */
  38306. keysHeightOffsetModifierAlt: boolean;
  38307. /**
  38308. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38309. */
  38310. keysHeightOffsetModifierCtrl: boolean;
  38311. /**
  38312. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38313. */
  38314. keysHeightOffsetModifierShift: boolean;
  38315. /**
  38316. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38317. */
  38318. keysRotationOffsetIncr: number[];
  38319. /**
  38320. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38321. */
  38322. keysRotationOffsetDecr: number[];
  38323. /**
  38324. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38325. */
  38326. keysRotationOffsetModifierAlt: boolean;
  38327. /**
  38328. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38329. */
  38330. keysRotationOffsetModifierCtrl: boolean;
  38331. /**
  38332. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38333. */
  38334. keysRotationOffsetModifierShift: boolean;
  38335. /**
  38336. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38337. */
  38338. keysRadiusIncr: number[];
  38339. /**
  38340. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38341. */
  38342. keysRadiusDecr: number[];
  38343. /**
  38344. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38345. */
  38346. keysRadiusModifierAlt: boolean;
  38347. /**
  38348. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38349. */
  38350. keysRadiusModifierCtrl: boolean;
  38351. /**
  38352. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38353. */
  38354. keysRadiusModifierShift: boolean;
  38355. /**
  38356. * Defines the rate of change of heightOffset.
  38357. */
  38358. heightSensibility: number;
  38359. /**
  38360. * Defines the rate of change of rotationOffset.
  38361. */
  38362. rotationSensibility: number;
  38363. /**
  38364. * Defines the rate of change of radius.
  38365. */
  38366. radiusSensibility: number;
  38367. private _keys;
  38368. private _ctrlPressed;
  38369. private _altPressed;
  38370. private _shiftPressed;
  38371. private _onCanvasBlurObserver;
  38372. private _onKeyboardObserver;
  38373. private _engine;
  38374. private _scene;
  38375. /**
  38376. * Attach the input controls to a specific dom element to get the input from.
  38377. * @param element Defines the element the controls should be listened from
  38378. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38379. */
  38380. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38381. /**
  38382. * Detach the current controls from the specified dom element.
  38383. * @param element Defines the element to stop listening the inputs from
  38384. */
  38385. detachControl(element: Nullable<HTMLElement>): void;
  38386. /**
  38387. * Update the current camera state depending on the inputs that have been used this frame.
  38388. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38389. */
  38390. checkInputs(): void;
  38391. /**
  38392. * Gets the class name of the current input.
  38393. * @returns the class name
  38394. */
  38395. getClassName(): string;
  38396. /**
  38397. * Get the friendly name associated with the input class.
  38398. * @returns the input friendly name
  38399. */
  38400. getSimpleName(): string;
  38401. /**
  38402. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38403. * allow modification of the heightOffset value.
  38404. */
  38405. private _modifierHeightOffset;
  38406. /**
  38407. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38408. * allow modification of the rotationOffset value.
  38409. */
  38410. private _modifierRotationOffset;
  38411. /**
  38412. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38413. * allow modification of the radius value.
  38414. */
  38415. private _modifierRadius;
  38416. }
  38417. }
  38418. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38419. import { Nullable } from "babylonjs/types";
  38420. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38421. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38422. import { Observable } from "babylonjs/Misc/observable";
  38423. module "babylonjs/Cameras/freeCameraInputsManager" {
  38424. interface FreeCameraInputsManager {
  38425. /**
  38426. * @hidden
  38427. */
  38428. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38429. /**
  38430. * Add orientation input support to the input manager.
  38431. * @returns the current input manager
  38432. */
  38433. addDeviceOrientation(): FreeCameraInputsManager;
  38434. }
  38435. }
  38436. /**
  38437. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38438. * Screen rotation is taken into account.
  38439. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38440. */
  38441. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38442. private _camera;
  38443. private _screenOrientationAngle;
  38444. private _constantTranform;
  38445. private _screenQuaternion;
  38446. private _alpha;
  38447. private _beta;
  38448. private _gamma;
  38449. /**
  38450. * @hidden
  38451. */
  38452. _onDeviceOrientationChangedObservable: Observable<void>;
  38453. /**
  38454. * Instantiates a new input
  38455. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38456. */
  38457. constructor();
  38458. /**
  38459. * Define the camera controlled by the input.
  38460. */
  38461. camera: FreeCamera;
  38462. /**
  38463. * Attach the input controls to a specific dom element to get the input from.
  38464. * @param element Defines the element the controls should be listened from
  38465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38466. */
  38467. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38468. private _orientationChanged;
  38469. private _deviceOrientation;
  38470. /**
  38471. * Detach the current controls from the specified dom element.
  38472. * @param element Defines the element to stop listening the inputs from
  38473. */
  38474. detachControl(element: Nullable<HTMLElement>): void;
  38475. /**
  38476. * Update the current camera state depending on the inputs that have been used this frame.
  38477. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38478. */
  38479. checkInputs(): void;
  38480. /**
  38481. * Gets the class name of the current intput.
  38482. * @returns the class name
  38483. */
  38484. getClassName(): string;
  38485. /**
  38486. * Get the friendly name associated with the input class.
  38487. * @returns the input friendly name
  38488. */
  38489. getSimpleName(): string;
  38490. }
  38491. }
  38492. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38493. import { Nullable } from "babylonjs/types";
  38494. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38495. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38496. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38497. /**
  38498. * Manage the gamepad inputs to control a free camera.
  38499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38500. */
  38501. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38502. /**
  38503. * Define the camera the input is attached to.
  38504. */
  38505. camera: FreeCamera;
  38506. /**
  38507. * Define the Gamepad controlling the input
  38508. */
  38509. gamepad: Nullable<Gamepad>;
  38510. /**
  38511. * Defines the gamepad rotation sensiblity.
  38512. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38513. */
  38514. gamepadAngularSensibility: number;
  38515. /**
  38516. * Defines the gamepad move sensiblity.
  38517. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38518. */
  38519. gamepadMoveSensibility: number;
  38520. private _onGamepadConnectedObserver;
  38521. private _onGamepadDisconnectedObserver;
  38522. private _cameraTransform;
  38523. private _deltaTransform;
  38524. private _vector3;
  38525. private _vector2;
  38526. /**
  38527. * Attach the input controls to a specific dom element to get the input from.
  38528. * @param element Defines the element the controls should be listened from
  38529. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38530. */
  38531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38532. /**
  38533. * Detach the current controls from the specified dom element.
  38534. * @param element Defines the element to stop listening the inputs from
  38535. */
  38536. detachControl(element: Nullable<HTMLElement>): void;
  38537. /**
  38538. * Update the current camera state depending on the inputs that have been used this frame.
  38539. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38540. */
  38541. checkInputs(): void;
  38542. /**
  38543. * Gets the class name of the current intput.
  38544. * @returns the class name
  38545. */
  38546. getClassName(): string;
  38547. /**
  38548. * Get the friendly name associated with the input class.
  38549. * @returns the input friendly name
  38550. */
  38551. getSimpleName(): string;
  38552. }
  38553. }
  38554. declare module "babylonjs/Misc/virtualJoystick" {
  38555. import { Nullable } from "babylonjs/types";
  38556. import { Vector3 } from "babylonjs/Maths/math";
  38557. /**
  38558. * Defines the potential axis of a Joystick
  38559. */
  38560. export enum JoystickAxis {
  38561. /** X axis */
  38562. X = 0,
  38563. /** Y axis */
  38564. Y = 1,
  38565. /** Z axis */
  38566. Z = 2
  38567. }
  38568. /**
  38569. * Class used to define virtual joystick (used in touch mode)
  38570. */
  38571. export class VirtualJoystick {
  38572. /**
  38573. * Gets or sets a boolean indicating that left and right values must be inverted
  38574. */
  38575. reverseLeftRight: boolean;
  38576. /**
  38577. * Gets or sets a boolean indicating that up and down values must be inverted
  38578. */
  38579. reverseUpDown: boolean;
  38580. /**
  38581. * Gets the offset value for the position (ie. the change of the position value)
  38582. */
  38583. deltaPosition: Vector3;
  38584. /**
  38585. * Gets a boolean indicating if the virtual joystick was pressed
  38586. */
  38587. pressed: boolean;
  38588. /**
  38589. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38590. */
  38591. static Canvas: Nullable<HTMLCanvasElement>;
  38592. private static _globalJoystickIndex;
  38593. private static vjCanvasContext;
  38594. private static vjCanvasWidth;
  38595. private static vjCanvasHeight;
  38596. private static halfWidth;
  38597. private _action;
  38598. private _axisTargetedByLeftAndRight;
  38599. private _axisTargetedByUpAndDown;
  38600. private _joystickSensibility;
  38601. private _inversedSensibility;
  38602. private _joystickPointerID;
  38603. private _joystickColor;
  38604. private _joystickPointerPos;
  38605. private _joystickPreviousPointerPos;
  38606. private _joystickPointerStartPos;
  38607. private _deltaJoystickVector;
  38608. private _leftJoystick;
  38609. private _touches;
  38610. private _onPointerDownHandlerRef;
  38611. private _onPointerMoveHandlerRef;
  38612. private _onPointerUpHandlerRef;
  38613. private _onResize;
  38614. /**
  38615. * Creates a new virtual joystick
  38616. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38617. */
  38618. constructor(leftJoystick?: boolean);
  38619. /**
  38620. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38621. * @param newJoystickSensibility defines the new sensibility
  38622. */
  38623. setJoystickSensibility(newJoystickSensibility: number): void;
  38624. private _onPointerDown;
  38625. private _onPointerMove;
  38626. private _onPointerUp;
  38627. /**
  38628. * Change the color of the virtual joystick
  38629. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38630. */
  38631. setJoystickColor(newColor: string): void;
  38632. /**
  38633. * Defines a callback to call when the joystick is touched
  38634. * @param action defines the callback
  38635. */
  38636. setActionOnTouch(action: () => any): void;
  38637. /**
  38638. * Defines which axis you'd like to control for left & right
  38639. * @param axis defines the axis to use
  38640. */
  38641. setAxisForLeftRight(axis: JoystickAxis): void;
  38642. /**
  38643. * Defines which axis you'd like to control for up & down
  38644. * @param axis defines the axis to use
  38645. */
  38646. setAxisForUpDown(axis: JoystickAxis): void;
  38647. private _drawVirtualJoystick;
  38648. /**
  38649. * Release internal HTML canvas
  38650. */
  38651. releaseCanvas(): void;
  38652. }
  38653. }
  38654. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38655. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38656. import { Nullable } from "babylonjs/types";
  38657. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38658. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38659. module "babylonjs/Cameras/freeCameraInputsManager" {
  38660. interface FreeCameraInputsManager {
  38661. /**
  38662. * Add virtual joystick input support to the input manager.
  38663. * @returns the current input manager
  38664. */
  38665. addVirtualJoystick(): FreeCameraInputsManager;
  38666. }
  38667. }
  38668. /**
  38669. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38670. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38671. */
  38672. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38673. /**
  38674. * Defines the camera the input is attached to.
  38675. */
  38676. camera: FreeCamera;
  38677. private _leftjoystick;
  38678. private _rightjoystick;
  38679. /**
  38680. * Gets the left stick of the virtual joystick.
  38681. * @returns The virtual Joystick
  38682. */
  38683. getLeftJoystick(): VirtualJoystick;
  38684. /**
  38685. * Gets the right stick of the virtual joystick.
  38686. * @returns The virtual Joystick
  38687. */
  38688. getRightJoystick(): VirtualJoystick;
  38689. /**
  38690. * Update the current camera state depending on the inputs that have been used this frame.
  38691. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38692. */
  38693. checkInputs(): void;
  38694. /**
  38695. * Attach the input controls to a specific dom element to get the input from.
  38696. * @param element Defines the element the controls should be listened from
  38697. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38698. */
  38699. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38700. /**
  38701. * Detach the current controls from the specified dom element.
  38702. * @param element Defines the element to stop listening the inputs from
  38703. */
  38704. detachControl(element: Nullable<HTMLElement>): void;
  38705. /**
  38706. * Gets the class name of the current intput.
  38707. * @returns the class name
  38708. */
  38709. getClassName(): string;
  38710. /**
  38711. * Get the friendly name associated with the input class.
  38712. * @returns the input friendly name
  38713. */
  38714. getSimpleName(): string;
  38715. }
  38716. }
  38717. declare module "babylonjs/Cameras/Inputs/index" {
  38718. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38719. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38720. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38721. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38722. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38723. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38724. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38725. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38726. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38727. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38728. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38729. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38730. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38731. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38732. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38733. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38734. }
  38735. declare module "babylonjs/Cameras/touchCamera" {
  38736. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38737. import { Scene } from "babylonjs/scene";
  38738. import { Vector3 } from "babylonjs/Maths/math";
  38739. /**
  38740. * This represents a FPS type of camera controlled by touch.
  38741. * This is like a universal camera minus the Gamepad controls.
  38742. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38743. */
  38744. export class TouchCamera extends FreeCamera {
  38745. /**
  38746. * Defines the touch sensibility for rotation.
  38747. * The higher the faster.
  38748. */
  38749. touchAngularSensibility: number;
  38750. /**
  38751. * Defines the touch sensibility for move.
  38752. * The higher the faster.
  38753. */
  38754. touchMoveSensibility: number;
  38755. /**
  38756. * Instantiates a new touch camera.
  38757. * This represents a FPS type of camera controlled by touch.
  38758. * This is like a universal camera minus the Gamepad controls.
  38759. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38760. * @param name Define the name of the camera in the scene
  38761. * @param position Define the start position of the camera in the scene
  38762. * @param scene Define the scene the camera belongs to
  38763. */
  38764. constructor(name: string, position: Vector3, scene: Scene);
  38765. /**
  38766. * Gets the current object class name.
  38767. * @return the class name
  38768. */
  38769. getClassName(): string;
  38770. /** @hidden */
  38771. _setupInputs(): void;
  38772. }
  38773. }
  38774. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38775. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38776. import { Scene } from "babylonjs/scene";
  38777. import { Vector3, Axis } from "babylonjs/Maths/math";
  38778. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38779. /**
  38780. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38781. * being tilted forward or back and left or right.
  38782. */
  38783. export class DeviceOrientationCamera extends FreeCamera {
  38784. private _initialQuaternion;
  38785. private _quaternionCache;
  38786. private _tmpDragQuaternion;
  38787. /**
  38788. * Creates a new device orientation camera
  38789. * @param name The name of the camera
  38790. * @param position The start position camera
  38791. * @param scene The scene the camera belongs to
  38792. */
  38793. constructor(name: string, position: Vector3, scene: Scene);
  38794. /**
  38795. * @hidden
  38796. * Disabled pointer input on first orientation sensor update (Default: true)
  38797. */
  38798. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38799. private _dragFactor;
  38800. /**
  38801. * Enabled turning on the y axis when the orientation sensor is active
  38802. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38803. */
  38804. enableHorizontalDragging(dragFactor?: number): void;
  38805. /**
  38806. * Gets the current instance class name ("DeviceOrientationCamera").
  38807. * This helps avoiding instanceof at run time.
  38808. * @returns the class name
  38809. */
  38810. getClassName(): string;
  38811. /**
  38812. * @hidden
  38813. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38814. */
  38815. _checkInputs(): void;
  38816. /**
  38817. * Reset the camera to its default orientation on the specified axis only.
  38818. * @param axis The axis to reset
  38819. */
  38820. resetToCurrentRotation(axis?: Axis): void;
  38821. }
  38822. }
  38823. declare module "babylonjs/Gamepads/xboxGamepad" {
  38824. import { Observable } from "babylonjs/Misc/observable";
  38825. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38826. /**
  38827. * Defines supported buttons for XBox360 compatible gamepads
  38828. */
  38829. export enum Xbox360Button {
  38830. /** A */
  38831. A = 0,
  38832. /** B */
  38833. B = 1,
  38834. /** X */
  38835. X = 2,
  38836. /** Y */
  38837. Y = 3,
  38838. /** Start */
  38839. Start = 4,
  38840. /** Back */
  38841. Back = 5,
  38842. /** Left button */
  38843. LB = 6,
  38844. /** Right button */
  38845. RB = 7,
  38846. /** Left stick */
  38847. LeftStick = 8,
  38848. /** Right stick */
  38849. RightStick = 9
  38850. }
  38851. /** Defines values for XBox360 DPad */
  38852. export enum Xbox360Dpad {
  38853. /** Up */
  38854. Up = 0,
  38855. /** Down */
  38856. Down = 1,
  38857. /** Left */
  38858. Left = 2,
  38859. /** Right */
  38860. Right = 3
  38861. }
  38862. /**
  38863. * Defines a XBox360 gamepad
  38864. */
  38865. export class Xbox360Pad extends Gamepad {
  38866. private _leftTrigger;
  38867. private _rightTrigger;
  38868. private _onlefttriggerchanged;
  38869. private _onrighttriggerchanged;
  38870. private _onbuttondown;
  38871. private _onbuttonup;
  38872. private _ondpaddown;
  38873. private _ondpadup;
  38874. /** Observable raised when a button is pressed */
  38875. onButtonDownObservable: Observable<Xbox360Button>;
  38876. /** Observable raised when a button is released */
  38877. onButtonUpObservable: Observable<Xbox360Button>;
  38878. /** Observable raised when a pad is pressed */
  38879. onPadDownObservable: Observable<Xbox360Dpad>;
  38880. /** Observable raised when a pad is released */
  38881. onPadUpObservable: Observable<Xbox360Dpad>;
  38882. private _buttonA;
  38883. private _buttonB;
  38884. private _buttonX;
  38885. private _buttonY;
  38886. private _buttonBack;
  38887. private _buttonStart;
  38888. private _buttonLB;
  38889. private _buttonRB;
  38890. private _buttonLeftStick;
  38891. private _buttonRightStick;
  38892. private _dPadUp;
  38893. private _dPadDown;
  38894. private _dPadLeft;
  38895. private _dPadRight;
  38896. private _isXboxOnePad;
  38897. /**
  38898. * Creates a new XBox360 gamepad object
  38899. * @param id defines the id of this gamepad
  38900. * @param index defines its index
  38901. * @param gamepad defines the internal HTML gamepad object
  38902. * @param xboxOne defines if it is a XBox One gamepad
  38903. */
  38904. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38905. /**
  38906. * Defines the callback to call when left trigger is pressed
  38907. * @param callback defines the callback to use
  38908. */
  38909. onlefttriggerchanged(callback: (value: number) => void): void;
  38910. /**
  38911. * Defines the callback to call when right trigger is pressed
  38912. * @param callback defines the callback to use
  38913. */
  38914. onrighttriggerchanged(callback: (value: number) => void): void;
  38915. /**
  38916. * Gets the left trigger value
  38917. */
  38918. /**
  38919. * Sets the left trigger value
  38920. */
  38921. leftTrigger: number;
  38922. /**
  38923. * Gets the right trigger value
  38924. */
  38925. /**
  38926. * Sets the right trigger value
  38927. */
  38928. rightTrigger: number;
  38929. /**
  38930. * Defines the callback to call when a button is pressed
  38931. * @param callback defines the callback to use
  38932. */
  38933. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38934. /**
  38935. * Defines the callback to call when a button is released
  38936. * @param callback defines the callback to use
  38937. */
  38938. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38939. /**
  38940. * Defines the callback to call when a pad is pressed
  38941. * @param callback defines the callback to use
  38942. */
  38943. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38944. /**
  38945. * Defines the callback to call when a pad is released
  38946. * @param callback defines the callback to use
  38947. */
  38948. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38949. private _setButtonValue;
  38950. private _setDPadValue;
  38951. /**
  38952. * Gets the value of the `A` button
  38953. */
  38954. /**
  38955. * Sets the value of the `A` button
  38956. */
  38957. buttonA: number;
  38958. /**
  38959. * Gets the value of the `B` button
  38960. */
  38961. /**
  38962. * Sets the value of the `B` button
  38963. */
  38964. buttonB: number;
  38965. /**
  38966. * Gets the value of the `X` button
  38967. */
  38968. /**
  38969. * Sets the value of the `X` button
  38970. */
  38971. buttonX: number;
  38972. /**
  38973. * Gets the value of the `Y` button
  38974. */
  38975. /**
  38976. * Sets the value of the `Y` button
  38977. */
  38978. buttonY: number;
  38979. /**
  38980. * Gets the value of the `Start` button
  38981. */
  38982. /**
  38983. * Sets the value of the `Start` button
  38984. */
  38985. buttonStart: number;
  38986. /**
  38987. * Gets the value of the `Back` button
  38988. */
  38989. /**
  38990. * Sets the value of the `Back` button
  38991. */
  38992. buttonBack: number;
  38993. /**
  38994. * Gets the value of the `Left` button
  38995. */
  38996. /**
  38997. * Sets the value of the `Left` button
  38998. */
  38999. buttonLB: number;
  39000. /**
  39001. * Gets the value of the `Right` button
  39002. */
  39003. /**
  39004. * Sets the value of the `Right` button
  39005. */
  39006. buttonRB: number;
  39007. /**
  39008. * Gets the value of the Left joystick
  39009. */
  39010. /**
  39011. * Sets the value of the Left joystick
  39012. */
  39013. buttonLeftStick: number;
  39014. /**
  39015. * Gets the value of the Right joystick
  39016. */
  39017. /**
  39018. * Sets the value of the Right joystick
  39019. */
  39020. buttonRightStick: number;
  39021. /**
  39022. * Gets the value of D-pad up
  39023. */
  39024. /**
  39025. * Sets the value of D-pad up
  39026. */
  39027. dPadUp: number;
  39028. /**
  39029. * Gets the value of D-pad down
  39030. */
  39031. /**
  39032. * Sets the value of D-pad down
  39033. */
  39034. dPadDown: number;
  39035. /**
  39036. * Gets the value of D-pad left
  39037. */
  39038. /**
  39039. * Sets the value of D-pad left
  39040. */
  39041. dPadLeft: number;
  39042. /**
  39043. * Gets the value of D-pad right
  39044. */
  39045. /**
  39046. * Sets the value of D-pad right
  39047. */
  39048. dPadRight: number;
  39049. /**
  39050. * Force the gamepad to synchronize with device values
  39051. */
  39052. update(): void;
  39053. /**
  39054. * Disposes the gamepad
  39055. */
  39056. dispose(): void;
  39057. }
  39058. }
  39059. declare module "babylonjs/Gamepads/gamepadManager" {
  39060. import { Observable } from "babylonjs/Misc/observable";
  39061. import { Nullable } from "babylonjs/types";
  39062. import { Scene } from "babylonjs/scene";
  39063. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39064. /**
  39065. * Manager for handling gamepads
  39066. */
  39067. export class GamepadManager {
  39068. private _scene?;
  39069. private _babylonGamepads;
  39070. private _oneGamepadConnected;
  39071. /** @hidden */
  39072. _isMonitoring: boolean;
  39073. private _gamepadEventSupported;
  39074. private _gamepadSupport;
  39075. /**
  39076. * observable to be triggered when the gamepad controller has been connected
  39077. */
  39078. onGamepadConnectedObservable: Observable<Gamepad>;
  39079. /**
  39080. * observable to be triggered when the gamepad controller has been disconnected
  39081. */
  39082. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39083. private _onGamepadConnectedEvent;
  39084. private _onGamepadDisconnectedEvent;
  39085. /**
  39086. * Initializes the gamepad manager
  39087. * @param _scene BabylonJS scene
  39088. */
  39089. constructor(_scene?: Scene | undefined);
  39090. /**
  39091. * The gamepads in the game pad manager
  39092. */
  39093. readonly gamepads: Gamepad[];
  39094. /**
  39095. * Get the gamepad controllers based on type
  39096. * @param type The type of gamepad controller
  39097. * @returns Nullable gamepad
  39098. */
  39099. getGamepadByType(type?: number): Nullable<Gamepad>;
  39100. /**
  39101. * Disposes the gamepad manager
  39102. */
  39103. dispose(): void;
  39104. private _addNewGamepad;
  39105. private _startMonitoringGamepads;
  39106. private _stopMonitoringGamepads;
  39107. /** @hidden */
  39108. _checkGamepadsStatus(): void;
  39109. private _updateGamepadObjects;
  39110. }
  39111. }
  39112. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39113. import { Nullable } from "babylonjs/types";
  39114. import { Scene } from "babylonjs/scene";
  39115. import { ISceneComponent } from "babylonjs/sceneComponent";
  39116. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39117. module "babylonjs/scene" {
  39118. interface Scene {
  39119. /** @hidden */
  39120. _gamepadManager: Nullable<GamepadManager>;
  39121. /**
  39122. * Gets the gamepad manager associated with the scene
  39123. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39124. */
  39125. gamepadManager: GamepadManager;
  39126. }
  39127. }
  39128. module "babylonjs/Cameras/freeCameraInputsManager" {
  39129. /**
  39130. * Interface representing a free camera inputs manager
  39131. */
  39132. interface FreeCameraInputsManager {
  39133. /**
  39134. * Adds gamepad input support to the FreeCameraInputsManager.
  39135. * @returns the FreeCameraInputsManager
  39136. */
  39137. addGamepad(): FreeCameraInputsManager;
  39138. }
  39139. }
  39140. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39141. /**
  39142. * Interface representing an arc rotate camera inputs manager
  39143. */
  39144. interface ArcRotateCameraInputsManager {
  39145. /**
  39146. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39147. * @returns the camera inputs manager
  39148. */
  39149. addGamepad(): ArcRotateCameraInputsManager;
  39150. }
  39151. }
  39152. /**
  39153. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39154. */
  39155. export class GamepadSystemSceneComponent implements ISceneComponent {
  39156. /**
  39157. * The component name helpfull to identify the component in the list of scene components.
  39158. */
  39159. readonly name: string;
  39160. /**
  39161. * The scene the component belongs to.
  39162. */
  39163. scene: Scene;
  39164. /**
  39165. * Creates a new instance of the component for the given scene
  39166. * @param scene Defines the scene to register the component in
  39167. */
  39168. constructor(scene: Scene);
  39169. /**
  39170. * Registers the component in a given scene
  39171. */
  39172. register(): void;
  39173. /**
  39174. * Rebuilds the elements related to this component in case of
  39175. * context lost for instance.
  39176. */
  39177. rebuild(): void;
  39178. /**
  39179. * Disposes the component and the associated ressources
  39180. */
  39181. dispose(): void;
  39182. private _beforeCameraUpdate;
  39183. }
  39184. }
  39185. declare module "babylonjs/Cameras/universalCamera" {
  39186. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39187. import { Scene } from "babylonjs/scene";
  39188. import { Vector3 } from "babylonjs/Maths/math";
  39189. import "babylonjs/Gamepads/gamepadSceneComponent";
  39190. /**
  39191. * 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,
  39192. * which still works and will still be found in many Playgrounds.
  39193. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39194. */
  39195. export class UniversalCamera extends TouchCamera {
  39196. /**
  39197. * Defines the gamepad rotation sensiblity.
  39198. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39199. */
  39200. gamepadAngularSensibility: number;
  39201. /**
  39202. * Defines the gamepad move sensiblity.
  39203. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39204. */
  39205. gamepadMoveSensibility: number;
  39206. /**
  39207. * 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,
  39208. * which still works and will still be found in many Playgrounds.
  39209. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39210. * @param name Define the name of the camera in the scene
  39211. * @param position Define the start position of the camera in the scene
  39212. * @param scene Define the scene the camera belongs to
  39213. */
  39214. constructor(name: string, position: Vector3, scene: Scene);
  39215. /**
  39216. * Gets the current object class name.
  39217. * @return the class name
  39218. */
  39219. getClassName(): string;
  39220. }
  39221. }
  39222. declare module "babylonjs/Cameras/gamepadCamera" {
  39223. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39224. import { Scene } from "babylonjs/scene";
  39225. import { Vector3 } from "babylonjs/Maths/math";
  39226. /**
  39227. * This represents a FPS type of camera. This is only here for back compat purpose.
  39228. * Please use the UniversalCamera instead as both are identical.
  39229. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39230. */
  39231. export class GamepadCamera extends UniversalCamera {
  39232. /**
  39233. * Instantiates a new Gamepad Camera
  39234. * This represents a FPS type of camera. This is only here for back compat purpose.
  39235. * Please use the UniversalCamera instead as both are identical.
  39236. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39237. * @param name Define the name of the camera in the scene
  39238. * @param position Define the start position of the camera in the scene
  39239. * @param scene Define the scene the camera belongs to
  39240. */
  39241. constructor(name: string, position: Vector3, scene: Scene);
  39242. /**
  39243. * Gets the current object class name.
  39244. * @return the class name
  39245. */
  39246. getClassName(): string;
  39247. }
  39248. }
  39249. declare module "babylonjs/Shaders/pass.fragment" {
  39250. /** @hidden */
  39251. export var passPixelShader: {
  39252. name: string;
  39253. shader: string;
  39254. };
  39255. }
  39256. declare module "babylonjs/Shaders/passCube.fragment" {
  39257. /** @hidden */
  39258. export var passCubePixelShader: {
  39259. name: string;
  39260. shader: string;
  39261. };
  39262. }
  39263. declare module "babylonjs/PostProcesses/passPostProcess" {
  39264. import { Nullable } from "babylonjs/types";
  39265. import { Camera } from "babylonjs/Cameras/camera";
  39266. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39267. import { Engine } from "babylonjs/Engines/engine";
  39268. import "babylonjs/Shaders/pass.fragment";
  39269. import "babylonjs/Shaders/passCube.fragment";
  39270. /**
  39271. * PassPostProcess which produces an output the same as it's input
  39272. */
  39273. export class PassPostProcess extends PostProcess {
  39274. /**
  39275. * Creates the PassPostProcess
  39276. * @param name The name of the effect.
  39277. * @param options The required width/height ratio to downsize to before computing the render pass.
  39278. * @param camera The camera to apply the render pass to.
  39279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39280. * @param engine The engine which the post process will be applied. (default: current engine)
  39281. * @param reusable If the post process can be reused on the same frame. (default: false)
  39282. * @param textureType The type of texture to be used when performing the post processing.
  39283. * @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)
  39284. */
  39285. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39286. }
  39287. /**
  39288. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39289. */
  39290. export class PassCubePostProcess extends PostProcess {
  39291. private _face;
  39292. /**
  39293. * Gets or sets the cube face to display.
  39294. * * 0 is +X
  39295. * * 1 is -X
  39296. * * 2 is +Y
  39297. * * 3 is -Y
  39298. * * 4 is +Z
  39299. * * 5 is -Z
  39300. */
  39301. face: number;
  39302. /**
  39303. * Creates the PassCubePostProcess
  39304. * @param name The name of the effect.
  39305. * @param options The required width/height ratio to downsize to before computing the render pass.
  39306. * @param camera The camera to apply the render pass to.
  39307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39308. * @param engine The engine which the post process will be applied. (default: current engine)
  39309. * @param reusable If the post process can be reused on the same frame. (default: false)
  39310. * @param textureType The type of texture to be used when performing the post processing.
  39311. * @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)
  39312. */
  39313. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39314. }
  39315. }
  39316. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39317. /** @hidden */
  39318. export var anaglyphPixelShader: {
  39319. name: string;
  39320. shader: string;
  39321. };
  39322. }
  39323. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39324. import { Engine } from "babylonjs/Engines/engine";
  39325. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39326. import { Camera } from "babylonjs/Cameras/camera";
  39327. import "babylonjs/Shaders/anaglyph.fragment";
  39328. /**
  39329. * Postprocess used to generate anaglyphic rendering
  39330. */
  39331. export class AnaglyphPostProcess extends PostProcess {
  39332. private _passedProcess;
  39333. /**
  39334. * Creates a new AnaglyphPostProcess
  39335. * @param name defines postprocess name
  39336. * @param options defines creation options or target ratio scale
  39337. * @param rigCameras defines cameras using this postprocess
  39338. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39339. * @param engine defines hosting engine
  39340. * @param reusable defines if the postprocess will be reused multiple times per frame
  39341. */
  39342. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39343. }
  39344. }
  39345. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39346. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39347. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39348. import { Scene } from "babylonjs/scene";
  39349. import { Vector3 } from "babylonjs/Maths/math";
  39350. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39351. /**
  39352. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39353. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39354. */
  39355. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39356. /**
  39357. * Creates a new AnaglyphArcRotateCamera
  39358. * @param name defines camera name
  39359. * @param alpha defines alpha angle (in radians)
  39360. * @param beta defines beta angle (in radians)
  39361. * @param radius defines radius
  39362. * @param target defines camera target
  39363. * @param interaxialDistance defines distance between each color axis
  39364. * @param scene defines the hosting scene
  39365. */
  39366. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39367. /**
  39368. * Gets camera class name
  39369. * @returns AnaglyphArcRotateCamera
  39370. */
  39371. getClassName(): string;
  39372. }
  39373. }
  39374. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39375. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39376. import { Scene } from "babylonjs/scene";
  39377. import { Vector3 } from "babylonjs/Maths/math";
  39378. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39379. /**
  39380. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39381. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39382. */
  39383. export class AnaglyphFreeCamera extends FreeCamera {
  39384. /**
  39385. * Creates a new AnaglyphFreeCamera
  39386. * @param name defines camera name
  39387. * @param position defines initial position
  39388. * @param interaxialDistance defines distance between each color axis
  39389. * @param scene defines the hosting scene
  39390. */
  39391. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39392. /**
  39393. * Gets camera class name
  39394. * @returns AnaglyphFreeCamera
  39395. */
  39396. getClassName(): string;
  39397. }
  39398. }
  39399. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39400. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39401. import { Scene } from "babylonjs/scene";
  39402. import { Vector3 } from "babylonjs/Maths/math";
  39403. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39404. /**
  39405. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39406. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39407. */
  39408. export class AnaglyphGamepadCamera extends GamepadCamera {
  39409. /**
  39410. * Creates a new AnaglyphGamepadCamera
  39411. * @param name defines camera name
  39412. * @param position defines initial position
  39413. * @param interaxialDistance defines distance between each color axis
  39414. * @param scene defines the hosting scene
  39415. */
  39416. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39417. /**
  39418. * Gets camera class name
  39419. * @returns AnaglyphGamepadCamera
  39420. */
  39421. getClassName(): string;
  39422. }
  39423. }
  39424. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39425. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39426. import { Scene } from "babylonjs/scene";
  39427. import { Vector3 } from "babylonjs/Maths/math";
  39428. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39429. /**
  39430. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39431. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39432. */
  39433. export class AnaglyphUniversalCamera extends UniversalCamera {
  39434. /**
  39435. * Creates a new AnaglyphUniversalCamera
  39436. * @param name defines camera name
  39437. * @param position defines initial position
  39438. * @param interaxialDistance defines distance between each color axis
  39439. * @param scene defines the hosting scene
  39440. */
  39441. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39442. /**
  39443. * Gets camera class name
  39444. * @returns AnaglyphUniversalCamera
  39445. */
  39446. getClassName(): string;
  39447. }
  39448. }
  39449. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39450. /** @hidden */
  39451. export var stereoscopicInterlacePixelShader: {
  39452. name: string;
  39453. shader: string;
  39454. };
  39455. }
  39456. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39457. import { Camera } from "babylonjs/Cameras/camera";
  39458. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39459. import { Engine } from "babylonjs/Engines/engine";
  39460. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39461. /**
  39462. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39463. */
  39464. export class StereoscopicInterlacePostProcess extends PostProcess {
  39465. private _stepSize;
  39466. private _passedProcess;
  39467. /**
  39468. * Initializes a StereoscopicInterlacePostProcess
  39469. * @param name The name of the effect.
  39470. * @param rigCameras The rig cameras to be appled to the post process
  39471. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39472. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39473. * @param engine The engine which the post process will be applied. (default: current engine)
  39474. * @param reusable If the post process can be reused on the same frame. (default: false)
  39475. */
  39476. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39477. }
  39478. }
  39479. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39480. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39481. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39482. import { Scene } from "babylonjs/scene";
  39483. import { Vector3 } from "babylonjs/Maths/math";
  39484. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39485. /**
  39486. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39487. * @see http://doc.babylonjs.com/features/cameras
  39488. */
  39489. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39490. /**
  39491. * Creates a new StereoscopicArcRotateCamera
  39492. * @param name defines camera name
  39493. * @param alpha defines alpha angle (in radians)
  39494. * @param beta defines beta angle (in radians)
  39495. * @param radius defines radius
  39496. * @param target defines camera target
  39497. * @param interaxialDistance defines distance between each color axis
  39498. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39499. * @param scene defines the hosting scene
  39500. */
  39501. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39502. /**
  39503. * Gets camera class name
  39504. * @returns StereoscopicArcRotateCamera
  39505. */
  39506. getClassName(): string;
  39507. }
  39508. }
  39509. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39510. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39511. import { Scene } from "babylonjs/scene";
  39512. import { Vector3 } from "babylonjs/Maths/math";
  39513. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39514. /**
  39515. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39516. * @see http://doc.babylonjs.com/features/cameras
  39517. */
  39518. export class StereoscopicFreeCamera extends FreeCamera {
  39519. /**
  39520. * Creates a new StereoscopicFreeCamera
  39521. * @param name defines camera name
  39522. * @param position defines initial position
  39523. * @param interaxialDistance defines distance between each color axis
  39524. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39525. * @param scene defines the hosting scene
  39526. */
  39527. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39528. /**
  39529. * Gets camera class name
  39530. * @returns StereoscopicFreeCamera
  39531. */
  39532. getClassName(): string;
  39533. }
  39534. }
  39535. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39536. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39537. import { Scene } from "babylonjs/scene";
  39538. import { Vector3 } from "babylonjs/Maths/math";
  39539. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39540. /**
  39541. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39542. * @see http://doc.babylonjs.com/features/cameras
  39543. */
  39544. export class StereoscopicGamepadCamera extends GamepadCamera {
  39545. /**
  39546. * Creates a new StereoscopicGamepadCamera
  39547. * @param name defines camera name
  39548. * @param position defines initial position
  39549. * @param interaxialDistance defines distance between each color axis
  39550. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39551. * @param scene defines the hosting scene
  39552. */
  39553. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39554. /**
  39555. * Gets camera class name
  39556. * @returns StereoscopicGamepadCamera
  39557. */
  39558. getClassName(): string;
  39559. }
  39560. }
  39561. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39562. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39563. import { Scene } from "babylonjs/scene";
  39564. import { Vector3 } from "babylonjs/Maths/math";
  39565. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39566. /**
  39567. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39568. * @see http://doc.babylonjs.com/features/cameras
  39569. */
  39570. export class StereoscopicUniversalCamera extends UniversalCamera {
  39571. /**
  39572. * Creates a new StereoscopicUniversalCamera
  39573. * @param name defines camera name
  39574. * @param position defines initial position
  39575. * @param interaxialDistance defines distance between each color axis
  39576. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39577. * @param scene defines the hosting scene
  39578. */
  39579. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39580. /**
  39581. * Gets camera class name
  39582. * @returns StereoscopicUniversalCamera
  39583. */
  39584. getClassName(): string;
  39585. }
  39586. }
  39587. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39588. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39589. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39590. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39591. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39592. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39593. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39594. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39595. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39596. }
  39597. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39598. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39599. import { Scene } from "babylonjs/scene";
  39600. import { Vector3 } from "babylonjs/Maths/math";
  39601. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39602. /**
  39603. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39604. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39605. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39606. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39607. */
  39608. export class VirtualJoysticksCamera extends FreeCamera {
  39609. /**
  39610. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39611. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39612. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39613. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39614. * @param name Define the name of the camera in the scene
  39615. * @param position Define the start position of the camera in the scene
  39616. * @param scene Define the scene the camera belongs to
  39617. */
  39618. constructor(name: string, position: Vector3, scene: Scene);
  39619. /**
  39620. * Gets the current object class name.
  39621. * @return the class name
  39622. */
  39623. getClassName(): string;
  39624. }
  39625. }
  39626. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39627. import { Matrix } from "babylonjs/Maths/math";
  39628. /**
  39629. * This represents all the required metrics to create a VR camera.
  39630. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39631. */
  39632. export class VRCameraMetrics {
  39633. /**
  39634. * Define the horizontal resolution off the screen.
  39635. */
  39636. hResolution: number;
  39637. /**
  39638. * Define the vertical resolution off the screen.
  39639. */
  39640. vResolution: number;
  39641. /**
  39642. * Define the horizontal screen size.
  39643. */
  39644. hScreenSize: number;
  39645. /**
  39646. * Define the vertical screen size.
  39647. */
  39648. vScreenSize: number;
  39649. /**
  39650. * Define the vertical screen center position.
  39651. */
  39652. vScreenCenter: number;
  39653. /**
  39654. * Define the distance of the eyes to the screen.
  39655. */
  39656. eyeToScreenDistance: number;
  39657. /**
  39658. * Define the distance between both lenses
  39659. */
  39660. lensSeparationDistance: number;
  39661. /**
  39662. * Define the distance between both viewer's eyes.
  39663. */
  39664. interpupillaryDistance: number;
  39665. /**
  39666. * Define the distortion factor of the VR postprocess.
  39667. * Please, touch with care.
  39668. */
  39669. distortionK: number[];
  39670. /**
  39671. * Define the chromatic aberration correction factors for the VR post process.
  39672. */
  39673. chromaAbCorrection: number[];
  39674. /**
  39675. * Define the scale factor of the post process.
  39676. * The smaller the better but the slower.
  39677. */
  39678. postProcessScaleFactor: number;
  39679. /**
  39680. * Define an offset for the lens center.
  39681. */
  39682. lensCenterOffset: number;
  39683. /**
  39684. * Define if the current vr camera should compensate the distortion of the lense or not.
  39685. */
  39686. compensateDistortion: boolean;
  39687. /**
  39688. * Defines if multiview should be enabled when rendering (Default: false)
  39689. */
  39690. multiviewEnabled: boolean;
  39691. /**
  39692. * Gets the rendering aspect ratio based on the provided resolutions.
  39693. */
  39694. readonly aspectRatio: number;
  39695. /**
  39696. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39697. */
  39698. readonly aspectRatioFov: number;
  39699. /**
  39700. * @hidden
  39701. */
  39702. readonly leftHMatrix: Matrix;
  39703. /**
  39704. * @hidden
  39705. */
  39706. readonly rightHMatrix: Matrix;
  39707. /**
  39708. * @hidden
  39709. */
  39710. readonly leftPreViewMatrix: Matrix;
  39711. /**
  39712. * @hidden
  39713. */
  39714. readonly rightPreViewMatrix: Matrix;
  39715. /**
  39716. * Get the default VRMetrics based on the most generic setup.
  39717. * @returns the default vr metrics
  39718. */
  39719. static GetDefault(): VRCameraMetrics;
  39720. }
  39721. }
  39722. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39723. /** @hidden */
  39724. export var vrDistortionCorrectionPixelShader: {
  39725. name: string;
  39726. shader: string;
  39727. };
  39728. }
  39729. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39730. import { Camera } from "babylonjs/Cameras/camera";
  39731. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39732. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39733. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39734. /**
  39735. * VRDistortionCorrectionPostProcess used for mobile VR
  39736. */
  39737. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39738. private _isRightEye;
  39739. private _distortionFactors;
  39740. private _postProcessScaleFactor;
  39741. private _lensCenterOffset;
  39742. private _scaleIn;
  39743. private _scaleFactor;
  39744. private _lensCenter;
  39745. /**
  39746. * Initializes the VRDistortionCorrectionPostProcess
  39747. * @param name The name of the effect.
  39748. * @param camera The camera to apply the render pass to.
  39749. * @param isRightEye If this is for the right eye distortion
  39750. * @param vrMetrics All the required metrics for the VR camera
  39751. */
  39752. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39753. }
  39754. }
  39755. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39756. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39757. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39758. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39759. import { Scene } from "babylonjs/scene";
  39760. import { Vector3 } from "babylonjs/Maths/math";
  39761. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39762. import "babylonjs/Cameras/RigModes/vrRigMode";
  39763. /**
  39764. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39765. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39766. */
  39767. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39768. /**
  39769. * Creates a new VRDeviceOrientationArcRotateCamera
  39770. * @param name defines camera name
  39771. * @param alpha defines the camera rotation along the logitudinal axis
  39772. * @param beta defines the camera rotation along the latitudinal axis
  39773. * @param radius defines the camera distance from its target
  39774. * @param target defines the camera target
  39775. * @param scene defines the scene the camera belongs to
  39776. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39777. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39778. */
  39779. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39780. /**
  39781. * Gets camera class name
  39782. * @returns VRDeviceOrientationArcRotateCamera
  39783. */
  39784. getClassName(): string;
  39785. }
  39786. }
  39787. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39788. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39789. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39790. import { Scene } from "babylonjs/scene";
  39791. import { Vector3 } from "babylonjs/Maths/math";
  39792. import "babylonjs/Cameras/RigModes/vrRigMode";
  39793. /**
  39794. * Camera used to simulate VR rendering (based on FreeCamera)
  39795. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39796. */
  39797. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39798. /**
  39799. * Creates a new VRDeviceOrientationFreeCamera
  39800. * @param name defines camera name
  39801. * @param position defines the start position of the camera
  39802. * @param scene defines the scene the camera belongs to
  39803. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39804. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39805. */
  39806. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39807. /**
  39808. * Gets camera class name
  39809. * @returns VRDeviceOrientationFreeCamera
  39810. */
  39811. getClassName(): string;
  39812. }
  39813. }
  39814. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39815. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39816. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39817. import { Scene } from "babylonjs/scene";
  39818. import { Vector3 } from "babylonjs/Maths/math";
  39819. import "babylonjs/Gamepads/gamepadSceneComponent";
  39820. /**
  39821. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39822. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39823. */
  39824. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39825. /**
  39826. * Creates a new VRDeviceOrientationGamepadCamera
  39827. * @param name defines camera name
  39828. * @param position defines the start position of the camera
  39829. * @param scene defines the scene the camera belongs to
  39830. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39831. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39832. */
  39833. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39834. /**
  39835. * Gets camera class name
  39836. * @returns VRDeviceOrientationGamepadCamera
  39837. */
  39838. getClassName(): string;
  39839. }
  39840. }
  39841. declare module "babylonjs/Materials/pushMaterial" {
  39842. import { Nullable } from "babylonjs/types";
  39843. import { Scene } from "babylonjs/scene";
  39844. import { Matrix } from "babylonjs/Maths/math";
  39845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39846. import { Mesh } from "babylonjs/Meshes/mesh";
  39847. import { Material } from "babylonjs/Materials/material";
  39848. import { Effect } from "babylonjs/Materials/effect";
  39849. /**
  39850. * Base class of materials working in push mode in babylon JS
  39851. * @hidden
  39852. */
  39853. export class PushMaterial extends Material {
  39854. protected _activeEffect: Effect;
  39855. protected _normalMatrix: Matrix;
  39856. /**
  39857. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39858. * This means that the material can keep using a previous shader while a new one is being compiled.
  39859. * This is mostly used when shader parallel compilation is supported (true by default)
  39860. */
  39861. allowShaderHotSwapping: boolean;
  39862. constructor(name: string, scene: Scene);
  39863. getEffect(): Effect;
  39864. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39865. /**
  39866. * Binds the given world matrix to the active effect
  39867. *
  39868. * @param world the matrix to bind
  39869. */
  39870. bindOnlyWorldMatrix(world: Matrix): void;
  39871. /**
  39872. * Binds the given normal matrix to the active effect
  39873. *
  39874. * @param normalMatrix the matrix to bind
  39875. */
  39876. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39877. bind(world: Matrix, mesh?: Mesh): void;
  39878. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39879. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39880. }
  39881. }
  39882. declare module "babylonjs/Materials/materialFlags" {
  39883. /**
  39884. * This groups all the flags used to control the materials channel.
  39885. */
  39886. export class MaterialFlags {
  39887. private static _DiffuseTextureEnabled;
  39888. /**
  39889. * Are diffuse textures enabled in the application.
  39890. */
  39891. static DiffuseTextureEnabled: boolean;
  39892. private static _AmbientTextureEnabled;
  39893. /**
  39894. * Are ambient textures enabled in the application.
  39895. */
  39896. static AmbientTextureEnabled: boolean;
  39897. private static _OpacityTextureEnabled;
  39898. /**
  39899. * Are opacity textures enabled in the application.
  39900. */
  39901. static OpacityTextureEnabled: boolean;
  39902. private static _ReflectionTextureEnabled;
  39903. /**
  39904. * Are reflection textures enabled in the application.
  39905. */
  39906. static ReflectionTextureEnabled: boolean;
  39907. private static _EmissiveTextureEnabled;
  39908. /**
  39909. * Are emissive textures enabled in the application.
  39910. */
  39911. static EmissiveTextureEnabled: boolean;
  39912. private static _SpecularTextureEnabled;
  39913. /**
  39914. * Are specular textures enabled in the application.
  39915. */
  39916. static SpecularTextureEnabled: boolean;
  39917. private static _BumpTextureEnabled;
  39918. /**
  39919. * Are bump textures enabled in the application.
  39920. */
  39921. static BumpTextureEnabled: boolean;
  39922. private static _LightmapTextureEnabled;
  39923. /**
  39924. * Are lightmap textures enabled in the application.
  39925. */
  39926. static LightmapTextureEnabled: boolean;
  39927. private static _RefractionTextureEnabled;
  39928. /**
  39929. * Are refraction textures enabled in the application.
  39930. */
  39931. static RefractionTextureEnabled: boolean;
  39932. private static _ColorGradingTextureEnabled;
  39933. /**
  39934. * Are color grading textures enabled in the application.
  39935. */
  39936. static ColorGradingTextureEnabled: boolean;
  39937. private static _FresnelEnabled;
  39938. /**
  39939. * Are fresnels enabled in the application.
  39940. */
  39941. static FresnelEnabled: boolean;
  39942. private static _ClearCoatTextureEnabled;
  39943. /**
  39944. * Are clear coat textures enabled in the application.
  39945. */
  39946. static ClearCoatTextureEnabled: boolean;
  39947. private static _ClearCoatBumpTextureEnabled;
  39948. /**
  39949. * Are clear coat bump textures enabled in the application.
  39950. */
  39951. static ClearCoatBumpTextureEnabled: boolean;
  39952. private static _ClearCoatTintTextureEnabled;
  39953. /**
  39954. * Are clear coat tint textures enabled in the application.
  39955. */
  39956. static ClearCoatTintTextureEnabled: boolean;
  39957. private static _SheenTextureEnabled;
  39958. /**
  39959. * Are sheen textures enabled in the application.
  39960. */
  39961. static SheenTextureEnabled: boolean;
  39962. private static _AnisotropicTextureEnabled;
  39963. /**
  39964. * Are anisotropic textures enabled in the application.
  39965. */
  39966. static AnisotropicTextureEnabled: boolean;
  39967. private static _ThicknessTextureEnabled;
  39968. /**
  39969. * Are thickness textures enabled in the application.
  39970. */
  39971. static ThicknessTextureEnabled: boolean;
  39972. }
  39973. }
  39974. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39975. /** @hidden */
  39976. export var defaultFragmentDeclaration: {
  39977. name: string;
  39978. shader: string;
  39979. };
  39980. }
  39981. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39982. /** @hidden */
  39983. export var defaultUboDeclaration: {
  39984. name: string;
  39985. shader: string;
  39986. };
  39987. }
  39988. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39989. /** @hidden */
  39990. export var lightFragmentDeclaration: {
  39991. name: string;
  39992. shader: string;
  39993. };
  39994. }
  39995. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39996. /** @hidden */
  39997. export var lightUboDeclaration: {
  39998. name: string;
  39999. shader: string;
  40000. };
  40001. }
  40002. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40003. /** @hidden */
  40004. export var lightsFragmentFunctions: {
  40005. name: string;
  40006. shader: string;
  40007. };
  40008. }
  40009. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40010. /** @hidden */
  40011. export var shadowsFragmentFunctions: {
  40012. name: string;
  40013. shader: string;
  40014. };
  40015. }
  40016. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40017. /** @hidden */
  40018. export var fresnelFunction: {
  40019. name: string;
  40020. shader: string;
  40021. };
  40022. }
  40023. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40024. /** @hidden */
  40025. export var reflectionFunction: {
  40026. name: string;
  40027. shader: string;
  40028. };
  40029. }
  40030. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40031. /** @hidden */
  40032. export var bumpFragmentFunctions: {
  40033. name: string;
  40034. shader: string;
  40035. };
  40036. }
  40037. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40038. /** @hidden */
  40039. export var logDepthDeclaration: {
  40040. name: string;
  40041. shader: string;
  40042. };
  40043. }
  40044. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40045. /** @hidden */
  40046. export var bumpFragment: {
  40047. name: string;
  40048. shader: string;
  40049. };
  40050. }
  40051. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40052. /** @hidden */
  40053. export var depthPrePass: {
  40054. name: string;
  40055. shader: string;
  40056. };
  40057. }
  40058. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40059. /** @hidden */
  40060. export var lightFragment: {
  40061. name: string;
  40062. shader: string;
  40063. };
  40064. }
  40065. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40066. /** @hidden */
  40067. export var logDepthFragment: {
  40068. name: string;
  40069. shader: string;
  40070. };
  40071. }
  40072. declare module "babylonjs/Shaders/default.fragment" {
  40073. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40074. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40075. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40076. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40077. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40078. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40079. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40080. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40081. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40082. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40083. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40084. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40085. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40086. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40087. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40088. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40089. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40090. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40091. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40092. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40093. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40094. /** @hidden */
  40095. export var defaultPixelShader: {
  40096. name: string;
  40097. shader: string;
  40098. };
  40099. }
  40100. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40101. /** @hidden */
  40102. export var defaultVertexDeclaration: {
  40103. name: string;
  40104. shader: string;
  40105. };
  40106. }
  40107. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40108. /** @hidden */
  40109. export var bumpVertexDeclaration: {
  40110. name: string;
  40111. shader: string;
  40112. };
  40113. }
  40114. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40115. /** @hidden */
  40116. export var bumpVertex: {
  40117. name: string;
  40118. shader: string;
  40119. };
  40120. }
  40121. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40122. /** @hidden */
  40123. export var fogVertex: {
  40124. name: string;
  40125. shader: string;
  40126. };
  40127. }
  40128. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40129. /** @hidden */
  40130. export var shadowsVertex: {
  40131. name: string;
  40132. shader: string;
  40133. };
  40134. }
  40135. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40136. /** @hidden */
  40137. export var pointCloudVertex: {
  40138. name: string;
  40139. shader: string;
  40140. };
  40141. }
  40142. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40143. /** @hidden */
  40144. export var logDepthVertex: {
  40145. name: string;
  40146. shader: string;
  40147. };
  40148. }
  40149. declare module "babylonjs/Shaders/default.vertex" {
  40150. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40151. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40152. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40153. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40154. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40155. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40156. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40157. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40158. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40159. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40160. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40161. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40162. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40163. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40164. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40165. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40166. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40167. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40168. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40169. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40170. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40171. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40172. /** @hidden */
  40173. export var defaultVertexShader: {
  40174. name: string;
  40175. shader: string;
  40176. };
  40177. }
  40178. declare module "babylonjs/Materials/standardMaterial" {
  40179. import { SmartArray } from "babylonjs/Misc/smartArray";
  40180. import { IAnimatable } from "babylonjs/Misc/tools";
  40181. import { Nullable } from "babylonjs/types";
  40182. import { Scene } from "babylonjs/scene";
  40183. import { Matrix, Color3 } from "babylonjs/Maths/math";
  40184. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40186. import { Mesh } from "babylonjs/Meshes/mesh";
  40187. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40188. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40189. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40190. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40191. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40192. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40193. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40194. import "babylonjs/Shaders/default.fragment";
  40195. import "babylonjs/Shaders/default.vertex";
  40196. /** @hidden */
  40197. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40198. MAINUV1: boolean;
  40199. MAINUV2: boolean;
  40200. DIFFUSE: boolean;
  40201. DIFFUSEDIRECTUV: number;
  40202. AMBIENT: boolean;
  40203. AMBIENTDIRECTUV: number;
  40204. OPACITY: boolean;
  40205. OPACITYDIRECTUV: number;
  40206. OPACITYRGB: boolean;
  40207. REFLECTION: boolean;
  40208. EMISSIVE: boolean;
  40209. EMISSIVEDIRECTUV: number;
  40210. SPECULAR: boolean;
  40211. SPECULARDIRECTUV: number;
  40212. BUMP: boolean;
  40213. BUMPDIRECTUV: number;
  40214. PARALLAX: boolean;
  40215. PARALLAXOCCLUSION: boolean;
  40216. SPECULAROVERALPHA: boolean;
  40217. CLIPPLANE: boolean;
  40218. CLIPPLANE2: boolean;
  40219. CLIPPLANE3: boolean;
  40220. CLIPPLANE4: boolean;
  40221. ALPHATEST: boolean;
  40222. DEPTHPREPASS: boolean;
  40223. ALPHAFROMDIFFUSE: boolean;
  40224. POINTSIZE: boolean;
  40225. FOG: boolean;
  40226. SPECULARTERM: boolean;
  40227. DIFFUSEFRESNEL: boolean;
  40228. OPACITYFRESNEL: boolean;
  40229. REFLECTIONFRESNEL: boolean;
  40230. REFRACTIONFRESNEL: boolean;
  40231. EMISSIVEFRESNEL: boolean;
  40232. FRESNEL: boolean;
  40233. NORMAL: boolean;
  40234. UV1: boolean;
  40235. UV2: boolean;
  40236. VERTEXCOLOR: boolean;
  40237. VERTEXALPHA: boolean;
  40238. NUM_BONE_INFLUENCERS: number;
  40239. BonesPerMesh: number;
  40240. BONETEXTURE: boolean;
  40241. INSTANCES: boolean;
  40242. GLOSSINESS: boolean;
  40243. ROUGHNESS: boolean;
  40244. EMISSIVEASILLUMINATION: boolean;
  40245. LINKEMISSIVEWITHDIFFUSE: boolean;
  40246. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40247. LIGHTMAP: boolean;
  40248. LIGHTMAPDIRECTUV: number;
  40249. OBJECTSPACE_NORMALMAP: boolean;
  40250. USELIGHTMAPASSHADOWMAP: boolean;
  40251. REFLECTIONMAP_3D: boolean;
  40252. REFLECTIONMAP_SPHERICAL: boolean;
  40253. REFLECTIONMAP_PLANAR: boolean;
  40254. REFLECTIONMAP_CUBIC: boolean;
  40255. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40256. REFLECTIONMAP_PROJECTION: boolean;
  40257. REFLECTIONMAP_SKYBOX: boolean;
  40258. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40259. REFLECTIONMAP_EXPLICIT: boolean;
  40260. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40261. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40262. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40263. INVERTCUBICMAP: boolean;
  40264. LOGARITHMICDEPTH: boolean;
  40265. REFRACTION: boolean;
  40266. REFRACTIONMAP_3D: boolean;
  40267. REFLECTIONOVERALPHA: boolean;
  40268. TWOSIDEDLIGHTING: boolean;
  40269. SHADOWFLOAT: boolean;
  40270. MORPHTARGETS: boolean;
  40271. MORPHTARGETS_NORMAL: boolean;
  40272. MORPHTARGETS_TANGENT: boolean;
  40273. NUM_MORPH_INFLUENCERS: number;
  40274. NONUNIFORMSCALING: boolean;
  40275. PREMULTIPLYALPHA: boolean;
  40276. IMAGEPROCESSING: boolean;
  40277. VIGNETTE: boolean;
  40278. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40279. VIGNETTEBLENDMODEOPAQUE: boolean;
  40280. TONEMAPPING: boolean;
  40281. TONEMAPPING_ACES: boolean;
  40282. CONTRAST: boolean;
  40283. COLORCURVES: boolean;
  40284. COLORGRADING: boolean;
  40285. COLORGRADING3D: boolean;
  40286. SAMPLER3DGREENDEPTH: boolean;
  40287. SAMPLER3DBGRMAP: boolean;
  40288. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40289. MULTIVIEW: boolean;
  40290. /**
  40291. * If the reflection texture on this material is in linear color space
  40292. * @hidden
  40293. */
  40294. IS_REFLECTION_LINEAR: boolean;
  40295. /**
  40296. * If the refraction texture on this material is in linear color space
  40297. * @hidden
  40298. */
  40299. IS_REFRACTION_LINEAR: boolean;
  40300. EXPOSURE: boolean;
  40301. constructor();
  40302. setReflectionMode(modeToEnable: string): void;
  40303. }
  40304. /**
  40305. * This is the default material used in Babylon. It is the best trade off between quality
  40306. * and performances.
  40307. * @see http://doc.babylonjs.com/babylon101/materials
  40308. */
  40309. export class StandardMaterial extends PushMaterial {
  40310. private _diffuseTexture;
  40311. /**
  40312. * The basic texture of the material as viewed under a light.
  40313. */
  40314. diffuseTexture: Nullable<BaseTexture>;
  40315. private _ambientTexture;
  40316. /**
  40317. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40318. */
  40319. ambientTexture: Nullable<BaseTexture>;
  40320. private _opacityTexture;
  40321. /**
  40322. * Define the transparency of the material from a texture.
  40323. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40324. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40325. */
  40326. opacityTexture: Nullable<BaseTexture>;
  40327. private _reflectionTexture;
  40328. /**
  40329. * Define the texture used to display the reflection.
  40330. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40331. */
  40332. reflectionTexture: Nullable<BaseTexture>;
  40333. private _emissiveTexture;
  40334. /**
  40335. * Define texture of the material as if self lit.
  40336. * This will be mixed in the final result even in the absence of light.
  40337. */
  40338. emissiveTexture: Nullable<BaseTexture>;
  40339. private _specularTexture;
  40340. /**
  40341. * Define how the color and intensity of the highlight given by the light in the material.
  40342. */
  40343. specularTexture: Nullable<BaseTexture>;
  40344. private _bumpTexture;
  40345. /**
  40346. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40347. * 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.
  40348. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40349. */
  40350. bumpTexture: Nullable<BaseTexture>;
  40351. private _lightmapTexture;
  40352. /**
  40353. * Complex lighting can be computationally expensive to compute at runtime.
  40354. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40355. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40356. */
  40357. lightmapTexture: Nullable<BaseTexture>;
  40358. private _refractionTexture;
  40359. /**
  40360. * Define the texture used to display the refraction.
  40361. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40362. */
  40363. refractionTexture: Nullable<BaseTexture>;
  40364. /**
  40365. * The color of the material lit by the environmental background lighting.
  40366. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40367. */
  40368. ambientColor: Color3;
  40369. /**
  40370. * The basic color of the material as viewed under a light.
  40371. */
  40372. diffuseColor: Color3;
  40373. /**
  40374. * Define how the color and intensity of the highlight given by the light in the material.
  40375. */
  40376. specularColor: Color3;
  40377. /**
  40378. * Define the color of the material as if self lit.
  40379. * This will be mixed in the final result even in the absence of light.
  40380. */
  40381. emissiveColor: Color3;
  40382. /**
  40383. * Defines how sharp are the highlights in the material.
  40384. * The bigger the value the sharper giving a more glossy feeling to the result.
  40385. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40386. */
  40387. specularPower: number;
  40388. private _useAlphaFromDiffuseTexture;
  40389. /**
  40390. * Does the transparency come from the diffuse texture alpha channel.
  40391. */
  40392. useAlphaFromDiffuseTexture: boolean;
  40393. private _useEmissiveAsIllumination;
  40394. /**
  40395. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40396. */
  40397. useEmissiveAsIllumination: boolean;
  40398. private _linkEmissiveWithDiffuse;
  40399. /**
  40400. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40401. * the emissive level when the final color is close to one.
  40402. */
  40403. linkEmissiveWithDiffuse: boolean;
  40404. private _useSpecularOverAlpha;
  40405. /**
  40406. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40407. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40408. */
  40409. useSpecularOverAlpha: boolean;
  40410. private _useReflectionOverAlpha;
  40411. /**
  40412. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40413. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40414. */
  40415. useReflectionOverAlpha: boolean;
  40416. private _disableLighting;
  40417. /**
  40418. * Does lights from the scene impacts this material.
  40419. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40420. */
  40421. disableLighting: boolean;
  40422. private _useObjectSpaceNormalMap;
  40423. /**
  40424. * Allows using an object space normal map (instead of tangent space).
  40425. */
  40426. useObjectSpaceNormalMap: boolean;
  40427. private _useParallax;
  40428. /**
  40429. * Is parallax enabled or not.
  40430. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40431. */
  40432. useParallax: boolean;
  40433. private _useParallaxOcclusion;
  40434. /**
  40435. * Is parallax occlusion enabled or not.
  40436. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40437. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40438. */
  40439. useParallaxOcclusion: boolean;
  40440. /**
  40441. * 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.
  40442. */
  40443. parallaxScaleBias: number;
  40444. private _roughness;
  40445. /**
  40446. * Helps to define how blurry the reflections should appears in the material.
  40447. */
  40448. roughness: number;
  40449. /**
  40450. * In case of refraction, define the value of the indice of refraction.
  40451. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40452. */
  40453. indexOfRefraction: number;
  40454. /**
  40455. * Invert the refraction texture alongside the y axis.
  40456. * It can be useful with procedural textures or probe for instance.
  40457. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40458. */
  40459. invertRefractionY: boolean;
  40460. /**
  40461. * Defines the alpha limits in alpha test mode.
  40462. */
  40463. alphaCutOff: number;
  40464. private _useLightmapAsShadowmap;
  40465. /**
  40466. * In case of light mapping, define whether the map contains light or shadow informations.
  40467. */
  40468. useLightmapAsShadowmap: boolean;
  40469. private _diffuseFresnelParameters;
  40470. /**
  40471. * Define the diffuse fresnel parameters of the material.
  40472. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40473. */
  40474. diffuseFresnelParameters: FresnelParameters;
  40475. private _opacityFresnelParameters;
  40476. /**
  40477. * Define the opacity fresnel parameters of the material.
  40478. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40479. */
  40480. opacityFresnelParameters: FresnelParameters;
  40481. private _reflectionFresnelParameters;
  40482. /**
  40483. * Define the reflection fresnel parameters of the material.
  40484. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40485. */
  40486. reflectionFresnelParameters: FresnelParameters;
  40487. private _refractionFresnelParameters;
  40488. /**
  40489. * Define the refraction fresnel parameters of the material.
  40490. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40491. */
  40492. refractionFresnelParameters: FresnelParameters;
  40493. private _emissiveFresnelParameters;
  40494. /**
  40495. * Define the emissive fresnel parameters of the material.
  40496. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40497. */
  40498. emissiveFresnelParameters: FresnelParameters;
  40499. private _useReflectionFresnelFromSpecular;
  40500. /**
  40501. * If true automatically deducts the fresnels values from the material specularity.
  40502. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40503. */
  40504. useReflectionFresnelFromSpecular: boolean;
  40505. private _useGlossinessFromSpecularMapAlpha;
  40506. /**
  40507. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40508. */
  40509. useGlossinessFromSpecularMapAlpha: boolean;
  40510. private _maxSimultaneousLights;
  40511. /**
  40512. * Defines the maximum number of lights that can be used in the material
  40513. */
  40514. maxSimultaneousLights: number;
  40515. private _invertNormalMapX;
  40516. /**
  40517. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40518. */
  40519. invertNormalMapX: boolean;
  40520. private _invertNormalMapY;
  40521. /**
  40522. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40523. */
  40524. invertNormalMapY: boolean;
  40525. private _twoSidedLighting;
  40526. /**
  40527. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40528. */
  40529. twoSidedLighting: boolean;
  40530. /**
  40531. * Default configuration related to image processing available in the standard Material.
  40532. */
  40533. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40534. /**
  40535. * Gets the image processing configuration used either in this material.
  40536. */
  40537. /**
  40538. * Sets the Default image processing configuration used either in the this material.
  40539. *
  40540. * If sets to null, the scene one is in use.
  40541. */
  40542. imageProcessingConfiguration: ImageProcessingConfiguration;
  40543. /**
  40544. * Keep track of the image processing observer to allow dispose and replace.
  40545. */
  40546. private _imageProcessingObserver;
  40547. /**
  40548. * Attaches a new image processing configuration to the Standard Material.
  40549. * @param configuration
  40550. */
  40551. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40552. /**
  40553. * Gets wether the color curves effect is enabled.
  40554. */
  40555. /**
  40556. * Sets wether the color curves effect is enabled.
  40557. */
  40558. cameraColorCurvesEnabled: boolean;
  40559. /**
  40560. * Gets wether the color grading effect is enabled.
  40561. */
  40562. /**
  40563. * Gets wether the color grading effect is enabled.
  40564. */
  40565. cameraColorGradingEnabled: boolean;
  40566. /**
  40567. * Gets wether tonemapping is enabled or not.
  40568. */
  40569. /**
  40570. * Sets wether tonemapping is enabled or not
  40571. */
  40572. cameraToneMappingEnabled: boolean;
  40573. /**
  40574. * The camera exposure used on this material.
  40575. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40576. * This corresponds to a photographic exposure.
  40577. */
  40578. /**
  40579. * The camera exposure used on this material.
  40580. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40581. * This corresponds to a photographic exposure.
  40582. */
  40583. cameraExposure: number;
  40584. /**
  40585. * Gets The camera contrast used on this material.
  40586. */
  40587. /**
  40588. * Sets The camera contrast used on this material.
  40589. */
  40590. cameraContrast: number;
  40591. /**
  40592. * Gets the Color Grading 2D Lookup Texture.
  40593. */
  40594. /**
  40595. * Sets the Color Grading 2D Lookup Texture.
  40596. */
  40597. cameraColorGradingTexture: Nullable<BaseTexture>;
  40598. /**
  40599. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40600. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40601. * 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;
  40602. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40603. */
  40604. /**
  40605. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40606. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40607. * 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;
  40608. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40609. */
  40610. cameraColorCurves: Nullable<ColorCurves>;
  40611. /**
  40612. * Custom callback helping to override the default shader used in the material.
  40613. */
  40614. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40615. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40616. protected _worldViewProjectionMatrix: Matrix;
  40617. protected _globalAmbientColor: Color3;
  40618. protected _useLogarithmicDepth: boolean;
  40619. /**
  40620. * Instantiates a new standard material.
  40621. * This is the default material used in Babylon. It is the best trade off between quality
  40622. * and performances.
  40623. * @see http://doc.babylonjs.com/babylon101/materials
  40624. * @param name Define the name of the material in the scene
  40625. * @param scene Define the scene the material belong to
  40626. */
  40627. constructor(name: string, scene: Scene);
  40628. /**
  40629. * Gets a boolean indicating that current material needs to register RTT
  40630. */
  40631. readonly hasRenderTargetTextures: boolean;
  40632. /**
  40633. * Gets the current class name of the material e.g. "StandardMaterial"
  40634. * Mainly use in serialization.
  40635. * @returns the class name
  40636. */
  40637. getClassName(): string;
  40638. /**
  40639. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40640. * You can try switching to logarithmic depth.
  40641. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40642. */
  40643. useLogarithmicDepth: boolean;
  40644. /**
  40645. * Specifies if the material will require alpha blending
  40646. * @returns a boolean specifying if alpha blending is needed
  40647. */
  40648. needAlphaBlending(): boolean;
  40649. /**
  40650. * Specifies if this material should be rendered in alpha test mode
  40651. * @returns a boolean specifying if an alpha test is needed.
  40652. */
  40653. needAlphaTesting(): boolean;
  40654. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40655. /**
  40656. * Get the texture used for alpha test purpose.
  40657. * @returns the diffuse texture in case of the standard material.
  40658. */
  40659. getAlphaTestTexture(): Nullable<BaseTexture>;
  40660. /**
  40661. * Get if the submesh is ready to be used and all its information available.
  40662. * Child classes can use it to update shaders
  40663. * @param mesh defines the mesh to check
  40664. * @param subMesh defines which submesh to check
  40665. * @param useInstances specifies that instances should be used
  40666. * @returns a boolean indicating that the submesh is ready or not
  40667. */
  40668. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40669. /**
  40670. * Builds the material UBO layouts.
  40671. * Used internally during the effect preparation.
  40672. */
  40673. buildUniformLayout(): void;
  40674. /**
  40675. * Unbinds the material from the mesh
  40676. */
  40677. unbind(): void;
  40678. /**
  40679. * Binds the submesh to this material by preparing the effect and shader to draw
  40680. * @param world defines the world transformation matrix
  40681. * @param mesh defines the mesh containing the submesh
  40682. * @param subMesh defines the submesh to bind the material to
  40683. */
  40684. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40685. /**
  40686. * Get the list of animatables in the material.
  40687. * @returns the list of animatables object used in the material
  40688. */
  40689. getAnimatables(): IAnimatable[];
  40690. /**
  40691. * Gets the active textures from the material
  40692. * @returns an array of textures
  40693. */
  40694. getActiveTextures(): BaseTexture[];
  40695. /**
  40696. * Specifies if the material uses a texture
  40697. * @param texture defines the texture to check against the material
  40698. * @returns a boolean specifying if the material uses the texture
  40699. */
  40700. hasTexture(texture: BaseTexture): boolean;
  40701. /**
  40702. * Disposes the material
  40703. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40704. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40705. */
  40706. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40707. /**
  40708. * Makes a duplicate of the material, and gives it a new name
  40709. * @param name defines the new name for the duplicated material
  40710. * @returns the cloned material
  40711. */
  40712. clone(name: string): StandardMaterial;
  40713. /**
  40714. * Serializes this material in a JSON representation
  40715. * @returns the serialized material object
  40716. */
  40717. serialize(): any;
  40718. /**
  40719. * Creates a standard material from parsed material data
  40720. * @param source defines the JSON representation of the material
  40721. * @param scene defines the hosting scene
  40722. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40723. * @returns a new standard material
  40724. */
  40725. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40726. /**
  40727. * Are diffuse textures enabled in the application.
  40728. */
  40729. static DiffuseTextureEnabled: boolean;
  40730. /**
  40731. * Are ambient textures enabled in the application.
  40732. */
  40733. static AmbientTextureEnabled: boolean;
  40734. /**
  40735. * Are opacity textures enabled in the application.
  40736. */
  40737. static OpacityTextureEnabled: boolean;
  40738. /**
  40739. * Are reflection textures enabled in the application.
  40740. */
  40741. static ReflectionTextureEnabled: boolean;
  40742. /**
  40743. * Are emissive textures enabled in the application.
  40744. */
  40745. static EmissiveTextureEnabled: boolean;
  40746. /**
  40747. * Are specular textures enabled in the application.
  40748. */
  40749. static SpecularTextureEnabled: boolean;
  40750. /**
  40751. * Are bump textures enabled in the application.
  40752. */
  40753. static BumpTextureEnabled: boolean;
  40754. /**
  40755. * Are lightmap textures enabled in the application.
  40756. */
  40757. static LightmapTextureEnabled: boolean;
  40758. /**
  40759. * Are refraction textures enabled in the application.
  40760. */
  40761. static RefractionTextureEnabled: boolean;
  40762. /**
  40763. * Are color grading textures enabled in the application.
  40764. */
  40765. static ColorGradingTextureEnabled: boolean;
  40766. /**
  40767. * Are fresnels enabled in the application.
  40768. */
  40769. static FresnelEnabled: boolean;
  40770. }
  40771. }
  40772. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40773. import { Scene } from "babylonjs/scene";
  40774. import { Texture } from "babylonjs/Materials/Textures/texture";
  40775. /**
  40776. * A class extending Texture allowing drawing on a texture
  40777. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40778. */
  40779. export class DynamicTexture extends Texture {
  40780. private _generateMipMaps;
  40781. private _canvas;
  40782. private _context;
  40783. private _engine;
  40784. /**
  40785. * Creates a DynamicTexture
  40786. * @param name defines the name of the texture
  40787. * @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
  40788. * @param scene defines the scene where you want the texture
  40789. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40790. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40791. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40792. */
  40793. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40794. /**
  40795. * Get the current class name of the texture useful for serialization or dynamic coding.
  40796. * @returns "DynamicTexture"
  40797. */
  40798. getClassName(): string;
  40799. /**
  40800. * Gets the current state of canRescale
  40801. */
  40802. readonly canRescale: boolean;
  40803. private _recreate;
  40804. /**
  40805. * Scales the texture
  40806. * @param ratio the scale factor to apply to both width and height
  40807. */
  40808. scale(ratio: number): void;
  40809. /**
  40810. * Resizes the texture
  40811. * @param width the new width
  40812. * @param height the new height
  40813. */
  40814. scaleTo(width: number, height: number): void;
  40815. /**
  40816. * Gets the context of the canvas used by the texture
  40817. * @returns the canvas context of the dynamic texture
  40818. */
  40819. getContext(): CanvasRenderingContext2D;
  40820. /**
  40821. * Clears the texture
  40822. */
  40823. clear(): void;
  40824. /**
  40825. * Updates the texture
  40826. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40827. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40828. */
  40829. update(invertY?: boolean, premulAlpha?: boolean): void;
  40830. /**
  40831. * Draws text onto the texture
  40832. * @param text defines the text to be drawn
  40833. * @param x defines the placement of the text from the left
  40834. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40835. * @param font defines the font to be used with font-style, font-size, font-name
  40836. * @param color defines the color used for the text
  40837. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40838. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40839. * @param update defines whether texture is immediately update (default is true)
  40840. */
  40841. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40842. /**
  40843. * Clones the texture
  40844. * @returns the clone of the texture.
  40845. */
  40846. clone(): DynamicTexture;
  40847. /**
  40848. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40849. * @returns a serialized dynamic texture object
  40850. */
  40851. serialize(): any;
  40852. /** @hidden */
  40853. _rebuild(): void;
  40854. }
  40855. }
  40856. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40857. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40858. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40859. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40860. /** @hidden */
  40861. export var imageProcessingPixelShader: {
  40862. name: string;
  40863. shader: string;
  40864. };
  40865. }
  40866. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40867. import { Nullable } from "babylonjs/types";
  40868. import { Color4 } from "babylonjs/Maths/math";
  40869. import { Camera } from "babylonjs/Cameras/camera";
  40870. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40871. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40872. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40873. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40874. import { Engine } from "babylonjs/Engines/engine";
  40875. import "babylonjs/Shaders/imageProcessing.fragment";
  40876. import "babylonjs/Shaders/postprocess.vertex";
  40877. /**
  40878. * ImageProcessingPostProcess
  40879. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40880. */
  40881. export class ImageProcessingPostProcess extends PostProcess {
  40882. /**
  40883. * Default configuration related to image processing available in the PBR Material.
  40884. */
  40885. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40886. /**
  40887. * Gets the image processing configuration used either in this material.
  40888. */
  40889. /**
  40890. * Sets the Default image processing configuration used either in the this material.
  40891. *
  40892. * If sets to null, the scene one is in use.
  40893. */
  40894. imageProcessingConfiguration: ImageProcessingConfiguration;
  40895. /**
  40896. * Keep track of the image processing observer to allow dispose and replace.
  40897. */
  40898. private _imageProcessingObserver;
  40899. /**
  40900. * Attaches a new image processing configuration to the PBR Material.
  40901. * @param configuration
  40902. */
  40903. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40904. /**
  40905. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40906. */
  40907. /**
  40908. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40909. */
  40910. colorCurves: Nullable<ColorCurves>;
  40911. /**
  40912. * Gets wether the color curves effect is enabled.
  40913. */
  40914. /**
  40915. * Sets wether the color curves effect is enabled.
  40916. */
  40917. colorCurvesEnabled: boolean;
  40918. /**
  40919. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40920. */
  40921. /**
  40922. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40923. */
  40924. colorGradingTexture: Nullable<BaseTexture>;
  40925. /**
  40926. * Gets wether the color grading effect is enabled.
  40927. */
  40928. /**
  40929. * Gets wether the color grading effect is enabled.
  40930. */
  40931. colorGradingEnabled: boolean;
  40932. /**
  40933. * Gets exposure used in the effect.
  40934. */
  40935. /**
  40936. * Sets exposure used in the effect.
  40937. */
  40938. exposure: number;
  40939. /**
  40940. * Gets wether tonemapping is enabled or not.
  40941. */
  40942. /**
  40943. * Sets wether tonemapping is enabled or not
  40944. */
  40945. toneMappingEnabled: boolean;
  40946. /**
  40947. * Gets the type of tone mapping effect.
  40948. */
  40949. /**
  40950. * Sets the type of tone mapping effect.
  40951. */
  40952. toneMappingType: number;
  40953. /**
  40954. * Gets contrast used in the effect.
  40955. */
  40956. /**
  40957. * Sets contrast used in the effect.
  40958. */
  40959. contrast: number;
  40960. /**
  40961. * Gets Vignette stretch size.
  40962. */
  40963. /**
  40964. * Sets Vignette stretch size.
  40965. */
  40966. vignetteStretch: number;
  40967. /**
  40968. * Gets Vignette centre X Offset.
  40969. */
  40970. /**
  40971. * Sets Vignette centre X Offset.
  40972. */
  40973. vignetteCentreX: number;
  40974. /**
  40975. * Gets Vignette centre Y Offset.
  40976. */
  40977. /**
  40978. * Sets Vignette centre Y Offset.
  40979. */
  40980. vignetteCentreY: number;
  40981. /**
  40982. * Gets Vignette weight or intensity of the vignette effect.
  40983. */
  40984. /**
  40985. * Sets Vignette weight or intensity of the vignette effect.
  40986. */
  40987. vignetteWeight: number;
  40988. /**
  40989. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40990. * if vignetteEnabled is set to true.
  40991. */
  40992. /**
  40993. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40994. * if vignetteEnabled is set to true.
  40995. */
  40996. vignetteColor: Color4;
  40997. /**
  40998. * Gets Camera field of view used by the Vignette effect.
  40999. */
  41000. /**
  41001. * Sets Camera field of view used by the Vignette effect.
  41002. */
  41003. vignetteCameraFov: number;
  41004. /**
  41005. * Gets the vignette blend mode allowing different kind of effect.
  41006. */
  41007. /**
  41008. * Sets the vignette blend mode allowing different kind of effect.
  41009. */
  41010. vignetteBlendMode: number;
  41011. /**
  41012. * Gets wether the vignette effect is enabled.
  41013. */
  41014. /**
  41015. * Sets wether the vignette effect is enabled.
  41016. */
  41017. vignetteEnabled: boolean;
  41018. private _fromLinearSpace;
  41019. /**
  41020. * Gets wether the input of the processing is in Gamma or Linear Space.
  41021. */
  41022. /**
  41023. * Sets wether the input of the processing is in Gamma or Linear Space.
  41024. */
  41025. fromLinearSpace: boolean;
  41026. /**
  41027. * Defines cache preventing GC.
  41028. */
  41029. private _defines;
  41030. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41031. /**
  41032. * "ImageProcessingPostProcess"
  41033. * @returns "ImageProcessingPostProcess"
  41034. */
  41035. getClassName(): string;
  41036. protected _updateParameters(): void;
  41037. dispose(camera?: Camera): void;
  41038. }
  41039. }
  41040. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41041. import { Scene } from "babylonjs/scene";
  41042. import { Color3 } from "babylonjs/Maths/math";
  41043. import { Mesh } from "babylonjs/Meshes/mesh";
  41044. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41045. import { Nullable } from "babylonjs/types";
  41046. /**
  41047. * Class containing static functions to help procedurally build meshes
  41048. */
  41049. export class GroundBuilder {
  41050. /**
  41051. * Creates a ground mesh
  41052. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41053. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41055. * @param name defines the name of the mesh
  41056. * @param options defines the options used to create the mesh
  41057. * @param scene defines the hosting scene
  41058. * @returns the ground mesh
  41059. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41060. */
  41061. static CreateGround(name: string, options: {
  41062. width?: number;
  41063. height?: number;
  41064. subdivisions?: number;
  41065. subdivisionsX?: number;
  41066. subdivisionsY?: number;
  41067. updatable?: boolean;
  41068. }, scene: any): Mesh;
  41069. /**
  41070. * Creates a tiled ground mesh
  41071. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41072. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41073. * * 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
  41074. * * 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
  41075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41076. * @param name defines the name of the mesh
  41077. * @param options defines the options used to create the mesh
  41078. * @param scene defines the hosting scene
  41079. * @returns the tiled ground mesh
  41080. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41081. */
  41082. static CreateTiledGround(name: string, options: {
  41083. xmin: number;
  41084. zmin: number;
  41085. xmax: number;
  41086. zmax: number;
  41087. subdivisions?: {
  41088. w: number;
  41089. h: number;
  41090. };
  41091. precision?: {
  41092. w: number;
  41093. h: number;
  41094. };
  41095. updatable?: boolean;
  41096. }, scene?: Nullable<Scene>): Mesh;
  41097. /**
  41098. * Creates a ground mesh from a height map
  41099. * * The parameter `url` sets the URL of the height map image resource.
  41100. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41101. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41102. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41103. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41104. * * 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.
  41105. * * 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).
  41106. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41108. * @param name defines the name of the mesh
  41109. * @param url defines the url to the height map
  41110. * @param options defines the options used to create the mesh
  41111. * @param scene defines the hosting scene
  41112. * @returns the ground mesh
  41113. * @see https://doc.babylonjs.com/babylon101/height_map
  41114. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41115. */
  41116. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41117. width?: number;
  41118. height?: number;
  41119. subdivisions?: number;
  41120. minHeight?: number;
  41121. maxHeight?: number;
  41122. colorFilter?: Color3;
  41123. alphaFilter?: number;
  41124. updatable?: boolean;
  41125. onReady?: (mesh: GroundMesh) => void;
  41126. }, scene?: Nullable<Scene>): GroundMesh;
  41127. }
  41128. }
  41129. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41130. import { Vector4 } from "babylonjs/Maths/math";
  41131. import { Mesh } from "babylonjs/Meshes/mesh";
  41132. /**
  41133. * Class containing static functions to help procedurally build meshes
  41134. */
  41135. export class TorusBuilder {
  41136. /**
  41137. * Creates a torus mesh
  41138. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41139. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41140. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41142. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41144. * @param name defines the name of the mesh
  41145. * @param options defines the options used to create the mesh
  41146. * @param scene defines the hosting scene
  41147. * @returns the torus mesh
  41148. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41149. */
  41150. static CreateTorus(name: string, options: {
  41151. diameter?: number;
  41152. thickness?: number;
  41153. tessellation?: number;
  41154. updatable?: boolean;
  41155. sideOrientation?: number;
  41156. frontUVs?: Vector4;
  41157. backUVs?: Vector4;
  41158. }, scene: any): Mesh;
  41159. }
  41160. }
  41161. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41162. import { Color4, Vector4 } from "babylonjs/Maths/math";
  41163. import { Mesh } from "babylonjs/Meshes/mesh";
  41164. /**
  41165. * Class containing static functions to help procedurally build meshes
  41166. */
  41167. export class CylinderBuilder {
  41168. /**
  41169. * Creates a cylinder or a cone mesh
  41170. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41171. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41172. * * 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.
  41173. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41174. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41175. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41176. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41177. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  41178. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41179. * * 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).
  41180. * * 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
  41181. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41182. * * 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
  41183. * * 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.
  41184. * * If `enclose` is false, a ring surface is one element.
  41185. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41186. * * 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
  41187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41190. * @param name defines the name of the mesh
  41191. * @param options defines the options used to create the mesh
  41192. * @param scene defines the hosting scene
  41193. * @returns the cylinder mesh
  41194. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41195. */
  41196. static CreateCylinder(name: string, options: {
  41197. height?: number;
  41198. diameterTop?: number;
  41199. diameterBottom?: number;
  41200. diameter?: number;
  41201. tessellation?: number;
  41202. subdivisions?: number;
  41203. arc?: number;
  41204. faceColors?: Color4[];
  41205. faceUV?: Vector4[];
  41206. updatable?: boolean;
  41207. hasRings?: boolean;
  41208. enclose?: boolean;
  41209. cap?: number;
  41210. sideOrientation?: number;
  41211. frontUVs?: Vector4;
  41212. backUVs?: Vector4;
  41213. }, scene: any): Mesh;
  41214. }
  41215. }
  41216. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41217. import { Observable } from "babylonjs/Misc/observable";
  41218. import { Nullable } from "babylonjs/types";
  41219. import { Camera } from "babylonjs/Cameras/camera";
  41220. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41221. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41222. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41223. import { Scene } from "babylonjs/scene";
  41224. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41225. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41227. import { Mesh } from "babylonjs/Meshes/mesh";
  41228. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41229. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41230. import "babylonjs/Meshes/Builders/groundBuilder";
  41231. import "babylonjs/Meshes/Builders/torusBuilder";
  41232. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41233. import "babylonjs/Gamepads/gamepadSceneComponent";
  41234. import "babylonjs/Animations/animatable";
  41235. /**
  41236. * Options to modify the vr teleportation behavior.
  41237. */
  41238. export interface VRTeleportationOptions {
  41239. /**
  41240. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41241. */
  41242. floorMeshName?: string;
  41243. /**
  41244. * A list of meshes to be used as the teleportation floor. (default: empty)
  41245. */
  41246. floorMeshes?: Mesh[];
  41247. }
  41248. /**
  41249. * Options to modify the vr experience helper's behavior.
  41250. */
  41251. export interface VRExperienceHelperOptions extends WebVROptions {
  41252. /**
  41253. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41254. */
  41255. createDeviceOrientationCamera?: boolean;
  41256. /**
  41257. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41258. */
  41259. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41260. /**
  41261. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41262. */
  41263. laserToggle?: boolean;
  41264. /**
  41265. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41266. */
  41267. floorMeshes?: Mesh[];
  41268. /**
  41269. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41270. */
  41271. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41272. }
  41273. /**
  41274. * Event containing information after VR has been entered
  41275. */
  41276. export class OnAfterEnteringVRObservableEvent {
  41277. /**
  41278. * If entering vr was successful
  41279. */
  41280. success: boolean;
  41281. }
  41282. /**
  41283. * Helps to quickly add VR support to an existing scene.
  41284. * See http://doc.babylonjs.com/how_to/webvr_helper
  41285. */
  41286. export class VRExperienceHelper {
  41287. /** Options to modify the vr experience helper's behavior. */
  41288. webVROptions: VRExperienceHelperOptions;
  41289. private _scene;
  41290. private _position;
  41291. private _btnVR;
  41292. private _btnVRDisplayed;
  41293. private _webVRsupported;
  41294. private _webVRready;
  41295. private _webVRrequesting;
  41296. private _webVRpresenting;
  41297. private _hasEnteredVR;
  41298. private _fullscreenVRpresenting;
  41299. private _canvas;
  41300. private _webVRCamera;
  41301. private _vrDeviceOrientationCamera;
  41302. private _deviceOrientationCamera;
  41303. private _existingCamera;
  41304. private _onKeyDown;
  41305. private _onVrDisplayPresentChange;
  41306. private _onVRDisplayChanged;
  41307. private _onVRRequestPresentStart;
  41308. private _onVRRequestPresentComplete;
  41309. /**
  41310. * Observable raised right before entering VR.
  41311. */
  41312. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41313. /**
  41314. * Observable raised when entering VR has completed.
  41315. */
  41316. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41317. /**
  41318. * Observable raised when exiting VR.
  41319. */
  41320. onExitingVRObservable: Observable<VRExperienceHelper>;
  41321. /**
  41322. * Observable raised when controller mesh is loaded.
  41323. */
  41324. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41325. /** Return this.onEnteringVRObservable
  41326. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41327. */
  41328. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41329. /** Return this.onExitingVRObservable
  41330. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41331. */
  41332. readonly onExitingVR: Observable<VRExperienceHelper>;
  41333. /** Return this.onControllerMeshLoadedObservable
  41334. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41335. */
  41336. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41337. private _rayLength;
  41338. private _useCustomVRButton;
  41339. private _teleportationRequested;
  41340. private _teleportActive;
  41341. private _floorMeshName;
  41342. private _floorMeshesCollection;
  41343. private _rotationAllowed;
  41344. private _teleportBackwardsVector;
  41345. private _teleportationTarget;
  41346. private _isDefaultTeleportationTarget;
  41347. private _postProcessMove;
  41348. private _teleportationFillColor;
  41349. private _teleportationBorderColor;
  41350. private _rotationAngle;
  41351. private _haloCenter;
  41352. private _cameraGazer;
  41353. private _padSensibilityUp;
  41354. private _padSensibilityDown;
  41355. private _leftController;
  41356. private _rightController;
  41357. /**
  41358. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41359. */
  41360. onNewMeshSelected: Observable<AbstractMesh>;
  41361. /**
  41362. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41363. */
  41364. onNewMeshPicked: Observable<PickingInfo>;
  41365. private _circleEase;
  41366. /**
  41367. * Observable raised before camera teleportation
  41368. */
  41369. onBeforeCameraTeleport: Observable<Vector3>;
  41370. /**
  41371. * Observable raised after camera teleportation
  41372. */
  41373. onAfterCameraTeleport: Observable<Vector3>;
  41374. /**
  41375. * Observable raised when current selected mesh gets unselected
  41376. */
  41377. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41378. private _raySelectionPredicate;
  41379. /**
  41380. * To be optionaly changed by user to define custom ray selection
  41381. */
  41382. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41383. /**
  41384. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41385. */
  41386. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41387. /**
  41388. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41389. */
  41390. teleportationEnabled: boolean;
  41391. private _defaultHeight;
  41392. private _teleportationInitialized;
  41393. private _interactionsEnabled;
  41394. private _interactionsRequested;
  41395. private _displayGaze;
  41396. private _displayLaserPointer;
  41397. /**
  41398. * The mesh used to display where the user is going to teleport.
  41399. */
  41400. /**
  41401. * Sets the mesh to be used to display where the user is going to teleport.
  41402. */
  41403. teleportationTarget: Mesh;
  41404. /**
  41405. * 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
  41406. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41407. * See http://doc.babylonjs.com/resources/baking_transformations
  41408. */
  41409. gazeTrackerMesh: Mesh;
  41410. /**
  41411. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41412. */
  41413. updateGazeTrackerScale: boolean;
  41414. /**
  41415. * If the gaze trackers color should be updated when selecting meshes
  41416. */
  41417. updateGazeTrackerColor: boolean;
  41418. /**
  41419. * The gaze tracking mesh corresponding to the left controller
  41420. */
  41421. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41422. /**
  41423. * The gaze tracking mesh corresponding to the right controller
  41424. */
  41425. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41426. /**
  41427. * If the ray of the gaze should be displayed.
  41428. */
  41429. /**
  41430. * Sets if the ray of the gaze should be displayed.
  41431. */
  41432. displayGaze: boolean;
  41433. /**
  41434. * If the ray of the LaserPointer should be displayed.
  41435. */
  41436. /**
  41437. * Sets if the ray of the LaserPointer should be displayed.
  41438. */
  41439. displayLaserPointer: boolean;
  41440. /**
  41441. * The deviceOrientationCamera used as the camera when not in VR.
  41442. */
  41443. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41444. /**
  41445. * Based on the current WebVR support, returns the current VR camera used.
  41446. */
  41447. readonly currentVRCamera: Nullable<Camera>;
  41448. /**
  41449. * The webVRCamera which is used when in VR.
  41450. */
  41451. readonly webVRCamera: WebVRFreeCamera;
  41452. /**
  41453. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41454. */
  41455. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41456. private readonly _teleportationRequestInitiated;
  41457. /**
  41458. * Defines wether or not Pointer lock should be requested when switching to
  41459. * full screen.
  41460. */
  41461. requestPointerLockOnFullScreen: boolean;
  41462. /**
  41463. * Instantiates a VRExperienceHelper.
  41464. * Helps to quickly add VR support to an existing scene.
  41465. * @param scene The scene the VRExperienceHelper belongs to.
  41466. * @param webVROptions Options to modify the vr experience helper's behavior.
  41467. */
  41468. constructor(scene: Scene,
  41469. /** Options to modify the vr experience helper's behavior. */
  41470. webVROptions?: VRExperienceHelperOptions);
  41471. private _onDefaultMeshLoaded;
  41472. private _onResize;
  41473. private _onFullscreenChange;
  41474. /**
  41475. * Gets a value indicating if we are currently in VR mode.
  41476. */
  41477. readonly isInVRMode: boolean;
  41478. private onVrDisplayPresentChange;
  41479. private onVRDisplayChanged;
  41480. private moveButtonToBottomRight;
  41481. private displayVRButton;
  41482. private updateButtonVisibility;
  41483. private _cachedAngularSensibility;
  41484. /**
  41485. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41486. * Otherwise, will use the fullscreen API.
  41487. */
  41488. enterVR(): void;
  41489. /**
  41490. * Attempt to exit VR, or fullscreen.
  41491. */
  41492. exitVR(): void;
  41493. /**
  41494. * The position of the vr experience helper.
  41495. */
  41496. /**
  41497. * Sets the position of the vr experience helper.
  41498. */
  41499. position: Vector3;
  41500. /**
  41501. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41502. */
  41503. enableInteractions(): void;
  41504. private readonly _noControllerIsActive;
  41505. private beforeRender;
  41506. private _isTeleportationFloor;
  41507. /**
  41508. * Adds a floor mesh to be used for teleportation.
  41509. * @param floorMesh the mesh to be used for teleportation.
  41510. */
  41511. addFloorMesh(floorMesh: Mesh): void;
  41512. /**
  41513. * Removes a floor mesh from being used for teleportation.
  41514. * @param floorMesh the mesh to be removed.
  41515. */
  41516. removeFloorMesh(floorMesh: Mesh): void;
  41517. /**
  41518. * Enables interactions and teleportation using the VR controllers and gaze.
  41519. * @param vrTeleportationOptions options to modify teleportation behavior.
  41520. */
  41521. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41522. private _onNewGamepadConnected;
  41523. private _tryEnableInteractionOnController;
  41524. private _onNewGamepadDisconnected;
  41525. private _enableInteractionOnController;
  41526. private _checkTeleportWithRay;
  41527. private _checkRotate;
  41528. private _checkTeleportBackwards;
  41529. private _enableTeleportationOnController;
  41530. private _createTeleportationCircles;
  41531. private _displayTeleportationTarget;
  41532. private _hideTeleportationTarget;
  41533. private _rotateCamera;
  41534. private _moveTeleportationSelectorTo;
  41535. private _workingVector;
  41536. private _workingQuaternion;
  41537. private _workingMatrix;
  41538. /**
  41539. * Teleports the users feet to the desired location
  41540. * @param location The location where the user's feet should be placed
  41541. */
  41542. teleportCamera(location: Vector3): void;
  41543. private _convertNormalToDirectionOfRay;
  41544. private _castRayAndSelectObject;
  41545. private _notifySelectedMeshUnselected;
  41546. /**
  41547. * Sets the color of the laser ray from the vr controllers.
  41548. * @param color new color for the ray.
  41549. */
  41550. changeLaserColor(color: Color3): void;
  41551. /**
  41552. * Sets the color of the ray from the vr headsets gaze.
  41553. * @param color new color for the ray.
  41554. */
  41555. changeGazeColor(color: Color3): void;
  41556. /**
  41557. * Exits VR and disposes of the vr experience helper
  41558. */
  41559. dispose(): void;
  41560. /**
  41561. * Gets the name of the VRExperienceHelper class
  41562. * @returns "VRExperienceHelper"
  41563. */
  41564. getClassName(): string;
  41565. }
  41566. }
  41567. declare module "babylonjs/Cameras/VR/index" {
  41568. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41569. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41570. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41571. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41572. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41573. export * from "babylonjs/Cameras/VR/webVRCamera";
  41574. }
  41575. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41576. import { Observable } from "babylonjs/Misc/observable";
  41577. import { Nullable } from "babylonjs/types";
  41578. import { IDisposable, Scene } from "babylonjs/scene";
  41579. import { Vector3 } from "babylonjs/Maths/math";
  41580. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41581. import { Ray } from "babylonjs/Culling/ray";
  41582. /**
  41583. * Manages an XRSession
  41584. * @see https://doc.babylonjs.com/how_to/webxr
  41585. */
  41586. export class WebXRSessionManager implements IDisposable {
  41587. private scene;
  41588. /**
  41589. * Fires every time a new xrFrame arrives which can be used to update the camera
  41590. */
  41591. onXRFrameObservable: Observable<any>;
  41592. /**
  41593. * Fires when the xr session is ended either by the device or manually done
  41594. */
  41595. onXRSessionEnded: Observable<any>;
  41596. /** @hidden */
  41597. _xrSession: XRSession;
  41598. /** @hidden */
  41599. _frameOfReference: XRFrameOfReference;
  41600. /** @hidden */
  41601. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41602. /** @hidden */
  41603. _currentXRFrame: Nullable<XRFrame>;
  41604. private _xrNavigator;
  41605. private _xrDevice;
  41606. private _tmpMatrix;
  41607. /**
  41608. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41609. * @param scene The scene which the session should be created for
  41610. */
  41611. constructor(scene: Scene);
  41612. /**
  41613. * Initializes the manager
  41614. * After initialization enterXR can be called to start an XR session
  41615. * @returns Promise which resolves after it is initialized
  41616. */
  41617. initializeAsync(): Promise<void>;
  41618. /**
  41619. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41620. * @param sessionCreationOptions xr options to create the session with
  41621. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41622. * @returns Promise which resolves after it enters XR
  41623. */
  41624. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41625. /**
  41626. * Stops the xrSession and restores the renderloop
  41627. * @returns Promise which resolves after it exits XR
  41628. */
  41629. exitXRAsync(): Promise<void>;
  41630. /**
  41631. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41632. * @param ray ray to cast into the environment
  41633. * @returns Promise which resolves with a collision point in the environment if it exists
  41634. */
  41635. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41636. /**
  41637. * Checks if a session would be supported for the creation options specified
  41638. * @param options creation options to check if they are supported
  41639. * @returns true if supported
  41640. */
  41641. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41642. /**
  41643. * @hidden
  41644. * Converts the render layer of xrSession to a render target
  41645. * @param session session to create render target for
  41646. * @param scene scene the new render target should be created for
  41647. */
  41648. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41649. /**
  41650. * Disposes of the session manager
  41651. */
  41652. dispose(): void;
  41653. }
  41654. }
  41655. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41656. import { Scene } from "babylonjs/scene";
  41657. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41658. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41659. /**
  41660. * WebXR Camera which holds the views for the xrSession
  41661. * @see https://doc.babylonjs.com/how_to/webxr
  41662. */
  41663. export class WebXRCamera extends FreeCamera {
  41664. private static _TmpMatrix;
  41665. /**
  41666. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41667. * @param name the name of the camera
  41668. * @param scene the scene to add the camera to
  41669. */
  41670. constructor(name: string, scene: Scene);
  41671. private _updateNumberOfRigCameras;
  41672. /** @hidden */
  41673. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41674. /**
  41675. * Updates the cameras position from the current pose information of the XR session
  41676. * @param xrSessionManager the session containing pose information
  41677. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41678. */
  41679. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41680. }
  41681. }
  41682. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41683. import { Nullable } from "babylonjs/types";
  41684. import { Observable } from "babylonjs/Misc/observable";
  41685. import { IDisposable, Scene } from "babylonjs/scene";
  41686. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41688. import { Ray } from "babylonjs/Culling/ray";
  41689. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41690. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41691. /**
  41692. * States of the webXR experience
  41693. */
  41694. export enum WebXRState {
  41695. /**
  41696. * Transitioning to being in XR mode
  41697. */
  41698. ENTERING_XR = 0,
  41699. /**
  41700. * Transitioning to non XR mode
  41701. */
  41702. EXITING_XR = 1,
  41703. /**
  41704. * In XR mode and presenting
  41705. */
  41706. IN_XR = 2,
  41707. /**
  41708. * Not entered XR mode
  41709. */
  41710. NOT_IN_XR = 3
  41711. }
  41712. /**
  41713. * Helper class used to enable XR
  41714. * @see https://doc.babylonjs.com/how_to/webxr
  41715. */
  41716. export class WebXRExperienceHelper implements IDisposable {
  41717. private scene;
  41718. /**
  41719. * 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
  41720. */
  41721. container: AbstractMesh;
  41722. /**
  41723. * Camera used to render xr content
  41724. */
  41725. camera: WebXRCamera;
  41726. /**
  41727. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41728. */
  41729. state: WebXRState;
  41730. private _setState;
  41731. private static _TmpVector;
  41732. /**
  41733. * Fires when the state of the experience helper has changed
  41734. */
  41735. onStateChangedObservable: Observable<WebXRState>;
  41736. /** @hidden */
  41737. _sessionManager: WebXRSessionManager;
  41738. private _nonVRCamera;
  41739. private _originalSceneAutoClear;
  41740. private _supported;
  41741. /**
  41742. * Creates the experience helper
  41743. * @param scene the scene to attach the experience helper to
  41744. * @returns a promise for the experience helper
  41745. */
  41746. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41747. /**
  41748. * Creates a WebXRExperienceHelper
  41749. * @param scene The scene the helper should be created in
  41750. */
  41751. private constructor();
  41752. /**
  41753. * Exits XR mode and returns the scene to its original state
  41754. * @returns promise that resolves after xr mode has exited
  41755. */
  41756. exitXRAsync(): Promise<void>;
  41757. /**
  41758. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41759. * @param sessionCreationOptions options for the XR session
  41760. * @param frameOfReference frame of reference of the XR session
  41761. * @returns promise that resolves after xr mode has entered
  41762. */
  41763. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41764. /**
  41765. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41766. * @param ray ray to cast into the environment
  41767. * @returns Promise which resolves with a collision point in the environment if it exists
  41768. */
  41769. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41770. /**
  41771. * Updates the global position of the camera by moving the camera's container
  41772. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41773. * @param position The desired global position of the camera
  41774. */
  41775. setPositionOfCameraUsingContainer(position: Vector3): void;
  41776. /**
  41777. * Rotates the xr camera by rotating the camera's container around the camera's position
  41778. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41779. * @param rotation the desired quaternion rotation to apply to the camera
  41780. */
  41781. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41782. /**
  41783. * Checks if the creation options are supported by the xr session
  41784. * @param options creation options
  41785. * @returns true if supported
  41786. */
  41787. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41788. /**
  41789. * Disposes of the experience helper
  41790. */
  41791. dispose(): void;
  41792. }
  41793. }
  41794. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41795. import { Nullable } from "babylonjs/types";
  41796. import { Observable } from "babylonjs/Misc/observable";
  41797. import { IDisposable, Scene } from "babylonjs/scene";
  41798. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41799. /**
  41800. * Button which can be used to enter a different mode of XR
  41801. */
  41802. export class WebXREnterExitUIButton {
  41803. /** button element */
  41804. element: HTMLElement;
  41805. /** XR initialization options for the button */
  41806. initializationOptions: XRSessionCreationOptions;
  41807. /**
  41808. * Creates a WebXREnterExitUIButton
  41809. * @param element button element
  41810. * @param initializationOptions XR initialization options for the button
  41811. */
  41812. constructor(
  41813. /** button element */
  41814. element: HTMLElement,
  41815. /** XR initialization options for the button */
  41816. initializationOptions: XRSessionCreationOptions);
  41817. /**
  41818. * Overwritable function which can be used to update the button's visuals when the state changes
  41819. * @param activeButton the current active button in the UI
  41820. */
  41821. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41822. }
  41823. /**
  41824. * Options to create the webXR UI
  41825. */
  41826. export class WebXREnterExitUIOptions {
  41827. /**
  41828. * Context to enter xr with
  41829. */
  41830. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41831. /**
  41832. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41833. */
  41834. customButtons?: Array<WebXREnterExitUIButton>;
  41835. }
  41836. /**
  41837. * UI to allow the user to enter/exit XR mode
  41838. */
  41839. export class WebXREnterExitUI implements IDisposable {
  41840. private scene;
  41841. private _overlay;
  41842. private _buttons;
  41843. private _activeButton;
  41844. /**
  41845. * Fired every time the active button is changed.
  41846. *
  41847. * When xr is entered via a button that launches xr that button will be the callback parameter
  41848. *
  41849. * When exiting xr the callback parameter will be null)
  41850. */
  41851. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41852. /**
  41853. * Creates UI to allow the user to enter/exit XR mode
  41854. * @param scene the scene to add the ui to
  41855. * @param helper the xr experience helper to enter/exit xr with
  41856. * @param options options to configure the UI
  41857. * @returns the created ui
  41858. */
  41859. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41860. private constructor();
  41861. private _updateButtons;
  41862. /**
  41863. * Disposes of the object
  41864. */
  41865. dispose(): void;
  41866. }
  41867. }
  41868. declare module "babylonjs/Cameras/XR/webXRInput" {
  41869. import { IDisposable, Scene } from "babylonjs/scene";
  41870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41871. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41872. /**
  41873. * Represents an XR input
  41874. */
  41875. export class WebXRController {
  41876. /**
  41877. * 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
  41878. */
  41879. grip?: AbstractMesh;
  41880. /**
  41881. * Pointer which can be used to select objects or attach a visible laser to
  41882. */
  41883. pointer: AbstractMesh;
  41884. /**
  41885. * Creates the controller
  41886. * @see https://doc.babylonjs.com/how_to/webxr
  41887. * @param scene the scene which the controller should be associated to
  41888. */
  41889. constructor(scene: Scene);
  41890. /**
  41891. * Disposes of the object
  41892. */
  41893. dispose(): void;
  41894. }
  41895. /**
  41896. * XR input used to track XR inputs such as controllers/rays
  41897. */
  41898. export class WebXRInput implements IDisposable {
  41899. private helper;
  41900. /**
  41901. * XR controllers being tracked
  41902. */
  41903. controllers: Array<WebXRController>;
  41904. private _tmpMatrix;
  41905. private _frameObserver;
  41906. /**
  41907. * Initializes the WebXRInput
  41908. * @param helper experience helper which the input should be created for
  41909. */
  41910. constructor(helper: WebXRExperienceHelper);
  41911. /**
  41912. * Disposes of the object
  41913. */
  41914. dispose(): void;
  41915. }
  41916. }
  41917. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41918. import { Nullable } from "babylonjs/types";
  41919. import { IDisposable } from "babylonjs/scene";
  41920. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41921. /**
  41922. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41923. */
  41924. export class WebXRManagedOutputCanvas implements IDisposable {
  41925. private _canvas;
  41926. /**
  41927. * xrpresent context of the canvas which can be used to display/mirror xr content
  41928. */
  41929. canvasContext: Nullable<WebGLRenderingContext>;
  41930. /**
  41931. * Initializes the canvas to be added/removed upon entering/exiting xr
  41932. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41933. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41934. */
  41935. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41936. /**
  41937. * Disposes of the object
  41938. */
  41939. dispose(): void;
  41940. private _setManagedOutputCanvas;
  41941. private _addCanvas;
  41942. private _removeCanvas;
  41943. }
  41944. }
  41945. declare module "babylonjs/Cameras/XR/index" {
  41946. export * from "babylonjs/Cameras/XR/webXRCamera";
  41947. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41948. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41949. export * from "babylonjs/Cameras/XR/webXRInput";
  41950. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41951. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41952. }
  41953. declare module "babylonjs/Cameras/RigModes/index" {
  41954. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41955. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41956. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41957. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41958. }
  41959. declare module "babylonjs/Cameras/index" {
  41960. export * from "babylonjs/Cameras/Inputs/index";
  41961. export * from "babylonjs/Cameras/cameraInputsManager";
  41962. export * from "babylonjs/Cameras/camera";
  41963. export * from "babylonjs/Cameras/targetCamera";
  41964. export * from "babylonjs/Cameras/freeCamera";
  41965. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41966. export * from "babylonjs/Cameras/touchCamera";
  41967. export * from "babylonjs/Cameras/arcRotateCamera";
  41968. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41969. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41970. export * from "babylonjs/Cameras/flyCamera";
  41971. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41972. export * from "babylonjs/Cameras/followCamera";
  41973. export * from "babylonjs/Cameras/gamepadCamera";
  41974. export * from "babylonjs/Cameras/Stereoscopic/index";
  41975. export * from "babylonjs/Cameras/universalCamera";
  41976. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41977. export * from "babylonjs/Cameras/VR/index";
  41978. export * from "babylonjs/Cameras/XR/index";
  41979. export * from "babylonjs/Cameras/RigModes/index";
  41980. }
  41981. declare module "babylonjs/Collisions/index" {
  41982. export * from "babylonjs/Collisions/collider";
  41983. export * from "babylonjs/Collisions/collisionCoordinator";
  41984. export * from "babylonjs/Collisions/pickingInfo";
  41985. export * from "babylonjs/Collisions/intersectionInfo";
  41986. export * from "babylonjs/Collisions/meshCollisionData";
  41987. }
  41988. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41989. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41990. import { Vector3, Plane } from "babylonjs/Maths/math";
  41991. import { Ray } from "babylonjs/Culling/ray";
  41992. /**
  41993. * Contains an array of blocks representing the octree
  41994. */
  41995. export interface IOctreeContainer<T> {
  41996. /**
  41997. * Blocks within the octree
  41998. */
  41999. blocks: Array<OctreeBlock<T>>;
  42000. }
  42001. /**
  42002. * Class used to store a cell in an octree
  42003. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42004. */
  42005. export class OctreeBlock<T> {
  42006. /**
  42007. * Gets the content of the current block
  42008. */
  42009. entries: T[];
  42010. /**
  42011. * Gets the list of block children
  42012. */
  42013. blocks: Array<OctreeBlock<T>>;
  42014. private _depth;
  42015. private _maxDepth;
  42016. private _capacity;
  42017. private _minPoint;
  42018. private _maxPoint;
  42019. private _boundingVectors;
  42020. private _creationFunc;
  42021. /**
  42022. * Creates a new block
  42023. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42024. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42025. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42026. * @param depth defines the current depth of this block in the octree
  42027. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42028. * @param creationFunc defines a callback to call when an element is added to the block
  42029. */
  42030. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42031. /**
  42032. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42033. */
  42034. readonly capacity: number;
  42035. /**
  42036. * Gets the minimum vector (in world space) of the block's bounding box
  42037. */
  42038. readonly minPoint: Vector3;
  42039. /**
  42040. * Gets the maximum vector (in world space) of the block's bounding box
  42041. */
  42042. readonly maxPoint: Vector3;
  42043. /**
  42044. * Add a new element to this block
  42045. * @param entry defines the element to add
  42046. */
  42047. addEntry(entry: T): void;
  42048. /**
  42049. * Remove an element from this block
  42050. * @param entry defines the element to remove
  42051. */
  42052. removeEntry(entry: T): void;
  42053. /**
  42054. * Add an array of elements to this block
  42055. * @param entries defines the array of elements to add
  42056. */
  42057. addEntries(entries: T[]): void;
  42058. /**
  42059. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42060. * @param frustumPlanes defines the frustum planes to test
  42061. * @param selection defines the array to store current content if selection is positive
  42062. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42063. */
  42064. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42065. /**
  42066. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42067. * @param sphereCenter defines the bounding sphere center
  42068. * @param sphereRadius defines the bounding sphere radius
  42069. * @param selection defines the array to store current content if selection is positive
  42070. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42071. */
  42072. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42073. /**
  42074. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42075. * @param ray defines the ray to test with
  42076. * @param selection defines the array to store current content if selection is positive
  42077. */
  42078. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42079. /**
  42080. * Subdivide the content into child blocks (this block will then be empty)
  42081. */
  42082. createInnerBlocks(): void;
  42083. /**
  42084. * @hidden
  42085. */
  42086. 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;
  42087. }
  42088. }
  42089. declare module "babylonjs/Culling/Octrees/octree" {
  42090. import { SmartArray } from "babylonjs/Misc/smartArray";
  42091. import { Vector3, Plane } from "babylonjs/Maths/math";
  42092. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42094. import { Ray } from "babylonjs/Culling/ray";
  42095. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  42096. /**
  42097. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42098. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42099. */
  42100. export class Octree<T> {
  42101. /** 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.) */
  42102. maxDepth: number;
  42103. /**
  42104. * Blocks within the octree containing objects
  42105. */
  42106. blocks: Array<OctreeBlock<T>>;
  42107. /**
  42108. * Content stored in the octree
  42109. */
  42110. dynamicContent: T[];
  42111. private _maxBlockCapacity;
  42112. private _selectionContent;
  42113. private _creationFunc;
  42114. /**
  42115. * Creates a octree
  42116. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42117. * @param creationFunc function to be used to instatiate the octree
  42118. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42119. * @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.)
  42120. */
  42121. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42122. /** 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.) */
  42123. maxDepth?: number);
  42124. /**
  42125. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42126. * @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);
  42127. * @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);
  42128. * @param entries meshes to be added to the octree blocks
  42129. */
  42130. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42131. /**
  42132. * Adds a mesh to the octree
  42133. * @param entry Mesh to add to the octree
  42134. */
  42135. addMesh(entry: T): void;
  42136. /**
  42137. * Remove an element from the octree
  42138. * @param entry defines the element to remove
  42139. */
  42140. removeMesh(entry: T): void;
  42141. /**
  42142. * Selects an array of meshes within the frustum
  42143. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42144. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42145. * @returns array of meshes within the frustum
  42146. */
  42147. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42148. /**
  42149. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42150. * @param sphereCenter defines the bounding sphere center
  42151. * @param sphereRadius defines the bounding sphere radius
  42152. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42153. * @returns an array of objects that intersect the sphere
  42154. */
  42155. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42156. /**
  42157. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42158. * @param ray defines the ray to test with
  42159. * @returns array of intersected objects
  42160. */
  42161. intersectsRay(ray: Ray): SmartArray<T>;
  42162. /**
  42163. * Adds a mesh into the octree block if it intersects the block
  42164. */
  42165. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42166. /**
  42167. * Adds a submesh into the octree block if it intersects the block
  42168. */
  42169. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42170. }
  42171. }
  42172. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  42173. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  42174. import { Scene } from "babylonjs/scene";
  42175. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42177. import { Ray } from "babylonjs/Culling/ray";
  42178. import { Octree } from "babylonjs/Culling/Octrees/octree";
  42179. import { Collider } from "babylonjs/Collisions/collider";
  42180. module "babylonjs/scene" {
  42181. interface Scene {
  42182. /**
  42183. * @hidden
  42184. * Backing Filed
  42185. */
  42186. _selectionOctree: Octree<AbstractMesh>;
  42187. /**
  42188. * Gets the octree used to boost mesh selection (picking)
  42189. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42190. */
  42191. selectionOctree: Octree<AbstractMesh>;
  42192. /**
  42193. * Creates or updates the octree used to boost selection (picking)
  42194. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42195. * @param maxCapacity defines the maximum capacity per leaf
  42196. * @param maxDepth defines the maximum depth of the octree
  42197. * @returns an octree of AbstractMesh
  42198. */
  42199. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42200. }
  42201. }
  42202. module "babylonjs/Meshes/abstractMesh" {
  42203. interface AbstractMesh {
  42204. /**
  42205. * @hidden
  42206. * Backing Field
  42207. */
  42208. _submeshesOctree: Octree<SubMesh>;
  42209. /**
  42210. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42211. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42212. * @param maxCapacity defines the maximum size of each block (64 by default)
  42213. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42214. * @returns the new octree
  42215. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42216. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42217. */
  42218. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42219. }
  42220. }
  42221. /**
  42222. * Defines the octree scene component responsible to manage any octrees
  42223. * in a given scene.
  42224. */
  42225. export class OctreeSceneComponent {
  42226. /**
  42227. * The component name help to identify the component in the list of scene components.
  42228. */
  42229. readonly name: string;
  42230. /**
  42231. * The scene the component belongs to.
  42232. */
  42233. scene: Scene;
  42234. /**
  42235. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42236. */
  42237. readonly checksIsEnabled: boolean;
  42238. /**
  42239. * Creates a new instance of the component for the given scene
  42240. * @param scene Defines the scene to register the component in
  42241. */
  42242. constructor(scene: Scene);
  42243. /**
  42244. * Registers the component in a given scene
  42245. */
  42246. register(): void;
  42247. /**
  42248. * Return the list of active meshes
  42249. * @returns the list of active meshes
  42250. */
  42251. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42252. /**
  42253. * Return the list of active sub meshes
  42254. * @param mesh The mesh to get the candidates sub meshes from
  42255. * @returns the list of active sub meshes
  42256. */
  42257. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42258. private _tempRay;
  42259. /**
  42260. * Return the list of sub meshes intersecting with a given local ray
  42261. * @param mesh defines the mesh to find the submesh for
  42262. * @param localRay defines the ray in local space
  42263. * @returns the list of intersecting sub meshes
  42264. */
  42265. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42266. /**
  42267. * Return the list of sub meshes colliding with a collider
  42268. * @param mesh defines the mesh to find the submesh for
  42269. * @param collider defines the collider to evaluate the collision against
  42270. * @returns the list of colliding sub meshes
  42271. */
  42272. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42273. /**
  42274. * Rebuilds the elements related to this component in case of
  42275. * context lost for instance.
  42276. */
  42277. rebuild(): void;
  42278. /**
  42279. * Disposes the component and the associated ressources.
  42280. */
  42281. dispose(): void;
  42282. }
  42283. }
  42284. declare module "babylonjs/Culling/Octrees/index" {
  42285. export * from "babylonjs/Culling/Octrees/octree";
  42286. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42287. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42288. }
  42289. declare module "babylonjs/Culling/index" {
  42290. export * from "babylonjs/Culling/boundingBox";
  42291. export * from "babylonjs/Culling/boundingInfo";
  42292. export * from "babylonjs/Culling/boundingSphere";
  42293. export * from "babylonjs/Culling/Octrees/index";
  42294. export * from "babylonjs/Culling/ray";
  42295. }
  42296. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42297. import { IDisposable, Scene } from "babylonjs/scene";
  42298. import { Nullable } from "babylonjs/types";
  42299. import { Observable } from "babylonjs/Misc/observable";
  42300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42301. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42302. /**
  42303. * Renders a layer on top of an existing scene
  42304. */
  42305. export class UtilityLayerRenderer implements IDisposable {
  42306. /** the original scene that will be rendered on top of */
  42307. originalScene: Scene;
  42308. private _pointerCaptures;
  42309. private _lastPointerEvents;
  42310. private static _DefaultUtilityLayer;
  42311. private static _DefaultKeepDepthUtilityLayer;
  42312. private _sharedGizmoLight;
  42313. /**
  42314. * @hidden
  42315. * Light which used by gizmos to get light shading
  42316. */
  42317. _getSharedGizmoLight(): HemisphericLight;
  42318. /**
  42319. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42320. */
  42321. pickUtilitySceneFirst: boolean;
  42322. /**
  42323. * 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)
  42324. */
  42325. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42326. /**
  42327. * 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)
  42328. */
  42329. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42330. /**
  42331. * The scene that is rendered on top of the original scene
  42332. */
  42333. utilityLayerScene: Scene;
  42334. /**
  42335. * If the utility layer should automatically be rendered on top of existing scene
  42336. */
  42337. shouldRender: boolean;
  42338. /**
  42339. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42340. */
  42341. onlyCheckPointerDownEvents: boolean;
  42342. /**
  42343. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42344. */
  42345. processAllEvents: boolean;
  42346. /**
  42347. * Observable raised when the pointer move from the utility layer scene to the main scene
  42348. */
  42349. onPointerOutObservable: Observable<number>;
  42350. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42351. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42352. private _afterRenderObserver;
  42353. private _sceneDisposeObserver;
  42354. private _originalPointerObserver;
  42355. /**
  42356. * Instantiates a UtilityLayerRenderer
  42357. * @param originalScene the original scene that will be rendered on top of
  42358. * @param handleEvents boolean indicating if the utility layer should handle events
  42359. */
  42360. constructor(
  42361. /** the original scene that will be rendered on top of */
  42362. originalScene: Scene, handleEvents?: boolean);
  42363. private _notifyObservers;
  42364. /**
  42365. * Renders the utility layers scene on top of the original scene
  42366. */
  42367. render(): void;
  42368. /**
  42369. * Disposes of the renderer
  42370. */
  42371. dispose(): void;
  42372. private _updateCamera;
  42373. }
  42374. }
  42375. declare module "babylonjs/Gizmos/gizmo" {
  42376. import { Nullable } from "babylonjs/types";
  42377. import { IDisposable } from "babylonjs/scene";
  42378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42379. import { Mesh } from "babylonjs/Meshes/mesh";
  42380. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42381. /**
  42382. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42383. */
  42384. export class Gizmo implements IDisposable {
  42385. /** The utility layer the gizmo will be added to */
  42386. gizmoLayer: UtilityLayerRenderer;
  42387. /**
  42388. * The root mesh of the gizmo
  42389. */
  42390. _rootMesh: Mesh;
  42391. private _attachedMesh;
  42392. /**
  42393. * Ratio for the scale of the gizmo (Default: 1)
  42394. */
  42395. scaleRatio: number;
  42396. /**
  42397. * If a custom mesh has been set (Default: false)
  42398. */
  42399. protected _customMeshSet: boolean;
  42400. /**
  42401. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42402. * * When set, interactions will be enabled
  42403. */
  42404. attachedMesh: Nullable<AbstractMesh>;
  42405. /**
  42406. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42407. * @param mesh The mesh to replace the default mesh of the gizmo
  42408. */
  42409. setCustomMesh(mesh: Mesh): void;
  42410. /**
  42411. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42412. */
  42413. updateGizmoRotationToMatchAttachedMesh: boolean;
  42414. /**
  42415. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42416. */
  42417. updateGizmoPositionToMatchAttachedMesh: boolean;
  42418. /**
  42419. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42420. */
  42421. protected _updateScale: boolean;
  42422. protected _interactionsEnabled: boolean;
  42423. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42424. private _beforeRenderObserver;
  42425. private _tempVector;
  42426. /**
  42427. * Creates a gizmo
  42428. * @param gizmoLayer The utility layer the gizmo will be added to
  42429. */
  42430. constructor(
  42431. /** The utility layer the gizmo will be added to */
  42432. gizmoLayer?: UtilityLayerRenderer);
  42433. /**
  42434. * Updates the gizmo to match the attached mesh's position/rotation
  42435. */
  42436. protected _update(): void;
  42437. /**
  42438. * Disposes of the gizmo
  42439. */
  42440. dispose(): void;
  42441. }
  42442. }
  42443. declare module "babylonjs/Gizmos/planeDragGizmo" {
  42444. import { Observable } from "babylonjs/Misc/observable";
  42445. import { Nullable } from "babylonjs/types";
  42446. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42447. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42449. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42450. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42451. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42452. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42453. import { Scene } from "babylonjs/scene";
  42454. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42455. /**
  42456. * Single plane drag gizmo
  42457. */
  42458. export class PlaneDragGizmo extends Gizmo {
  42459. /**
  42460. * Drag behavior responsible for the gizmos dragging interactions
  42461. */
  42462. dragBehavior: PointerDragBehavior;
  42463. private _pointerObserver;
  42464. /**
  42465. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42466. */
  42467. snapDistance: number;
  42468. /**
  42469. * Event that fires each time the gizmo snaps to a new location.
  42470. * * snapDistance is the the change in distance
  42471. */
  42472. onSnapObservable: Observable<{
  42473. snapDistance: number;
  42474. }>;
  42475. private _plane;
  42476. private _coloredMaterial;
  42477. private _hoverMaterial;
  42478. private _isEnabled;
  42479. private _parent;
  42480. /** @hidden */
  42481. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42482. /** @hidden */
  42483. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42484. /**
  42485. * Creates a PlaneDragGizmo
  42486. * @param gizmoLayer The utility layer the gizmo will be added to
  42487. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42488. * @param color The color of the gizmo
  42489. */
  42490. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42491. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42492. /**
  42493. * If the gizmo is enabled
  42494. */
  42495. isEnabled: boolean;
  42496. /**
  42497. * Disposes of the gizmo
  42498. */
  42499. dispose(): void;
  42500. }
  42501. }
  42502. declare module "babylonjs/Gizmos/positionGizmo" {
  42503. import { Observable } from "babylonjs/Misc/observable";
  42504. import { Nullable } from "babylonjs/types";
  42505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42506. import { Mesh } from "babylonjs/Meshes/mesh";
  42507. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42508. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42509. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  42510. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42511. /**
  42512. * Gizmo that enables dragging a mesh along 3 axis
  42513. */
  42514. export class PositionGizmo extends Gizmo {
  42515. /**
  42516. * Internal gizmo used for interactions on the x axis
  42517. */
  42518. xGizmo: AxisDragGizmo;
  42519. /**
  42520. * Internal gizmo used for interactions on the y axis
  42521. */
  42522. yGizmo: AxisDragGizmo;
  42523. /**
  42524. * Internal gizmo used for interactions on the z axis
  42525. */
  42526. zGizmo: AxisDragGizmo;
  42527. /**
  42528. * Internal gizmo used for interactions on the yz plane
  42529. */
  42530. xPlaneGizmo: PlaneDragGizmo;
  42531. /**
  42532. * Internal gizmo used for interactions on the xz plane
  42533. */
  42534. yPlaneGizmo: PlaneDragGizmo;
  42535. /**
  42536. * Internal gizmo used for interactions on the xy plane
  42537. */
  42538. zPlaneGizmo: PlaneDragGizmo;
  42539. /**
  42540. * private variables
  42541. */
  42542. private _meshAttached;
  42543. private _updateGizmoRotationToMatchAttachedMesh;
  42544. private _snapDistance;
  42545. private _scaleRatio;
  42546. /** Fires an event when any of it's sub gizmos are dragged */
  42547. onDragStartObservable: Observable<{}>;
  42548. /** Fires an event when any of it's sub gizmos are released from dragging */
  42549. onDragEndObservable: Observable<{}>;
  42550. /**
  42551. * If set to true, planar drag is enabled
  42552. */
  42553. private _planarGizmoEnabled;
  42554. attachedMesh: Nullable<AbstractMesh>;
  42555. /**
  42556. * Creates a PositionGizmo
  42557. * @param gizmoLayer The utility layer the gizmo will be added to
  42558. */
  42559. constructor(gizmoLayer?: UtilityLayerRenderer);
  42560. /**
  42561. * If the planar drag gizmo is enabled
  42562. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42563. */
  42564. planarGizmoEnabled: boolean;
  42565. updateGizmoRotationToMatchAttachedMesh: boolean;
  42566. /**
  42567. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42568. */
  42569. snapDistance: number;
  42570. /**
  42571. * Ratio for the scale of the gizmo (Default: 1)
  42572. */
  42573. scaleRatio: number;
  42574. /**
  42575. * Disposes of the gizmo
  42576. */
  42577. dispose(): void;
  42578. /**
  42579. * CustomMeshes are not supported by this gizmo
  42580. * @param mesh The mesh to replace the default mesh of the gizmo
  42581. */
  42582. setCustomMesh(mesh: Mesh): void;
  42583. }
  42584. }
  42585. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42586. import { Observable } from "babylonjs/Misc/observable";
  42587. import { Nullable } from "babylonjs/types";
  42588. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42589. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42591. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42592. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42593. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42594. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42595. import { Scene } from "babylonjs/scene";
  42596. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42597. /**
  42598. * Single axis drag gizmo
  42599. */
  42600. export class AxisDragGizmo extends Gizmo {
  42601. /**
  42602. * Drag behavior responsible for the gizmos dragging interactions
  42603. */
  42604. dragBehavior: PointerDragBehavior;
  42605. private _pointerObserver;
  42606. /**
  42607. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42608. */
  42609. snapDistance: number;
  42610. /**
  42611. * Event that fires each time the gizmo snaps to a new location.
  42612. * * snapDistance is the the change in distance
  42613. */
  42614. onSnapObservable: Observable<{
  42615. snapDistance: number;
  42616. }>;
  42617. private _isEnabled;
  42618. private _parent;
  42619. private _arrow;
  42620. private _coloredMaterial;
  42621. private _hoverMaterial;
  42622. /** @hidden */
  42623. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42624. /** @hidden */
  42625. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42626. /**
  42627. * Creates an AxisDragGizmo
  42628. * @param gizmoLayer The utility layer the gizmo will be added to
  42629. * @param dragAxis The axis which the gizmo will be able to drag on
  42630. * @param color The color of the gizmo
  42631. */
  42632. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42633. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42634. /**
  42635. * If the gizmo is enabled
  42636. */
  42637. isEnabled: boolean;
  42638. /**
  42639. * Disposes of the gizmo
  42640. */
  42641. dispose(): void;
  42642. }
  42643. }
  42644. declare module "babylonjs/Debug/axesViewer" {
  42645. import { Vector3 } from "babylonjs/Maths/math";
  42646. import { Nullable } from "babylonjs/types";
  42647. import { Scene } from "babylonjs/scene";
  42648. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42649. /**
  42650. * The Axes viewer will show 3 axes in a specific point in space
  42651. */
  42652. export class AxesViewer {
  42653. private _xAxis;
  42654. private _yAxis;
  42655. private _zAxis;
  42656. private _scaleLinesFactor;
  42657. private _instanced;
  42658. /**
  42659. * Gets the hosting scene
  42660. */
  42661. scene: Scene;
  42662. /**
  42663. * Gets or sets a number used to scale line length
  42664. */
  42665. scaleLines: number;
  42666. /** Gets the node hierarchy used to render x-axis */
  42667. readonly xAxis: TransformNode;
  42668. /** Gets the node hierarchy used to render y-axis */
  42669. readonly yAxis: TransformNode;
  42670. /** Gets the node hierarchy used to render z-axis */
  42671. readonly zAxis: TransformNode;
  42672. /**
  42673. * Creates a new AxesViewer
  42674. * @param scene defines the hosting scene
  42675. * @param scaleLines defines a number used to scale line length (1 by default)
  42676. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42677. * @param xAxis defines the node hierarchy used to render the x-axis
  42678. * @param yAxis defines the node hierarchy used to render the y-axis
  42679. * @param zAxis defines the node hierarchy used to render the z-axis
  42680. */
  42681. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42682. /**
  42683. * Force the viewer to update
  42684. * @param position defines the position of the viewer
  42685. * @param xaxis defines the x axis of the viewer
  42686. * @param yaxis defines the y axis of the viewer
  42687. * @param zaxis defines the z axis of the viewer
  42688. */
  42689. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42690. /**
  42691. * Creates an instance of this axes viewer.
  42692. * @returns a new axes viewer with instanced meshes
  42693. */
  42694. createInstance(): AxesViewer;
  42695. /** Releases resources */
  42696. dispose(): void;
  42697. private static _SetRenderingGroupId;
  42698. }
  42699. }
  42700. declare module "babylonjs/Debug/boneAxesViewer" {
  42701. import { Nullable } from "babylonjs/types";
  42702. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42703. import { Vector3 } from "babylonjs/Maths/math";
  42704. import { Mesh } from "babylonjs/Meshes/mesh";
  42705. import { Bone } from "babylonjs/Bones/bone";
  42706. import { Scene } from "babylonjs/scene";
  42707. /**
  42708. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42709. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42710. */
  42711. export class BoneAxesViewer extends AxesViewer {
  42712. /**
  42713. * Gets or sets the target mesh where to display the axes viewer
  42714. */
  42715. mesh: Nullable<Mesh>;
  42716. /**
  42717. * Gets or sets the target bone where to display the axes viewer
  42718. */
  42719. bone: Nullable<Bone>;
  42720. /** Gets current position */
  42721. pos: Vector3;
  42722. /** Gets direction of X axis */
  42723. xaxis: Vector3;
  42724. /** Gets direction of Y axis */
  42725. yaxis: Vector3;
  42726. /** Gets direction of Z axis */
  42727. zaxis: Vector3;
  42728. /**
  42729. * Creates a new BoneAxesViewer
  42730. * @param scene defines the hosting scene
  42731. * @param bone defines the target bone
  42732. * @param mesh defines the target mesh
  42733. * @param scaleLines defines a scaling factor for line length (1 by default)
  42734. */
  42735. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42736. /**
  42737. * Force the viewer to update
  42738. */
  42739. update(): void;
  42740. /** Releases resources */
  42741. dispose(): void;
  42742. }
  42743. }
  42744. declare module "babylonjs/Debug/debugLayer" {
  42745. import { Observable } from "babylonjs/Misc/observable";
  42746. import { Scene } from "babylonjs/scene";
  42747. /**
  42748. * Interface used to define scene explorer extensibility option
  42749. */
  42750. export interface IExplorerExtensibilityOption {
  42751. /**
  42752. * Define the option label
  42753. */
  42754. label: string;
  42755. /**
  42756. * Defines the action to execute on click
  42757. */
  42758. action: (entity: any) => void;
  42759. }
  42760. /**
  42761. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42762. */
  42763. export interface IExplorerExtensibilityGroup {
  42764. /**
  42765. * Defines a predicate to test if a given type mut be extended
  42766. */
  42767. predicate: (entity: any) => boolean;
  42768. /**
  42769. * Gets the list of options added to a type
  42770. */
  42771. entries: IExplorerExtensibilityOption[];
  42772. }
  42773. /**
  42774. * Interface used to define the options to use to create the Inspector
  42775. */
  42776. export interface IInspectorOptions {
  42777. /**
  42778. * Display in overlay mode (default: false)
  42779. */
  42780. overlay?: boolean;
  42781. /**
  42782. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42783. */
  42784. globalRoot?: HTMLElement;
  42785. /**
  42786. * Display the Scene explorer
  42787. */
  42788. showExplorer?: boolean;
  42789. /**
  42790. * Display the property inspector
  42791. */
  42792. showInspector?: boolean;
  42793. /**
  42794. * Display in embed mode (both panes on the right)
  42795. */
  42796. embedMode?: boolean;
  42797. /**
  42798. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42799. */
  42800. handleResize?: boolean;
  42801. /**
  42802. * Allow the panes to popup (default: true)
  42803. */
  42804. enablePopup?: boolean;
  42805. /**
  42806. * Allow the panes to be closed by users (default: true)
  42807. */
  42808. enableClose?: boolean;
  42809. /**
  42810. * Optional list of extensibility entries
  42811. */
  42812. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42813. /**
  42814. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42815. */
  42816. inspectorURL?: string;
  42817. }
  42818. module "babylonjs/scene" {
  42819. interface Scene {
  42820. /**
  42821. * @hidden
  42822. * Backing field
  42823. */
  42824. _debugLayer: DebugLayer;
  42825. /**
  42826. * Gets the debug layer (aka Inspector) associated with the scene
  42827. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42828. */
  42829. debugLayer: DebugLayer;
  42830. }
  42831. }
  42832. /**
  42833. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42834. * what is happening in your scene
  42835. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42836. */
  42837. export class DebugLayer {
  42838. /**
  42839. * Define the url to get the inspector script from.
  42840. * By default it uses the babylonjs CDN.
  42841. * @ignoreNaming
  42842. */
  42843. static InspectorURL: string;
  42844. private _scene;
  42845. private BJSINSPECTOR;
  42846. /**
  42847. * Observable triggered when a property is changed through the inspector.
  42848. */
  42849. onPropertyChangedObservable: Observable<{
  42850. object: any;
  42851. property: string;
  42852. value: any;
  42853. initialValue: any;
  42854. }>;
  42855. /**
  42856. * Instantiates a new debug layer.
  42857. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42858. * what is happening in your scene
  42859. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42860. * @param scene Defines the scene to inspect
  42861. */
  42862. constructor(scene: Scene);
  42863. /** Creates the inspector window. */
  42864. private _createInspector;
  42865. /**
  42866. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42867. * @param entity defines the entity to select
  42868. * @param lineContainerTitle defines the specific block to highlight
  42869. */
  42870. select(entity: any, lineContainerTitle?: string): void;
  42871. /** Get the inspector from bundle or global */
  42872. private _getGlobalInspector;
  42873. /**
  42874. * Get if the inspector is visible or not.
  42875. * @returns true if visible otherwise, false
  42876. */
  42877. isVisible(): boolean;
  42878. /**
  42879. * Hide the inspector and close its window.
  42880. */
  42881. hide(): void;
  42882. /**
  42883. * Launch the debugLayer.
  42884. * @param config Define the configuration of the inspector
  42885. * @return a promise fulfilled when the debug layer is visible
  42886. */
  42887. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42888. }
  42889. }
  42890. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42891. import { Nullable } from "babylonjs/types";
  42892. import { Scene } from "babylonjs/scene";
  42893. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42894. import { Mesh } from "babylonjs/Meshes/mesh";
  42895. /**
  42896. * Class containing static functions to help procedurally build meshes
  42897. */
  42898. export class BoxBuilder {
  42899. /**
  42900. * Creates a box mesh
  42901. * * The parameter `size` sets the size (float) of each box side (default 1)
  42902. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42903. * * 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)
  42904. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42906. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42908. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42909. * @param name defines the name of the mesh
  42910. * @param options defines the options used to create the mesh
  42911. * @param scene defines the hosting scene
  42912. * @returns the box mesh
  42913. */
  42914. static CreateBox(name: string, options: {
  42915. size?: number;
  42916. width?: number;
  42917. height?: number;
  42918. depth?: number;
  42919. faceUV?: Vector4[];
  42920. faceColors?: Color4[];
  42921. sideOrientation?: number;
  42922. frontUVs?: Vector4;
  42923. backUVs?: Vector4;
  42924. wrap?: boolean;
  42925. topBaseAt?: number;
  42926. bottomBaseAt?: number;
  42927. updatable?: boolean;
  42928. }, scene?: Nullable<Scene>): Mesh;
  42929. }
  42930. }
  42931. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42932. import { Vector4 } from "babylonjs/Maths/math";
  42933. import { Mesh } from "babylonjs/Meshes/mesh";
  42934. /**
  42935. * Class containing static functions to help procedurally build meshes
  42936. */
  42937. export class SphereBuilder {
  42938. /**
  42939. * Creates a sphere mesh
  42940. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42941. * * 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`)
  42942. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42943. * * 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
  42944. * * 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)
  42945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42948. * @param name defines the name of the mesh
  42949. * @param options defines the options used to create the mesh
  42950. * @param scene defines the hosting scene
  42951. * @returns the sphere mesh
  42952. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42953. */
  42954. static CreateSphere(name: string, options: {
  42955. segments?: number;
  42956. diameter?: number;
  42957. diameterX?: number;
  42958. diameterY?: number;
  42959. diameterZ?: number;
  42960. arc?: number;
  42961. slice?: number;
  42962. sideOrientation?: number;
  42963. frontUVs?: Vector4;
  42964. backUVs?: Vector4;
  42965. updatable?: boolean;
  42966. }, scene: any): Mesh;
  42967. }
  42968. }
  42969. declare module "babylonjs/Debug/physicsViewer" {
  42970. import { Nullable } from "babylonjs/types";
  42971. import { Scene } from "babylonjs/scene";
  42972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42973. import { Mesh } from "babylonjs/Meshes/mesh";
  42974. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42975. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42976. /**
  42977. * Used to show the physics impostor around the specific mesh
  42978. */
  42979. export class PhysicsViewer {
  42980. /** @hidden */
  42981. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42982. /** @hidden */
  42983. protected _meshes: Array<Nullable<AbstractMesh>>;
  42984. /** @hidden */
  42985. protected _scene: Nullable<Scene>;
  42986. /** @hidden */
  42987. protected _numMeshes: number;
  42988. /** @hidden */
  42989. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42990. private _renderFunction;
  42991. private _utilityLayer;
  42992. private _debugBoxMesh;
  42993. private _debugSphereMesh;
  42994. private _debugCylinderMesh;
  42995. private _debugMaterial;
  42996. private _debugMeshMeshes;
  42997. /**
  42998. * Creates a new PhysicsViewer
  42999. * @param scene defines the hosting scene
  43000. */
  43001. constructor(scene: Scene);
  43002. /** @hidden */
  43003. protected _updateDebugMeshes(): void;
  43004. /**
  43005. * Renders a specified physic impostor
  43006. * @param impostor defines the impostor to render
  43007. * @param targetMesh defines the mesh represented by the impostor
  43008. * @returns the new debug mesh used to render the impostor
  43009. */
  43010. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43011. /**
  43012. * Hides a specified physic impostor
  43013. * @param impostor defines the impostor to hide
  43014. */
  43015. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43016. private _getDebugMaterial;
  43017. private _getDebugBoxMesh;
  43018. private _getDebugSphereMesh;
  43019. private _getDebugCylinderMesh;
  43020. private _getDebugMeshMesh;
  43021. private _getDebugMesh;
  43022. /** Releases all resources */
  43023. dispose(): void;
  43024. }
  43025. }
  43026. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  43027. import { Vector3, Color4 } from "babylonjs/Maths/math";
  43028. import { Nullable } from "babylonjs/types";
  43029. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43030. import { Scene } from "babylonjs/scene";
  43031. /**
  43032. * Class containing static functions to help procedurally build meshes
  43033. */
  43034. export class LinesBuilder {
  43035. /**
  43036. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43037. * * 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
  43038. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43039. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43040. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43041. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43042. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43043. * * 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
  43044. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43046. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43047. * @param name defines the name of the new line system
  43048. * @param options defines the options used to create the line system
  43049. * @param scene defines the hosting scene
  43050. * @returns a new line system mesh
  43051. */
  43052. static CreateLineSystem(name: string, options: {
  43053. lines: Vector3[][];
  43054. updatable?: boolean;
  43055. instance?: Nullable<LinesMesh>;
  43056. colors?: Nullable<Color4[][]>;
  43057. useVertexAlpha?: boolean;
  43058. }, scene: Nullable<Scene>): LinesMesh;
  43059. /**
  43060. * Creates a line mesh
  43061. * 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
  43062. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43063. * * The parameter `points` is an array successive Vector3
  43064. * * 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
  43065. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43066. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43067. * * When updating an instance, remember that only point positions can change, not the number of points
  43068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43070. * @param name defines the name of the new line system
  43071. * @param options defines the options used to create the line system
  43072. * @param scene defines the hosting scene
  43073. * @returns a new line mesh
  43074. */
  43075. static CreateLines(name: string, options: {
  43076. points: Vector3[];
  43077. updatable?: boolean;
  43078. instance?: Nullable<LinesMesh>;
  43079. colors?: Color4[];
  43080. useVertexAlpha?: boolean;
  43081. }, scene?: Nullable<Scene>): LinesMesh;
  43082. /**
  43083. * Creates a dashed line mesh
  43084. * * 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
  43085. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43086. * * The parameter `points` is an array successive Vector3
  43087. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43088. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43089. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43090. * * 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
  43091. * * When updating an instance, remember that only point positions can change, not the number of points
  43092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43093. * @param name defines the name of the mesh
  43094. * @param options defines the options used to create the mesh
  43095. * @param scene defines the hosting scene
  43096. * @returns the dashed line mesh
  43097. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43098. */
  43099. static CreateDashedLines(name: string, options: {
  43100. points: Vector3[];
  43101. dashSize?: number;
  43102. gapSize?: number;
  43103. dashNb?: number;
  43104. updatable?: boolean;
  43105. instance?: LinesMesh;
  43106. }, scene?: Nullable<Scene>): LinesMesh;
  43107. }
  43108. }
  43109. declare module "babylonjs/Debug/rayHelper" {
  43110. import { Nullable } from "babylonjs/types";
  43111. import { Ray } from "babylonjs/Culling/ray";
  43112. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43113. import { Scene } from "babylonjs/scene";
  43114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43115. import "babylonjs/Meshes/Builders/linesBuilder";
  43116. /**
  43117. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43118. * in order to better appreciate the issue one might have.
  43119. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43120. */
  43121. export class RayHelper {
  43122. /**
  43123. * Defines the ray we are currently tryin to visualize.
  43124. */
  43125. ray: Nullable<Ray>;
  43126. private _renderPoints;
  43127. private _renderLine;
  43128. private _renderFunction;
  43129. private _scene;
  43130. private _updateToMeshFunction;
  43131. private _attachedToMesh;
  43132. private _meshSpaceDirection;
  43133. private _meshSpaceOrigin;
  43134. /**
  43135. * Helper function to create a colored helper in a scene in one line.
  43136. * @param ray Defines the ray we are currently tryin to visualize
  43137. * @param scene Defines the scene the ray is used in
  43138. * @param color Defines the color we want to see the ray in
  43139. * @returns The newly created ray helper.
  43140. */
  43141. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43142. /**
  43143. * Instantiate a new ray helper.
  43144. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43145. * in order to better appreciate the issue one might have.
  43146. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43147. * @param ray Defines the ray we are currently tryin to visualize
  43148. */
  43149. constructor(ray: Ray);
  43150. /**
  43151. * Shows the ray we are willing to debug.
  43152. * @param scene Defines the scene the ray needs to be rendered in
  43153. * @param color Defines the color the ray needs to be rendered in
  43154. */
  43155. show(scene: Scene, color?: Color3): void;
  43156. /**
  43157. * Hides the ray we are debugging.
  43158. */
  43159. hide(): void;
  43160. private _render;
  43161. /**
  43162. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43163. * @param mesh Defines the mesh we want the helper attached to
  43164. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43165. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43166. * @param length Defines the length of the ray
  43167. */
  43168. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43169. /**
  43170. * Detach the ray helper from the mesh it has previously been attached to.
  43171. */
  43172. detachFromMesh(): void;
  43173. private _updateToMesh;
  43174. /**
  43175. * Dispose the helper and release its associated resources.
  43176. */
  43177. dispose(): void;
  43178. }
  43179. }
  43180. declare module "babylonjs/Debug/skeletonViewer" {
  43181. import { Color3 } from "babylonjs/Maths/math";
  43182. import { Scene } from "babylonjs/scene";
  43183. import { Nullable } from "babylonjs/types";
  43184. import { Skeleton } from "babylonjs/Bones/skeleton";
  43185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43186. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43187. /**
  43188. * Class used to render a debug view of a given skeleton
  43189. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43190. */
  43191. export class SkeletonViewer {
  43192. /** defines the skeleton to render */
  43193. skeleton: Skeleton;
  43194. /** defines the mesh attached to the skeleton */
  43195. mesh: AbstractMesh;
  43196. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43197. autoUpdateBonesMatrices: boolean;
  43198. /** defines the rendering group id to use with the viewer */
  43199. renderingGroupId: number;
  43200. /** Gets or sets the color used to render the skeleton */
  43201. color: Color3;
  43202. private _scene;
  43203. private _debugLines;
  43204. private _debugMesh;
  43205. private _isEnabled;
  43206. private _renderFunction;
  43207. private _utilityLayer;
  43208. /**
  43209. * Returns the mesh used to render the bones
  43210. */
  43211. readonly debugMesh: Nullable<LinesMesh>;
  43212. /**
  43213. * Creates a new SkeletonViewer
  43214. * @param skeleton defines the skeleton to render
  43215. * @param mesh defines the mesh attached to the skeleton
  43216. * @param scene defines the hosting scene
  43217. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43218. * @param renderingGroupId defines the rendering group id to use with the viewer
  43219. */
  43220. constructor(
  43221. /** defines the skeleton to render */
  43222. skeleton: Skeleton,
  43223. /** defines the mesh attached to the skeleton */
  43224. mesh: AbstractMesh, scene: Scene,
  43225. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43226. autoUpdateBonesMatrices?: boolean,
  43227. /** defines the rendering group id to use with the viewer */
  43228. renderingGroupId?: number);
  43229. /** Gets or sets a boolean indicating if the viewer is enabled */
  43230. isEnabled: boolean;
  43231. private _getBonePosition;
  43232. private _getLinesForBonesWithLength;
  43233. private _getLinesForBonesNoLength;
  43234. /** Update the viewer to sync with current skeleton state */
  43235. update(): void;
  43236. /** Release associated resources */
  43237. dispose(): void;
  43238. }
  43239. }
  43240. declare module "babylonjs/Debug/index" {
  43241. export * from "babylonjs/Debug/axesViewer";
  43242. export * from "babylonjs/Debug/boneAxesViewer";
  43243. export * from "babylonjs/Debug/debugLayer";
  43244. export * from "babylonjs/Debug/physicsViewer";
  43245. export * from "babylonjs/Debug/rayHelper";
  43246. export * from "babylonjs/Debug/skeletonViewer";
  43247. }
  43248. declare module "babylonjs/Engines/nullEngine" {
  43249. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  43250. import { Scene } from "babylonjs/scene";
  43251. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  43252. import { Engine } from "babylonjs/Engines/engine";
  43253. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  43254. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  43255. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43256. import { Effect } from "babylonjs/Materials/effect";
  43257. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43258. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43259. /**
  43260. * Options to create the null engine
  43261. */
  43262. export class NullEngineOptions {
  43263. /**
  43264. * Render width (Default: 512)
  43265. */
  43266. renderWidth: number;
  43267. /**
  43268. * Render height (Default: 256)
  43269. */
  43270. renderHeight: number;
  43271. /**
  43272. * Texture size (Default: 512)
  43273. */
  43274. textureSize: number;
  43275. /**
  43276. * If delta time between frames should be constant
  43277. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43278. */
  43279. deterministicLockstep: boolean;
  43280. /**
  43281. * Maximum about of steps between frames (Default: 4)
  43282. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43283. */
  43284. lockstepMaxSteps: number;
  43285. }
  43286. /**
  43287. * The null engine class provides support for headless version of babylon.js.
  43288. * This can be used in server side scenario or for testing purposes
  43289. */
  43290. export class NullEngine extends Engine {
  43291. private _options;
  43292. /**
  43293. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43294. */
  43295. isDeterministicLockStep(): boolean;
  43296. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43297. getLockstepMaxSteps(): number;
  43298. /**
  43299. * Sets hardware scaling, used to save performance if needed
  43300. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43301. */
  43302. getHardwareScalingLevel(): number;
  43303. constructor(options?: NullEngineOptions);
  43304. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43305. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43306. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43307. getRenderWidth(useScreen?: boolean): number;
  43308. getRenderHeight(useScreen?: boolean): number;
  43309. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43310. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43311. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43312. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43313. bindSamplers(effect: Effect): void;
  43314. enableEffect(effect: Effect): void;
  43315. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43316. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43317. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43318. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43319. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43320. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43321. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43322. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43323. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43324. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43325. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43326. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43327. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43328. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43329. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43330. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43331. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43332. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43333. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43334. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43335. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43336. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43337. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43338. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43339. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43340. bindBuffers(vertexBuffers: {
  43341. [key: string]: VertexBuffer;
  43342. }, indexBuffer: DataBuffer, effect: Effect): void;
  43343. wipeCaches(bruteForce?: boolean): void;
  43344. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43345. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43346. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43347. /** @hidden */
  43348. _createTexture(): WebGLTexture;
  43349. /** @hidden */
  43350. _releaseTexture(texture: InternalTexture): void;
  43351. 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;
  43352. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43353. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43354. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43355. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43356. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43357. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43358. areAllEffectsReady(): boolean;
  43359. /**
  43360. * @hidden
  43361. * Get the current error code of the webGL context
  43362. * @returns the error code
  43363. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43364. */
  43365. getError(): number;
  43366. /** @hidden */
  43367. _getUnpackAlignement(): number;
  43368. /** @hidden */
  43369. _unpackFlipY(value: boolean): void;
  43370. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43371. /**
  43372. * Updates a dynamic vertex buffer.
  43373. * @param vertexBuffer the vertex buffer to update
  43374. * @param data the data used to update the vertex buffer
  43375. * @param byteOffset the byte offset of the data (optional)
  43376. * @param byteLength the byte length of the data (optional)
  43377. */
  43378. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43379. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43380. /** @hidden */
  43381. _bindTexture(channel: number, texture: InternalTexture): void;
  43382. /** @hidden */
  43383. _releaseBuffer(buffer: DataBuffer): boolean;
  43384. releaseEffects(): void;
  43385. displayLoadingUI(): void;
  43386. hideLoadingUI(): void;
  43387. /** @hidden */
  43388. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43389. /** @hidden */
  43390. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43391. /** @hidden */
  43392. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43393. /** @hidden */
  43394. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43395. }
  43396. }
  43397. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43398. import { Nullable, int } from "babylonjs/types";
  43399. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43400. /** @hidden */
  43401. export class _OcclusionDataStorage {
  43402. /** @hidden */
  43403. occlusionInternalRetryCounter: number;
  43404. /** @hidden */
  43405. isOcclusionQueryInProgress: boolean;
  43406. /** @hidden */
  43407. isOccluded: boolean;
  43408. /** @hidden */
  43409. occlusionRetryCount: number;
  43410. /** @hidden */
  43411. occlusionType: number;
  43412. /** @hidden */
  43413. occlusionQueryAlgorithmType: number;
  43414. }
  43415. module "babylonjs/Engines/engine" {
  43416. interface Engine {
  43417. /**
  43418. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43419. * @return the new query
  43420. */
  43421. createQuery(): WebGLQuery;
  43422. /**
  43423. * Delete and release a webGL query
  43424. * @param query defines the query to delete
  43425. * @return the current engine
  43426. */
  43427. deleteQuery(query: WebGLQuery): Engine;
  43428. /**
  43429. * Check if a given query has resolved and got its value
  43430. * @param query defines the query to check
  43431. * @returns true if the query got its value
  43432. */
  43433. isQueryResultAvailable(query: WebGLQuery): boolean;
  43434. /**
  43435. * Gets the value of a given query
  43436. * @param query defines the query to check
  43437. * @returns the value of the query
  43438. */
  43439. getQueryResult(query: WebGLQuery): number;
  43440. /**
  43441. * Initiates an occlusion query
  43442. * @param algorithmType defines the algorithm to use
  43443. * @param query defines the query to use
  43444. * @returns the current engine
  43445. * @see http://doc.babylonjs.com/features/occlusionquery
  43446. */
  43447. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43448. /**
  43449. * Ends an occlusion query
  43450. * @see http://doc.babylonjs.com/features/occlusionquery
  43451. * @param algorithmType defines the algorithm to use
  43452. * @returns the current engine
  43453. */
  43454. endOcclusionQuery(algorithmType: number): Engine;
  43455. /**
  43456. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43457. * Please note that only one query can be issued at a time
  43458. * @returns a time token used to track the time span
  43459. */
  43460. startTimeQuery(): Nullable<_TimeToken>;
  43461. /**
  43462. * Ends a time query
  43463. * @param token defines the token used to measure the time span
  43464. * @returns the time spent (in ns)
  43465. */
  43466. endTimeQuery(token: _TimeToken): int;
  43467. /** @hidden */
  43468. _currentNonTimestampToken: Nullable<_TimeToken>;
  43469. /** @hidden */
  43470. _createTimeQuery(): WebGLQuery;
  43471. /** @hidden */
  43472. _deleteTimeQuery(query: WebGLQuery): void;
  43473. /** @hidden */
  43474. _getGlAlgorithmType(algorithmType: number): number;
  43475. /** @hidden */
  43476. _getTimeQueryResult(query: WebGLQuery): any;
  43477. /** @hidden */
  43478. _getTimeQueryAvailability(query: WebGLQuery): any;
  43479. }
  43480. }
  43481. module "babylonjs/Meshes/abstractMesh" {
  43482. interface AbstractMesh {
  43483. /**
  43484. * Backing filed
  43485. * @hidden
  43486. */
  43487. __occlusionDataStorage: _OcclusionDataStorage;
  43488. /**
  43489. * Access property
  43490. * @hidden
  43491. */
  43492. _occlusionDataStorage: _OcclusionDataStorage;
  43493. /**
  43494. * 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.
  43495. * The default value is -1 which means don't break the query and wait till the result
  43496. * @see http://doc.babylonjs.com/features/occlusionquery
  43497. */
  43498. occlusionRetryCount: number;
  43499. /**
  43500. * 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:
  43501. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43502. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43503. * * 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.
  43504. * @see http://doc.babylonjs.com/features/occlusionquery
  43505. */
  43506. occlusionType: number;
  43507. /**
  43508. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43509. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43510. * * 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.
  43511. * @see http://doc.babylonjs.com/features/occlusionquery
  43512. */
  43513. occlusionQueryAlgorithmType: number;
  43514. /**
  43515. * 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
  43516. * @see http://doc.babylonjs.com/features/occlusionquery
  43517. */
  43518. isOccluded: boolean;
  43519. /**
  43520. * Flag to check the progress status of the query
  43521. * @see http://doc.babylonjs.com/features/occlusionquery
  43522. */
  43523. isOcclusionQueryInProgress: boolean;
  43524. }
  43525. }
  43526. }
  43527. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43528. import { Nullable } from "babylonjs/types";
  43529. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43530. /** @hidden */
  43531. export var _forceTransformFeedbackToBundle: boolean;
  43532. module "babylonjs/Engines/engine" {
  43533. interface Engine {
  43534. /**
  43535. * Creates a webGL transform feedback object
  43536. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43537. * @returns the webGL transform feedback object
  43538. */
  43539. createTransformFeedback(): WebGLTransformFeedback;
  43540. /**
  43541. * Delete a webGL transform feedback object
  43542. * @param value defines the webGL transform feedback object to delete
  43543. */
  43544. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43545. /**
  43546. * Bind a webGL transform feedback object to the webgl context
  43547. * @param value defines the webGL transform feedback object to bind
  43548. */
  43549. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43550. /**
  43551. * Begins a transform feedback operation
  43552. * @param usePoints defines if points or triangles must be used
  43553. */
  43554. beginTransformFeedback(usePoints: boolean): void;
  43555. /**
  43556. * Ends a transform feedback operation
  43557. */
  43558. endTransformFeedback(): void;
  43559. /**
  43560. * Specify the varyings to use with transform feedback
  43561. * @param program defines the associated webGL program
  43562. * @param value defines the list of strings representing the varying names
  43563. */
  43564. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43565. /**
  43566. * Bind a webGL buffer for a transform feedback operation
  43567. * @param value defines the webGL buffer to bind
  43568. */
  43569. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43570. }
  43571. }
  43572. }
  43573. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43574. import { Scene } from "babylonjs/scene";
  43575. import { Engine } from "babylonjs/Engines/engine";
  43576. import { Texture } from "babylonjs/Materials/Textures/texture";
  43577. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43578. import "babylonjs/Engines/Extensions/engine.multiRender";
  43579. /**
  43580. * Creation options of the multi render target texture.
  43581. */
  43582. export interface IMultiRenderTargetOptions {
  43583. /**
  43584. * Define if the texture needs to create mip maps after render.
  43585. */
  43586. generateMipMaps?: boolean;
  43587. /**
  43588. * Define the types of all the draw buffers we want to create
  43589. */
  43590. types?: number[];
  43591. /**
  43592. * Define the sampling modes of all the draw buffers we want to create
  43593. */
  43594. samplingModes?: number[];
  43595. /**
  43596. * Define if a depth buffer is required
  43597. */
  43598. generateDepthBuffer?: boolean;
  43599. /**
  43600. * Define if a stencil buffer is required
  43601. */
  43602. generateStencilBuffer?: boolean;
  43603. /**
  43604. * Define if a depth texture is required instead of a depth buffer
  43605. */
  43606. generateDepthTexture?: boolean;
  43607. /**
  43608. * Define the number of desired draw buffers
  43609. */
  43610. textureCount?: number;
  43611. /**
  43612. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43613. */
  43614. doNotChangeAspectRatio?: boolean;
  43615. /**
  43616. * Define the default type of the buffers we are creating
  43617. */
  43618. defaultType?: number;
  43619. }
  43620. /**
  43621. * A multi render target, like a render target provides the ability to render to a texture.
  43622. * Unlike the render target, it can render to several draw buffers in one draw.
  43623. * This is specially interesting in deferred rendering or for any effects requiring more than
  43624. * just one color from a single pass.
  43625. */
  43626. export class MultiRenderTarget extends RenderTargetTexture {
  43627. private _internalTextures;
  43628. private _textures;
  43629. private _multiRenderTargetOptions;
  43630. /**
  43631. * Get if draw buffers are currently supported by the used hardware and browser.
  43632. */
  43633. readonly isSupported: boolean;
  43634. /**
  43635. * Get the list of textures generated by the multi render target.
  43636. */
  43637. readonly textures: Texture[];
  43638. /**
  43639. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43640. */
  43641. readonly depthTexture: Texture;
  43642. /**
  43643. * Set the wrapping mode on U of all the textures we are rendering to.
  43644. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43645. */
  43646. wrapU: number;
  43647. /**
  43648. * Set the wrapping mode on V of all the textures we are rendering to.
  43649. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43650. */
  43651. wrapV: number;
  43652. /**
  43653. * Instantiate a new multi render target texture.
  43654. * A multi render target, like a render target provides the ability to render to a texture.
  43655. * Unlike the render target, it can render to several draw buffers in one draw.
  43656. * This is specially interesting in deferred rendering or for any effects requiring more than
  43657. * just one color from a single pass.
  43658. * @param name Define the name of the texture
  43659. * @param size Define the size of the buffers to render to
  43660. * @param count Define the number of target we are rendering into
  43661. * @param scene Define the scene the texture belongs to
  43662. * @param options Define the options used to create the multi render target
  43663. */
  43664. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43665. /** @hidden */
  43666. _rebuild(): void;
  43667. private _createInternalTextures;
  43668. private _createTextures;
  43669. /**
  43670. * Define the number of samples used if MSAA is enabled.
  43671. */
  43672. samples: number;
  43673. /**
  43674. * Resize all the textures in the multi render target.
  43675. * Be carrefull as it will recreate all the data in the new texture.
  43676. * @param size Define the new size
  43677. */
  43678. resize(size: any): void;
  43679. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43680. /**
  43681. * Dispose the render targets and their associated resources
  43682. */
  43683. dispose(): void;
  43684. /**
  43685. * Release all the underlying texture used as draw buffers.
  43686. */
  43687. releaseInternalTextures(): void;
  43688. }
  43689. }
  43690. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43691. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43692. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43693. import { Nullable } from "babylonjs/types";
  43694. module "babylonjs/Engines/engine" {
  43695. interface Engine {
  43696. /**
  43697. * Unbind a list of render target textures from the webGL context
  43698. * This is used only when drawBuffer extension or webGL2 are active
  43699. * @param textures defines the render target textures to unbind
  43700. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43701. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43702. */
  43703. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43704. /**
  43705. * Create a multi render target texture
  43706. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43707. * @param size defines the size of the texture
  43708. * @param options defines the creation options
  43709. * @returns the cube texture as an InternalTexture
  43710. */
  43711. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43712. /**
  43713. * Update the sample count for a given multiple render target texture
  43714. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43715. * @param textures defines the textures to update
  43716. * @param samples defines the sample count to set
  43717. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43718. */
  43719. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43720. }
  43721. }
  43722. }
  43723. declare module "babylonjs/Engines/Extensions/index" {
  43724. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43725. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43726. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43727. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43728. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43729. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43730. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43731. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43732. }
  43733. declare module "babylonjs/Engines/index" {
  43734. export * from "babylonjs/Engines/constants";
  43735. export * from "babylonjs/Engines/engine";
  43736. export * from "babylonjs/Engines/engineStore";
  43737. export * from "babylonjs/Engines/nullEngine";
  43738. export * from "babylonjs/Engines/Extensions/index";
  43739. export * from "babylonjs/Engines/IPipelineContext";
  43740. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43741. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  43742. }
  43743. declare module "babylonjs/Events/clipboardEvents" {
  43744. /**
  43745. * Gather the list of clipboard event types as constants.
  43746. */
  43747. export class ClipboardEventTypes {
  43748. /**
  43749. * The clipboard event is fired when a copy command is active (pressed).
  43750. */
  43751. static readonly COPY: number;
  43752. /**
  43753. * The clipboard event is fired when a cut command is active (pressed).
  43754. */
  43755. static readonly CUT: number;
  43756. /**
  43757. * The clipboard event is fired when a paste command is active (pressed).
  43758. */
  43759. static readonly PASTE: number;
  43760. }
  43761. /**
  43762. * This class is used to store clipboard related info for the onClipboardObservable event.
  43763. */
  43764. export class ClipboardInfo {
  43765. /**
  43766. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43767. */
  43768. type: number;
  43769. /**
  43770. * Defines the related dom event
  43771. */
  43772. event: ClipboardEvent;
  43773. /**
  43774. *Creates an instance of ClipboardInfo.
  43775. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43776. * @param event Defines the related dom event
  43777. */
  43778. constructor(
  43779. /**
  43780. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43781. */
  43782. type: number,
  43783. /**
  43784. * Defines the related dom event
  43785. */
  43786. event: ClipboardEvent);
  43787. /**
  43788. * Get the clipboard event's type from the keycode.
  43789. * @param keyCode Defines the keyCode for the current keyboard event.
  43790. * @return {number}
  43791. */
  43792. static GetTypeFromCharacter(keyCode: number): number;
  43793. }
  43794. }
  43795. declare module "babylonjs/Events/index" {
  43796. export * from "babylonjs/Events/keyboardEvents";
  43797. export * from "babylonjs/Events/pointerEvents";
  43798. export * from "babylonjs/Events/clipboardEvents";
  43799. }
  43800. declare module "babylonjs/Loading/sceneLoader" {
  43801. import { Observable } from "babylonjs/Misc/observable";
  43802. import { Nullable } from "babylonjs/types";
  43803. import { Scene } from "babylonjs/scene";
  43804. import { Engine } from "babylonjs/Engines/engine";
  43805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43806. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43807. import { AssetContainer } from "babylonjs/assetContainer";
  43808. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43809. import { Skeleton } from "babylonjs/Bones/skeleton";
  43810. /**
  43811. * Class used to represent data loading progression
  43812. */
  43813. export class SceneLoaderProgressEvent {
  43814. /** defines if data length to load can be evaluated */
  43815. readonly lengthComputable: boolean;
  43816. /** defines the loaded data length */
  43817. readonly loaded: number;
  43818. /** defines the data length to load */
  43819. readonly total: number;
  43820. /**
  43821. * Create a new progress event
  43822. * @param lengthComputable defines if data length to load can be evaluated
  43823. * @param loaded defines the loaded data length
  43824. * @param total defines the data length to load
  43825. */
  43826. constructor(
  43827. /** defines if data length to load can be evaluated */
  43828. lengthComputable: boolean,
  43829. /** defines the loaded data length */
  43830. loaded: number,
  43831. /** defines the data length to load */
  43832. total: number);
  43833. /**
  43834. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43835. * @param event defines the source event
  43836. * @returns a new SceneLoaderProgressEvent
  43837. */
  43838. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43839. }
  43840. /**
  43841. * Interface used by SceneLoader plugins to define supported file extensions
  43842. */
  43843. export interface ISceneLoaderPluginExtensions {
  43844. /**
  43845. * Defines the list of supported extensions
  43846. */
  43847. [extension: string]: {
  43848. isBinary: boolean;
  43849. };
  43850. }
  43851. /**
  43852. * Interface used by SceneLoader plugin factory
  43853. */
  43854. export interface ISceneLoaderPluginFactory {
  43855. /**
  43856. * Defines the name of the factory
  43857. */
  43858. name: string;
  43859. /**
  43860. * Function called to create a new plugin
  43861. * @return the new plugin
  43862. */
  43863. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43864. /**
  43865. * Boolean indicating if the plugin can direct load specific data
  43866. */
  43867. canDirectLoad?: (data: string) => boolean;
  43868. }
  43869. /**
  43870. * Interface used to define a SceneLoader plugin
  43871. */
  43872. export interface ISceneLoaderPlugin {
  43873. /**
  43874. * The friendly name of this plugin.
  43875. */
  43876. name: string;
  43877. /**
  43878. * The file extensions supported by this plugin.
  43879. */
  43880. extensions: string | ISceneLoaderPluginExtensions;
  43881. /**
  43882. * Import meshes into a scene.
  43883. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43884. * @param scene The scene to import into
  43885. * @param data The data to import
  43886. * @param rootUrl The root url for scene and resources
  43887. * @param meshes The meshes array to import into
  43888. * @param particleSystems The particle systems array to import into
  43889. * @param skeletons The skeletons array to import into
  43890. * @param onError The callback when import fails
  43891. * @returns True if successful or false otherwise
  43892. */
  43893. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43894. /**
  43895. * Load into a scene.
  43896. * @param scene The scene to load into
  43897. * @param data The data to import
  43898. * @param rootUrl The root url for scene and resources
  43899. * @param onError The callback when import fails
  43900. * @returns true if successful or false otherwise
  43901. */
  43902. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43903. /**
  43904. * The callback that returns true if the data can be directly loaded.
  43905. */
  43906. canDirectLoad?: (data: string) => boolean;
  43907. /**
  43908. * The callback that allows custom handling of the root url based on the response url.
  43909. */
  43910. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43911. /**
  43912. * Load into an asset container.
  43913. * @param scene The scene to load into
  43914. * @param data The data to import
  43915. * @param rootUrl The root url for scene and resources
  43916. * @param onError The callback when import fails
  43917. * @returns The loaded asset container
  43918. */
  43919. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43920. }
  43921. /**
  43922. * Interface used to define an async SceneLoader plugin
  43923. */
  43924. export interface ISceneLoaderPluginAsync {
  43925. /**
  43926. * The friendly name of this plugin.
  43927. */
  43928. name: string;
  43929. /**
  43930. * The file extensions supported by this plugin.
  43931. */
  43932. extensions: string | ISceneLoaderPluginExtensions;
  43933. /**
  43934. * Import meshes into a scene.
  43935. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43936. * @param scene The scene to import into
  43937. * @param data The data to import
  43938. * @param rootUrl The root url for scene and resources
  43939. * @param onProgress The callback when the load progresses
  43940. * @param fileName Defines the name of the file to load
  43941. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43942. */
  43943. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43944. meshes: AbstractMesh[];
  43945. particleSystems: IParticleSystem[];
  43946. skeletons: Skeleton[];
  43947. animationGroups: AnimationGroup[];
  43948. }>;
  43949. /**
  43950. * Load into a scene.
  43951. * @param scene The scene to load into
  43952. * @param data The data to import
  43953. * @param rootUrl The root url for scene and resources
  43954. * @param onProgress The callback when the load progresses
  43955. * @param fileName Defines the name of the file to load
  43956. * @returns Nothing
  43957. */
  43958. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43959. /**
  43960. * The callback that returns true if the data can be directly loaded.
  43961. */
  43962. canDirectLoad?: (data: string) => boolean;
  43963. /**
  43964. * The callback that allows custom handling of the root url based on the response url.
  43965. */
  43966. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43967. /**
  43968. * Load into an asset container.
  43969. * @param scene The scene to load into
  43970. * @param data The data to import
  43971. * @param rootUrl The root url for scene and resources
  43972. * @param onProgress The callback when the load progresses
  43973. * @param fileName Defines the name of the file to load
  43974. * @returns The loaded asset container
  43975. */
  43976. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43977. }
  43978. /**
  43979. * Class used to load scene from various file formats using registered plugins
  43980. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43981. */
  43982. export class SceneLoader {
  43983. /**
  43984. * No logging while loading
  43985. */
  43986. static readonly NO_LOGGING: number;
  43987. /**
  43988. * Minimal logging while loading
  43989. */
  43990. static readonly MINIMAL_LOGGING: number;
  43991. /**
  43992. * Summary logging while loading
  43993. */
  43994. static readonly SUMMARY_LOGGING: number;
  43995. /**
  43996. * Detailled logging while loading
  43997. */
  43998. static readonly DETAILED_LOGGING: number;
  43999. /**
  44000. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44001. */
  44002. static ForceFullSceneLoadingForIncremental: boolean;
  44003. /**
  44004. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44005. */
  44006. static ShowLoadingScreen: boolean;
  44007. /**
  44008. * Defines the current logging level (while loading the scene)
  44009. * @ignorenaming
  44010. */
  44011. static loggingLevel: number;
  44012. /**
  44013. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44014. */
  44015. static CleanBoneMatrixWeights: boolean;
  44016. /**
  44017. * Event raised when a plugin is used to load a scene
  44018. */
  44019. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44020. private static _registeredPlugins;
  44021. private static _getDefaultPlugin;
  44022. private static _getPluginForExtension;
  44023. private static _getPluginForDirectLoad;
  44024. private static _getPluginForFilename;
  44025. private static _getDirectLoad;
  44026. private static _loadData;
  44027. private static _getFileInfo;
  44028. /**
  44029. * Gets a plugin that can load the given extension
  44030. * @param extension defines the extension to load
  44031. * @returns a plugin or null if none works
  44032. */
  44033. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44034. /**
  44035. * Gets a boolean indicating that the given extension can be loaded
  44036. * @param extension defines the extension to load
  44037. * @returns true if the extension is supported
  44038. */
  44039. static IsPluginForExtensionAvailable(extension: string): boolean;
  44040. /**
  44041. * Adds a new plugin to the list of registered plugins
  44042. * @param plugin defines the plugin to add
  44043. */
  44044. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44045. /**
  44046. * Import meshes into a scene
  44047. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44048. * @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)
  44049. * @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)
  44050. * @param scene the instance of BABYLON.Scene to append to
  44051. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44052. * @param onProgress a callback with a progress event for each file being loaded
  44053. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44054. * @param pluginExtension the extension used to determine the plugin
  44055. * @returns The loaded plugin
  44056. */
  44057. 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>;
  44058. /**
  44059. * Import meshes into a scene
  44060. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44061. * @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)
  44062. * @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)
  44063. * @param scene the instance of BABYLON.Scene to append to
  44064. * @param onProgress a callback with a progress event for each file being loaded
  44065. * @param pluginExtension the extension used to determine the plugin
  44066. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44067. */
  44068. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44069. meshes: AbstractMesh[];
  44070. particleSystems: IParticleSystem[];
  44071. skeletons: Skeleton[];
  44072. animationGroups: AnimationGroup[];
  44073. }>;
  44074. /**
  44075. * Load a scene
  44076. * @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)
  44077. * @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)
  44078. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44079. * @param onSuccess a callback with the scene when import succeeds
  44080. * @param onProgress a callback with a progress event for each file being loaded
  44081. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44082. * @param pluginExtension the extension used to determine the plugin
  44083. * @returns The loaded plugin
  44084. */
  44085. 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>;
  44086. /**
  44087. * Load a scene
  44088. * @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)
  44089. * @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)
  44090. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44091. * @param onProgress a callback with a progress event for each file being loaded
  44092. * @param pluginExtension the extension used to determine the plugin
  44093. * @returns The loaded scene
  44094. */
  44095. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44096. /**
  44097. * Append a scene
  44098. * @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)
  44099. * @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)
  44100. * @param scene is the instance of BABYLON.Scene to append to
  44101. * @param onSuccess a callback with the scene when import succeeds
  44102. * @param onProgress a callback with a progress event for each file being loaded
  44103. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44104. * @param pluginExtension the extension used to determine the plugin
  44105. * @returns The loaded plugin
  44106. */
  44107. 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>;
  44108. /**
  44109. * Append a scene
  44110. * @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)
  44111. * @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)
  44112. * @param scene is the instance of BABYLON.Scene to append to
  44113. * @param onProgress a callback with a progress event for each file being loaded
  44114. * @param pluginExtension the extension used to determine the plugin
  44115. * @returns The given scene
  44116. */
  44117. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44118. /**
  44119. * Load a scene into an asset container
  44120. * @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)
  44121. * @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)
  44122. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44123. * @param onSuccess a callback with the scene when import succeeds
  44124. * @param onProgress a callback with a progress event for each file being loaded
  44125. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44126. * @param pluginExtension the extension used to determine the plugin
  44127. * @returns The loaded plugin
  44128. */
  44129. 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>;
  44130. /**
  44131. * Load a scene into an asset container
  44132. * @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)
  44133. * @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)
  44134. * @param scene is the instance of Scene to append to
  44135. * @param onProgress a callback with a progress event for each file being loaded
  44136. * @param pluginExtension the extension used to determine the plugin
  44137. * @returns The loaded asset container
  44138. */
  44139. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44140. }
  44141. }
  44142. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  44143. import { Scene } from "babylonjs/scene";
  44144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44145. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44146. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44147. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44148. /**
  44149. * Google Daydream controller
  44150. */
  44151. export class DaydreamController extends WebVRController {
  44152. /**
  44153. * Base Url for the controller model.
  44154. */
  44155. static MODEL_BASE_URL: string;
  44156. /**
  44157. * File name for the controller model.
  44158. */
  44159. static MODEL_FILENAME: string;
  44160. /**
  44161. * Gamepad Id prefix used to identify Daydream Controller.
  44162. */
  44163. static readonly GAMEPAD_ID_PREFIX: string;
  44164. /**
  44165. * Creates a new DaydreamController from a gamepad
  44166. * @param vrGamepad the gamepad that the controller should be created from
  44167. */
  44168. constructor(vrGamepad: any);
  44169. /**
  44170. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44171. * @param scene scene in which to add meshes
  44172. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44173. */
  44174. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44175. /**
  44176. * Called once for each button that changed state since the last frame
  44177. * @param buttonIdx Which button index changed
  44178. * @param state New state of the button
  44179. * @param changes Which properties on the state changed since last frame
  44180. */
  44181. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44182. }
  44183. }
  44184. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  44185. import { Scene } from "babylonjs/scene";
  44186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44187. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44188. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44189. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44190. /**
  44191. * Gear VR Controller
  44192. */
  44193. export class GearVRController extends WebVRController {
  44194. /**
  44195. * Base Url for the controller model.
  44196. */
  44197. static MODEL_BASE_URL: string;
  44198. /**
  44199. * File name for the controller model.
  44200. */
  44201. static MODEL_FILENAME: string;
  44202. /**
  44203. * Gamepad Id prefix used to identify this controller.
  44204. */
  44205. static readonly GAMEPAD_ID_PREFIX: string;
  44206. private readonly _buttonIndexToObservableNameMap;
  44207. /**
  44208. * Creates a new GearVRController from a gamepad
  44209. * @param vrGamepad the gamepad that the controller should be created from
  44210. */
  44211. constructor(vrGamepad: any);
  44212. /**
  44213. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44214. * @param scene scene in which to add meshes
  44215. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44216. */
  44217. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44218. /**
  44219. * Called once for each button that changed state since the last frame
  44220. * @param buttonIdx Which button index changed
  44221. * @param state New state of the button
  44222. * @param changes Which properties on the state changed since last frame
  44223. */
  44224. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44225. }
  44226. }
  44227. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44228. import { Scene } from "babylonjs/scene";
  44229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44230. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44231. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44232. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44233. /**
  44234. * Generic Controller
  44235. */
  44236. export class GenericController extends WebVRController {
  44237. /**
  44238. * Base Url for the controller model.
  44239. */
  44240. static readonly MODEL_BASE_URL: string;
  44241. /**
  44242. * File name for the controller model.
  44243. */
  44244. static readonly MODEL_FILENAME: string;
  44245. /**
  44246. * Creates a new GenericController from a gamepad
  44247. * @param vrGamepad the gamepad that the controller should be created from
  44248. */
  44249. constructor(vrGamepad: any);
  44250. /**
  44251. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44252. * @param scene scene in which to add meshes
  44253. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44254. */
  44255. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44256. /**
  44257. * Called once for each button that changed state since the last frame
  44258. * @param buttonIdx Which button index changed
  44259. * @param state New state of the button
  44260. * @param changes Which properties on the state changed since last frame
  44261. */
  44262. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44263. }
  44264. }
  44265. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44266. import { Observable } from "babylonjs/Misc/observable";
  44267. import { Scene } from "babylonjs/scene";
  44268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44269. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44270. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44271. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44272. /**
  44273. * Oculus Touch Controller
  44274. */
  44275. export class OculusTouchController extends WebVRController {
  44276. /**
  44277. * Base Url for the controller model.
  44278. */
  44279. static MODEL_BASE_URL: string;
  44280. /**
  44281. * File name for the left controller model.
  44282. */
  44283. static MODEL_LEFT_FILENAME: string;
  44284. /**
  44285. * File name for the right controller model.
  44286. */
  44287. static MODEL_RIGHT_FILENAME: string;
  44288. /**
  44289. * Fired when the secondary trigger on this controller is modified
  44290. */
  44291. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44292. /**
  44293. * Fired when the thumb rest on this controller is modified
  44294. */
  44295. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44296. /**
  44297. * Creates a new OculusTouchController from a gamepad
  44298. * @param vrGamepad the gamepad that the controller should be created from
  44299. */
  44300. constructor(vrGamepad: any);
  44301. /**
  44302. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44303. * @param scene scene in which to add meshes
  44304. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44305. */
  44306. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44307. /**
  44308. * Fired when the A button on this controller is modified
  44309. */
  44310. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44311. /**
  44312. * Fired when the B button on this controller is modified
  44313. */
  44314. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44315. /**
  44316. * Fired when the X button on this controller is modified
  44317. */
  44318. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44319. /**
  44320. * Fired when the Y button on this controller is modified
  44321. */
  44322. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44323. /**
  44324. * Called once for each button that changed state since the last frame
  44325. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44326. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44327. * 2) secondary trigger (same)
  44328. * 3) A (right) X (left), touch, pressed = value
  44329. * 4) B / Y
  44330. * 5) thumb rest
  44331. * @param buttonIdx Which button index changed
  44332. * @param state New state of the button
  44333. * @param changes Which properties on the state changed since last frame
  44334. */
  44335. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44336. }
  44337. }
  44338. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44339. import { Scene } from "babylonjs/scene";
  44340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44341. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44342. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44343. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44344. import { Observable } from "babylonjs/Misc/observable";
  44345. /**
  44346. * Vive Controller
  44347. */
  44348. export class ViveController extends WebVRController {
  44349. /**
  44350. * Base Url for the controller model.
  44351. */
  44352. static MODEL_BASE_URL: string;
  44353. /**
  44354. * File name for the controller model.
  44355. */
  44356. static MODEL_FILENAME: string;
  44357. /**
  44358. * Creates a new ViveController from a gamepad
  44359. * @param vrGamepad the gamepad that the controller should be created from
  44360. */
  44361. constructor(vrGamepad: any);
  44362. /**
  44363. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44364. * @param scene scene in which to add meshes
  44365. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44366. */
  44367. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44368. /**
  44369. * Fired when the left button on this controller is modified
  44370. */
  44371. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44372. /**
  44373. * Fired when the right button on this controller is modified
  44374. */
  44375. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44376. /**
  44377. * Fired when the menu button on this controller is modified
  44378. */
  44379. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44380. /**
  44381. * Called once for each button that changed state since the last frame
  44382. * Vive mapping:
  44383. * 0: touchpad
  44384. * 1: trigger
  44385. * 2: left AND right buttons
  44386. * 3: menu button
  44387. * @param buttonIdx Which button index changed
  44388. * @param state New state of the button
  44389. * @param changes Which properties on the state changed since last frame
  44390. */
  44391. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44392. }
  44393. }
  44394. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44395. import { Observable } from "babylonjs/Misc/observable";
  44396. import { Scene } from "babylonjs/scene";
  44397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44398. import { Ray } from "babylonjs/Culling/ray";
  44399. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44400. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44401. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44402. /**
  44403. * Defines the WindowsMotionController object that the state of the windows motion controller
  44404. */
  44405. export class WindowsMotionController extends WebVRController {
  44406. /**
  44407. * The base url used to load the left and right controller models
  44408. */
  44409. static MODEL_BASE_URL: string;
  44410. /**
  44411. * The name of the left controller model file
  44412. */
  44413. static MODEL_LEFT_FILENAME: string;
  44414. /**
  44415. * The name of the right controller model file
  44416. */
  44417. static MODEL_RIGHT_FILENAME: string;
  44418. /**
  44419. * The controller name prefix for this controller type
  44420. */
  44421. static readonly GAMEPAD_ID_PREFIX: string;
  44422. /**
  44423. * The controller id pattern for this controller type
  44424. */
  44425. private static readonly GAMEPAD_ID_PATTERN;
  44426. private _loadedMeshInfo;
  44427. private readonly _mapping;
  44428. /**
  44429. * Fired when the trackpad on this controller is clicked
  44430. */
  44431. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44432. /**
  44433. * Fired when the trackpad on this controller is modified
  44434. */
  44435. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44436. /**
  44437. * The current x and y values of this controller's trackpad
  44438. */
  44439. trackpad: StickValues;
  44440. /**
  44441. * Creates a new WindowsMotionController from a gamepad
  44442. * @param vrGamepad the gamepad that the controller should be created from
  44443. */
  44444. constructor(vrGamepad: any);
  44445. /**
  44446. * Fired when the trigger on this controller is modified
  44447. */
  44448. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44449. /**
  44450. * Fired when the menu button on this controller is modified
  44451. */
  44452. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44453. /**
  44454. * Fired when the grip button on this controller is modified
  44455. */
  44456. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44457. /**
  44458. * Fired when the thumbstick button on this controller is modified
  44459. */
  44460. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44461. /**
  44462. * Fired when the touchpad button on this controller is modified
  44463. */
  44464. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44465. /**
  44466. * Fired when the touchpad values on this controller are modified
  44467. */
  44468. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44469. private _updateTrackpad;
  44470. /**
  44471. * Called once per frame by the engine.
  44472. */
  44473. update(): void;
  44474. /**
  44475. * Called once for each button that changed state since the last frame
  44476. * @param buttonIdx Which button index changed
  44477. * @param state New state of the button
  44478. * @param changes Which properties on the state changed since last frame
  44479. */
  44480. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44481. /**
  44482. * Moves the buttons on the controller mesh based on their current state
  44483. * @param buttonName the name of the button to move
  44484. * @param buttonValue the value of the button which determines the buttons new position
  44485. */
  44486. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44487. /**
  44488. * Moves the axis on the controller mesh based on its current state
  44489. * @param axis the index of the axis
  44490. * @param axisValue the value of the axis which determines the meshes new position
  44491. * @hidden
  44492. */
  44493. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44494. /**
  44495. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44496. * @param scene scene in which to add meshes
  44497. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44498. */
  44499. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44500. /**
  44501. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44502. * can be transformed by button presses and axes values, based on this._mapping.
  44503. *
  44504. * @param scene scene in which the meshes exist
  44505. * @param meshes list of meshes that make up the controller model to process
  44506. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44507. */
  44508. private processModel;
  44509. private createMeshInfo;
  44510. /**
  44511. * Gets the ray of the controller in the direction the controller is pointing
  44512. * @param length the length the resulting ray should be
  44513. * @returns a ray in the direction the controller is pointing
  44514. */
  44515. getForwardRay(length?: number): Ray;
  44516. /**
  44517. * Disposes of the controller
  44518. */
  44519. dispose(): void;
  44520. }
  44521. }
  44522. declare module "babylonjs/Gamepads/Controllers/index" {
  44523. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44524. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44525. export * from "babylonjs/Gamepads/Controllers/genericController";
  44526. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44527. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44528. export * from "babylonjs/Gamepads/Controllers/viveController";
  44529. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44530. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44531. }
  44532. declare module "babylonjs/Gamepads/index" {
  44533. export * from "babylonjs/Gamepads/Controllers/index";
  44534. export * from "babylonjs/Gamepads/gamepad";
  44535. export * from "babylonjs/Gamepads/gamepadManager";
  44536. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44537. export * from "babylonjs/Gamepads/xboxGamepad";
  44538. }
  44539. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44540. import { Scene } from "babylonjs/scene";
  44541. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44542. import { Mesh } from "babylonjs/Meshes/mesh";
  44543. import { Nullable } from "babylonjs/types";
  44544. /**
  44545. * Class containing static functions to help procedurally build meshes
  44546. */
  44547. export class PolyhedronBuilder {
  44548. /**
  44549. * Creates a polyhedron mesh
  44550. * * 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
  44551. * * The parameter `size` (positive float, default 1) sets the polygon size
  44552. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44553. * * 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`
  44554. * * 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
  44555. * * 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)`)
  44556. * * 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
  44557. * * 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
  44558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44559. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44561. * @param name defines the name of the mesh
  44562. * @param options defines the options used to create the mesh
  44563. * @param scene defines the hosting scene
  44564. * @returns the polyhedron mesh
  44565. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44566. */
  44567. static CreatePolyhedron(name: string, options: {
  44568. type?: number;
  44569. size?: number;
  44570. sizeX?: number;
  44571. sizeY?: number;
  44572. sizeZ?: number;
  44573. custom?: any;
  44574. faceUV?: Vector4[];
  44575. faceColors?: Color4[];
  44576. flat?: boolean;
  44577. updatable?: boolean;
  44578. sideOrientation?: number;
  44579. frontUVs?: Vector4;
  44580. backUVs?: Vector4;
  44581. }, scene?: Nullable<Scene>): Mesh;
  44582. }
  44583. }
  44584. declare module "babylonjs/Gizmos/scaleGizmo" {
  44585. import { Observable } from "babylonjs/Misc/observable";
  44586. import { Nullable } from "babylonjs/types";
  44587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44588. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44589. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44590. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44591. /**
  44592. * Gizmo that enables scaling a mesh along 3 axis
  44593. */
  44594. export class ScaleGizmo extends Gizmo {
  44595. /**
  44596. * Internal gizmo used for interactions on the x axis
  44597. */
  44598. xGizmo: AxisScaleGizmo;
  44599. /**
  44600. * Internal gizmo used for interactions on the y axis
  44601. */
  44602. yGizmo: AxisScaleGizmo;
  44603. /**
  44604. * Internal gizmo used for interactions on the z axis
  44605. */
  44606. zGizmo: AxisScaleGizmo;
  44607. /**
  44608. * Internal gizmo used to scale all axis equally
  44609. */
  44610. uniformScaleGizmo: AxisScaleGizmo;
  44611. private _meshAttached;
  44612. private _updateGizmoRotationToMatchAttachedMesh;
  44613. private _snapDistance;
  44614. private _scaleRatio;
  44615. private _uniformScalingMesh;
  44616. private _octahedron;
  44617. /** Fires an event when any of it's sub gizmos are dragged */
  44618. onDragStartObservable: Observable<{}>;
  44619. /** Fires an event when any of it's sub gizmos are released from dragging */
  44620. onDragEndObservable: Observable<{}>;
  44621. attachedMesh: Nullable<AbstractMesh>;
  44622. /**
  44623. * Creates a ScaleGizmo
  44624. * @param gizmoLayer The utility layer the gizmo will be added to
  44625. */
  44626. constructor(gizmoLayer?: UtilityLayerRenderer);
  44627. updateGizmoRotationToMatchAttachedMesh: boolean;
  44628. /**
  44629. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44630. */
  44631. snapDistance: number;
  44632. /**
  44633. * Ratio for the scale of the gizmo (Default: 1)
  44634. */
  44635. scaleRatio: number;
  44636. /**
  44637. * Disposes of the gizmo
  44638. */
  44639. dispose(): void;
  44640. }
  44641. }
  44642. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44643. import { Observable } from "babylonjs/Misc/observable";
  44644. import { Nullable } from "babylonjs/types";
  44645. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44647. import { Mesh } from "babylonjs/Meshes/mesh";
  44648. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44649. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44650. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44651. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44652. /**
  44653. * Single axis scale gizmo
  44654. */
  44655. export class AxisScaleGizmo extends Gizmo {
  44656. /**
  44657. * Drag behavior responsible for the gizmos dragging interactions
  44658. */
  44659. dragBehavior: PointerDragBehavior;
  44660. private _pointerObserver;
  44661. /**
  44662. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44663. */
  44664. snapDistance: number;
  44665. /**
  44666. * Event that fires each time the gizmo snaps to a new location.
  44667. * * snapDistance is the the change in distance
  44668. */
  44669. onSnapObservable: Observable<{
  44670. snapDistance: number;
  44671. }>;
  44672. /**
  44673. * If the scaling operation should be done on all axis (default: false)
  44674. */
  44675. uniformScaling: boolean;
  44676. private _isEnabled;
  44677. private _parent;
  44678. private _arrow;
  44679. private _coloredMaterial;
  44680. private _hoverMaterial;
  44681. /**
  44682. * Creates an AxisScaleGizmo
  44683. * @param gizmoLayer The utility layer the gizmo will be added to
  44684. * @param dragAxis The axis which the gizmo will be able to scale on
  44685. * @param color The color of the gizmo
  44686. */
  44687. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44688. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44689. /**
  44690. * If the gizmo is enabled
  44691. */
  44692. isEnabled: boolean;
  44693. /**
  44694. * Disposes of the gizmo
  44695. */
  44696. dispose(): void;
  44697. /**
  44698. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44699. * @param mesh The mesh to replace the default mesh of the gizmo
  44700. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44701. */
  44702. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44703. }
  44704. }
  44705. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44706. import { Observable } from "babylonjs/Misc/observable";
  44707. import { Nullable } from "babylonjs/types";
  44708. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44710. import { Mesh } from "babylonjs/Meshes/mesh";
  44711. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44712. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44713. import "babylonjs/Meshes/Builders/boxBuilder";
  44714. /**
  44715. * Bounding box gizmo
  44716. */
  44717. export class BoundingBoxGizmo extends Gizmo {
  44718. private _lineBoundingBox;
  44719. private _rotateSpheresParent;
  44720. private _scaleBoxesParent;
  44721. private _boundingDimensions;
  44722. private _renderObserver;
  44723. private _pointerObserver;
  44724. private _scaleDragSpeed;
  44725. private _tmpQuaternion;
  44726. private _tmpVector;
  44727. private _tmpRotationMatrix;
  44728. /**
  44729. * 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)
  44730. */
  44731. ignoreChildren: boolean;
  44732. /**
  44733. * 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)
  44734. */
  44735. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44736. /**
  44737. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44738. */
  44739. rotationSphereSize: number;
  44740. /**
  44741. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44742. */
  44743. scaleBoxSize: number;
  44744. /**
  44745. * 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)
  44746. */
  44747. fixedDragMeshScreenSize: boolean;
  44748. /**
  44749. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44750. */
  44751. fixedDragMeshScreenSizeDistanceFactor: number;
  44752. /**
  44753. * Fired when a rotation sphere or scale box is dragged
  44754. */
  44755. onDragStartObservable: Observable<{}>;
  44756. /**
  44757. * Fired when a scale box is dragged
  44758. */
  44759. onScaleBoxDragObservable: Observable<{}>;
  44760. /**
  44761. * Fired when a scale box drag is ended
  44762. */
  44763. onScaleBoxDragEndObservable: Observable<{}>;
  44764. /**
  44765. * Fired when a rotation sphere is dragged
  44766. */
  44767. onRotationSphereDragObservable: Observable<{}>;
  44768. /**
  44769. * Fired when a rotation sphere drag is ended
  44770. */
  44771. onRotationSphereDragEndObservable: Observable<{}>;
  44772. /**
  44773. * 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)
  44774. */
  44775. scalePivot: Nullable<Vector3>;
  44776. /**
  44777. * Mesh used as a pivot to rotate the attached mesh
  44778. */
  44779. private _anchorMesh;
  44780. private _existingMeshScale;
  44781. private _dragMesh;
  44782. private pointerDragBehavior;
  44783. private coloredMaterial;
  44784. private hoverColoredMaterial;
  44785. /**
  44786. * Sets the color of the bounding box gizmo
  44787. * @param color the color to set
  44788. */
  44789. setColor(color: Color3): void;
  44790. /**
  44791. * Creates an BoundingBoxGizmo
  44792. * @param gizmoLayer The utility layer the gizmo will be added to
  44793. * @param color The color of the gizmo
  44794. */
  44795. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44796. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44797. private _selectNode;
  44798. /**
  44799. * Updates the bounding box information for the Gizmo
  44800. */
  44801. updateBoundingBox(): void;
  44802. private _updateRotationSpheres;
  44803. private _updateScaleBoxes;
  44804. /**
  44805. * Enables rotation on the specified axis and disables rotation on the others
  44806. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44807. */
  44808. setEnabledRotationAxis(axis: string): void;
  44809. /**
  44810. * Enables/disables scaling
  44811. * @param enable if scaling should be enabled
  44812. */
  44813. setEnabledScaling(enable: boolean): void;
  44814. private _updateDummy;
  44815. /**
  44816. * Enables a pointer drag behavior on the bounding box of the gizmo
  44817. */
  44818. enableDragBehavior(): void;
  44819. /**
  44820. * Disposes of the gizmo
  44821. */
  44822. dispose(): void;
  44823. /**
  44824. * 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)
  44825. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44826. * @returns the bounding box mesh with the passed in mesh as a child
  44827. */
  44828. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44829. /**
  44830. * CustomMeshes are not supported by this gizmo
  44831. * @param mesh The mesh to replace the default mesh of the gizmo
  44832. */
  44833. setCustomMesh(mesh: Mesh): void;
  44834. }
  44835. }
  44836. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44837. import { Observable } from "babylonjs/Misc/observable";
  44838. import { Nullable } from "babylonjs/types";
  44839. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44841. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44842. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44843. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44844. import "babylonjs/Meshes/Builders/linesBuilder";
  44845. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44846. /**
  44847. * Single plane rotation gizmo
  44848. */
  44849. export class PlaneRotationGizmo extends Gizmo {
  44850. /**
  44851. * Drag behavior responsible for the gizmos dragging interactions
  44852. */
  44853. dragBehavior: PointerDragBehavior;
  44854. private _pointerObserver;
  44855. /**
  44856. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44857. */
  44858. snapDistance: number;
  44859. /**
  44860. * Event that fires each time the gizmo snaps to a new location.
  44861. * * snapDistance is the the change in distance
  44862. */
  44863. onSnapObservable: Observable<{
  44864. snapDistance: number;
  44865. }>;
  44866. private _isEnabled;
  44867. private _parent;
  44868. /**
  44869. * Creates a PlaneRotationGizmo
  44870. * @param gizmoLayer The utility layer the gizmo will be added to
  44871. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44872. * @param color The color of the gizmo
  44873. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44874. */
  44875. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  44876. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44877. /**
  44878. * If the gizmo is enabled
  44879. */
  44880. isEnabled: boolean;
  44881. /**
  44882. * Disposes of the gizmo
  44883. */
  44884. dispose(): void;
  44885. }
  44886. }
  44887. declare module "babylonjs/Gizmos/rotationGizmo" {
  44888. import { Observable } from "babylonjs/Misc/observable";
  44889. import { Nullable } from "babylonjs/types";
  44890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44891. import { Mesh } from "babylonjs/Meshes/mesh";
  44892. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44893. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44894. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44895. /**
  44896. * Gizmo that enables rotating a mesh along 3 axis
  44897. */
  44898. export class RotationGizmo extends Gizmo {
  44899. /**
  44900. * Internal gizmo used for interactions on the x axis
  44901. */
  44902. xGizmo: PlaneRotationGizmo;
  44903. /**
  44904. * Internal gizmo used for interactions on the y axis
  44905. */
  44906. yGizmo: PlaneRotationGizmo;
  44907. /**
  44908. * Internal gizmo used for interactions on the z axis
  44909. */
  44910. zGizmo: PlaneRotationGizmo;
  44911. /** Fires an event when any of it's sub gizmos are dragged */
  44912. onDragStartObservable: Observable<{}>;
  44913. /** Fires an event when any of it's sub gizmos are released from dragging */
  44914. onDragEndObservable: Observable<{}>;
  44915. private _meshAttached;
  44916. attachedMesh: Nullable<AbstractMesh>;
  44917. /**
  44918. * Creates a RotationGizmo
  44919. * @param gizmoLayer The utility layer the gizmo will be added to
  44920. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44921. */
  44922. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44923. updateGizmoRotationToMatchAttachedMesh: boolean;
  44924. /**
  44925. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44926. */
  44927. snapDistance: number;
  44928. /**
  44929. * Ratio for the scale of the gizmo (Default: 1)
  44930. */
  44931. scaleRatio: number;
  44932. /**
  44933. * Disposes of the gizmo
  44934. */
  44935. dispose(): void;
  44936. /**
  44937. * CustomMeshes are not supported by this gizmo
  44938. * @param mesh The mesh to replace the default mesh of the gizmo
  44939. */
  44940. setCustomMesh(mesh: Mesh): void;
  44941. }
  44942. }
  44943. declare module "babylonjs/Gizmos/gizmoManager" {
  44944. import { Observable } from "babylonjs/Misc/observable";
  44945. import { Nullable } from "babylonjs/types";
  44946. import { Scene, IDisposable } from "babylonjs/scene";
  44947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44948. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44949. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44950. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44951. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44952. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44953. /**
  44954. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44955. */
  44956. export class GizmoManager implements IDisposable {
  44957. private scene;
  44958. /**
  44959. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44960. */
  44961. gizmos: {
  44962. positionGizmo: Nullable<PositionGizmo>;
  44963. rotationGizmo: Nullable<RotationGizmo>;
  44964. scaleGizmo: Nullable<ScaleGizmo>;
  44965. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44966. };
  44967. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44968. clearGizmoOnEmptyPointerEvent: boolean;
  44969. /** Fires an event when the manager is attached to a mesh */
  44970. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44971. private _gizmosEnabled;
  44972. private _pointerObserver;
  44973. private _attachedMesh;
  44974. private _boundingBoxColor;
  44975. private _defaultUtilityLayer;
  44976. private _defaultKeepDepthUtilityLayer;
  44977. /**
  44978. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44979. */
  44980. boundingBoxDragBehavior: SixDofDragBehavior;
  44981. /**
  44982. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44983. */
  44984. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44985. /**
  44986. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44987. */
  44988. usePointerToAttachGizmos: boolean;
  44989. /**
  44990. * Instatiates a gizmo manager
  44991. * @param scene the scene to overlay the gizmos on top of
  44992. */
  44993. constructor(scene: Scene);
  44994. /**
  44995. * Attaches a set of gizmos to the specified mesh
  44996. * @param mesh The mesh the gizmo's should be attached to
  44997. */
  44998. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44999. /**
  45000. * If the position gizmo is enabled
  45001. */
  45002. positionGizmoEnabled: boolean;
  45003. /**
  45004. * If the rotation gizmo is enabled
  45005. */
  45006. rotationGizmoEnabled: boolean;
  45007. /**
  45008. * If the scale gizmo is enabled
  45009. */
  45010. scaleGizmoEnabled: boolean;
  45011. /**
  45012. * If the boundingBox gizmo is enabled
  45013. */
  45014. boundingBoxGizmoEnabled: boolean;
  45015. /**
  45016. * Disposes of the gizmo manager
  45017. */
  45018. dispose(): void;
  45019. }
  45020. }
  45021. declare module "babylonjs/Lights/directionalLight" {
  45022. import { Camera } from "babylonjs/Cameras/camera";
  45023. import { Scene } from "babylonjs/scene";
  45024. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45026. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45027. import { Effect } from "babylonjs/Materials/effect";
  45028. /**
  45029. * A directional light is defined by a direction (what a surprise!).
  45030. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45031. * 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.
  45032. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45033. */
  45034. export class DirectionalLight extends ShadowLight {
  45035. private _shadowFrustumSize;
  45036. /**
  45037. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45038. */
  45039. /**
  45040. * Specifies a fix frustum size for the shadow generation.
  45041. */
  45042. shadowFrustumSize: number;
  45043. private _shadowOrthoScale;
  45044. /**
  45045. * Gets the shadow projection scale against the optimal computed one.
  45046. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45047. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45048. */
  45049. /**
  45050. * Sets the shadow projection scale against the optimal computed one.
  45051. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45052. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45053. */
  45054. shadowOrthoScale: number;
  45055. /**
  45056. * Automatically compute the projection matrix to best fit (including all the casters)
  45057. * on each frame.
  45058. */
  45059. autoUpdateExtends: boolean;
  45060. private _orthoLeft;
  45061. private _orthoRight;
  45062. private _orthoTop;
  45063. private _orthoBottom;
  45064. /**
  45065. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45066. * The directional light is emitted from everywhere in the given direction.
  45067. * It can cast shadows.
  45068. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45069. * @param name The friendly name of the light
  45070. * @param direction The direction of the light
  45071. * @param scene The scene the light belongs to
  45072. */
  45073. constructor(name: string, direction: Vector3, scene: Scene);
  45074. /**
  45075. * Returns the string "DirectionalLight".
  45076. * @return The class name
  45077. */
  45078. getClassName(): string;
  45079. /**
  45080. * Returns the integer 1.
  45081. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45082. */
  45083. getTypeID(): number;
  45084. /**
  45085. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45086. * Returns the DirectionalLight Shadow projection matrix.
  45087. */
  45088. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45089. /**
  45090. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45091. * Returns the DirectionalLight Shadow projection matrix.
  45092. */
  45093. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45094. /**
  45095. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45096. * Returns the DirectionalLight Shadow projection matrix.
  45097. */
  45098. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45099. protected _buildUniformLayout(): void;
  45100. /**
  45101. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45102. * @param effect The effect to update
  45103. * @param lightIndex The index of the light in the effect to update
  45104. * @returns The directional light
  45105. */
  45106. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45107. /**
  45108. * Gets the minZ used for shadow according to both the scene and the light.
  45109. *
  45110. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45111. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45112. * @param activeCamera The camera we are returning the min for
  45113. * @returns the depth min z
  45114. */
  45115. getDepthMinZ(activeCamera: Camera): number;
  45116. /**
  45117. * Gets the maxZ used for shadow according to both the scene and the light.
  45118. *
  45119. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45120. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45121. * @param activeCamera The camera we are returning the max for
  45122. * @returns the depth max z
  45123. */
  45124. getDepthMaxZ(activeCamera: Camera): number;
  45125. /**
  45126. * Prepares the list of defines specific to the light type.
  45127. * @param defines the list of defines
  45128. * @param lightIndex defines the index of the light for the effect
  45129. */
  45130. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45131. }
  45132. }
  45133. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45134. import { Mesh } from "babylonjs/Meshes/mesh";
  45135. /**
  45136. * Class containing static functions to help procedurally build meshes
  45137. */
  45138. export class HemisphereBuilder {
  45139. /**
  45140. * Creates a hemisphere mesh
  45141. * @param name defines the name of the mesh
  45142. * @param options defines the options used to create the mesh
  45143. * @param scene defines the hosting scene
  45144. * @returns the hemisphere mesh
  45145. */
  45146. static CreateHemisphere(name: string, options: {
  45147. segments?: number;
  45148. diameter?: number;
  45149. sideOrientation?: number;
  45150. }, scene: any): Mesh;
  45151. }
  45152. }
  45153. declare module "babylonjs/Lights/spotLight" {
  45154. import { Nullable } from "babylonjs/types";
  45155. import { Scene } from "babylonjs/scene";
  45156. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45158. import { Effect } from "babylonjs/Materials/effect";
  45159. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45160. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45161. /**
  45162. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45163. * These values define a cone of light starting from the position, emitting toward the direction.
  45164. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45165. * and the exponent defines the speed of the decay of the light with distance (reach).
  45166. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45167. */
  45168. export class SpotLight extends ShadowLight {
  45169. private _angle;
  45170. private _innerAngle;
  45171. private _cosHalfAngle;
  45172. private _lightAngleScale;
  45173. private _lightAngleOffset;
  45174. /**
  45175. * Gets the cone angle of the spot light in Radians.
  45176. */
  45177. /**
  45178. * Sets the cone angle of the spot light in Radians.
  45179. */
  45180. angle: number;
  45181. /**
  45182. * Only used in gltf falloff mode, this defines the angle where
  45183. * the directional falloff will start before cutting at angle which could be seen
  45184. * as outer angle.
  45185. */
  45186. /**
  45187. * Only used in gltf falloff mode, this defines the angle where
  45188. * the directional falloff will start before cutting at angle which could be seen
  45189. * as outer angle.
  45190. */
  45191. innerAngle: number;
  45192. private _shadowAngleScale;
  45193. /**
  45194. * Allows scaling the angle of the light for shadow generation only.
  45195. */
  45196. /**
  45197. * Allows scaling the angle of the light for shadow generation only.
  45198. */
  45199. shadowAngleScale: number;
  45200. /**
  45201. * The light decay speed with the distance from the emission spot.
  45202. */
  45203. exponent: number;
  45204. private _projectionTextureMatrix;
  45205. /**
  45206. * Allows reading the projecton texture
  45207. */
  45208. readonly projectionTextureMatrix: Matrix;
  45209. protected _projectionTextureLightNear: number;
  45210. /**
  45211. * Gets the near clip of the Spotlight for texture projection.
  45212. */
  45213. /**
  45214. * Sets the near clip of the Spotlight for texture projection.
  45215. */
  45216. projectionTextureLightNear: number;
  45217. protected _projectionTextureLightFar: number;
  45218. /**
  45219. * Gets the far clip of the Spotlight for texture projection.
  45220. */
  45221. /**
  45222. * Sets the far clip of the Spotlight for texture projection.
  45223. */
  45224. projectionTextureLightFar: number;
  45225. protected _projectionTextureUpDirection: Vector3;
  45226. /**
  45227. * Gets the Up vector of the Spotlight for texture projection.
  45228. */
  45229. /**
  45230. * Sets the Up vector of the Spotlight for texture projection.
  45231. */
  45232. projectionTextureUpDirection: Vector3;
  45233. private _projectionTexture;
  45234. /**
  45235. * Gets the projection texture of the light.
  45236. */
  45237. /**
  45238. * Sets the projection texture of the light.
  45239. */
  45240. projectionTexture: Nullable<BaseTexture>;
  45241. private _projectionTextureViewLightDirty;
  45242. private _projectionTextureProjectionLightDirty;
  45243. private _projectionTextureDirty;
  45244. private _projectionTextureViewTargetVector;
  45245. private _projectionTextureViewLightMatrix;
  45246. private _projectionTextureProjectionLightMatrix;
  45247. private _projectionTextureScalingMatrix;
  45248. /**
  45249. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45250. * It can cast shadows.
  45251. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45252. * @param name The light friendly name
  45253. * @param position The position of the spot light in the scene
  45254. * @param direction The direction of the light in the scene
  45255. * @param angle The cone angle of the light in Radians
  45256. * @param exponent The light decay speed with the distance from the emission spot
  45257. * @param scene The scene the lights belongs to
  45258. */
  45259. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45260. /**
  45261. * Returns the string "SpotLight".
  45262. * @returns the class name
  45263. */
  45264. getClassName(): string;
  45265. /**
  45266. * Returns the integer 2.
  45267. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45268. */
  45269. getTypeID(): number;
  45270. /**
  45271. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45272. */
  45273. protected _setDirection(value: Vector3): void;
  45274. /**
  45275. * Overrides the position setter to recompute the projection texture view light Matrix.
  45276. */
  45277. protected _setPosition(value: Vector3): void;
  45278. /**
  45279. * 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.
  45280. * Returns the SpotLight.
  45281. */
  45282. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45283. protected _computeProjectionTextureViewLightMatrix(): void;
  45284. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45285. /**
  45286. * Main function for light texture projection matrix computing.
  45287. */
  45288. protected _computeProjectionTextureMatrix(): void;
  45289. protected _buildUniformLayout(): void;
  45290. private _computeAngleValues;
  45291. /**
  45292. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45293. * @param effect The effect to update
  45294. * @param lightIndex The index of the light in the effect to update
  45295. * @returns The spot light
  45296. */
  45297. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45298. /**
  45299. * Disposes the light and the associated resources.
  45300. */
  45301. dispose(): void;
  45302. /**
  45303. * Prepares the list of defines specific to the light type.
  45304. * @param defines the list of defines
  45305. * @param lightIndex defines the index of the light for the effect
  45306. */
  45307. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45308. }
  45309. }
  45310. declare module "babylonjs/Gizmos/lightGizmo" {
  45311. import { Nullable } from "babylonjs/types";
  45312. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45313. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45314. import { Light } from "babylonjs/Lights/light";
  45315. /**
  45316. * Gizmo that enables viewing a light
  45317. */
  45318. export class LightGizmo extends Gizmo {
  45319. private _lightMesh;
  45320. private _material;
  45321. private cachedPosition;
  45322. private cachedForward;
  45323. /**
  45324. * Creates a LightGizmo
  45325. * @param gizmoLayer The utility layer the gizmo will be added to
  45326. */
  45327. constructor(gizmoLayer?: UtilityLayerRenderer);
  45328. private _light;
  45329. /**
  45330. * The light that the gizmo is attached to
  45331. */
  45332. light: Nullable<Light>;
  45333. /**
  45334. * @hidden
  45335. * Updates the gizmo to match the attached mesh's position/rotation
  45336. */
  45337. protected _update(): void;
  45338. private static _Scale;
  45339. /**
  45340. * Creates the lines for a light mesh
  45341. */
  45342. private static _createLightLines;
  45343. /**
  45344. * Disposes of the light gizmo
  45345. */
  45346. dispose(): void;
  45347. private static _CreateHemisphericLightMesh;
  45348. private static _CreatePointLightMesh;
  45349. private static _CreateSpotLightMesh;
  45350. private static _CreateDirectionalLightMesh;
  45351. }
  45352. }
  45353. declare module "babylonjs/Gizmos/index" {
  45354. export * from "babylonjs/Gizmos/axisDragGizmo";
  45355. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45356. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45357. export * from "babylonjs/Gizmos/gizmo";
  45358. export * from "babylonjs/Gizmos/gizmoManager";
  45359. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45360. export * from "babylonjs/Gizmos/positionGizmo";
  45361. export * from "babylonjs/Gizmos/rotationGizmo";
  45362. export * from "babylonjs/Gizmos/scaleGizmo";
  45363. export * from "babylonjs/Gizmos/lightGizmo";
  45364. }
  45365. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45366. /** @hidden */
  45367. export var backgroundFragmentDeclaration: {
  45368. name: string;
  45369. shader: string;
  45370. };
  45371. }
  45372. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45373. /** @hidden */
  45374. export var backgroundUboDeclaration: {
  45375. name: string;
  45376. shader: string;
  45377. };
  45378. }
  45379. declare module "babylonjs/Shaders/background.fragment" {
  45380. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45381. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45382. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45383. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45384. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45385. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45386. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45387. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45388. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45389. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45390. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45391. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45392. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45393. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45394. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45395. /** @hidden */
  45396. export var backgroundPixelShader: {
  45397. name: string;
  45398. shader: string;
  45399. };
  45400. }
  45401. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45402. /** @hidden */
  45403. export var backgroundVertexDeclaration: {
  45404. name: string;
  45405. shader: string;
  45406. };
  45407. }
  45408. declare module "babylonjs/Shaders/background.vertex" {
  45409. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45410. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45411. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45412. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45413. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45414. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45415. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45416. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45417. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45418. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45419. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45420. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45421. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45422. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45423. /** @hidden */
  45424. export var backgroundVertexShader: {
  45425. name: string;
  45426. shader: string;
  45427. };
  45428. }
  45429. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45430. import { Nullable, int, float } from "babylonjs/types";
  45431. import { Scene } from "babylonjs/scene";
  45432. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45433. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45435. import { Mesh } from "babylonjs/Meshes/mesh";
  45436. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45437. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45438. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45439. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45440. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45441. import "babylonjs/Shaders/background.fragment";
  45442. import "babylonjs/Shaders/background.vertex";
  45443. /**
  45444. * Background material used to create an efficient environement around your scene.
  45445. */
  45446. export class BackgroundMaterial extends PushMaterial {
  45447. /**
  45448. * Standard reflectance value at parallel view angle.
  45449. */
  45450. static StandardReflectance0: number;
  45451. /**
  45452. * Standard reflectance value at grazing angle.
  45453. */
  45454. static StandardReflectance90: number;
  45455. protected _primaryColor: Color3;
  45456. /**
  45457. * Key light Color (multiply against the environement texture)
  45458. */
  45459. primaryColor: Color3;
  45460. protected __perceptualColor: Nullable<Color3>;
  45461. /**
  45462. * Experimental Internal Use Only.
  45463. *
  45464. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45465. * This acts as a helper to set the primary color to a more "human friendly" value.
  45466. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45467. * output color as close as possible from the chosen value.
  45468. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45469. * part of lighting setup.)
  45470. */
  45471. _perceptualColor: Nullable<Color3>;
  45472. protected _primaryColorShadowLevel: float;
  45473. /**
  45474. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45475. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45476. */
  45477. primaryColorShadowLevel: float;
  45478. protected _primaryColorHighlightLevel: float;
  45479. /**
  45480. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45481. * The primary color is used at the level chosen to define what the white area would look.
  45482. */
  45483. primaryColorHighlightLevel: float;
  45484. protected _reflectionTexture: Nullable<BaseTexture>;
  45485. /**
  45486. * Reflection Texture used in the material.
  45487. * Should be author in a specific way for the best result (refer to the documentation).
  45488. */
  45489. reflectionTexture: Nullable<BaseTexture>;
  45490. protected _reflectionBlur: float;
  45491. /**
  45492. * Reflection Texture level of blur.
  45493. *
  45494. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45495. * texture twice.
  45496. */
  45497. reflectionBlur: float;
  45498. protected _diffuseTexture: Nullable<BaseTexture>;
  45499. /**
  45500. * Diffuse Texture used in the material.
  45501. * Should be author in a specific way for the best result (refer to the documentation).
  45502. */
  45503. diffuseTexture: Nullable<BaseTexture>;
  45504. protected _shadowLights: Nullable<IShadowLight[]>;
  45505. /**
  45506. * Specify the list of lights casting shadow on the material.
  45507. * All scene shadow lights will be included if null.
  45508. */
  45509. shadowLights: Nullable<IShadowLight[]>;
  45510. protected _shadowLevel: float;
  45511. /**
  45512. * Helps adjusting the shadow to a softer level if required.
  45513. * 0 means black shadows and 1 means no shadows.
  45514. */
  45515. shadowLevel: float;
  45516. protected _sceneCenter: Vector3;
  45517. /**
  45518. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45519. * It is usually zero but might be interesting to modify according to your setup.
  45520. */
  45521. sceneCenter: Vector3;
  45522. protected _opacityFresnel: boolean;
  45523. /**
  45524. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45525. * This helps ensuring a nice transition when the camera goes under the ground.
  45526. */
  45527. opacityFresnel: boolean;
  45528. protected _reflectionFresnel: boolean;
  45529. /**
  45530. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45531. * This helps adding a mirror texture on the ground.
  45532. */
  45533. reflectionFresnel: boolean;
  45534. protected _reflectionFalloffDistance: number;
  45535. /**
  45536. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45537. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45538. */
  45539. reflectionFalloffDistance: number;
  45540. protected _reflectionAmount: number;
  45541. /**
  45542. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45543. */
  45544. reflectionAmount: number;
  45545. protected _reflectionReflectance0: number;
  45546. /**
  45547. * This specifies the weight of the reflection at grazing angle.
  45548. */
  45549. reflectionReflectance0: number;
  45550. protected _reflectionReflectance90: number;
  45551. /**
  45552. * This specifies the weight of the reflection at a perpendicular point of view.
  45553. */
  45554. reflectionReflectance90: number;
  45555. /**
  45556. * Sets the reflection reflectance fresnel values according to the default standard
  45557. * empirically know to work well :-)
  45558. */
  45559. reflectionStandardFresnelWeight: number;
  45560. protected _useRGBColor: boolean;
  45561. /**
  45562. * Helps to directly use the maps channels instead of their level.
  45563. */
  45564. useRGBColor: boolean;
  45565. protected _enableNoise: boolean;
  45566. /**
  45567. * This helps reducing the banding effect that could occur on the background.
  45568. */
  45569. enableNoise: boolean;
  45570. /**
  45571. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45572. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45573. * Recommended to be keep at 1.0 except for special cases.
  45574. */
  45575. fovMultiplier: number;
  45576. private _fovMultiplier;
  45577. /**
  45578. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45579. */
  45580. useEquirectangularFOV: boolean;
  45581. private _maxSimultaneousLights;
  45582. /**
  45583. * Number of Simultaneous lights allowed on the material.
  45584. */
  45585. maxSimultaneousLights: int;
  45586. /**
  45587. * Default configuration related to image processing available in the Background Material.
  45588. */
  45589. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45590. /**
  45591. * Keep track of the image processing observer to allow dispose and replace.
  45592. */
  45593. private _imageProcessingObserver;
  45594. /**
  45595. * Attaches a new image processing configuration to the PBR Material.
  45596. * @param configuration (if null the scene configuration will be use)
  45597. */
  45598. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45599. /**
  45600. * Gets the image processing configuration used either in this material.
  45601. */
  45602. /**
  45603. * Sets the Default image processing configuration used either in the this material.
  45604. *
  45605. * If sets to null, the scene one is in use.
  45606. */
  45607. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45608. /**
  45609. * Gets wether the color curves effect is enabled.
  45610. */
  45611. /**
  45612. * Sets wether the color curves effect is enabled.
  45613. */
  45614. cameraColorCurvesEnabled: boolean;
  45615. /**
  45616. * Gets wether the color grading effect is enabled.
  45617. */
  45618. /**
  45619. * Gets wether the color grading effect is enabled.
  45620. */
  45621. cameraColorGradingEnabled: boolean;
  45622. /**
  45623. * Gets wether tonemapping is enabled or not.
  45624. */
  45625. /**
  45626. * Sets wether tonemapping is enabled or not
  45627. */
  45628. cameraToneMappingEnabled: boolean;
  45629. /**
  45630. * The camera exposure used on this material.
  45631. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45632. * This corresponds to a photographic exposure.
  45633. */
  45634. /**
  45635. * The camera exposure used on this material.
  45636. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45637. * This corresponds to a photographic exposure.
  45638. */
  45639. cameraExposure: float;
  45640. /**
  45641. * Gets The camera contrast used on this material.
  45642. */
  45643. /**
  45644. * Sets The camera contrast used on this material.
  45645. */
  45646. cameraContrast: float;
  45647. /**
  45648. * Gets the Color Grading 2D Lookup Texture.
  45649. */
  45650. /**
  45651. * Sets the Color Grading 2D Lookup Texture.
  45652. */
  45653. cameraColorGradingTexture: Nullable<BaseTexture>;
  45654. /**
  45655. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45656. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45657. * 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;
  45658. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45659. */
  45660. /**
  45661. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45662. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45663. * 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;
  45664. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45665. */
  45666. cameraColorCurves: Nullable<ColorCurves>;
  45667. /**
  45668. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45669. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45670. */
  45671. switchToBGR: boolean;
  45672. private _renderTargets;
  45673. private _reflectionControls;
  45674. private _white;
  45675. private _primaryShadowColor;
  45676. private _primaryHighlightColor;
  45677. /**
  45678. * Instantiates a Background Material in the given scene
  45679. * @param name The friendly name of the material
  45680. * @param scene The scene to add the material to
  45681. */
  45682. constructor(name: string, scene: Scene);
  45683. /**
  45684. * Gets a boolean indicating that current material needs to register RTT
  45685. */
  45686. readonly hasRenderTargetTextures: boolean;
  45687. /**
  45688. * The entire material has been created in order to prevent overdraw.
  45689. * @returns false
  45690. */
  45691. needAlphaTesting(): boolean;
  45692. /**
  45693. * The entire material has been created in order to prevent overdraw.
  45694. * @returns true if blending is enable
  45695. */
  45696. needAlphaBlending(): boolean;
  45697. /**
  45698. * Checks wether the material is ready to be rendered for a given mesh.
  45699. * @param mesh The mesh to render
  45700. * @param subMesh The submesh to check against
  45701. * @param useInstances Specify wether or not the material is used with instances
  45702. * @returns true if all the dependencies are ready (Textures, Effects...)
  45703. */
  45704. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45705. /**
  45706. * Compute the primary color according to the chosen perceptual color.
  45707. */
  45708. private _computePrimaryColorFromPerceptualColor;
  45709. /**
  45710. * Compute the highlights and shadow colors according to their chosen levels.
  45711. */
  45712. private _computePrimaryColors;
  45713. /**
  45714. * Build the uniform buffer used in the material.
  45715. */
  45716. buildUniformLayout(): void;
  45717. /**
  45718. * Unbind the material.
  45719. */
  45720. unbind(): void;
  45721. /**
  45722. * Bind only the world matrix to the material.
  45723. * @param world The world matrix to bind.
  45724. */
  45725. bindOnlyWorldMatrix(world: Matrix): void;
  45726. /**
  45727. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45728. * @param world The world matrix to bind.
  45729. * @param subMesh The submesh to bind for.
  45730. */
  45731. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45732. /**
  45733. * Dispose the material.
  45734. * @param forceDisposeEffect Force disposal of the associated effect.
  45735. * @param forceDisposeTextures Force disposal of the associated textures.
  45736. */
  45737. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45738. /**
  45739. * Clones the material.
  45740. * @param name The cloned name.
  45741. * @returns The cloned material.
  45742. */
  45743. clone(name: string): BackgroundMaterial;
  45744. /**
  45745. * Serializes the current material to its JSON representation.
  45746. * @returns The JSON representation.
  45747. */
  45748. serialize(): any;
  45749. /**
  45750. * Gets the class name of the material
  45751. * @returns "BackgroundMaterial"
  45752. */
  45753. getClassName(): string;
  45754. /**
  45755. * Parse a JSON input to create back a background material.
  45756. * @param source The JSON data to parse
  45757. * @param scene The scene to create the parsed material in
  45758. * @param rootUrl The root url of the assets the material depends upon
  45759. * @returns the instantiated BackgroundMaterial.
  45760. */
  45761. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45762. }
  45763. }
  45764. declare module "babylonjs/Helpers/environmentHelper" {
  45765. import { Observable } from "babylonjs/Misc/observable";
  45766. import { Nullable } from "babylonjs/types";
  45767. import { Scene } from "babylonjs/scene";
  45768. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45770. import { Mesh } from "babylonjs/Meshes/mesh";
  45771. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45772. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45773. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45774. import "babylonjs/Meshes/Builders/planeBuilder";
  45775. import "babylonjs/Meshes/Builders/boxBuilder";
  45776. /**
  45777. * Represents the different options available during the creation of
  45778. * a Environment helper.
  45779. *
  45780. * This can control the default ground, skybox and image processing setup of your scene.
  45781. */
  45782. export interface IEnvironmentHelperOptions {
  45783. /**
  45784. * Specifies wether or not to create a ground.
  45785. * True by default.
  45786. */
  45787. createGround: boolean;
  45788. /**
  45789. * Specifies the ground size.
  45790. * 15 by default.
  45791. */
  45792. groundSize: number;
  45793. /**
  45794. * The texture used on the ground for the main color.
  45795. * Comes from the BabylonJS CDN by default.
  45796. *
  45797. * Remarks: Can be either a texture or a url.
  45798. */
  45799. groundTexture: string | BaseTexture;
  45800. /**
  45801. * The color mixed in the ground texture by default.
  45802. * BabylonJS clearColor by default.
  45803. */
  45804. groundColor: Color3;
  45805. /**
  45806. * Specifies the ground opacity.
  45807. * 1 by default.
  45808. */
  45809. groundOpacity: number;
  45810. /**
  45811. * Enables the ground to receive shadows.
  45812. * True by default.
  45813. */
  45814. enableGroundShadow: boolean;
  45815. /**
  45816. * Helps preventing the shadow to be fully black on the ground.
  45817. * 0.5 by default.
  45818. */
  45819. groundShadowLevel: number;
  45820. /**
  45821. * Creates a mirror texture attach to the ground.
  45822. * false by default.
  45823. */
  45824. enableGroundMirror: boolean;
  45825. /**
  45826. * Specifies the ground mirror size ratio.
  45827. * 0.3 by default as the default kernel is 64.
  45828. */
  45829. groundMirrorSizeRatio: number;
  45830. /**
  45831. * Specifies the ground mirror blur kernel size.
  45832. * 64 by default.
  45833. */
  45834. groundMirrorBlurKernel: number;
  45835. /**
  45836. * Specifies the ground mirror visibility amount.
  45837. * 1 by default
  45838. */
  45839. groundMirrorAmount: number;
  45840. /**
  45841. * Specifies the ground mirror reflectance weight.
  45842. * This uses the standard weight of the background material to setup the fresnel effect
  45843. * of the mirror.
  45844. * 1 by default.
  45845. */
  45846. groundMirrorFresnelWeight: number;
  45847. /**
  45848. * Specifies the ground mirror Falloff distance.
  45849. * This can helps reducing the size of the reflection.
  45850. * 0 by Default.
  45851. */
  45852. groundMirrorFallOffDistance: number;
  45853. /**
  45854. * Specifies the ground mirror texture type.
  45855. * Unsigned Int by Default.
  45856. */
  45857. groundMirrorTextureType: number;
  45858. /**
  45859. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45860. * the shown objects.
  45861. */
  45862. groundYBias: number;
  45863. /**
  45864. * Specifies wether or not to create a skybox.
  45865. * True by default.
  45866. */
  45867. createSkybox: boolean;
  45868. /**
  45869. * Specifies the skybox size.
  45870. * 20 by default.
  45871. */
  45872. skyboxSize: number;
  45873. /**
  45874. * The texture used on the skybox for the main color.
  45875. * Comes from the BabylonJS CDN by default.
  45876. *
  45877. * Remarks: Can be either a texture or a url.
  45878. */
  45879. skyboxTexture: string | BaseTexture;
  45880. /**
  45881. * The color mixed in the skybox texture by default.
  45882. * BabylonJS clearColor by default.
  45883. */
  45884. skyboxColor: Color3;
  45885. /**
  45886. * The background rotation around the Y axis of the scene.
  45887. * This helps aligning the key lights of your scene with the background.
  45888. * 0 by default.
  45889. */
  45890. backgroundYRotation: number;
  45891. /**
  45892. * Compute automatically the size of the elements to best fit with the scene.
  45893. */
  45894. sizeAuto: boolean;
  45895. /**
  45896. * Default position of the rootMesh if autoSize is not true.
  45897. */
  45898. rootPosition: Vector3;
  45899. /**
  45900. * Sets up the image processing in the scene.
  45901. * true by default.
  45902. */
  45903. setupImageProcessing: boolean;
  45904. /**
  45905. * The texture used as your environment texture in the scene.
  45906. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45907. *
  45908. * Remarks: Can be either a texture or a url.
  45909. */
  45910. environmentTexture: string | BaseTexture;
  45911. /**
  45912. * The value of the exposure to apply to the scene.
  45913. * 0.6 by default if setupImageProcessing is true.
  45914. */
  45915. cameraExposure: number;
  45916. /**
  45917. * The value of the contrast to apply to the scene.
  45918. * 1.6 by default if setupImageProcessing is true.
  45919. */
  45920. cameraContrast: number;
  45921. /**
  45922. * Specifies wether or not tonemapping should be enabled in the scene.
  45923. * true by default if setupImageProcessing is true.
  45924. */
  45925. toneMappingEnabled: boolean;
  45926. }
  45927. /**
  45928. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45929. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45930. * It also helps with the default setup of your imageProcessing configuration.
  45931. */
  45932. export class EnvironmentHelper {
  45933. /**
  45934. * Default ground texture URL.
  45935. */
  45936. private static _groundTextureCDNUrl;
  45937. /**
  45938. * Default skybox texture URL.
  45939. */
  45940. private static _skyboxTextureCDNUrl;
  45941. /**
  45942. * Default environment texture URL.
  45943. */
  45944. private static _environmentTextureCDNUrl;
  45945. /**
  45946. * Creates the default options for the helper.
  45947. */
  45948. private static _getDefaultOptions;
  45949. private _rootMesh;
  45950. /**
  45951. * Gets the root mesh created by the helper.
  45952. */
  45953. readonly rootMesh: Mesh;
  45954. private _skybox;
  45955. /**
  45956. * Gets the skybox created by the helper.
  45957. */
  45958. readonly skybox: Nullable<Mesh>;
  45959. private _skyboxTexture;
  45960. /**
  45961. * Gets the skybox texture created by the helper.
  45962. */
  45963. readonly skyboxTexture: Nullable<BaseTexture>;
  45964. private _skyboxMaterial;
  45965. /**
  45966. * Gets the skybox material created by the helper.
  45967. */
  45968. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45969. private _ground;
  45970. /**
  45971. * Gets the ground mesh created by the helper.
  45972. */
  45973. readonly ground: Nullable<Mesh>;
  45974. private _groundTexture;
  45975. /**
  45976. * Gets the ground texture created by the helper.
  45977. */
  45978. readonly groundTexture: Nullable<BaseTexture>;
  45979. private _groundMirror;
  45980. /**
  45981. * Gets the ground mirror created by the helper.
  45982. */
  45983. readonly groundMirror: Nullable<MirrorTexture>;
  45984. /**
  45985. * Gets the ground mirror render list to helps pushing the meshes
  45986. * you wish in the ground reflection.
  45987. */
  45988. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45989. private _groundMaterial;
  45990. /**
  45991. * Gets the ground material created by the helper.
  45992. */
  45993. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45994. /**
  45995. * Stores the creation options.
  45996. */
  45997. private readonly _scene;
  45998. private _options;
  45999. /**
  46000. * This observable will be notified with any error during the creation of the environment,
  46001. * mainly texture creation errors.
  46002. */
  46003. onErrorObservable: Observable<{
  46004. message?: string;
  46005. exception?: any;
  46006. }>;
  46007. /**
  46008. * constructor
  46009. * @param options Defines the options we want to customize the helper
  46010. * @param scene The scene to add the material to
  46011. */
  46012. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46013. /**
  46014. * Updates the background according to the new options
  46015. * @param options
  46016. */
  46017. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46018. /**
  46019. * Sets the primary color of all the available elements.
  46020. * @param color the main color to affect to the ground and the background
  46021. */
  46022. setMainColor(color: Color3): void;
  46023. /**
  46024. * Setup the image processing according to the specified options.
  46025. */
  46026. private _setupImageProcessing;
  46027. /**
  46028. * Setup the environment texture according to the specified options.
  46029. */
  46030. private _setupEnvironmentTexture;
  46031. /**
  46032. * Setup the background according to the specified options.
  46033. */
  46034. private _setupBackground;
  46035. /**
  46036. * Get the scene sizes according to the setup.
  46037. */
  46038. private _getSceneSize;
  46039. /**
  46040. * Setup the ground according to the specified options.
  46041. */
  46042. private _setupGround;
  46043. /**
  46044. * Setup the ground material according to the specified options.
  46045. */
  46046. private _setupGroundMaterial;
  46047. /**
  46048. * Setup the ground diffuse texture according to the specified options.
  46049. */
  46050. private _setupGroundDiffuseTexture;
  46051. /**
  46052. * Setup the ground mirror texture according to the specified options.
  46053. */
  46054. private _setupGroundMirrorTexture;
  46055. /**
  46056. * Setup the ground to receive the mirror texture.
  46057. */
  46058. private _setupMirrorInGroundMaterial;
  46059. /**
  46060. * Setup the skybox according to the specified options.
  46061. */
  46062. private _setupSkybox;
  46063. /**
  46064. * Setup the skybox material according to the specified options.
  46065. */
  46066. private _setupSkyboxMaterial;
  46067. /**
  46068. * Setup the skybox reflection texture according to the specified options.
  46069. */
  46070. private _setupSkyboxReflectionTexture;
  46071. private _errorHandler;
  46072. /**
  46073. * Dispose all the elements created by the Helper.
  46074. */
  46075. dispose(): void;
  46076. }
  46077. }
  46078. declare module "babylonjs/Helpers/photoDome" {
  46079. import { Observable } from "babylonjs/Misc/observable";
  46080. import { Nullable } from "babylonjs/types";
  46081. import { Scene } from "babylonjs/scene";
  46082. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46083. import { Mesh } from "babylonjs/Meshes/mesh";
  46084. import { Texture } from "babylonjs/Materials/Textures/texture";
  46085. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46086. import "babylonjs/Meshes/Builders/sphereBuilder";
  46087. /**
  46088. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46089. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46090. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46091. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46092. */
  46093. export class PhotoDome extends TransformNode {
  46094. /**
  46095. * Define the image as a Monoscopic panoramic 360 image.
  46096. */
  46097. static readonly MODE_MONOSCOPIC: number;
  46098. /**
  46099. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46100. */
  46101. static readonly MODE_TOPBOTTOM: number;
  46102. /**
  46103. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46104. */
  46105. static readonly MODE_SIDEBYSIDE: number;
  46106. private _useDirectMapping;
  46107. /**
  46108. * The texture being displayed on the sphere
  46109. */
  46110. protected _photoTexture: Texture;
  46111. /**
  46112. * Gets or sets the texture being displayed on the sphere
  46113. */
  46114. photoTexture: Texture;
  46115. /**
  46116. * Observable raised when an error occured while loading the 360 image
  46117. */
  46118. onLoadErrorObservable: Observable<string>;
  46119. /**
  46120. * The skybox material
  46121. */
  46122. protected _material: BackgroundMaterial;
  46123. /**
  46124. * The surface used for the skybox
  46125. */
  46126. protected _mesh: Mesh;
  46127. /**
  46128. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46129. * Also see the options.resolution property.
  46130. */
  46131. fovMultiplier: number;
  46132. private _imageMode;
  46133. /**
  46134. * Gets or set the current video mode for the video. It can be:
  46135. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46136. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46137. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46138. */
  46139. imageMode: number;
  46140. /**
  46141. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46142. * @param name Element's name, child elements will append suffixes for their own names.
  46143. * @param urlsOfPhoto defines the url of the photo to display
  46144. * @param options defines an object containing optional or exposed sub element properties
  46145. * @param onError defines a callback called when an error occured while loading the texture
  46146. */
  46147. constructor(name: string, urlOfPhoto: string, options: {
  46148. resolution?: number;
  46149. size?: number;
  46150. useDirectMapping?: boolean;
  46151. faceForward?: boolean;
  46152. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46153. private _onBeforeCameraRenderObserver;
  46154. private _changeImageMode;
  46155. /**
  46156. * Releases resources associated with this node.
  46157. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46158. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46159. */
  46160. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46161. }
  46162. }
  46163. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46164. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46165. /** @hidden */
  46166. export var rgbdDecodePixelShader: {
  46167. name: string;
  46168. shader: string;
  46169. };
  46170. }
  46171. declare module "babylonjs/Misc/brdfTextureTools" {
  46172. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46173. import { Scene } from "babylonjs/scene";
  46174. import "babylonjs/Shaders/rgbdDecode.fragment";
  46175. /**
  46176. * Class used to host texture specific utilities
  46177. */
  46178. export class BRDFTextureTools {
  46179. /**
  46180. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46181. * @param texture the texture to expand.
  46182. */
  46183. private static _ExpandDefaultBRDFTexture;
  46184. /**
  46185. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46186. * @param scene defines the hosting scene
  46187. * @returns the environment BRDF texture
  46188. */
  46189. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46190. private static _environmentBRDFBase64Texture;
  46191. }
  46192. }
  46193. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46194. import { Nullable } from "babylonjs/types";
  46195. import { IAnimatable } from "babylonjs/Misc/tools";
  46196. import { Color3 } from "babylonjs/Maths/math";
  46197. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46198. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46199. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46200. import { Engine } from "babylonjs/Engines/engine";
  46201. import { Scene } from "babylonjs/scene";
  46202. /**
  46203. * @hidden
  46204. */
  46205. export interface IMaterialClearCoatDefines {
  46206. CLEARCOAT: boolean;
  46207. CLEARCOAT_DEFAULTIOR: boolean;
  46208. CLEARCOAT_TEXTURE: boolean;
  46209. CLEARCOAT_TEXTUREDIRECTUV: number;
  46210. CLEARCOAT_BUMP: boolean;
  46211. CLEARCOAT_BUMPDIRECTUV: number;
  46212. CLEARCOAT_TINT: boolean;
  46213. CLEARCOAT_TINT_TEXTURE: boolean;
  46214. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46215. /** @hidden */
  46216. _areTexturesDirty: boolean;
  46217. }
  46218. /**
  46219. * Define the code related to the clear coat parameters of the pbr material.
  46220. */
  46221. export class PBRClearCoatConfiguration {
  46222. /**
  46223. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46224. * The default fits with a polyurethane material.
  46225. */
  46226. private static readonly _DefaultIndiceOfRefraction;
  46227. private _isEnabled;
  46228. /**
  46229. * Defines if the clear coat is enabled in the material.
  46230. */
  46231. isEnabled: boolean;
  46232. /**
  46233. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46234. */
  46235. intensity: number;
  46236. /**
  46237. * Defines the clear coat layer roughness.
  46238. */
  46239. roughness: number;
  46240. private _indiceOfRefraction;
  46241. /**
  46242. * Defines the indice of refraction of the clear coat.
  46243. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46244. * The default fits with a polyurethane material.
  46245. * Changing the default value is more performance intensive.
  46246. */
  46247. indiceOfRefraction: number;
  46248. private _texture;
  46249. /**
  46250. * Stores the clear coat values in a texture.
  46251. */
  46252. texture: Nullable<BaseTexture>;
  46253. private _bumpTexture;
  46254. /**
  46255. * Define the clear coat specific bump texture.
  46256. */
  46257. bumpTexture: Nullable<BaseTexture>;
  46258. private _isTintEnabled;
  46259. /**
  46260. * Defines if the clear coat tint is enabled in the material.
  46261. */
  46262. isTintEnabled: boolean;
  46263. /**
  46264. * Defines the clear coat tint of the material.
  46265. * This is only use if tint is enabled
  46266. */
  46267. tintColor: Color3;
  46268. /**
  46269. * Defines the distance at which the tint color should be found in the
  46270. * clear coat media.
  46271. * This is only use if tint is enabled
  46272. */
  46273. tintColorAtDistance: number;
  46274. /**
  46275. * Defines the clear coat layer thickness.
  46276. * This is only use if tint is enabled
  46277. */
  46278. tintThickness: number;
  46279. private _tintTexture;
  46280. /**
  46281. * Stores the clear tint values in a texture.
  46282. * rgb is tint
  46283. * a is a thickness factor
  46284. */
  46285. tintTexture: Nullable<BaseTexture>;
  46286. /** @hidden */
  46287. private _internalMarkAllSubMeshesAsTexturesDirty;
  46288. /** @hidden */
  46289. _markAllSubMeshesAsTexturesDirty(): void;
  46290. /**
  46291. * Instantiate a new istance of clear coat configuration.
  46292. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46293. */
  46294. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46295. /**
  46296. * Gets wehter the submesh is ready to be used or not.
  46297. * @param defines the list of "defines" to update.
  46298. * @param scene defines the scene the material belongs to.
  46299. * @param engine defines the engine the material belongs to.
  46300. * @param disableBumpMap defines wether the material disables bump or not.
  46301. * @returns - boolean indicating that the submesh is ready or not.
  46302. */
  46303. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46304. /**
  46305. * Checks to see if a texture is used in the material.
  46306. * @param defines the list of "defines" to update.
  46307. * @param scene defines the scene to the material belongs to.
  46308. */
  46309. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46310. /**
  46311. * Binds the material data.
  46312. * @param uniformBuffer defines the Uniform buffer to fill in.
  46313. * @param scene defines the scene the material belongs to.
  46314. * @param engine defines the engine the material belongs to.
  46315. * @param disableBumpMap defines wether the material disables bump or not.
  46316. * @param isFrozen defines wether the material is frozen or not.
  46317. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46318. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46319. */
  46320. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46321. /**
  46322. * Checks to see if a texture is used in the material.
  46323. * @param texture - Base texture to use.
  46324. * @returns - Boolean specifying if a texture is used in the material.
  46325. */
  46326. hasTexture(texture: BaseTexture): boolean;
  46327. /**
  46328. * Returns an array of the actively used textures.
  46329. * @param activeTextures Array of BaseTextures
  46330. */
  46331. getActiveTextures(activeTextures: BaseTexture[]): void;
  46332. /**
  46333. * Returns the animatable textures.
  46334. * @param animatables Array of animatable textures.
  46335. */
  46336. getAnimatables(animatables: IAnimatable[]): void;
  46337. /**
  46338. * Disposes the resources of the material.
  46339. * @param forceDisposeTextures - Forces the disposal of all textures.
  46340. */
  46341. dispose(forceDisposeTextures?: boolean): void;
  46342. /**
  46343. * Get the current class name of the texture useful for serialization or dynamic coding.
  46344. * @returns "PBRClearCoatConfiguration"
  46345. */
  46346. getClassName(): string;
  46347. /**
  46348. * Add fallbacks to the effect fallbacks list.
  46349. * @param defines defines the Base texture to use.
  46350. * @param fallbacks defines the current fallback list.
  46351. * @param currentRank defines the current fallback rank.
  46352. * @returns the new fallback rank.
  46353. */
  46354. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46355. /**
  46356. * Add the required uniforms to the current list.
  46357. * @param uniforms defines the current uniform list.
  46358. */
  46359. static AddUniforms(uniforms: string[]): void;
  46360. /**
  46361. * Add the required samplers to the current list.
  46362. * @param samplers defines the current sampler list.
  46363. */
  46364. static AddSamplers(samplers: string[]): void;
  46365. /**
  46366. * Add the required uniforms to the current buffer.
  46367. * @param uniformBuffer defines the current uniform buffer.
  46368. */
  46369. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46370. /**
  46371. * Makes a duplicate of the current configuration into another one.
  46372. * @param clearCoatConfiguration define the config where to copy the info
  46373. */
  46374. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46375. /**
  46376. * Serializes this clear coat configuration.
  46377. * @returns - An object with the serialized config.
  46378. */
  46379. serialize(): any;
  46380. /**
  46381. * Parses a Clear Coat Configuration from a serialized object.
  46382. * @param source - Serialized object.
  46383. */
  46384. parse(source: any): void;
  46385. }
  46386. }
  46387. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46388. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46389. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46391. import { Vector2 } from "babylonjs/Maths/math";
  46392. import { Scene } from "babylonjs/scene";
  46393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46394. import { IAnimatable } from "babylonjs/Misc/tools";
  46395. import { Nullable } from "babylonjs/types";
  46396. /**
  46397. * @hidden
  46398. */
  46399. export interface IMaterialAnisotropicDefines {
  46400. ANISOTROPIC: boolean;
  46401. ANISOTROPIC_TEXTURE: boolean;
  46402. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46403. MAINUV1: boolean;
  46404. _areTexturesDirty: boolean;
  46405. _needUVs: boolean;
  46406. }
  46407. /**
  46408. * Define the code related to the anisotropic parameters of the pbr material.
  46409. */
  46410. export class PBRAnisotropicConfiguration {
  46411. private _isEnabled;
  46412. /**
  46413. * Defines if the anisotropy is enabled in the material.
  46414. */
  46415. isEnabled: boolean;
  46416. /**
  46417. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46418. */
  46419. intensity: number;
  46420. /**
  46421. * Defines if the effect is along the tangents, bitangents or in between.
  46422. * By default, the effect is "strectching" the highlights along the tangents.
  46423. */
  46424. direction: Vector2;
  46425. private _texture;
  46426. /**
  46427. * Stores the anisotropy values in a texture.
  46428. * rg is direction (like normal from -1 to 1)
  46429. * b is a intensity
  46430. */
  46431. texture: Nullable<BaseTexture>;
  46432. /** @hidden */
  46433. private _internalMarkAllSubMeshesAsTexturesDirty;
  46434. /** @hidden */
  46435. _markAllSubMeshesAsTexturesDirty(): void;
  46436. /**
  46437. * Instantiate a new istance of anisotropy configuration.
  46438. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46439. */
  46440. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46441. /**
  46442. * Specifies that the submesh is ready to be used.
  46443. * @param defines the list of "defines" to update.
  46444. * @param scene defines the scene the material belongs to.
  46445. * @returns - boolean indicating that the submesh is ready or not.
  46446. */
  46447. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46448. /**
  46449. * Checks to see if a texture is used in the material.
  46450. * @param defines the list of "defines" to update.
  46451. * @param mesh the mesh we are preparing the defines for.
  46452. * @param scene defines the scene the material belongs to.
  46453. */
  46454. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46455. /**
  46456. * Binds the material data.
  46457. * @param uniformBuffer defines the Uniform buffer to fill in.
  46458. * @param scene defines the scene the material belongs to.
  46459. * @param isFrozen defines wether the material is frozen or not.
  46460. */
  46461. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46462. /**
  46463. * Checks to see if a texture is used in the material.
  46464. * @param texture - Base texture to use.
  46465. * @returns - Boolean specifying if a texture is used in the material.
  46466. */
  46467. hasTexture(texture: BaseTexture): boolean;
  46468. /**
  46469. * Returns an array of the actively used textures.
  46470. * @param activeTextures Array of BaseTextures
  46471. */
  46472. getActiveTextures(activeTextures: BaseTexture[]): void;
  46473. /**
  46474. * Returns the animatable textures.
  46475. * @param animatables Array of animatable textures.
  46476. */
  46477. getAnimatables(animatables: IAnimatable[]): void;
  46478. /**
  46479. * Disposes the resources of the material.
  46480. * @param forceDisposeTextures - Forces the disposal of all textures.
  46481. */
  46482. dispose(forceDisposeTextures?: boolean): void;
  46483. /**
  46484. * Get the current class name of the texture useful for serialization or dynamic coding.
  46485. * @returns "PBRAnisotropicConfiguration"
  46486. */
  46487. getClassName(): string;
  46488. /**
  46489. * Add fallbacks to the effect fallbacks list.
  46490. * @param defines defines the Base texture to use.
  46491. * @param fallbacks defines the current fallback list.
  46492. * @param currentRank defines the current fallback rank.
  46493. * @returns the new fallback rank.
  46494. */
  46495. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46496. /**
  46497. * Add the required uniforms to the current list.
  46498. * @param uniforms defines the current uniform list.
  46499. */
  46500. static AddUniforms(uniforms: string[]): void;
  46501. /**
  46502. * Add the required uniforms to the current buffer.
  46503. * @param uniformBuffer defines the current uniform buffer.
  46504. */
  46505. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46506. /**
  46507. * Add the required samplers to the current list.
  46508. * @param samplers defines the current sampler list.
  46509. */
  46510. static AddSamplers(samplers: string[]): void;
  46511. /**
  46512. * Makes a duplicate of the current configuration into another one.
  46513. * @param anisotropicConfiguration define the config where to copy the info
  46514. */
  46515. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46516. /**
  46517. * Serializes this anisotropy configuration.
  46518. * @returns - An object with the serialized config.
  46519. */
  46520. serialize(): any;
  46521. /**
  46522. * Parses a anisotropy Configuration from a serialized object.
  46523. * @param source - Serialized object.
  46524. */
  46525. parse(source: any): void;
  46526. }
  46527. }
  46528. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46529. /**
  46530. * @hidden
  46531. */
  46532. export interface IMaterialBRDFDefines {
  46533. BRDF_V_HEIGHT_CORRELATED: boolean;
  46534. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46535. SPHERICAL_HARMONICS: boolean;
  46536. /** @hidden */
  46537. _areMiscDirty: boolean;
  46538. }
  46539. /**
  46540. * Define the code related to the BRDF parameters of the pbr material.
  46541. */
  46542. export class PBRBRDFConfiguration {
  46543. /**
  46544. * Default value used for the energy conservation.
  46545. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46546. */
  46547. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46548. /**
  46549. * Default value used for the Smith Visibility Height Correlated mode.
  46550. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46551. */
  46552. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46553. /**
  46554. * Default value used for the IBL diffuse part.
  46555. * This can help switching back to the polynomials mode globally which is a tiny bit
  46556. * less GPU intensive at the drawback of a lower quality.
  46557. */
  46558. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46559. private _useEnergyConservation;
  46560. /**
  46561. * Defines if the material uses energy conservation.
  46562. */
  46563. useEnergyConservation: boolean;
  46564. private _useSmithVisibilityHeightCorrelated;
  46565. /**
  46566. * LEGACY Mode set to false
  46567. * Defines if the material uses height smith correlated visibility term.
  46568. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46569. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46570. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46571. * Not relying on height correlated will also disable energy conservation.
  46572. */
  46573. useSmithVisibilityHeightCorrelated: boolean;
  46574. private _useSphericalHarmonics;
  46575. /**
  46576. * LEGACY Mode set to false
  46577. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46578. * diffuse part of the IBL.
  46579. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46580. * to the ground truth.
  46581. */
  46582. useSphericalHarmonics: boolean;
  46583. /** @hidden */
  46584. private _internalMarkAllSubMeshesAsMiscDirty;
  46585. /** @hidden */
  46586. _markAllSubMeshesAsMiscDirty(): void;
  46587. /**
  46588. * Instantiate a new istance of clear coat configuration.
  46589. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46590. */
  46591. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46592. /**
  46593. * Checks to see if a texture is used in the material.
  46594. * @param defines the list of "defines" to update.
  46595. */
  46596. prepareDefines(defines: IMaterialBRDFDefines): void;
  46597. /**
  46598. * Get the current class name of the texture useful for serialization or dynamic coding.
  46599. * @returns "PBRClearCoatConfiguration"
  46600. */
  46601. getClassName(): string;
  46602. /**
  46603. * Makes a duplicate of the current configuration into another one.
  46604. * @param brdfConfiguration define the config where to copy the info
  46605. */
  46606. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46607. /**
  46608. * Serializes this BRDF configuration.
  46609. * @returns - An object with the serialized config.
  46610. */
  46611. serialize(): any;
  46612. /**
  46613. * Parses a BRDF Configuration from a serialized object.
  46614. * @param source - Serialized object.
  46615. */
  46616. parse(source: any): void;
  46617. }
  46618. }
  46619. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46620. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46621. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46622. import { Color3 } from "babylonjs/Maths/math";
  46623. import { Scene } from "babylonjs/scene";
  46624. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46625. import { IAnimatable } from "babylonjs/Misc/tools";
  46626. import { Nullable } from "babylonjs/types";
  46627. /**
  46628. * @hidden
  46629. */
  46630. export interface IMaterialSheenDefines {
  46631. SHEEN: boolean;
  46632. SHEEN_TEXTURE: boolean;
  46633. SHEEN_TEXTUREDIRECTUV: number;
  46634. SHEEN_LINKWITHALBEDO: boolean;
  46635. /** @hidden */
  46636. _areTexturesDirty: boolean;
  46637. }
  46638. /**
  46639. * Define the code related to the Sheen parameters of the pbr material.
  46640. */
  46641. export class PBRSheenConfiguration {
  46642. private _isEnabled;
  46643. /**
  46644. * Defines if the material uses sheen.
  46645. */
  46646. isEnabled: boolean;
  46647. private _linkSheenWithAlbedo;
  46648. /**
  46649. * Defines if the sheen is linked to the sheen color.
  46650. */
  46651. linkSheenWithAlbedo: boolean;
  46652. /**
  46653. * Defines the sheen intensity.
  46654. */
  46655. intensity: number;
  46656. /**
  46657. * Defines the sheen color.
  46658. */
  46659. color: Color3;
  46660. private _texture;
  46661. /**
  46662. * Stores the sheen tint values in a texture.
  46663. * rgb is tint
  46664. * a is a intensity
  46665. */
  46666. texture: Nullable<BaseTexture>;
  46667. /** @hidden */
  46668. private _internalMarkAllSubMeshesAsTexturesDirty;
  46669. /** @hidden */
  46670. _markAllSubMeshesAsTexturesDirty(): void;
  46671. /**
  46672. * Instantiate a new istance of clear coat configuration.
  46673. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46674. */
  46675. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46676. /**
  46677. * Specifies that the submesh is ready to be used.
  46678. * @param defines the list of "defines" to update.
  46679. * @param scene defines the scene the material belongs to.
  46680. * @returns - boolean indicating that the submesh is ready or not.
  46681. */
  46682. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46683. /**
  46684. * Checks to see if a texture is used in the material.
  46685. * @param defines the list of "defines" to update.
  46686. * @param scene defines the scene the material belongs to.
  46687. */
  46688. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46689. /**
  46690. * Binds the material data.
  46691. * @param uniformBuffer defines the Uniform buffer to fill in.
  46692. * @param scene defines the scene the material belongs to.
  46693. * @param isFrozen defines wether the material is frozen or not.
  46694. */
  46695. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46696. /**
  46697. * Checks to see if a texture is used in the material.
  46698. * @param texture - Base texture to use.
  46699. * @returns - Boolean specifying if a texture is used in the material.
  46700. */
  46701. hasTexture(texture: BaseTexture): boolean;
  46702. /**
  46703. * Returns an array of the actively used textures.
  46704. * @param activeTextures Array of BaseTextures
  46705. */
  46706. getActiveTextures(activeTextures: BaseTexture[]): void;
  46707. /**
  46708. * Returns the animatable textures.
  46709. * @param animatables Array of animatable textures.
  46710. */
  46711. getAnimatables(animatables: IAnimatable[]): void;
  46712. /**
  46713. * Disposes the resources of the material.
  46714. * @param forceDisposeTextures - Forces the disposal of all textures.
  46715. */
  46716. dispose(forceDisposeTextures?: boolean): void;
  46717. /**
  46718. * Get the current class name of the texture useful for serialization or dynamic coding.
  46719. * @returns "PBRSheenConfiguration"
  46720. */
  46721. getClassName(): string;
  46722. /**
  46723. * Add fallbacks to the effect fallbacks list.
  46724. * @param defines defines the Base texture to use.
  46725. * @param fallbacks defines the current fallback list.
  46726. * @param currentRank defines the current fallback rank.
  46727. * @returns the new fallback rank.
  46728. */
  46729. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46730. /**
  46731. * Add the required uniforms to the current list.
  46732. * @param uniforms defines the current uniform list.
  46733. */
  46734. static AddUniforms(uniforms: string[]): void;
  46735. /**
  46736. * Add the required uniforms to the current buffer.
  46737. * @param uniformBuffer defines the current uniform buffer.
  46738. */
  46739. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46740. /**
  46741. * Add the required samplers to the current list.
  46742. * @param samplers defines the current sampler list.
  46743. */
  46744. static AddSamplers(samplers: string[]): void;
  46745. /**
  46746. * Makes a duplicate of the current configuration into another one.
  46747. * @param sheenConfiguration define the config where to copy the info
  46748. */
  46749. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46750. /**
  46751. * Serializes this BRDF configuration.
  46752. * @returns - An object with the serialized config.
  46753. */
  46754. serialize(): any;
  46755. /**
  46756. * Parses a Sheen Configuration from a serialized object.
  46757. * @param source - Serialized object.
  46758. */
  46759. parse(source: any): void;
  46760. }
  46761. }
  46762. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46763. import { Nullable } from "babylonjs/types";
  46764. import { IAnimatable } from "babylonjs/Misc/tools";
  46765. import { Color3 } from "babylonjs/Maths/math";
  46766. import { SmartArray } from "babylonjs/Misc/smartArray";
  46767. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46768. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46769. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46770. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46771. import { Engine } from "babylonjs/Engines/engine";
  46772. import { Scene } from "babylonjs/scene";
  46773. /**
  46774. * @hidden
  46775. */
  46776. export interface IMaterialSubSurfaceDefines {
  46777. SUBSURFACE: boolean;
  46778. SS_REFRACTION: boolean;
  46779. SS_TRANSLUCENCY: boolean;
  46780. SS_SCATERRING: boolean;
  46781. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46782. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46783. SS_REFRACTIONMAP_3D: boolean;
  46784. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46785. SS_LODINREFRACTIONALPHA: boolean;
  46786. SS_GAMMAREFRACTION: boolean;
  46787. SS_RGBDREFRACTION: boolean;
  46788. SS_LINEARSPECULARREFRACTION: boolean;
  46789. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46790. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46791. /** @hidden */
  46792. _areTexturesDirty: boolean;
  46793. }
  46794. /**
  46795. * Define the code related to the sub surface parameters of the pbr material.
  46796. */
  46797. export class PBRSubSurfaceConfiguration {
  46798. private _isRefractionEnabled;
  46799. /**
  46800. * Defines if the refraction is enabled in the material.
  46801. */
  46802. isRefractionEnabled: boolean;
  46803. private _isTranslucencyEnabled;
  46804. /**
  46805. * Defines if the translucency is enabled in the material.
  46806. */
  46807. isTranslucencyEnabled: boolean;
  46808. private _isScatteringEnabled;
  46809. /**
  46810. * Defines the refraction intensity of the material.
  46811. * The refraction when enabled replaces the Diffuse part of the material.
  46812. * The intensity helps transitionning between diffuse and refraction.
  46813. */
  46814. refractionIntensity: number;
  46815. /**
  46816. * Defines the translucency intensity of the material.
  46817. * When translucency has been enabled, this defines how much of the "translucency"
  46818. * is addded to the diffuse part of the material.
  46819. */
  46820. translucencyIntensity: number;
  46821. /**
  46822. * Defines the scattering intensity of the material.
  46823. * When scattering has been enabled, this defines how much of the "scattered light"
  46824. * is addded to the diffuse part of the material.
  46825. */
  46826. scatteringIntensity: number;
  46827. private _thicknessTexture;
  46828. /**
  46829. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46830. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46831. * 0 would mean minimumThickness
  46832. * 1 would mean maximumThickness
  46833. * The other channels might be use as a mask to vary the different effects intensity.
  46834. */
  46835. thicknessTexture: Nullable<BaseTexture>;
  46836. private _refractionTexture;
  46837. /**
  46838. * Defines the texture to use for refraction.
  46839. */
  46840. refractionTexture: Nullable<BaseTexture>;
  46841. private _indexOfRefraction;
  46842. /**
  46843. * Defines the indice of refraction used in the material.
  46844. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46845. */
  46846. indexOfRefraction: number;
  46847. private _invertRefractionY;
  46848. /**
  46849. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46850. */
  46851. invertRefractionY: boolean;
  46852. private _linkRefractionWithTransparency;
  46853. /**
  46854. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46855. * Materials half opaque for instance using refraction could benefit from this control.
  46856. */
  46857. linkRefractionWithTransparency: boolean;
  46858. /**
  46859. * Defines the minimum thickness stored in the thickness map.
  46860. * If no thickness map is defined, this value will be used to simulate thickness.
  46861. */
  46862. minimumThickness: number;
  46863. /**
  46864. * Defines the maximum thickness stored in the thickness map.
  46865. */
  46866. maximumThickness: number;
  46867. /**
  46868. * Defines the volume tint of the material.
  46869. * This is used for both translucency and scattering.
  46870. */
  46871. tintColor: Color3;
  46872. /**
  46873. * Defines the distance at which the tint color should be found in the media.
  46874. * This is used for refraction only.
  46875. */
  46876. tintColorAtDistance: number;
  46877. /**
  46878. * Defines how far each channel transmit through the media.
  46879. * It is defined as a color to simplify it selection.
  46880. */
  46881. diffusionDistance: Color3;
  46882. private _useMaskFromThicknessTexture;
  46883. /**
  46884. * Stores the intensity of the different subsurface effects in the thickness texture.
  46885. * * the green channel is the translucency intensity.
  46886. * * the blue channel is the scattering intensity.
  46887. * * the alpha channel is the refraction intensity.
  46888. */
  46889. useMaskFromThicknessTexture: boolean;
  46890. /** @hidden */
  46891. private _internalMarkAllSubMeshesAsTexturesDirty;
  46892. /** @hidden */
  46893. _markAllSubMeshesAsTexturesDirty(): void;
  46894. /**
  46895. * Instantiate a new istance of sub surface configuration.
  46896. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46897. */
  46898. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46899. /**
  46900. * Gets wehter the submesh is ready to be used or not.
  46901. * @param defines the list of "defines" to update.
  46902. * @param scene defines the scene the material belongs to.
  46903. * @returns - boolean indicating that the submesh is ready or not.
  46904. */
  46905. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46906. /**
  46907. * Checks to see if a texture is used in the material.
  46908. * @param defines the list of "defines" to update.
  46909. * @param scene defines the scene to the material belongs to.
  46910. */
  46911. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46912. /**
  46913. * Binds the material data.
  46914. * @param uniformBuffer defines the Uniform buffer to fill in.
  46915. * @param scene defines the scene the material belongs to.
  46916. * @param engine defines the engine the material belongs to.
  46917. * @param isFrozen defines wether the material is frozen or not.
  46918. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46919. */
  46920. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46921. /**
  46922. * Unbinds the material from the mesh.
  46923. * @param activeEffect defines the effect that should be unbound from.
  46924. * @returns true if unbound, otherwise false
  46925. */
  46926. unbind(activeEffect: Effect): boolean;
  46927. /**
  46928. * Returns the texture used for refraction or null if none is used.
  46929. * @param scene defines the scene the material belongs to.
  46930. * @returns - Refraction texture if present. If no refraction texture and refraction
  46931. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46932. */
  46933. private _getRefractionTexture;
  46934. /**
  46935. * Returns true if alpha blending should be disabled.
  46936. */
  46937. readonly disableAlphaBlending: boolean;
  46938. /**
  46939. * Fills the list of render target textures.
  46940. * @param renderTargets the list of render targets to update
  46941. */
  46942. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46943. /**
  46944. * Checks to see if a texture is used in the material.
  46945. * @param texture - Base texture to use.
  46946. * @returns - Boolean specifying if a texture is used in the material.
  46947. */
  46948. hasTexture(texture: BaseTexture): boolean;
  46949. /**
  46950. * Gets a boolean indicating that current material needs to register RTT
  46951. * @returns true if this uses a render target otherwise false.
  46952. */
  46953. hasRenderTargetTextures(): boolean;
  46954. /**
  46955. * Returns an array of the actively used textures.
  46956. * @param activeTextures Array of BaseTextures
  46957. */
  46958. getActiveTextures(activeTextures: BaseTexture[]): void;
  46959. /**
  46960. * Returns the animatable textures.
  46961. * @param animatables Array of animatable textures.
  46962. */
  46963. getAnimatables(animatables: IAnimatable[]): void;
  46964. /**
  46965. * Disposes the resources of the material.
  46966. * @param forceDisposeTextures - Forces the disposal of all textures.
  46967. */
  46968. dispose(forceDisposeTextures?: boolean): void;
  46969. /**
  46970. * Get the current class name of the texture useful for serialization or dynamic coding.
  46971. * @returns "PBRSubSurfaceConfiguration"
  46972. */
  46973. getClassName(): string;
  46974. /**
  46975. * Add fallbacks to the effect fallbacks list.
  46976. * @param defines defines the Base texture to use.
  46977. * @param fallbacks defines the current fallback list.
  46978. * @param currentRank defines the current fallback rank.
  46979. * @returns the new fallback rank.
  46980. */
  46981. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46982. /**
  46983. * Add the required uniforms to the current list.
  46984. * @param uniforms defines the current uniform list.
  46985. */
  46986. static AddUniforms(uniforms: string[]): void;
  46987. /**
  46988. * Add the required samplers to the current list.
  46989. * @param samplers defines the current sampler list.
  46990. */
  46991. static AddSamplers(samplers: string[]): void;
  46992. /**
  46993. * Add the required uniforms to the current buffer.
  46994. * @param uniformBuffer defines the current uniform buffer.
  46995. */
  46996. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46997. /**
  46998. * Makes a duplicate of the current configuration into another one.
  46999. * @param configuration define the config where to copy the info
  47000. */
  47001. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47002. /**
  47003. * Serializes this Sub Surface configuration.
  47004. * @returns - An object with the serialized config.
  47005. */
  47006. serialize(): any;
  47007. /**
  47008. * Parses a Sub Surface Configuration from a serialized object.
  47009. * @param source - Serialized object.
  47010. */
  47011. parse(source: any): void;
  47012. }
  47013. }
  47014. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47015. /** @hidden */
  47016. export var pbrFragmentDeclaration: {
  47017. name: string;
  47018. shader: string;
  47019. };
  47020. }
  47021. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47022. /** @hidden */
  47023. export var pbrUboDeclaration: {
  47024. name: string;
  47025. shader: string;
  47026. };
  47027. }
  47028. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47029. /** @hidden */
  47030. export var pbrFragmentExtraDeclaration: {
  47031. name: string;
  47032. shader: string;
  47033. };
  47034. }
  47035. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47036. /** @hidden */
  47037. export var pbrFragmentSamplersDeclaration: {
  47038. name: string;
  47039. shader: string;
  47040. };
  47041. }
  47042. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47043. /** @hidden */
  47044. export var pbrHelperFunctions: {
  47045. name: string;
  47046. shader: string;
  47047. };
  47048. }
  47049. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47050. /** @hidden */
  47051. export var harmonicsFunctions: {
  47052. name: string;
  47053. shader: string;
  47054. };
  47055. }
  47056. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47057. /** @hidden */
  47058. export var pbrDirectLightingSetupFunctions: {
  47059. name: string;
  47060. shader: string;
  47061. };
  47062. }
  47063. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47064. /** @hidden */
  47065. export var pbrDirectLightingFalloffFunctions: {
  47066. name: string;
  47067. shader: string;
  47068. };
  47069. }
  47070. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47071. /** @hidden */
  47072. export var pbrBRDFFunctions: {
  47073. name: string;
  47074. shader: string;
  47075. };
  47076. }
  47077. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47078. /** @hidden */
  47079. export var pbrDirectLightingFunctions: {
  47080. name: string;
  47081. shader: string;
  47082. };
  47083. }
  47084. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47085. /** @hidden */
  47086. export var pbrIBLFunctions: {
  47087. name: string;
  47088. shader: string;
  47089. };
  47090. }
  47091. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47092. /** @hidden */
  47093. export var pbrDebug: {
  47094. name: string;
  47095. shader: string;
  47096. };
  47097. }
  47098. declare module "babylonjs/Shaders/pbr.fragment" {
  47099. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47100. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47101. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47102. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47103. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47104. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47105. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47106. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47107. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47108. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47109. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47110. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47111. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47112. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47113. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47114. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47115. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47116. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47117. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47118. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47119. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47120. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47121. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47122. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47123. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47124. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47125. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47126. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47127. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47128. /** @hidden */
  47129. export var pbrPixelShader: {
  47130. name: string;
  47131. shader: string;
  47132. };
  47133. }
  47134. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47135. /** @hidden */
  47136. export var pbrVertexDeclaration: {
  47137. name: string;
  47138. shader: string;
  47139. };
  47140. }
  47141. declare module "babylonjs/Shaders/pbr.vertex" {
  47142. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47143. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47144. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47145. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47146. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47147. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47148. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47149. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47150. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47151. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47152. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47153. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47154. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47155. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47156. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47157. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47158. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47159. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47160. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47161. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47162. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47163. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47164. /** @hidden */
  47165. export var pbrVertexShader: {
  47166. name: string;
  47167. shader: string;
  47168. };
  47169. }
  47170. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47171. import { IAnimatable } from "babylonjs/Misc/tools";
  47172. import { Nullable } from "babylonjs/types";
  47173. import { Scene } from "babylonjs/scene";
  47174. import { Matrix, Color3 } from "babylonjs/Maths/math";
  47175. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47177. import { Mesh } from "babylonjs/Meshes/mesh";
  47178. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47179. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47180. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47181. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47182. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47183. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47184. import { Material } from "babylonjs/Materials/material";
  47185. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47186. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47187. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47188. import "babylonjs/Shaders/pbr.fragment";
  47189. import "babylonjs/Shaders/pbr.vertex";
  47190. /**
  47191. * Manages the defines for the PBR Material.
  47192. * @hidden
  47193. */
  47194. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47195. PBR: boolean;
  47196. MAINUV1: boolean;
  47197. MAINUV2: boolean;
  47198. UV1: boolean;
  47199. UV2: boolean;
  47200. ALBEDO: boolean;
  47201. ALBEDODIRECTUV: number;
  47202. VERTEXCOLOR: boolean;
  47203. AMBIENT: boolean;
  47204. AMBIENTDIRECTUV: number;
  47205. AMBIENTINGRAYSCALE: boolean;
  47206. OPACITY: boolean;
  47207. VERTEXALPHA: boolean;
  47208. OPACITYDIRECTUV: number;
  47209. OPACITYRGB: boolean;
  47210. ALPHATEST: boolean;
  47211. DEPTHPREPASS: boolean;
  47212. ALPHABLEND: boolean;
  47213. ALPHAFROMALBEDO: boolean;
  47214. ALPHATESTVALUE: string;
  47215. SPECULAROVERALPHA: boolean;
  47216. RADIANCEOVERALPHA: boolean;
  47217. ALPHAFRESNEL: boolean;
  47218. LINEARALPHAFRESNEL: boolean;
  47219. PREMULTIPLYALPHA: boolean;
  47220. EMISSIVE: boolean;
  47221. EMISSIVEDIRECTUV: number;
  47222. REFLECTIVITY: boolean;
  47223. REFLECTIVITYDIRECTUV: number;
  47224. SPECULARTERM: boolean;
  47225. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47226. MICROSURFACEAUTOMATIC: boolean;
  47227. LODBASEDMICROSFURACE: boolean;
  47228. MICROSURFACEMAP: boolean;
  47229. MICROSURFACEMAPDIRECTUV: number;
  47230. METALLICWORKFLOW: boolean;
  47231. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47232. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47233. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47234. AOSTOREINMETALMAPRED: boolean;
  47235. ENVIRONMENTBRDF: boolean;
  47236. ENVIRONMENTBRDF_RGBD: boolean;
  47237. NORMAL: boolean;
  47238. TANGENT: boolean;
  47239. BUMP: boolean;
  47240. BUMPDIRECTUV: number;
  47241. OBJECTSPACE_NORMALMAP: boolean;
  47242. PARALLAX: boolean;
  47243. PARALLAXOCCLUSION: boolean;
  47244. NORMALXYSCALE: boolean;
  47245. LIGHTMAP: boolean;
  47246. LIGHTMAPDIRECTUV: number;
  47247. USELIGHTMAPASSHADOWMAP: boolean;
  47248. GAMMALIGHTMAP: boolean;
  47249. REFLECTION: boolean;
  47250. REFLECTIONMAP_3D: boolean;
  47251. REFLECTIONMAP_SPHERICAL: boolean;
  47252. REFLECTIONMAP_PLANAR: boolean;
  47253. REFLECTIONMAP_CUBIC: boolean;
  47254. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47255. REFLECTIONMAP_PROJECTION: boolean;
  47256. REFLECTIONMAP_SKYBOX: boolean;
  47257. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47258. REFLECTIONMAP_EXPLICIT: boolean;
  47259. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47260. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47261. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47262. INVERTCUBICMAP: boolean;
  47263. USESPHERICALFROMREFLECTIONMAP: boolean;
  47264. USEIRRADIANCEMAP: boolean;
  47265. SPHERICAL_HARMONICS: boolean;
  47266. USESPHERICALINVERTEX: boolean;
  47267. REFLECTIONMAP_OPPOSITEZ: boolean;
  47268. LODINREFLECTIONALPHA: boolean;
  47269. GAMMAREFLECTION: boolean;
  47270. RGBDREFLECTION: boolean;
  47271. LINEARSPECULARREFLECTION: boolean;
  47272. RADIANCEOCCLUSION: boolean;
  47273. HORIZONOCCLUSION: boolean;
  47274. INSTANCES: boolean;
  47275. NUM_BONE_INFLUENCERS: number;
  47276. BonesPerMesh: number;
  47277. BONETEXTURE: boolean;
  47278. NONUNIFORMSCALING: boolean;
  47279. MORPHTARGETS: boolean;
  47280. MORPHTARGETS_NORMAL: boolean;
  47281. MORPHTARGETS_TANGENT: boolean;
  47282. NUM_MORPH_INFLUENCERS: number;
  47283. IMAGEPROCESSING: boolean;
  47284. VIGNETTE: boolean;
  47285. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47286. VIGNETTEBLENDMODEOPAQUE: boolean;
  47287. TONEMAPPING: boolean;
  47288. TONEMAPPING_ACES: boolean;
  47289. CONTRAST: boolean;
  47290. COLORCURVES: boolean;
  47291. COLORGRADING: boolean;
  47292. COLORGRADING3D: boolean;
  47293. SAMPLER3DGREENDEPTH: boolean;
  47294. SAMPLER3DBGRMAP: boolean;
  47295. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47296. EXPOSURE: boolean;
  47297. MULTIVIEW: boolean;
  47298. USEPHYSICALLIGHTFALLOFF: boolean;
  47299. USEGLTFLIGHTFALLOFF: boolean;
  47300. TWOSIDEDLIGHTING: boolean;
  47301. SHADOWFLOAT: boolean;
  47302. CLIPPLANE: boolean;
  47303. CLIPPLANE2: boolean;
  47304. CLIPPLANE3: boolean;
  47305. CLIPPLANE4: boolean;
  47306. POINTSIZE: boolean;
  47307. FOG: boolean;
  47308. LOGARITHMICDEPTH: boolean;
  47309. FORCENORMALFORWARD: boolean;
  47310. SPECULARAA: boolean;
  47311. CLEARCOAT: boolean;
  47312. CLEARCOAT_DEFAULTIOR: boolean;
  47313. CLEARCOAT_TEXTURE: boolean;
  47314. CLEARCOAT_TEXTUREDIRECTUV: number;
  47315. CLEARCOAT_BUMP: boolean;
  47316. CLEARCOAT_BUMPDIRECTUV: number;
  47317. CLEARCOAT_TINT: boolean;
  47318. CLEARCOAT_TINT_TEXTURE: boolean;
  47319. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47320. ANISOTROPIC: boolean;
  47321. ANISOTROPIC_TEXTURE: boolean;
  47322. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47323. BRDF_V_HEIGHT_CORRELATED: boolean;
  47324. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47325. SHEEN: boolean;
  47326. SHEEN_TEXTURE: boolean;
  47327. SHEEN_TEXTUREDIRECTUV: number;
  47328. SHEEN_LINKWITHALBEDO: boolean;
  47329. SUBSURFACE: boolean;
  47330. SS_REFRACTION: boolean;
  47331. SS_TRANSLUCENCY: boolean;
  47332. SS_SCATERRING: boolean;
  47333. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47334. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47335. SS_REFRACTIONMAP_3D: boolean;
  47336. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47337. SS_LODINREFRACTIONALPHA: boolean;
  47338. SS_GAMMAREFRACTION: boolean;
  47339. SS_RGBDREFRACTION: boolean;
  47340. SS_LINEARSPECULARREFRACTION: boolean;
  47341. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47342. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47343. UNLIT: boolean;
  47344. DEBUGMODE: number;
  47345. /**
  47346. * Initializes the PBR Material defines.
  47347. */
  47348. constructor();
  47349. /**
  47350. * Resets the PBR Material defines.
  47351. */
  47352. reset(): void;
  47353. }
  47354. /**
  47355. * The Physically based material base class of BJS.
  47356. *
  47357. * This offers the main features of a standard PBR material.
  47358. * For more information, please refer to the documentation :
  47359. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47360. */
  47361. export abstract class PBRBaseMaterial extends PushMaterial {
  47362. /**
  47363. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47364. */
  47365. static readonly PBRMATERIAL_OPAQUE: number;
  47366. /**
  47367. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47368. */
  47369. static readonly PBRMATERIAL_ALPHATEST: number;
  47370. /**
  47371. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47372. */
  47373. static readonly PBRMATERIAL_ALPHABLEND: number;
  47374. /**
  47375. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47376. * They are also discarded below the alpha cutoff threshold to improve performances.
  47377. */
  47378. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47379. /**
  47380. * Defines the default value of how much AO map is occluding the analytical lights
  47381. * (point spot...).
  47382. */
  47383. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47384. /**
  47385. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47386. */
  47387. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47388. /**
  47389. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47390. * to enhance interoperability with other engines.
  47391. */
  47392. static readonly LIGHTFALLOFF_GLTF: number;
  47393. /**
  47394. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47395. * to enhance interoperability with other materials.
  47396. */
  47397. static readonly LIGHTFALLOFF_STANDARD: number;
  47398. /**
  47399. * Intensity of the direct lights e.g. the four lights available in your scene.
  47400. * This impacts both the direct diffuse and specular highlights.
  47401. */
  47402. protected _directIntensity: number;
  47403. /**
  47404. * Intensity of the emissive part of the material.
  47405. * This helps controlling the emissive effect without modifying the emissive color.
  47406. */
  47407. protected _emissiveIntensity: number;
  47408. /**
  47409. * Intensity of the environment e.g. how much the environment will light the object
  47410. * either through harmonics for rough material or through the refelction for shiny ones.
  47411. */
  47412. protected _environmentIntensity: number;
  47413. /**
  47414. * This is a special control allowing the reduction of the specular highlights coming from the
  47415. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47416. */
  47417. protected _specularIntensity: number;
  47418. /**
  47419. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47420. */
  47421. private _lightingInfos;
  47422. /**
  47423. * Debug Control allowing disabling the bump map on this material.
  47424. */
  47425. protected _disableBumpMap: boolean;
  47426. /**
  47427. * AKA Diffuse Texture in standard nomenclature.
  47428. */
  47429. protected _albedoTexture: Nullable<BaseTexture>;
  47430. /**
  47431. * AKA Occlusion Texture in other nomenclature.
  47432. */
  47433. protected _ambientTexture: Nullable<BaseTexture>;
  47434. /**
  47435. * AKA Occlusion Texture Intensity in other nomenclature.
  47436. */
  47437. protected _ambientTextureStrength: number;
  47438. /**
  47439. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47440. * 1 means it completely occludes it
  47441. * 0 mean it has no impact
  47442. */
  47443. protected _ambientTextureImpactOnAnalyticalLights: number;
  47444. /**
  47445. * Stores the alpha values in a texture.
  47446. */
  47447. protected _opacityTexture: Nullable<BaseTexture>;
  47448. /**
  47449. * Stores the reflection values in a texture.
  47450. */
  47451. protected _reflectionTexture: Nullable<BaseTexture>;
  47452. /**
  47453. * Stores the emissive values in a texture.
  47454. */
  47455. protected _emissiveTexture: Nullable<BaseTexture>;
  47456. /**
  47457. * AKA Specular texture in other nomenclature.
  47458. */
  47459. protected _reflectivityTexture: Nullable<BaseTexture>;
  47460. /**
  47461. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47462. */
  47463. protected _metallicTexture: Nullable<BaseTexture>;
  47464. /**
  47465. * Specifies the metallic scalar of the metallic/roughness workflow.
  47466. * Can also be used to scale the metalness values of the metallic texture.
  47467. */
  47468. protected _metallic: Nullable<number>;
  47469. /**
  47470. * Specifies the roughness scalar of the metallic/roughness workflow.
  47471. * Can also be used to scale the roughness values of the metallic texture.
  47472. */
  47473. protected _roughness: Nullable<number>;
  47474. /**
  47475. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47476. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47477. */
  47478. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47479. /**
  47480. * Stores surface normal data used to displace a mesh in a texture.
  47481. */
  47482. protected _bumpTexture: Nullable<BaseTexture>;
  47483. /**
  47484. * Stores the pre-calculated light information of a mesh in a texture.
  47485. */
  47486. protected _lightmapTexture: Nullable<BaseTexture>;
  47487. /**
  47488. * The color of a material in ambient lighting.
  47489. */
  47490. protected _ambientColor: Color3;
  47491. /**
  47492. * AKA Diffuse Color in other nomenclature.
  47493. */
  47494. protected _albedoColor: Color3;
  47495. /**
  47496. * AKA Specular Color in other nomenclature.
  47497. */
  47498. protected _reflectivityColor: Color3;
  47499. /**
  47500. * The color applied when light is reflected from a material.
  47501. */
  47502. protected _reflectionColor: Color3;
  47503. /**
  47504. * The color applied when light is emitted from a material.
  47505. */
  47506. protected _emissiveColor: Color3;
  47507. /**
  47508. * AKA Glossiness in other nomenclature.
  47509. */
  47510. protected _microSurface: number;
  47511. /**
  47512. * Specifies that the material will use the light map as a show map.
  47513. */
  47514. protected _useLightmapAsShadowmap: boolean;
  47515. /**
  47516. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47517. * makes the reflect vector face the model (under horizon).
  47518. */
  47519. protected _useHorizonOcclusion: boolean;
  47520. /**
  47521. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47522. * too much the area relying on ambient texture to define their ambient occlusion.
  47523. */
  47524. protected _useRadianceOcclusion: boolean;
  47525. /**
  47526. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47527. */
  47528. protected _useAlphaFromAlbedoTexture: boolean;
  47529. /**
  47530. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47531. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47532. */
  47533. protected _useSpecularOverAlpha: boolean;
  47534. /**
  47535. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47536. */
  47537. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47538. /**
  47539. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47540. */
  47541. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47542. /**
  47543. * Specifies if the metallic texture contains the roughness information in its green channel.
  47544. */
  47545. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47546. /**
  47547. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47548. */
  47549. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47550. /**
  47551. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47552. */
  47553. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47554. /**
  47555. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47556. */
  47557. protected _useAmbientInGrayScale: boolean;
  47558. /**
  47559. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47560. * The material will try to infer what glossiness each pixel should be.
  47561. */
  47562. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47563. /**
  47564. * Defines the falloff type used in this material.
  47565. * It by default is Physical.
  47566. */
  47567. protected _lightFalloff: number;
  47568. /**
  47569. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47570. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47571. */
  47572. protected _useRadianceOverAlpha: boolean;
  47573. /**
  47574. * Allows using an object space normal map (instead of tangent space).
  47575. */
  47576. protected _useObjectSpaceNormalMap: boolean;
  47577. /**
  47578. * Allows using the bump map in parallax mode.
  47579. */
  47580. protected _useParallax: boolean;
  47581. /**
  47582. * Allows using the bump map in parallax occlusion mode.
  47583. */
  47584. protected _useParallaxOcclusion: boolean;
  47585. /**
  47586. * Controls the scale bias of the parallax mode.
  47587. */
  47588. protected _parallaxScaleBias: number;
  47589. /**
  47590. * If sets to true, disables all the lights affecting the material.
  47591. */
  47592. protected _disableLighting: boolean;
  47593. /**
  47594. * Number of Simultaneous lights allowed on the material.
  47595. */
  47596. protected _maxSimultaneousLights: number;
  47597. /**
  47598. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47599. */
  47600. protected _invertNormalMapX: boolean;
  47601. /**
  47602. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47603. */
  47604. protected _invertNormalMapY: boolean;
  47605. /**
  47606. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47607. */
  47608. protected _twoSidedLighting: boolean;
  47609. /**
  47610. * Defines the alpha limits in alpha test mode.
  47611. */
  47612. protected _alphaCutOff: number;
  47613. /**
  47614. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47615. */
  47616. protected _forceAlphaTest: boolean;
  47617. /**
  47618. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47619. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47620. */
  47621. protected _useAlphaFresnel: boolean;
  47622. /**
  47623. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47624. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47625. */
  47626. protected _useLinearAlphaFresnel: boolean;
  47627. /**
  47628. * The transparency mode of the material.
  47629. */
  47630. protected _transparencyMode: Nullable<number>;
  47631. /**
  47632. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47633. * from cos thetav and roughness:
  47634. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47635. */
  47636. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47637. /**
  47638. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47639. */
  47640. protected _forceIrradianceInFragment: boolean;
  47641. /**
  47642. * Force normal to face away from face.
  47643. */
  47644. protected _forceNormalForward: boolean;
  47645. /**
  47646. * Enables specular anti aliasing in the PBR shader.
  47647. * It will both interacts on the Geometry for analytical and IBL lighting.
  47648. * It also prefilter the roughness map based on the bump values.
  47649. */
  47650. protected _enableSpecularAntiAliasing: boolean;
  47651. /**
  47652. * Default configuration related to image processing available in the PBR Material.
  47653. */
  47654. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47655. /**
  47656. * Keep track of the image processing observer to allow dispose and replace.
  47657. */
  47658. private _imageProcessingObserver;
  47659. /**
  47660. * Attaches a new image processing configuration to the PBR Material.
  47661. * @param configuration
  47662. */
  47663. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47664. /**
  47665. * Stores the available render targets.
  47666. */
  47667. private _renderTargets;
  47668. /**
  47669. * Sets the global ambient color for the material used in lighting calculations.
  47670. */
  47671. private _globalAmbientColor;
  47672. /**
  47673. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47674. */
  47675. private _useLogarithmicDepth;
  47676. /**
  47677. * If set to true, no lighting calculations will be applied.
  47678. */
  47679. private _unlit;
  47680. private _debugMode;
  47681. /**
  47682. * @hidden
  47683. * This is reserved for the inspector.
  47684. * Defines the material debug mode.
  47685. * It helps seeing only some components of the material while troubleshooting.
  47686. */
  47687. debugMode: number;
  47688. /**
  47689. * @hidden
  47690. * This is reserved for the inspector.
  47691. * Specify from where on screen the debug mode should start.
  47692. * The value goes from -1 (full screen) to 1 (not visible)
  47693. * It helps with side by side comparison against the final render
  47694. * This defaults to -1
  47695. */
  47696. private debugLimit;
  47697. /**
  47698. * @hidden
  47699. * This is reserved for the inspector.
  47700. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47701. * You can use the factor to better multiply the final value.
  47702. */
  47703. private debugFactor;
  47704. /**
  47705. * Defines the clear coat layer parameters for the material.
  47706. */
  47707. readonly clearCoat: PBRClearCoatConfiguration;
  47708. /**
  47709. * Defines the anisotropic parameters for the material.
  47710. */
  47711. readonly anisotropy: PBRAnisotropicConfiguration;
  47712. /**
  47713. * Defines the BRDF parameters for the material.
  47714. */
  47715. readonly brdf: PBRBRDFConfiguration;
  47716. /**
  47717. * Defines the Sheen parameters for the material.
  47718. */
  47719. readonly sheen: PBRSheenConfiguration;
  47720. /**
  47721. * Defines the SubSurface parameters for the material.
  47722. */
  47723. readonly subSurface: PBRSubSurfaceConfiguration;
  47724. /**
  47725. * Custom callback helping to override the default shader used in the material.
  47726. */
  47727. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47728. /**
  47729. * Instantiates a new PBRMaterial instance.
  47730. *
  47731. * @param name The material name
  47732. * @param scene The scene the material will be use in.
  47733. */
  47734. constructor(name: string, scene: Scene);
  47735. /**
  47736. * Gets a boolean indicating that current material needs to register RTT
  47737. */
  47738. readonly hasRenderTargetTextures: boolean;
  47739. /**
  47740. * Gets the name of the material class.
  47741. */
  47742. getClassName(): string;
  47743. /**
  47744. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47745. */
  47746. /**
  47747. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47748. */
  47749. useLogarithmicDepth: boolean;
  47750. /**
  47751. * Gets the current transparency mode.
  47752. */
  47753. /**
  47754. * Sets the transparency mode of the material.
  47755. *
  47756. * | Value | Type | Description |
  47757. * | ----- | ----------------------------------- | ----------- |
  47758. * | 0 | OPAQUE | |
  47759. * | 1 | ALPHATEST | |
  47760. * | 2 | ALPHABLEND | |
  47761. * | 3 | ALPHATESTANDBLEND | |
  47762. *
  47763. */
  47764. transparencyMode: Nullable<number>;
  47765. /**
  47766. * Returns true if alpha blending should be disabled.
  47767. */
  47768. private readonly _disableAlphaBlending;
  47769. /**
  47770. * Specifies whether or not this material should be rendered in alpha blend mode.
  47771. */
  47772. needAlphaBlending(): boolean;
  47773. /**
  47774. * Specifies if the mesh will require alpha blending.
  47775. * @param mesh - BJS mesh.
  47776. */
  47777. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47778. /**
  47779. * Specifies whether or not this material should be rendered in alpha test mode.
  47780. */
  47781. needAlphaTesting(): boolean;
  47782. /**
  47783. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47784. */
  47785. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47786. /**
  47787. * Gets the texture used for the alpha test.
  47788. */
  47789. getAlphaTestTexture(): Nullable<BaseTexture>;
  47790. /**
  47791. * Specifies that the submesh is ready to be used.
  47792. * @param mesh - BJS mesh.
  47793. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47794. * @param useInstances - Specifies that instances should be used.
  47795. * @returns - boolean indicating that the submesh is ready or not.
  47796. */
  47797. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47798. /**
  47799. * Specifies if the material uses metallic roughness workflow.
  47800. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47801. */
  47802. isMetallicWorkflow(): boolean;
  47803. private _prepareEffect;
  47804. private _prepareDefines;
  47805. /**
  47806. * Force shader compilation
  47807. */
  47808. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47809. clipPlane: boolean;
  47810. }>): void;
  47811. /**
  47812. * Initializes the uniform buffer layout for the shader.
  47813. */
  47814. buildUniformLayout(): void;
  47815. /**
  47816. * Unbinds the material from the mesh
  47817. */
  47818. unbind(): void;
  47819. /**
  47820. * Binds the submesh data.
  47821. * @param world - The world matrix.
  47822. * @param mesh - The BJS mesh.
  47823. * @param subMesh - A submesh of the BJS mesh.
  47824. */
  47825. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47826. /**
  47827. * Returns the animatable textures.
  47828. * @returns - Array of animatable textures.
  47829. */
  47830. getAnimatables(): IAnimatable[];
  47831. /**
  47832. * Returns the texture used for reflections.
  47833. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47834. */
  47835. private _getReflectionTexture;
  47836. /**
  47837. * Returns an array of the actively used textures.
  47838. * @returns - Array of BaseTextures
  47839. */
  47840. getActiveTextures(): BaseTexture[];
  47841. /**
  47842. * Checks to see if a texture is used in the material.
  47843. * @param texture - Base texture to use.
  47844. * @returns - Boolean specifying if a texture is used in the material.
  47845. */
  47846. hasTexture(texture: BaseTexture): boolean;
  47847. /**
  47848. * Disposes the resources of the material.
  47849. * @param forceDisposeEffect - Forces the disposal of effects.
  47850. * @param forceDisposeTextures - Forces the disposal of all textures.
  47851. */
  47852. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47853. }
  47854. }
  47855. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47856. import { Nullable } from "babylonjs/types";
  47857. import { Scene } from "babylonjs/scene";
  47858. import { Color3 } from "babylonjs/Maths/math";
  47859. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47860. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47861. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47862. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47863. /**
  47864. * The Physically based material of BJS.
  47865. *
  47866. * This offers the main features of a standard PBR material.
  47867. * For more information, please refer to the documentation :
  47868. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47869. */
  47870. export class PBRMaterial extends PBRBaseMaterial {
  47871. /**
  47872. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47873. */
  47874. static readonly PBRMATERIAL_OPAQUE: number;
  47875. /**
  47876. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47877. */
  47878. static readonly PBRMATERIAL_ALPHATEST: number;
  47879. /**
  47880. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47881. */
  47882. static readonly PBRMATERIAL_ALPHABLEND: number;
  47883. /**
  47884. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47885. * They are also discarded below the alpha cutoff threshold to improve performances.
  47886. */
  47887. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47888. /**
  47889. * Defines the default value of how much AO map is occluding the analytical lights
  47890. * (point spot...).
  47891. */
  47892. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47893. /**
  47894. * Intensity of the direct lights e.g. the four lights available in your scene.
  47895. * This impacts both the direct diffuse and specular highlights.
  47896. */
  47897. directIntensity: number;
  47898. /**
  47899. * Intensity of the emissive part of the material.
  47900. * This helps controlling the emissive effect without modifying the emissive color.
  47901. */
  47902. emissiveIntensity: number;
  47903. /**
  47904. * Intensity of the environment e.g. how much the environment will light the object
  47905. * either through harmonics for rough material or through the refelction for shiny ones.
  47906. */
  47907. environmentIntensity: number;
  47908. /**
  47909. * This is a special control allowing the reduction of the specular highlights coming from the
  47910. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47911. */
  47912. specularIntensity: number;
  47913. /**
  47914. * Debug Control allowing disabling the bump map on this material.
  47915. */
  47916. disableBumpMap: boolean;
  47917. /**
  47918. * AKA Diffuse Texture in standard nomenclature.
  47919. */
  47920. albedoTexture: BaseTexture;
  47921. /**
  47922. * AKA Occlusion Texture in other nomenclature.
  47923. */
  47924. ambientTexture: BaseTexture;
  47925. /**
  47926. * AKA Occlusion Texture Intensity in other nomenclature.
  47927. */
  47928. ambientTextureStrength: number;
  47929. /**
  47930. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47931. * 1 means it completely occludes it
  47932. * 0 mean it has no impact
  47933. */
  47934. ambientTextureImpactOnAnalyticalLights: number;
  47935. /**
  47936. * Stores the alpha values in a texture.
  47937. */
  47938. opacityTexture: BaseTexture;
  47939. /**
  47940. * Stores the reflection values in a texture.
  47941. */
  47942. reflectionTexture: Nullable<BaseTexture>;
  47943. /**
  47944. * Stores the emissive values in a texture.
  47945. */
  47946. emissiveTexture: BaseTexture;
  47947. /**
  47948. * AKA Specular texture in other nomenclature.
  47949. */
  47950. reflectivityTexture: BaseTexture;
  47951. /**
  47952. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47953. */
  47954. metallicTexture: BaseTexture;
  47955. /**
  47956. * Specifies the metallic scalar of the metallic/roughness workflow.
  47957. * Can also be used to scale the metalness values of the metallic texture.
  47958. */
  47959. metallic: Nullable<number>;
  47960. /**
  47961. * Specifies the roughness scalar of the metallic/roughness workflow.
  47962. * Can also be used to scale the roughness values of the metallic texture.
  47963. */
  47964. roughness: Nullable<number>;
  47965. /**
  47966. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47967. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47968. */
  47969. microSurfaceTexture: BaseTexture;
  47970. /**
  47971. * Stores surface normal data used to displace a mesh in a texture.
  47972. */
  47973. bumpTexture: BaseTexture;
  47974. /**
  47975. * Stores the pre-calculated light information of a mesh in a texture.
  47976. */
  47977. lightmapTexture: BaseTexture;
  47978. /**
  47979. * Stores the refracted light information in a texture.
  47980. */
  47981. refractionTexture: Nullable<BaseTexture>;
  47982. /**
  47983. * The color of a material in ambient lighting.
  47984. */
  47985. ambientColor: Color3;
  47986. /**
  47987. * AKA Diffuse Color in other nomenclature.
  47988. */
  47989. albedoColor: Color3;
  47990. /**
  47991. * AKA Specular Color in other nomenclature.
  47992. */
  47993. reflectivityColor: Color3;
  47994. /**
  47995. * The color reflected from the material.
  47996. */
  47997. reflectionColor: Color3;
  47998. /**
  47999. * The color emitted from the material.
  48000. */
  48001. emissiveColor: Color3;
  48002. /**
  48003. * AKA Glossiness in other nomenclature.
  48004. */
  48005. microSurface: number;
  48006. /**
  48007. * source material index of refraction (IOR)' / 'destination material IOR.
  48008. */
  48009. indexOfRefraction: number;
  48010. /**
  48011. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48012. */
  48013. invertRefractionY: boolean;
  48014. /**
  48015. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48016. * Materials half opaque for instance using refraction could benefit from this control.
  48017. */
  48018. linkRefractionWithTransparency: boolean;
  48019. /**
  48020. * If true, the light map contains occlusion information instead of lighting info.
  48021. */
  48022. useLightmapAsShadowmap: boolean;
  48023. /**
  48024. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48025. */
  48026. useAlphaFromAlbedoTexture: boolean;
  48027. /**
  48028. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48029. */
  48030. forceAlphaTest: boolean;
  48031. /**
  48032. * Defines the alpha limits in alpha test mode.
  48033. */
  48034. alphaCutOff: number;
  48035. /**
  48036. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48037. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48038. */
  48039. useSpecularOverAlpha: boolean;
  48040. /**
  48041. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48042. */
  48043. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48044. /**
  48045. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48046. */
  48047. useRoughnessFromMetallicTextureAlpha: boolean;
  48048. /**
  48049. * Specifies if the metallic texture contains the roughness information in its green channel.
  48050. */
  48051. useRoughnessFromMetallicTextureGreen: boolean;
  48052. /**
  48053. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48054. */
  48055. useMetallnessFromMetallicTextureBlue: boolean;
  48056. /**
  48057. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48058. */
  48059. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48060. /**
  48061. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48062. */
  48063. useAmbientInGrayScale: boolean;
  48064. /**
  48065. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48066. * The material will try to infer what glossiness each pixel should be.
  48067. */
  48068. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48069. /**
  48070. * BJS is using an harcoded light falloff based on a manually sets up range.
  48071. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48072. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48073. */
  48074. /**
  48075. * BJS is using an harcoded light falloff based on a manually sets up range.
  48076. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48077. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48078. */
  48079. usePhysicalLightFalloff: boolean;
  48080. /**
  48081. * In order to support the falloff compatibility with gltf, a special mode has been added
  48082. * to reproduce the gltf light falloff.
  48083. */
  48084. /**
  48085. * In order to support the falloff compatibility with gltf, a special mode has been added
  48086. * to reproduce the gltf light falloff.
  48087. */
  48088. useGLTFLightFalloff: boolean;
  48089. /**
  48090. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48091. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48092. */
  48093. useRadianceOverAlpha: boolean;
  48094. /**
  48095. * Allows using an object space normal map (instead of tangent space).
  48096. */
  48097. useObjectSpaceNormalMap: boolean;
  48098. /**
  48099. * Allows using the bump map in parallax mode.
  48100. */
  48101. useParallax: boolean;
  48102. /**
  48103. * Allows using the bump map in parallax occlusion mode.
  48104. */
  48105. useParallaxOcclusion: boolean;
  48106. /**
  48107. * Controls the scale bias of the parallax mode.
  48108. */
  48109. parallaxScaleBias: number;
  48110. /**
  48111. * If sets to true, disables all the lights affecting the material.
  48112. */
  48113. disableLighting: boolean;
  48114. /**
  48115. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48116. */
  48117. forceIrradianceInFragment: boolean;
  48118. /**
  48119. * Number of Simultaneous lights allowed on the material.
  48120. */
  48121. maxSimultaneousLights: number;
  48122. /**
  48123. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48124. */
  48125. invertNormalMapX: boolean;
  48126. /**
  48127. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48128. */
  48129. invertNormalMapY: boolean;
  48130. /**
  48131. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48132. */
  48133. twoSidedLighting: boolean;
  48134. /**
  48135. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48136. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48137. */
  48138. useAlphaFresnel: boolean;
  48139. /**
  48140. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48141. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48142. */
  48143. useLinearAlphaFresnel: boolean;
  48144. /**
  48145. * Let user defines the brdf lookup texture used for IBL.
  48146. * A default 8bit version is embedded but you could point at :
  48147. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  48148. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48149. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48150. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48151. */
  48152. environmentBRDFTexture: Nullable<BaseTexture>;
  48153. /**
  48154. * Force normal to face away from face.
  48155. */
  48156. forceNormalForward: boolean;
  48157. /**
  48158. * Enables specular anti aliasing in the PBR shader.
  48159. * It will both interacts on the Geometry for analytical and IBL lighting.
  48160. * It also prefilter the roughness map based on the bump values.
  48161. */
  48162. enableSpecularAntiAliasing: boolean;
  48163. /**
  48164. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48165. * makes the reflect vector face the model (under horizon).
  48166. */
  48167. useHorizonOcclusion: boolean;
  48168. /**
  48169. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48170. * too much the area relying on ambient texture to define their ambient occlusion.
  48171. */
  48172. useRadianceOcclusion: boolean;
  48173. /**
  48174. * If set to true, no lighting calculations will be applied.
  48175. */
  48176. unlit: boolean;
  48177. /**
  48178. * Gets the image processing configuration used either in this material.
  48179. */
  48180. /**
  48181. * Sets the Default image processing configuration used either in the this material.
  48182. *
  48183. * If sets to null, the scene one is in use.
  48184. */
  48185. imageProcessingConfiguration: ImageProcessingConfiguration;
  48186. /**
  48187. * Gets wether the color curves effect is enabled.
  48188. */
  48189. /**
  48190. * Sets wether the color curves effect is enabled.
  48191. */
  48192. cameraColorCurvesEnabled: boolean;
  48193. /**
  48194. * Gets wether the color grading effect is enabled.
  48195. */
  48196. /**
  48197. * Gets wether the color grading effect is enabled.
  48198. */
  48199. cameraColorGradingEnabled: boolean;
  48200. /**
  48201. * Gets wether tonemapping is enabled or not.
  48202. */
  48203. /**
  48204. * Sets wether tonemapping is enabled or not
  48205. */
  48206. cameraToneMappingEnabled: boolean;
  48207. /**
  48208. * The camera exposure used on this material.
  48209. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48210. * This corresponds to a photographic exposure.
  48211. */
  48212. /**
  48213. * The camera exposure used on this material.
  48214. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48215. * This corresponds to a photographic exposure.
  48216. */
  48217. cameraExposure: number;
  48218. /**
  48219. * Gets The camera contrast used on this material.
  48220. */
  48221. /**
  48222. * Sets The camera contrast used on this material.
  48223. */
  48224. cameraContrast: number;
  48225. /**
  48226. * Gets the Color Grading 2D Lookup Texture.
  48227. */
  48228. /**
  48229. * Sets the Color Grading 2D Lookup Texture.
  48230. */
  48231. cameraColorGradingTexture: Nullable<BaseTexture>;
  48232. /**
  48233. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48234. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48235. * 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;
  48236. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48237. */
  48238. /**
  48239. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48240. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48241. * 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;
  48242. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48243. */
  48244. cameraColorCurves: Nullable<ColorCurves>;
  48245. /**
  48246. * Instantiates a new PBRMaterial instance.
  48247. *
  48248. * @param name The material name
  48249. * @param scene The scene the material will be use in.
  48250. */
  48251. constructor(name: string, scene: Scene);
  48252. /**
  48253. * Returns the name of this material class.
  48254. */
  48255. getClassName(): string;
  48256. /**
  48257. * Makes a duplicate of the current material.
  48258. * @param name - name to use for the new material.
  48259. */
  48260. clone(name: string): PBRMaterial;
  48261. /**
  48262. * Serializes this PBR Material.
  48263. * @returns - An object with the serialized material.
  48264. */
  48265. serialize(): any;
  48266. /**
  48267. * Parses a PBR Material from a serialized object.
  48268. * @param source - Serialized object.
  48269. * @param scene - BJS scene instance.
  48270. * @param rootUrl - url for the scene object
  48271. * @returns - PBRMaterial
  48272. */
  48273. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48274. }
  48275. }
  48276. declare module "babylonjs/Misc/dds" {
  48277. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48278. import { Engine } from "babylonjs/Engines/engine";
  48279. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48280. import { Nullable } from "babylonjs/types";
  48281. import { Scene } from "babylonjs/scene";
  48282. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48283. /**
  48284. * Direct draw surface info
  48285. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48286. */
  48287. export interface DDSInfo {
  48288. /**
  48289. * Width of the texture
  48290. */
  48291. width: number;
  48292. /**
  48293. * Width of the texture
  48294. */
  48295. height: number;
  48296. /**
  48297. * Number of Mipmaps for the texture
  48298. * @see https://en.wikipedia.org/wiki/Mipmap
  48299. */
  48300. mipmapCount: number;
  48301. /**
  48302. * If the textures format is a known fourCC format
  48303. * @see https://www.fourcc.org/
  48304. */
  48305. isFourCC: boolean;
  48306. /**
  48307. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48308. */
  48309. isRGB: boolean;
  48310. /**
  48311. * If the texture is a lumincance format
  48312. */
  48313. isLuminance: boolean;
  48314. /**
  48315. * If this is a cube texture
  48316. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48317. */
  48318. isCube: boolean;
  48319. /**
  48320. * If the texture is a compressed format eg. FOURCC_DXT1
  48321. */
  48322. isCompressed: boolean;
  48323. /**
  48324. * The dxgiFormat of the texture
  48325. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48326. */
  48327. dxgiFormat: number;
  48328. /**
  48329. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48330. */
  48331. textureType: number;
  48332. /**
  48333. * Sphericle polynomial created for the dds texture
  48334. */
  48335. sphericalPolynomial?: SphericalPolynomial;
  48336. }
  48337. /**
  48338. * Class used to provide DDS decompression tools
  48339. */
  48340. export class DDSTools {
  48341. /**
  48342. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48343. */
  48344. static StoreLODInAlphaChannel: boolean;
  48345. /**
  48346. * Gets DDS information from an array buffer
  48347. * @param arrayBuffer defines the array buffer to read data from
  48348. * @returns the DDS information
  48349. */
  48350. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48351. private static _FloatView;
  48352. private static _Int32View;
  48353. private static _ToHalfFloat;
  48354. private static _FromHalfFloat;
  48355. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48356. private static _GetHalfFloatRGBAArrayBuffer;
  48357. private static _GetFloatRGBAArrayBuffer;
  48358. private static _GetFloatAsUIntRGBAArrayBuffer;
  48359. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48360. private static _GetRGBAArrayBuffer;
  48361. private static _ExtractLongWordOrder;
  48362. private static _GetRGBArrayBuffer;
  48363. private static _GetLuminanceArrayBuffer;
  48364. /**
  48365. * Uploads DDS Levels to a Babylon Texture
  48366. * @hidden
  48367. */
  48368. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48369. }
  48370. module "babylonjs/Engines/engine" {
  48371. interface Engine {
  48372. /**
  48373. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48374. * @param rootUrl defines the url where the file to load is located
  48375. * @param scene defines the current scene
  48376. * @param lodScale defines scale to apply to the mip map selection
  48377. * @param lodOffset defines offset to apply to the mip map selection
  48378. * @param onLoad defines an optional callback raised when the texture is loaded
  48379. * @param onError defines an optional callback raised if there is an issue to load the texture
  48380. * @param format defines the format of the data
  48381. * @param forcedExtension defines the extension to use to pick the right loader
  48382. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48383. * @returns the cube texture as an InternalTexture
  48384. */
  48385. 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;
  48386. }
  48387. }
  48388. }
  48389. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48390. import { Nullable } from "babylonjs/types";
  48391. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48392. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48393. /**
  48394. * Implementation of the DDS Texture Loader.
  48395. * @hidden
  48396. */
  48397. export class _DDSTextureLoader implements IInternalTextureLoader {
  48398. /**
  48399. * Defines wether the loader supports cascade loading the different faces.
  48400. */
  48401. readonly supportCascades: boolean;
  48402. /**
  48403. * This returns if the loader support the current file information.
  48404. * @param extension defines the file extension of the file being loaded
  48405. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48406. * @param fallback defines the fallback internal texture if any
  48407. * @param isBase64 defines whether the texture is encoded as a base64
  48408. * @param isBuffer defines whether the texture data are stored as a buffer
  48409. * @returns true if the loader can load the specified file
  48410. */
  48411. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48412. /**
  48413. * Transform the url before loading if required.
  48414. * @param rootUrl the url of the texture
  48415. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48416. * @returns the transformed texture
  48417. */
  48418. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48419. /**
  48420. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48421. * @param rootUrl the url of the texture
  48422. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48423. * @returns the fallback texture
  48424. */
  48425. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48426. /**
  48427. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48428. * @param data contains the texture data
  48429. * @param texture defines the BabylonJS internal texture
  48430. * @param createPolynomials will be true if polynomials have been requested
  48431. * @param onLoad defines the callback to trigger once the texture is ready
  48432. * @param onError defines the callback to trigger in case of error
  48433. */
  48434. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48435. /**
  48436. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48437. * @param data contains the texture data
  48438. * @param texture defines the BabylonJS internal texture
  48439. * @param callback defines the method to call once ready to upload
  48440. */
  48441. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48442. }
  48443. }
  48444. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48445. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48446. /** @hidden */
  48447. export var rgbdEncodePixelShader: {
  48448. name: string;
  48449. shader: string;
  48450. };
  48451. }
  48452. declare module "babylonjs/Misc/environmentTextureTools" {
  48453. import { Nullable } from "babylonjs/types";
  48454. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48455. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48456. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48457. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48458. import "babylonjs/Shaders/rgbdEncode.fragment";
  48459. import "babylonjs/Shaders/rgbdDecode.fragment";
  48460. /**
  48461. * Raw texture data and descriptor sufficient for WebGL texture upload
  48462. */
  48463. export interface EnvironmentTextureInfo {
  48464. /**
  48465. * Version of the environment map
  48466. */
  48467. version: number;
  48468. /**
  48469. * Width of image
  48470. */
  48471. width: number;
  48472. /**
  48473. * Irradiance information stored in the file.
  48474. */
  48475. irradiance: any;
  48476. /**
  48477. * Specular information stored in the file.
  48478. */
  48479. specular: any;
  48480. }
  48481. /**
  48482. * Sets of helpers addressing the serialization and deserialization of environment texture
  48483. * stored in a BabylonJS env file.
  48484. * Those files are usually stored as .env files.
  48485. */
  48486. export class EnvironmentTextureTools {
  48487. /**
  48488. * Magic number identifying the env file.
  48489. */
  48490. private static _MagicBytes;
  48491. /**
  48492. * Gets the environment info from an env file.
  48493. * @param data The array buffer containing the .env bytes.
  48494. * @returns the environment file info (the json header) if successfully parsed.
  48495. */
  48496. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48497. /**
  48498. * Creates an environment texture from a loaded cube texture.
  48499. * @param texture defines the cube texture to convert in env file
  48500. * @return a promise containing the environment data if succesfull.
  48501. */
  48502. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48503. /**
  48504. * Creates a JSON representation of the spherical data.
  48505. * @param texture defines the texture containing the polynomials
  48506. * @return the JSON representation of the spherical info
  48507. */
  48508. private static _CreateEnvTextureIrradiance;
  48509. /**
  48510. * Uploads the texture info contained in the env file to the GPU.
  48511. * @param texture defines the internal texture to upload to
  48512. * @param arrayBuffer defines the buffer cotaining the data to load
  48513. * @param info defines the texture info retrieved through the GetEnvInfo method
  48514. * @returns a promise
  48515. */
  48516. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48517. /**
  48518. * Uploads the levels of image data to the GPU.
  48519. * @param texture defines the internal texture to upload to
  48520. * @param imageData defines the array buffer views of image data [mipmap][face]
  48521. * @returns a promise
  48522. */
  48523. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48524. /**
  48525. * Uploads spherical polynomials information to the texture.
  48526. * @param texture defines the texture we are trying to upload the information to
  48527. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48528. */
  48529. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48530. /** @hidden */
  48531. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48532. }
  48533. }
  48534. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48535. import { Nullable } from "babylonjs/types";
  48536. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48537. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48538. /**
  48539. * Implementation of the ENV Texture Loader.
  48540. * @hidden
  48541. */
  48542. export class _ENVTextureLoader implements IInternalTextureLoader {
  48543. /**
  48544. * Defines wether the loader supports cascade loading the different faces.
  48545. */
  48546. readonly supportCascades: boolean;
  48547. /**
  48548. * This returns if the loader support the current file information.
  48549. * @param extension defines the file extension of the file being loaded
  48550. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48551. * @param fallback defines the fallback internal texture if any
  48552. * @param isBase64 defines whether the texture is encoded as a base64
  48553. * @param isBuffer defines whether the texture data are stored as a buffer
  48554. * @returns true if the loader can load the specified file
  48555. */
  48556. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48557. /**
  48558. * Transform the url before loading if required.
  48559. * @param rootUrl the url of the texture
  48560. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48561. * @returns the transformed texture
  48562. */
  48563. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48564. /**
  48565. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48566. * @param rootUrl the url of the texture
  48567. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48568. * @returns the fallback texture
  48569. */
  48570. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48571. /**
  48572. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48573. * @param data contains the texture data
  48574. * @param texture defines the BabylonJS internal texture
  48575. * @param createPolynomials will be true if polynomials have been requested
  48576. * @param onLoad defines the callback to trigger once the texture is ready
  48577. * @param onError defines the callback to trigger in case of error
  48578. */
  48579. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48580. /**
  48581. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48582. * @param data contains the texture data
  48583. * @param texture defines the BabylonJS internal texture
  48584. * @param callback defines the method to call once ready to upload
  48585. */
  48586. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48587. }
  48588. }
  48589. declare module "babylonjs/Misc/khronosTextureContainer" {
  48590. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48591. /**
  48592. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48593. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48594. */
  48595. export class KhronosTextureContainer {
  48596. /** contents of the KTX container file */
  48597. arrayBuffer: any;
  48598. private static HEADER_LEN;
  48599. private static COMPRESSED_2D;
  48600. private static COMPRESSED_3D;
  48601. private static TEX_2D;
  48602. private static TEX_3D;
  48603. /**
  48604. * Gets the openGL type
  48605. */
  48606. glType: number;
  48607. /**
  48608. * Gets the openGL type size
  48609. */
  48610. glTypeSize: number;
  48611. /**
  48612. * Gets the openGL format
  48613. */
  48614. glFormat: number;
  48615. /**
  48616. * Gets the openGL internal format
  48617. */
  48618. glInternalFormat: number;
  48619. /**
  48620. * Gets the base internal format
  48621. */
  48622. glBaseInternalFormat: number;
  48623. /**
  48624. * Gets image width in pixel
  48625. */
  48626. pixelWidth: number;
  48627. /**
  48628. * Gets image height in pixel
  48629. */
  48630. pixelHeight: number;
  48631. /**
  48632. * Gets image depth in pixels
  48633. */
  48634. pixelDepth: number;
  48635. /**
  48636. * Gets the number of array elements
  48637. */
  48638. numberOfArrayElements: number;
  48639. /**
  48640. * Gets the number of faces
  48641. */
  48642. numberOfFaces: number;
  48643. /**
  48644. * Gets the number of mipmap levels
  48645. */
  48646. numberOfMipmapLevels: number;
  48647. /**
  48648. * Gets the bytes of key value data
  48649. */
  48650. bytesOfKeyValueData: number;
  48651. /**
  48652. * Gets the load type
  48653. */
  48654. loadType: number;
  48655. /**
  48656. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48657. */
  48658. isInvalid: boolean;
  48659. /**
  48660. * Creates a new KhronosTextureContainer
  48661. * @param arrayBuffer contents of the KTX container file
  48662. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48663. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48664. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48665. */
  48666. constructor(
  48667. /** contents of the KTX container file */
  48668. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48669. /**
  48670. * Uploads KTX content to a Babylon Texture.
  48671. * It is assumed that the texture has already been created & is currently bound
  48672. * @hidden
  48673. */
  48674. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48675. private _upload2DCompressedLevels;
  48676. }
  48677. }
  48678. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48679. import { Nullable } from "babylonjs/types";
  48680. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48681. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48682. /**
  48683. * Implementation of the KTX Texture Loader.
  48684. * @hidden
  48685. */
  48686. export class _KTXTextureLoader implements IInternalTextureLoader {
  48687. /**
  48688. * Defines wether the loader supports cascade loading the different faces.
  48689. */
  48690. readonly supportCascades: boolean;
  48691. /**
  48692. * This returns if the loader support the current file information.
  48693. * @param extension defines the file extension of the file being loaded
  48694. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48695. * @param fallback defines the fallback internal texture if any
  48696. * @param isBase64 defines whether the texture is encoded as a base64
  48697. * @param isBuffer defines whether the texture data are stored as a buffer
  48698. * @returns true if the loader can load the specified file
  48699. */
  48700. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48701. /**
  48702. * Transform the url before loading if required.
  48703. * @param rootUrl the url of the texture
  48704. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48705. * @returns the transformed texture
  48706. */
  48707. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48708. /**
  48709. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48710. * @param rootUrl the url of the texture
  48711. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48712. * @returns the fallback texture
  48713. */
  48714. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48715. /**
  48716. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48717. * @param data contains the texture data
  48718. * @param texture defines the BabylonJS internal texture
  48719. * @param createPolynomials will be true if polynomials have been requested
  48720. * @param onLoad defines the callback to trigger once the texture is ready
  48721. * @param onError defines the callback to trigger in case of error
  48722. */
  48723. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48724. /**
  48725. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48726. * @param data contains the texture data
  48727. * @param texture defines the BabylonJS internal texture
  48728. * @param callback defines the method to call once ready to upload
  48729. */
  48730. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48731. }
  48732. }
  48733. declare module "babylonjs/Helpers/sceneHelpers" {
  48734. import { Nullable } from "babylonjs/types";
  48735. import { Mesh } from "babylonjs/Meshes/mesh";
  48736. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48737. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48738. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48739. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48740. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48741. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48742. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48743. import "babylonjs/Meshes/Builders/boxBuilder";
  48744. /** @hidden */
  48745. export var _forceSceneHelpersToBundle: boolean;
  48746. module "babylonjs/scene" {
  48747. interface Scene {
  48748. /**
  48749. * Creates a default light for the scene.
  48750. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48751. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48752. */
  48753. createDefaultLight(replace?: boolean): void;
  48754. /**
  48755. * Creates a default camera for the scene.
  48756. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48757. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48758. * @param replace has default false, when true replaces the active camera in the scene
  48759. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48760. */
  48761. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48762. /**
  48763. * Creates a default camera and a default light.
  48764. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48765. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48766. * @param replace has the default false, when true replaces the active camera/light in the scene
  48767. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48768. */
  48769. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48770. /**
  48771. * Creates a new sky box
  48772. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48773. * @param environmentTexture defines the texture to use as environment texture
  48774. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48775. * @param scale defines the overall scale of the skybox
  48776. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48777. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48778. * @returns a new mesh holding the sky box
  48779. */
  48780. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48781. /**
  48782. * Creates a new environment
  48783. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48784. * @param options defines the options you can use to configure the environment
  48785. * @returns the new EnvironmentHelper
  48786. */
  48787. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48788. /**
  48789. * Creates a new VREXperienceHelper
  48790. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48791. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48792. * @returns a new VREXperienceHelper
  48793. */
  48794. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48795. /**
  48796. * Creates a new XREXperienceHelper
  48797. * @see http://doc.babylonjs.com/how_to/webxr
  48798. * @returns a promise for a new XREXperienceHelper
  48799. */
  48800. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48801. }
  48802. }
  48803. }
  48804. declare module "babylonjs/Helpers/videoDome" {
  48805. import { Scene } from "babylonjs/scene";
  48806. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48807. import { Mesh } from "babylonjs/Meshes/mesh";
  48808. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48809. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48810. import "babylonjs/Meshes/Builders/sphereBuilder";
  48811. /**
  48812. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48813. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48814. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48815. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48816. */
  48817. export class VideoDome extends TransformNode {
  48818. /**
  48819. * Define the video source as a Monoscopic panoramic 360 video.
  48820. */
  48821. static readonly MODE_MONOSCOPIC: number;
  48822. /**
  48823. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48824. */
  48825. static readonly MODE_TOPBOTTOM: number;
  48826. /**
  48827. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48828. */
  48829. static readonly MODE_SIDEBYSIDE: number;
  48830. private _useDirectMapping;
  48831. /**
  48832. * The video texture being displayed on the sphere
  48833. */
  48834. protected _videoTexture: VideoTexture;
  48835. /**
  48836. * Gets the video texture being displayed on the sphere
  48837. */
  48838. readonly videoTexture: VideoTexture;
  48839. /**
  48840. * The skybox material
  48841. */
  48842. protected _material: BackgroundMaterial;
  48843. /**
  48844. * The surface used for the skybox
  48845. */
  48846. protected _mesh: Mesh;
  48847. /**
  48848. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48849. * Also see the options.resolution property.
  48850. */
  48851. fovMultiplier: number;
  48852. private _videoMode;
  48853. /**
  48854. * Gets or set the current video mode for the video. It can be:
  48855. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48856. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48857. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48858. */
  48859. videoMode: number;
  48860. /**
  48861. * Oberserver used in Stereoscopic VR Mode.
  48862. */
  48863. private _onBeforeCameraRenderObserver;
  48864. /**
  48865. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48866. * @param name Element's name, child elements will append suffixes for their own names.
  48867. * @param urlsOrVideo defines the url(s) or the video element to use
  48868. * @param options An object containing optional or exposed sub element properties
  48869. */
  48870. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48871. resolution?: number;
  48872. clickToPlay?: boolean;
  48873. autoPlay?: boolean;
  48874. loop?: boolean;
  48875. size?: number;
  48876. poster?: string;
  48877. faceForward?: boolean;
  48878. useDirectMapping?: boolean;
  48879. }, scene: Scene);
  48880. private _changeVideoMode;
  48881. /**
  48882. * Releases resources associated with this node.
  48883. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48884. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48885. */
  48886. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48887. }
  48888. }
  48889. declare module "babylonjs/Helpers/index" {
  48890. export * from "babylonjs/Helpers/environmentHelper";
  48891. export * from "babylonjs/Helpers/photoDome";
  48892. export * from "babylonjs/Helpers/sceneHelpers";
  48893. export * from "babylonjs/Helpers/videoDome";
  48894. }
  48895. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48896. import { PerfCounter } from "babylonjs/Misc/tools";
  48897. import { IDisposable } from "babylonjs/scene";
  48898. import { Engine } from "babylonjs/Engines/engine";
  48899. /**
  48900. * This class can be used to get instrumentation data from a Babylon engine
  48901. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48902. */
  48903. export class EngineInstrumentation implements IDisposable {
  48904. /**
  48905. * Define the instrumented engine.
  48906. */
  48907. engine: Engine;
  48908. private _captureGPUFrameTime;
  48909. private _gpuFrameTimeToken;
  48910. private _gpuFrameTime;
  48911. private _captureShaderCompilationTime;
  48912. private _shaderCompilationTime;
  48913. private _onBeginFrameObserver;
  48914. private _onEndFrameObserver;
  48915. private _onBeforeShaderCompilationObserver;
  48916. private _onAfterShaderCompilationObserver;
  48917. /**
  48918. * Gets the perf counter used for GPU frame time
  48919. */
  48920. readonly gpuFrameTimeCounter: PerfCounter;
  48921. /**
  48922. * Gets the GPU frame time capture status
  48923. */
  48924. /**
  48925. * Enable or disable the GPU frame time capture
  48926. */
  48927. captureGPUFrameTime: boolean;
  48928. /**
  48929. * Gets the perf counter used for shader compilation time
  48930. */
  48931. readonly shaderCompilationTimeCounter: PerfCounter;
  48932. /**
  48933. * Gets the shader compilation time capture status
  48934. */
  48935. /**
  48936. * Enable or disable the shader compilation time capture
  48937. */
  48938. captureShaderCompilationTime: boolean;
  48939. /**
  48940. * Instantiates a new engine instrumentation.
  48941. * This class can be used to get instrumentation data from a Babylon engine
  48942. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48943. * @param engine Defines the engine to instrument
  48944. */
  48945. constructor(
  48946. /**
  48947. * Define the instrumented engine.
  48948. */
  48949. engine: Engine);
  48950. /**
  48951. * Dispose and release associated resources.
  48952. */
  48953. dispose(): void;
  48954. }
  48955. }
  48956. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48957. import { PerfCounter } from "babylonjs/Misc/tools";
  48958. import { Scene, IDisposable } from "babylonjs/scene";
  48959. /**
  48960. * This class can be used to get instrumentation data from a Babylon engine
  48961. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48962. */
  48963. export class SceneInstrumentation implements IDisposable {
  48964. /**
  48965. * Defines the scene to instrument
  48966. */
  48967. scene: Scene;
  48968. private _captureActiveMeshesEvaluationTime;
  48969. private _activeMeshesEvaluationTime;
  48970. private _captureRenderTargetsRenderTime;
  48971. private _renderTargetsRenderTime;
  48972. private _captureFrameTime;
  48973. private _frameTime;
  48974. private _captureRenderTime;
  48975. private _renderTime;
  48976. private _captureInterFrameTime;
  48977. private _interFrameTime;
  48978. private _captureParticlesRenderTime;
  48979. private _particlesRenderTime;
  48980. private _captureSpritesRenderTime;
  48981. private _spritesRenderTime;
  48982. private _capturePhysicsTime;
  48983. private _physicsTime;
  48984. private _captureAnimationsTime;
  48985. private _animationsTime;
  48986. private _captureCameraRenderTime;
  48987. private _cameraRenderTime;
  48988. private _onBeforeActiveMeshesEvaluationObserver;
  48989. private _onAfterActiveMeshesEvaluationObserver;
  48990. private _onBeforeRenderTargetsRenderObserver;
  48991. private _onAfterRenderTargetsRenderObserver;
  48992. private _onAfterRenderObserver;
  48993. private _onBeforeDrawPhaseObserver;
  48994. private _onAfterDrawPhaseObserver;
  48995. private _onBeforeAnimationsObserver;
  48996. private _onBeforeParticlesRenderingObserver;
  48997. private _onAfterParticlesRenderingObserver;
  48998. private _onBeforeSpritesRenderingObserver;
  48999. private _onAfterSpritesRenderingObserver;
  49000. private _onBeforePhysicsObserver;
  49001. private _onAfterPhysicsObserver;
  49002. private _onAfterAnimationsObserver;
  49003. private _onBeforeCameraRenderObserver;
  49004. private _onAfterCameraRenderObserver;
  49005. /**
  49006. * Gets the perf counter used for active meshes evaluation time
  49007. */
  49008. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49009. /**
  49010. * Gets the active meshes evaluation time capture status
  49011. */
  49012. /**
  49013. * Enable or disable the active meshes evaluation time capture
  49014. */
  49015. captureActiveMeshesEvaluationTime: boolean;
  49016. /**
  49017. * Gets the perf counter used for render targets render time
  49018. */
  49019. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49020. /**
  49021. * Gets the render targets render time capture status
  49022. */
  49023. /**
  49024. * Enable or disable the render targets render time capture
  49025. */
  49026. captureRenderTargetsRenderTime: boolean;
  49027. /**
  49028. * Gets the perf counter used for particles render time
  49029. */
  49030. readonly particlesRenderTimeCounter: PerfCounter;
  49031. /**
  49032. * Gets the particles render time capture status
  49033. */
  49034. /**
  49035. * Enable or disable the particles render time capture
  49036. */
  49037. captureParticlesRenderTime: boolean;
  49038. /**
  49039. * Gets the perf counter used for sprites render time
  49040. */
  49041. readonly spritesRenderTimeCounter: PerfCounter;
  49042. /**
  49043. * Gets the sprites render time capture status
  49044. */
  49045. /**
  49046. * Enable or disable the sprites render time capture
  49047. */
  49048. captureSpritesRenderTime: boolean;
  49049. /**
  49050. * Gets the perf counter used for physics time
  49051. */
  49052. readonly physicsTimeCounter: PerfCounter;
  49053. /**
  49054. * Gets the physics time capture status
  49055. */
  49056. /**
  49057. * Enable or disable the physics time capture
  49058. */
  49059. capturePhysicsTime: boolean;
  49060. /**
  49061. * Gets the perf counter used for animations time
  49062. */
  49063. readonly animationsTimeCounter: PerfCounter;
  49064. /**
  49065. * Gets the animations time capture status
  49066. */
  49067. /**
  49068. * Enable or disable the animations time capture
  49069. */
  49070. captureAnimationsTime: boolean;
  49071. /**
  49072. * Gets the perf counter used for frame time capture
  49073. */
  49074. readonly frameTimeCounter: PerfCounter;
  49075. /**
  49076. * Gets the frame time capture status
  49077. */
  49078. /**
  49079. * Enable or disable the frame time capture
  49080. */
  49081. captureFrameTime: boolean;
  49082. /**
  49083. * Gets the perf counter used for inter-frames time capture
  49084. */
  49085. readonly interFrameTimeCounter: PerfCounter;
  49086. /**
  49087. * Gets the inter-frames time capture status
  49088. */
  49089. /**
  49090. * Enable or disable the inter-frames time capture
  49091. */
  49092. captureInterFrameTime: boolean;
  49093. /**
  49094. * Gets the perf counter used for render time capture
  49095. */
  49096. readonly renderTimeCounter: PerfCounter;
  49097. /**
  49098. * Gets the render time capture status
  49099. */
  49100. /**
  49101. * Enable or disable the render time capture
  49102. */
  49103. captureRenderTime: boolean;
  49104. /**
  49105. * Gets the perf counter used for camera render time capture
  49106. */
  49107. readonly cameraRenderTimeCounter: PerfCounter;
  49108. /**
  49109. * Gets the camera render time capture status
  49110. */
  49111. /**
  49112. * Enable or disable the camera render time capture
  49113. */
  49114. captureCameraRenderTime: boolean;
  49115. /**
  49116. * Gets the perf counter used for draw calls
  49117. */
  49118. readonly drawCallsCounter: PerfCounter;
  49119. /**
  49120. * Instantiates a new scene instrumentation.
  49121. * This class can be used to get instrumentation data from a Babylon engine
  49122. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49123. * @param scene Defines the scene to instrument
  49124. */
  49125. constructor(
  49126. /**
  49127. * Defines the scene to instrument
  49128. */
  49129. scene: Scene);
  49130. /**
  49131. * Dispose and release associated resources.
  49132. */
  49133. dispose(): void;
  49134. }
  49135. }
  49136. declare module "babylonjs/Instrumentation/index" {
  49137. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49138. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49139. export * from "babylonjs/Instrumentation/timeToken";
  49140. }
  49141. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49142. /** @hidden */
  49143. export var glowMapGenerationPixelShader: {
  49144. name: string;
  49145. shader: string;
  49146. };
  49147. }
  49148. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49149. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49150. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49151. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49152. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49153. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49154. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49155. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49156. /** @hidden */
  49157. export var glowMapGenerationVertexShader: {
  49158. name: string;
  49159. shader: string;
  49160. };
  49161. }
  49162. declare module "babylonjs/Layers/effectLayer" {
  49163. import { Observable } from "babylonjs/Misc/observable";
  49164. import { Nullable } from "babylonjs/types";
  49165. import { Camera } from "babylonjs/Cameras/camera";
  49166. import { Scene } from "babylonjs/scene";
  49167. import { Color4, ISize } from "babylonjs/Maths/math";
  49168. import { Engine } from "babylonjs/Engines/engine";
  49169. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49171. import { Mesh } from "babylonjs/Meshes/mesh";
  49172. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49173. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49174. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49175. import { Effect } from "babylonjs/Materials/effect";
  49176. import { Material } from "babylonjs/Materials/material";
  49177. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49178. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49179. /**
  49180. * Effect layer options. This helps customizing the behaviour
  49181. * of the effect layer.
  49182. */
  49183. export interface IEffectLayerOptions {
  49184. /**
  49185. * Multiplication factor apply to the canvas size to compute the render target size
  49186. * used to generated the objects (the smaller the faster).
  49187. */
  49188. mainTextureRatio: number;
  49189. /**
  49190. * Enforces a fixed size texture to ensure effect stability across devices.
  49191. */
  49192. mainTextureFixedSize?: number;
  49193. /**
  49194. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49195. */
  49196. alphaBlendingMode: number;
  49197. /**
  49198. * The camera attached to the layer.
  49199. */
  49200. camera: Nullable<Camera>;
  49201. /**
  49202. * The rendering group to draw the layer in.
  49203. */
  49204. renderingGroupId: number;
  49205. }
  49206. /**
  49207. * The effect layer Helps adding post process effect blended with the main pass.
  49208. *
  49209. * This can be for instance use to generate glow or higlight effects on the scene.
  49210. *
  49211. * The effect layer class can not be used directly and is intented to inherited from to be
  49212. * customized per effects.
  49213. */
  49214. export abstract class EffectLayer {
  49215. private _vertexBuffers;
  49216. private _indexBuffer;
  49217. private _cachedDefines;
  49218. private _effectLayerMapGenerationEffect;
  49219. private _effectLayerOptions;
  49220. private _mergeEffect;
  49221. protected _scene: Scene;
  49222. protected _engine: Engine;
  49223. protected _maxSize: number;
  49224. protected _mainTextureDesiredSize: ISize;
  49225. protected _mainTexture: RenderTargetTexture;
  49226. protected _shouldRender: boolean;
  49227. protected _postProcesses: PostProcess[];
  49228. protected _textures: BaseTexture[];
  49229. protected _emissiveTextureAndColor: {
  49230. texture: Nullable<BaseTexture>;
  49231. color: Color4;
  49232. };
  49233. /**
  49234. * The name of the layer
  49235. */
  49236. name: string;
  49237. /**
  49238. * The clear color of the texture used to generate the glow map.
  49239. */
  49240. neutralColor: Color4;
  49241. /**
  49242. * Specifies wether the highlight layer is enabled or not.
  49243. */
  49244. isEnabled: boolean;
  49245. /**
  49246. * Gets the camera attached to the layer.
  49247. */
  49248. readonly camera: Nullable<Camera>;
  49249. /**
  49250. * Gets the rendering group id the layer should render in.
  49251. */
  49252. readonly renderingGroupId: number;
  49253. /**
  49254. * An event triggered when the effect layer has been disposed.
  49255. */
  49256. onDisposeObservable: Observable<EffectLayer>;
  49257. /**
  49258. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49259. */
  49260. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49261. /**
  49262. * An event triggered when the generated texture is being merged in the scene.
  49263. */
  49264. onBeforeComposeObservable: Observable<EffectLayer>;
  49265. /**
  49266. * An event triggered when the generated texture has been merged in the scene.
  49267. */
  49268. onAfterComposeObservable: Observable<EffectLayer>;
  49269. /**
  49270. * An event triggered when the efffect layer changes its size.
  49271. */
  49272. onSizeChangedObservable: Observable<EffectLayer>;
  49273. /** @hidden */
  49274. static _SceneComponentInitialization: (scene: Scene) => void;
  49275. /**
  49276. * Instantiates a new effect Layer and references it in the scene.
  49277. * @param name The name of the layer
  49278. * @param scene The scene to use the layer in
  49279. */
  49280. constructor(
  49281. /** The Friendly of the effect in the scene */
  49282. name: string, scene: Scene);
  49283. /**
  49284. * Get the effect name of the layer.
  49285. * @return The effect name
  49286. */
  49287. abstract getEffectName(): string;
  49288. /**
  49289. * Checks for the readiness of the element composing the layer.
  49290. * @param subMesh the mesh to check for
  49291. * @param useInstances specify wether or not to use instances to render the mesh
  49292. * @return true if ready otherwise, false
  49293. */
  49294. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49295. /**
  49296. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49297. * @returns true if the effect requires stencil during the main canvas render pass.
  49298. */
  49299. abstract needStencil(): boolean;
  49300. /**
  49301. * Create the merge effect. This is the shader use to blit the information back
  49302. * to the main canvas at the end of the scene rendering.
  49303. * @returns The effect containing the shader used to merge the effect on the main canvas
  49304. */
  49305. protected abstract _createMergeEffect(): Effect;
  49306. /**
  49307. * Creates the render target textures and post processes used in the effect layer.
  49308. */
  49309. protected abstract _createTextureAndPostProcesses(): void;
  49310. /**
  49311. * Implementation specific of rendering the generating effect on the main canvas.
  49312. * @param effect The effect used to render through
  49313. */
  49314. protected abstract _internalRender(effect: Effect): void;
  49315. /**
  49316. * Sets the required values for both the emissive texture and and the main color.
  49317. */
  49318. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49319. /**
  49320. * Free any resources and references associated to a mesh.
  49321. * Internal use
  49322. * @param mesh The mesh to free.
  49323. */
  49324. abstract _disposeMesh(mesh: Mesh): void;
  49325. /**
  49326. * Serializes this layer (Glow or Highlight for example)
  49327. * @returns a serialized layer object
  49328. */
  49329. abstract serialize?(): any;
  49330. /**
  49331. * Initializes the effect layer with the required options.
  49332. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49333. */
  49334. protected _init(options: Partial<IEffectLayerOptions>): void;
  49335. /**
  49336. * Generates the index buffer of the full screen quad blending to the main canvas.
  49337. */
  49338. private _generateIndexBuffer;
  49339. /**
  49340. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49341. */
  49342. private _generateVertexBuffer;
  49343. /**
  49344. * Sets the main texture desired size which is the closest power of two
  49345. * of the engine canvas size.
  49346. */
  49347. private _setMainTextureSize;
  49348. /**
  49349. * Creates the main texture for the effect layer.
  49350. */
  49351. protected _createMainTexture(): void;
  49352. /**
  49353. * Adds specific effects defines.
  49354. * @param defines The defines to add specifics to.
  49355. */
  49356. protected _addCustomEffectDefines(defines: string[]): void;
  49357. /**
  49358. * Checks for the readiness of the element composing the layer.
  49359. * @param subMesh the mesh to check for
  49360. * @param useInstances specify wether or not to use instances to render the mesh
  49361. * @param emissiveTexture the associated emissive texture used to generate the glow
  49362. * @return true if ready otherwise, false
  49363. */
  49364. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49365. /**
  49366. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49367. */
  49368. render(): void;
  49369. /**
  49370. * Determine if a given mesh will be used in the current effect.
  49371. * @param mesh mesh to test
  49372. * @returns true if the mesh will be used
  49373. */
  49374. hasMesh(mesh: AbstractMesh): boolean;
  49375. /**
  49376. * Returns true if the layer contains information to display, otherwise false.
  49377. * @returns true if the glow layer should be rendered
  49378. */
  49379. shouldRender(): boolean;
  49380. /**
  49381. * Returns true if the mesh should render, otherwise false.
  49382. * @param mesh The mesh to render
  49383. * @returns true if it should render otherwise false
  49384. */
  49385. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49386. /**
  49387. * Returns true if the mesh can be rendered, otherwise false.
  49388. * @param mesh The mesh to render
  49389. * @param material The material used on the mesh
  49390. * @returns true if it can be rendered otherwise false
  49391. */
  49392. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49393. /**
  49394. * Returns true if the mesh should render, otherwise false.
  49395. * @param mesh The mesh to render
  49396. * @returns true if it should render otherwise false
  49397. */
  49398. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49399. /**
  49400. * Renders the submesh passed in parameter to the generation map.
  49401. */
  49402. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49403. /**
  49404. * Rebuild the required buffers.
  49405. * @hidden Internal use only.
  49406. */
  49407. _rebuild(): void;
  49408. /**
  49409. * Dispose only the render target textures and post process.
  49410. */
  49411. private _disposeTextureAndPostProcesses;
  49412. /**
  49413. * Dispose the highlight layer and free resources.
  49414. */
  49415. dispose(): void;
  49416. /**
  49417. * Gets the class name of the effect layer
  49418. * @returns the string with the class name of the effect layer
  49419. */
  49420. getClassName(): string;
  49421. /**
  49422. * Creates an effect layer from parsed effect layer data
  49423. * @param parsedEffectLayer defines effect layer data
  49424. * @param scene defines the current scene
  49425. * @param rootUrl defines the root URL containing the effect layer information
  49426. * @returns a parsed effect Layer
  49427. */
  49428. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49429. }
  49430. }
  49431. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49432. import { Scene } from "babylonjs/scene";
  49433. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49434. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49435. import { AbstractScene } from "babylonjs/abstractScene";
  49436. module "babylonjs/abstractScene" {
  49437. interface AbstractScene {
  49438. /**
  49439. * The list of effect layers (highlights/glow) added to the scene
  49440. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49441. * @see http://doc.babylonjs.com/how_to/glow_layer
  49442. */
  49443. effectLayers: Array<EffectLayer>;
  49444. /**
  49445. * Removes the given effect layer from this scene.
  49446. * @param toRemove defines the effect layer to remove
  49447. * @returns the index of the removed effect layer
  49448. */
  49449. removeEffectLayer(toRemove: EffectLayer): number;
  49450. /**
  49451. * Adds the given effect layer to this scene
  49452. * @param newEffectLayer defines the effect layer to add
  49453. */
  49454. addEffectLayer(newEffectLayer: EffectLayer): void;
  49455. }
  49456. }
  49457. /**
  49458. * Defines the layer scene component responsible to manage any effect layers
  49459. * in a given scene.
  49460. */
  49461. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49462. /**
  49463. * The component name helpfull to identify the component in the list of scene components.
  49464. */
  49465. readonly name: string;
  49466. /**
  49467. * The scene the component belongs to.
  49468. */
  49469. scene: Scene;
  49470. private _engine;
  49471. private _renderEffects;
  49472. private _needStencil;
  49473. private _previousStencilState;
  49474. /**
  49475. * Creates a new instance of the component for the given scene
  49476. * @param scene Defines the scene to register the component in
  49477. */
  49478. constructor(scene: Scene);
  49479. /**
  49480. * Registers the component in a given scene
  49481. */
  49482. register(): void;
  49483. /**
  49484. * Rebuilds the elements related to this component in case of
  49485. * context lost for instance.
  49486. */
  49487. rebuild(): void;
  49488. /**
  49489. * Serializes the component data to the specified json object
  49490. * @param serializationObject The object to serialize to
  49491. */
  49492. serialize(serializationObject: any): void;
  49493. /**
  49494. * Adds all the elements from the container to the scene
  49495. * @param container the container holding the elements
  49496. */
  49497. addFromContainer(container: AbstractScene): void;
  49498. /**
  49499. * Removes all the elements in the container from the scene
  49500. * @param container contains the elements to remove
  49501. * @param dispose if the removed element should be disposed (default: false)
  49502. */
  49503. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49504. /**
  49505. * Disposes the component and the associated ressources.
  49506. */
  49507. dispose(): void;
  49508. private _isReadyForMesh;
  49509. private _renderMainTexture;
  49510. private _setStencil;
  49511. private _setStencilBack;
  49512. private _draw;
  49513. private _drawCamera;
  49514. private _drawRenderingGroup;
  49515. }
  49516. }
  49517. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49518. /** @hidden */
  49519. export var glowMapMergePixelShader: {
  49520. name: string;
  49521. shader: string;
  49522. };
  49523. }
  49524. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49525. /** @hidden */
  49526. export var glowMapMergeVertexShader: {
  49527. name: string;
  49528. shader: string;
  49529. };
  49530. }
  49531. declare module "babylonjs/Layers/glowLayer" {
  49532. import { Nullable } from "babylonjs/types";
  49533. import { Camera } from "babylonjs/Cameras/camera";
  49534. import { Scene } from "babylonjs/scene";
  49535. import { Color4 } from "babylonjs/Maths/math";
  49536. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49538. import { Mesh } from "babylonjs/Meshes/mesh";
  49539. import { Texture } from "babylonjs/Materials/Textures/texture";
  49540. import { Effect } from "babylonjs/Materials/effect";
  49541. import { Material } from "babylonjs/Materials/material";
  49542. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49543. import "babylonjs/Shaders/glowMapMerge.fragment";
  49544. import "babylonjs/Shaders/glowMapMerge.vertex";
  49545. import "babylonjs/Layers/effectLayerSceneComponent";
  49546. module "babylonjs/abstractScene" {
  49547. interface AbstractScene {
  49548. /**
  49549. * Return a the first highlight layer of the scene with a given name.
  49550. * @param name The name of the highlight layer to look for.
  49551. * @return The highlight layer if found otherwise null.
  49552. */
  49553. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49554. }
  49555. }
  49556. /**
  49557. * Glow layer options. This helps customizing the behaviour
  49558. * of the glow layer.
  49559. */
  49560. export interface IGlowLayerOptions {
  49561. /**
  49562. * Multiplication factor apply to the canvas size to compute the render target size
  49563. * used to generated the glowing objects (the smaller the faster).
  49564. */
  49565. mainTextureRatio: number;
  49566. /**
  49567. * Enforces a fixed size texture to ensure resize independant blur.
  49568. */
  49569. mainTextureFixedSize?: number;
  49570. /**
  49571. * How big is the kernel of the blur texture.
  49572. */
  49573. blurKernelSize: number;
  49574. /**
  49575. * The camera attached to the layer.
  49576. */
  49577. camera: Nullable<Camera>;
  49578. /**
  49579. * Enable MSAA by chosing the number of samples.
  49580. */
  49581. mainTextureSamples?: number;
  49582. /**
  49583. * The rendering group to draw the layer in.
  49584. */
  49585. renderingGroupId: number;
  49586. }
  49587. /**
  49588. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49589. *
  49590. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49591. * glowy meshes to your scene.
  49592. *
  49593. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49594. */
  49595. export class GlowLayer extends EffectLayer {
  49596. /**
  49597. * Effect Name of the layer.
  49598. */
  49599. static readonly EffectName: string;
  49600. /**
  49601. * The default blur kernel size used for the glow.
  49602. */
  49603. static DefaultBlurKernelSize: number;
  49604. /**
  49605. * The default texture size ratio used for the glow.
  49606. */
  49607. static DefaultTextureRatio: number;
  49608. /**
  49609. * Sets the kernel size of the blur.
  49610. */
  49611. /**
  49612. * Gets the kernel size of the blur.
  49613. */
  49614. blurKernelSize: number;
  49615. /**
  49616. * Sets the glow intensity.
  49617. */
  49618. /**
  49619. * Gets the glow intensity.
  49620. */
  49621. intensity: number;
  49622. private _options;
  49623. private _intensity;
  49624. private _horizontalBlurPostprocess1;
  49625. private _verticalBlurPostprocess1;
  49626. private _horizontalBlurPostprocess2;
  49627. private _verticalBlurPostprocess2;
  49628. private _blurTexture1;
  49629. private _blurTexture2;
  49630. private _postProcesses1;
  49631. private _postProcesses2;
  49632. private _includedOnlyMeshes;
  49633. private _excludedMeshes;
  49634. /**
  49635. * Callback used to let the user override the color selection on a per mesh basis
  49636. */
  49637. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49638. /**
  49639. * Callback used to let the user override the texture selection on a per mesh basis
  49640. */
  49641. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49642. /**
  49643. * Instantiates a new glow Layer and references it to the scene.
  49644. * @param name The name of the layer
  49645. * @param scene The scene to use the layer in
  49646. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49647. */
  49648. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49649. /**
  49650. * Get the effect name of the layer.
  49651. * @return The effect name
  49652. */
  49653. getEffectName(): string;
  49654. /**
  49655. * Create the merge effect. This is the shader use to blit the information back
  49656. * to the main canvas at the end of the scene rendering.
  49657. */
  49658. protected _createMergeEffect(): Effect;
  49659. /**
  49660. * Creates the render target textures and post processes used in the glow layer.
  49661. */
  49662. protected _createTextureAndPostProcesses(): void;
  49663. /**
  49664. * Checks for the readiness of the element composing the layer.
  49665. * @param subMesh the mesh to check for
  49666. * @param useInstances specify wether or not to use instances to render the mesh
  49667. * @param emissiveTexture the associated emissive texture used to generate the glow
  49668. * @return true if ready otherwise, false
  49669. */
  49670. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49671. /**
  49672. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49673. */
  49674. needStencil(): boolean;
  49675. /**
  49676. * Returns true if the mesh can be rendered, otherwise false.
  49677. * @param mesh The mesh to render
  49678. * @param material The material used on the mesh
  49679. * @returns true if it can be rendered otherwise false
  49680. */
  49681. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49682. /**
  49683. * Implementation specific of rendering the generating effect on the main canvas.
  49684. * @param effect The effect used to render through
  49685. */
  49686. protected _internalRender(effect: Effect): void;
  49687. /**
  49688. * Sets the required values for both the emissive texture and and the main color.
  49689. */
  49690. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49691. /**
  49692. * Returns true if the mesh should render, otherwise false.
  49693. * @param mesh The mesh to render
  49694. * @returns true if it should render otherwise false
  49695. */
  49696. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49697. /**
  49698. * Adds specific effects defines.
  49699. * @param defines The defines to add specifics to.
  49700. */
  49701. protected _addCustomEffectDefines(defines: string[]): void;
  49702. /**
  49703. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49704. * @param mesh The mesh to exclude from the glow layer
  49705. */
  49706. addExcludedMesh(mesh: Mesh): void;
  49707. /**
  49708. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49709. * @param mesh The mesh to remove
  49710. */
  49711. removeExcludedMesh(mesh: Mesh): void;
  49712. /**
  49713. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49714. * @param mesh The mesh to include in the glow layer
  49715. */
  49716. addIncludedOnlyMesh(mesh: Mesh): void;
  49717. /**
  49718. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49719. * @param mesh The mesh to remove
  49720. */
  49721. removeIncludedOnlyMesh(mesh: Mesh): void;
  49722. /**
  49723. * Determine if a given mesh will be used in the glow layer
  49724. * @param mesh The mesh to test
  49725. * @returns true if the mesh will be highlighted by the current glow layer
  49726. */
  49727. hasMesh(mesh: AbstractMesh): boolean;
  49728. /**
  49729. * Free any resources and references associated to a mesh.
  49730. * Internal use
  49731. * @param mesh The mesh to free.
  49732. * @hidden
  49733. */
  49734. _disposeMesh(mesh: Mesh): void;
  49735. /**
  49736. * Gets the class name of the effect layer
  49737. * @returns the string with the class name of the effect layer
  49738. */
  49739. getClassName(): string;
  49740. /**
  49741. * Serializes this glow layer
  49742. * @returns a serialized glow layer object
  49743. */
  49744. serialize(): any;
  49745. /**
  49746. * Creates a Glow Layer from parsed glow layer data
  49747. * @param parsedGlowLayer defines glow layer data
  49748. * @param scene defines the current scene
  49749. * @param rootUrl defines the root URL containing the glow layer information
  49750. * @returns a parsed Glow Layer
  49751. */
  49752. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49753. }
  49754. }
  49755. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49756. /** @hidden */
  49757. export var glowBlurPostProcessPixelShader: {
  49758. name: string;
  49759. shader: string;
  49760. };
  49761. }
  49762. declare module "babylonjs/Layers/highlightLayer" {
  49763. import { Observable } from "babylonjs/Misc/observable";
  49764. import { Nullable } from "babylonjs/types";
  49765. import { Camera } from "babylonjs/Cameras/camera";
  49766. import { Scene } from "babylonjs/scene";
  49767. import { Color3, Color4 } from "babylonjs/Maths/math";
  49768. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49770. import { Mesh } from "babylonjs/Meshes/mesh";
  49771. import { Effect } from "babylonjs/Materials/effect";
  49772. import { Material } from "babylonjs/Materials/material";
  49773. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49774. import "babylonjs/Shaders/glowMapMerge.fragment";
  49775. import "babylonjs/Shaders/glowMapMerge.vertex";
  49776. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49777. module "babylonjs/abstractScene" {
  49778. interface AbstractScene {
  49779. /**
  49780. * Return a the first highlight layer of the scene with a given name.
  49781. * @param name The name of the highlight layer to look for.
  49782. * @return The highlight layer if found otherwise null.
  49783. */
  49784. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49785. }
  49786. }
  49787. /**
  49788. * Highlight layer options. This helps customizing the behaviour
  49789. * of the highlight layer.
  49790. */
  49791. export interface IHighlightLayerOptions {
  49792. /**
  49793. * Multiplication factor apply to the canvas size to compute the render target size
  49794. * used to generated the glowing objects (the smaller the faster).
  49795. */
  49796. mainTextureRatio: number;
  49797. /**
  49798. * Enforces a fixed size texture to ensure resize independant blur.
  49799. */
  49800. mainTextureFixedSize?: number;
  49801. /**
  49802. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49803. * of the picture to blur (the smaller the faster).
  49804. */
  49805. blurTextureSizeRatio: number;
  49806. /**
  49807. * How big in texel of the blur texture is the vertical blur.
  49808. */
  49809. blurVerticalSize: number;
  49810. /**
  49811. * How big in texel of the blur texture is the horizontal blur.
  49812. */
  49813. blurHorizontalSize: number;
  49814. /**
  49815. * Alpha blending mode used to apply the blur. Default is combine.
  49816. */
  49817. alphaBlendingMode: number;
  49818. /**
  49819. * The camera attached to the layer.
  49820. */
  49821. camera: Nullable<Camera>;
  49822. /**
  49823. * Should we display highlight as a solid stroke?
  49824. */
  49825. isStroke?: boolean;
  49826. /**
  49827. * The rendering group to draw the layer in.
  49828. */
  49829. renderingGroupId: number;
  49830. }
  49831. /**
  49832. * The highlight layer Helps adding a glow effect around a mesh.
  49833. *
  49834. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49835. * glowy meshes to your scene.
  49836. *
  49837. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49838. */
  49839. export class HighlightLayer extends EffectLayer {
  49840. name: string;
  49841. /**
  49842. * Effect Name of the highlight layer.
  49843. */
  49844. static readonly EffectName: string;
  49845. /**
  49846. * The neutral color used during the preparation of the glow effect.
  49847. * This is black by default as the blend operation is a blend operation.
  49848. */
  49849. static NeutralColor: Color4;
  49850. /**
  49851. * Stencil value used for glowing meshes.
  49852. */
  49853. static GlowingMeshStencilReference: number;
  49854. /**
  49855. * Stencil value used for the other meshes in the scene.
  49856. */
  49857. static NormalMeshStencilReference: number;
  49858. /**
  49859. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49860. */
  49861. innerGlow: boolean;
  49862. /**
  49863. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49864. */
  49865. outerGlow: boolean;
  49866. /**
  49867. * Specifies the horizontal size of the blur.
  49868. */
  49869. /**
  49870. * Gets the horizontal size of the blur.
  49871. */
  49872. blurHorizontalSize: number;
  49873. /**
  49874. * Specifies the vertical size of the blur.
  49875. */
  49876. /**
  49877. * Gets the vertical size of the blur.
  49878. */
  49879. blurVerticalSize: number;
  49880. /**
  49881. * An event triggered when the highlight layer is being blurred.
  49882. */
  49883. onBeforeBlurObservable: Observable<HighlightLayer>;
  49884. /**
  49885. * An event triggered when the highlight layer has been blurred.
  49886. */
  49887. onAfterBlurObservable: Observable<HighlightLayer>;
  49888. private _instanceGlowingMeshStencilReference;
  49889. private _options;
  49890. private _downSamplePostprocess;
  49891. private _horizontalBlurPostprocess;
  49892. private _verticalBlurPostprocess;
  49893. private _blurTexture;
  49894. private _meshes;
  49895. private _excludedMeshes;
  49896. /**
  49897. * Instantiates a new highlight Layer and references it to the scene..
  49898. * @param name The name of the layer
  49899. * @param scene The scene to use the layer in
  49900. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49901. */
  49902. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49903. /**
  49904. * Get the effect name of the layer.
  49905. * @return The effect name
  49906. */
  49907. getEffectName(): string;
  49908. /**
  49909. * Create the merge effect. This is the shader use to blit the information back
  49910. * to the main canvas at the end of the scene rendering.
  49911. */
  49912. protected _createMergeEffect(): Effect;
  49913. /**
  49914. * Creates the render target textures and post processes used in the highlight layer.
  49915. */
  49916. protected _createTextureAndPostProcesses(): void;
  49917. /**
  49918. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49919. */
  49920. needStencil(): boolean;
  49921. /**
  49922. * Checks for the readiness of the element composing the layer.
  49923. * @param subMesh the mesh to check for
  49924. * @param useInstances specify wether or not to use instances to render the mesh
  49925. * @param emissiveTexture the associated emissive texture used to generate the glow
  49926. * @return true if ready otherwise, false
  49927. */
  49928. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49929. /**
  49930. * Implementation specific of rendering the generating effect on the main canvas.
  49931. * @param effect The effect used to render through
  49932. */
  49933. protected _internalRender(effect: Effect): void;
  49934. /**
  49935. * Returns true if the layer contains information to display, otherwise false.
  49936. */
  49937. shouldRender(): boolean;
  49938. /**
  49939. * Returns true if the mesh should render, otherwise false.
  49940. * @param mesh The mesh to render
  49941. * @returns true if it should render otherwise false
  49942. */
  49943. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49944. /**
  49945. * Sets the required values for both the emissive texture and and the main color.
  49946. */
  49947. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49948. /**
  49949. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49950. * @param mesh The mesh to exclude from the highlight layer
  49951. */
  49952. addExcludedMesh(mesh: Mesh): void;
  49953. /**
  49954. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49955. * @param mesh The mesh to highlight
  49956. */
  49957. removeExcludedMesh(mesh: Mesh): void;
  49958. /**
  49959. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49960. * @param mesh mesh to test
  49961. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49962. */
  49963. hasMesh(mesh: AbstractMesh): boolean;
  49964. /**
  49965. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49966. * @param mesh The mesh to highlight
  49967. * @param color The color of the highlight
  49968. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49969. */
  49970. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49971. /**
  49972. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49973. * @param mesh The mesh to highlight
  49974. */
  49975. removeMesh(mesh: Mesh): void;
  49976. /**
  49977. * Force the stencil to the normal expected value for none glowing parts
  49978. */
  49979. private _defaultStencilReference;
  49980. /**
  49981. * Free any resources and references associated to a mesh.
  49982. * Internal use
  49983. * @param mesh The mesh to free.
  49984. * @hidden
  49985. */
  49986. _disposeMesh(mesh: Mesh): void;
  49987. /**
  49988. * Dispose the highlight layer and free resources.
  49989. */
  49990. dispose(): void;
  49991. /**
  49992. * Gets the class name of the effect layer
  49993. * @returns the string with the class name of the effect layer
  49994. */
  49995. getClassName(): string;
  49996. /**
  49997. * Serializes this Highlight layer
  49998. * @returns a serialized Highlight layer object
  49999. */
  50000. serialize(): any;
  50001. /**
  50002. * Creates a Highlight layer from parsed Highlight layer data
  50003. * @param parsedHightlightLayer defines the Highlight layer data
  50004. * @param scene defines the current scene
  50005. * @param rootUrl defines the root URL containing the Highlight layer information
  50006. * @returns a parsed Highlight layer
  50007. */
  50008. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50009. }
  50010. }
  50011. declare module "babylonjs/Layers/layerSceneComponent" {
  50012. import { Scene } from "babylonjs/scene";
  50013. import { ISceneComponent } from "babylonjs/sceneComponent";
  50014. import { Layer } from "babylonjs/Layers/layer";
  50015. import { AbstractScene } from "babylonjs/abstractScene";
  50016. module "babylonjs/abstractScene" {
  50017. interface AbstractScene {
  50018. /**
  50019. * The list of layers (background and foreground) of the scene
  50020. */
  50021. layers: Array<Layer>;
  50022. }
  50023. }
  50024. /**
  50025. * Defines the layer scene component responsible to manage any layers
  50026. * in a given scene.
  50027. */
  50028. export class LayerSceneComponent implements ISceneComponent {
  50029. /**
  50030. * The component name helpfull to identify the component in the list of scene components.
  50031. */
  50032. readonly name: string;
  50033. /**
  50034. * The scene the component belongs to.
  50035. */
  50036. scene: Scene;
  50037. private _engine;
  50038. /**
  50039. * Creates a new instance of the component for the given scene
  50040. * @param scene Defines the scene to register the component in
  50041. */
  50042. constructor(scene: Scene);
  50043. /**
  50044. * Registers the component in a given scene
  50045. */
  50046. register(): void;
  50047. /**
  50048. * Rebuilds the elements related to this component in case of
  50049. * context lost for instance.
  50050. */
  50051. rebuild(): void;
  50052. /**
  50053. * Disposes the component and the associated ressources.
  50054. */
  50055. dispose(): void;
  50056. private _draw;
  50057. private _drawCameraPredicate;
  50058. private _drawCameraBackground;
  50059. private _drawCameraForeground;
  50060. private _drawRenderTargetPredicate;
  50061. private _drawRenderTargetBackground;
  50062. private _drawRenderTargetForeground;
  50063. /**
  50064. * Adds all the elements from the container to the scene
  50065. * @param container the container holding the elements
  50066. */
  50067. addFromContainer(container: AbstractScene): void;
  50068. /**
  50069. * Removes all the elements in the container from the scene
  50070. * @param container contains the elements to remove
  50071. * @param dispose if the removed element should be disposed (default: false)
  50072. */
  50073. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50074. }
  50075. }
  50076. declare module "babylonjs/Shaders/layer.fragment" {
  50077. /** @hidden */
  50078. export var layerPixelShader: {
  50079. name: string;
  50080. shader: string;
  50081. };
  50082. }
  50083. declare module "babylonjs/Shaders/layer.vertex" {
  50084. /** @hidden */
  50085. export var layerVertexShader: {
  50086. name: string;
  50087. shader: string;
  50088. };
  50089. }
  50090. declare module "babylonjs/Layers/layer" {
  50091. import { Observable } from "babylonjs/Misc/observable";
  50092. import { Nullable } from "babylonjs/types";
  50093. import { Scene } from "babylonjs/scene";
  50094. import { Vector2, Color4 } from "babylonjs/Maths/math";
  50095. import { Texture } from "babylonjs/Materials/Textures/texture";
  50096. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50097. import "babylonjs/Shaders/layer.fragment";
  50098. import "babylonjs/Shaders/layer.vertex";
  50099. /**
  50100. * This represents a full screen 2d layer.
  50101. * This can be useful to display a picture in the background of your scene for instance.
  50102. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50103. */
  50104. export class Layer {
  50105. /**
  50106. * Define the name of the layer.
  50107. */
  50108. name: string;
  50109. /**
  50110. * Define the texture the layer should display.
  50111. */
  50112. texture: Nullable<Texture>;
  50113. /**
  50114. * Is the layer in background or foreground.
  50115. */
  50116. isBackground: boolean;
  50117. /**
  50118. * Define the color of the layer (instead of texture).
  50119. */
  50120. color: Color4;
  50121. /**
  50122. * Define the scale of the layer in order to zoom in out of the texture.
  50123. */
  50124. scale: Vector2;
  50125. /**
  50126. * Define an offset for the layer in order to shift the texture.
  50127. */
  50128. offset: Vector2;
  50129. /**
  50130. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50131. */
  50132. alphaBlendingMode: number;
  50133. /**
  50134. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50135. * Alpha test will not mix with the background color in case of transparency.
  50136. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50137. */
  50138. alphaTest: boolean;
  50139. /**
  50140. * Define a mask to restrict the layer to only some of the scene cameras.
  50141. */
  50142. layerMask: number;
  50143. /**
  50144. * Define the list of render target the layer is visible into.
  50145. */
  50146. renderTargetTextures: RenderTargetTexture[];
  50147. /**
  50148. * Define if the layer is only used in renderTarget or if it also
  50149. * renders in the main frame buffer of the canvas.
  50150. */
  50151. renderOnlyInRenderTargetTextures: boolean;
  50152. private _scene;
  50153. private _vertexBuffers;
  50154. private _indexBuffer;
  50155. private _effect;
  50156. private _alphaTestEffect;
  50157. /**
  50158. * An event triggered when the layer is disposed.
  50159. */
  50160. onDisposeObservable: Observable<Layer>;
  50161. private _onDisposeObserver;
  50162. /**
  50163. * Back compatibility with callback before the onDisposeObservable existed.
  50164. * The set callback will be triggered when the layer has been disposed.
  50165. */
  50166. onDispose: () => void;
  50167. /**
  50168. * An event triggered before rendering the scene
  50169. */
  50170. onBeforeRenderObservable: Observable<Layer>;
  50171. private _onBeforeRenderObserver;
  50172. /**
  50173. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50174. * The set callback will be triggered just before rendering the layer.
  50175. */
  50176. onBeforeRender: () => void;
  50177. /**
  50178. * An event triggered after rendering the scene
  50179. */
  50180. onAfterRenderObservable: Observable<Layer>;
  50181. private _onAfterRenderObserver;
  50182. /**
  50183. * Back compatibility with callback before the onAfterRenderObservable existed.
  50184. * The set callback will be triggered just after rendering the layer.
  50185. */
  50186. onAfterRender: () => void;
  50187. /**
  50188. * Instantiates a new layer.
  50189. * This represents a full screen 2d layer.
  50190. * This can be useful to display a picture in the background of your scene for instance.
  50191. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50192. * @param name Define the name of the layer in the scene
  50193. * @param imgUrl Define the url of the texture to display in the layer
  50194. * @param scene Define the scene the layer belongs to
  50195. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50196. * @param color Defines a color for the layer
  50197. */
  50198. constructor(
  50199. /**
  50200. * Define the name of the layer.
  50201. */
  50202. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50203. private _createIndexBuffer;
  50204. /** @hidden */
  50205. _rebuild(): void;
  50206. /**
  50207. * Renders the layer in the scene.
  50208. */
  50209. render(): void;
  50210. /**
  50211. * Disposes and releases the associated ressources.
  50212. */
  50213. dispose(): void;
  50214. }
  50215. }
  50216. declare module "babylonjs/Layers/index" {
  50217. export * from "babylonjs/Layers/effectLayer";
  50218. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50219. export * from "babylonjs/Layers/glowLayer";
  50220. export * from "babylonjs/Layers/highlightLayer";
  50221. export * from "babylonjs/Layers/layer";
  50222. export * from "babylonjs/Layers/layerSceneComponent";
  50223. }
  50224. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50225. /** @hidden */
  50226. export var lensFlarePixelShader: {
  50227. name: string;
  50228. shader: string;
  50229. };
  50230. }
  50231. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50232. /** @hidden */
  50233. export var lensFlareVertexShader: {
  50234. name: string;
  50235. shader: string;
  50236. };
  50237. }
  50238. declare module "babylonjs/LensFlares/lensFlareSystem" {
  50239. import { Scene } from "babylonjs/scene";
  50240. import { Vector3, Viewport } from "babylonjs/Maths/math";
  50241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50242. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  50243. import "babylonjs/Shaders/lensFlare.fragment";
  50244. import "babylonjs/Shaders/lensFlare.vertex";
  50245. /**
  50246. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50247. * It is usually composed of several `lensFlare`.
  50248. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50249. */
  50250. export class LensFlareSystem {
  50251. /**
  50252. * Define the name of the lens flare system
  50253. */
  50254. name: string;
  50255. /**
  50256. * List of lens flares used in this system.
  50257. */
  50258. lensFlares: LensFlare[];
  50259. /**
  50260. * Define a limit from the border the lens flare can be visible.
  50261. */
  50262. borderLimit: number;
  50263. /**
  50264. * Define a viewport border we do not want to see the lens flare in.
  50265. */
  50266. viewportBorder: number;
  50267. /**
  50268. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50269. */
  50270. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50271. /**
  50272. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50273. */
  50274. layerMask: number;
  50275. /**
  50276. * Define the id of the lens flare system in the scene.
  50277. * (equal to name by default)
  50278. */
  50279. id: string;
  50280. private _scene;
  50281. private _emitter;
  50282. private _vertexBuffers;
  50283. private _indexBuffer;
  50284. private _effect;
  50285. private _positionX;
  50286. private _positionY;
  50287. private _isEnabled;
  50288. /** @hidden */
  50289. static _SceneComponentInitialization: (scene: Scene) => void;
  50290. /**
  50291. * Instantiates a lens flare system.
  50292. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50293. * It is usually composed of several `lensFlare`.
  50294. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50295. * @param name Define the name of the lens flare system in the scene
  50296. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50297. * @param scene Define the scene the lens flare system belongs to
  50298. */
  50299. constructor(
  50300. /**
  50301. * Define the name of the lens flare system
  50302. */
  50303. name: string, emitter: any, scene: Scene);
  50304. /**
  50305. * Define if the lens flare system is enabled.
  50306. */
  50307. isEnabled: boolean;
  50308. /**
  50309. * Get the scene the effects belongs to.
  50310. * @returns the scene holding the lens flare system
  50311. */
  50312. getScene(): Scene;
  50313. /**
  50314. * Get the emitter of the lens flare system.
  50315. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50316. * @returns the emitter of the lens flare system
  50317. */
  50318. getEmitter(): any;
  50319. /**
  50320. * Set the emitter of the lens flare system.
  50321. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50322. * @param newEmitter Define the new emitter of the system
  50323. */
  50324. setEmitter(newEmitter: any): void;
  50325. /**
  50326. * Get the lens flare system emitter position.
  50327. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50328. * @returns the position
  50329. */
  50330. getEmitterPosition(): Vector3;
  50331. /**
  50332. * @hidden
  50333. */
  50334. computeEffectivePosition(globalViewport: Viewport): boolean;
  50335. /** @hidden */
  50336. _isVisible(): boolean;
  50337. /**
  50338. * @hidden
  50339. */
  50340. render(): boolean;
  50341. /**
  50342. * Dispose and release the lens flare with its associated resources.
  50343. */
  50344. dispose(): void;
  50345. /**
  50346. * Parse a lens flare system from a JSON repressentation
  50347. * @param parsedLensFlareSystem Define the JSON to parse
  50348. * @param scene Define the scene the parsed system should be instantiated in
  50349. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50350. * @returns the parsed system
  50351. */
  50352. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50353. /**
  50354. * Serialize the current Lens Flare System into a JSON representation.
  50355. * @returns the serialized JSON
  50356. */
  50357. serialize(): any;
  50358. }
  50359. }
  50360. declare module "babylonjs/LensFlares/lensFlare" {
  50361. import { Nullable } from "babylonjs/types";
  50362. import { Color3 } from "babylonjs/Maths/math";
  50363. import { Texture } from "babylonjs/Materials/Textures/texture";
  50364. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50365. /**
  50366. * This represents one of the lens effect in a `lensFlareSystem`.
  50367. * It controls one of the indiviual texture used in the effect.
  50368. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50369. */
  50370. export class LensFlare {
  50371. /**
  50372. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50373. */
  50374. size: number;
  50375. /**
  50376. * 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.
  50377. */
  50378. position: number;
  50379. /**
  50380. * Define the lens color.
  50381. */
  50382. color: Color3;
  50383. /**
  50384. * Define the lens texture.
  50385. */
  50386. texture: Nullable<Texture>;
  50387. /**
  50388. * Define the alpha mode to render this particular lens.
  50389. */
  50390. alphaMode: number;
  50391. private _system;
  50392. /**
  50393. * Creates a new Lens Flare.
  50394. * This represents one of the lens effect in a `lensFlareSystem`.
  50395. * It controls one of the indiviual texture used in the effect.
  50396. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50397. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50398. * @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.
  50399. * @param color Define the lens color
  50400. * @param imgUrl Define the lens texture url
  50401. * @param system Define the `lensFlareSystem` this flare is part of
  50402. * @returns The newly created Lens Flare
  50403. */
  50404. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50405. /**
  50406. * Instantiates a new Lens Flare.
  50407. * This represents one of the lens effect in a `lensFlareSystem`.
  50408. * It controls one of the indiviual texture used in the effect.
  50409. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50410. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50411. * @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.
  50412. * @param color Define the lens color
  50413. * @param imgUrl Define the lens texture url
  50414. * @param system Define the `lensFlareSystem` this flare is part of
  50415. */
  50416. constructor(
  50417. /**
  50418. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50419. */
  50420. size: number,
  50421. /**
  50422. * 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.
  50423. */
  50424. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50425. /**
  50426. * Dispose and release the lens flare with its associated resources.
  50427. */
  50428. dispose(): void;
  50429. }
  50430. }
  50431. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50432. import { Nullable } from "babylonjs/types";
  50433. import { Scene } from "babylonjs/scene";
  50434. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50435. import { AbstractScene } from "babylonjs/abstractScene";
  50436. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50437. module "babylonjs/abstractScene" {
  50438. interface AbstractScene {
  50439. /**
  50440. * The list of lens flare system added to the scene
  50441. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50442. */
  50443. lensFlareSystems: Array<LensFlareSystem>;
  50444. /**
  50445. * Removes the given lens flare system from this scene.
  50446. * @param toRemove The lens flare system to remove
  50447. * @returns The index of the removed lens flare system
  50448. */
  50449. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50450. /**
  50451. * Adds the given lens flare system to this scene
  50452. * @param newLensFlareSystem The lens flare system to add
  50453. */
  50454. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50455. /**
  50456. * Gets a lens flare system using its name
  50457. * @param name defines the name to look for
  50458. * @returns the lens flare system or null if not found
  50459. */
  50460. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50461. /**
  50462. * Gets a lens flare system using its id
  50463. * @param id defines the id to look for
  50464. * @returns the lens flare system or null if not found
  50465. */
  50466. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50467. }
  50468. }
  50469. /**
  50470. * Defines the lens flare scene component responsible to manage any lens flares
  50471. * in a given scene.
  50472. */
  50473. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50474. /**
  50475. * The component name helpfull to identify the component in the list of scene components.
  50476. */
  50477. readonly name: string;
  50478. /**
  50479. * The scene the component belongs to.
  50480. */
  50481. scene: Scene;
  50482. /**
  50483. * Creates a new instance of the component for the given scene
  50484. * @param scene Defines the scene to register the component in
  50485. */
  50486. constructor(scene: Scene);
  50487. /**
  50488. * Registers the component in a given scene
  50489. */
  50490. register(): void;
  50491. /**
  50492. * Rebuilds the elements related to this component in case of
  50493. * context lost for instance.
  50494. */
  50495. rebuild(): void;
  50496. /**
  50497. * Adds all the elements from the container to the scene
  50498. * @param container the container holding the elements
  50499. */
  50500. addFromContainer(container: AbstractScene): void;
  50501. /**
  50502. * Removes all the elements in the container from the scene
  50503. * @param container contains the elements to remove
  50504. * @param dispose if the removed element should be disposed (default: false)
  50505. */
  50506. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50507. /**
  50508. * Serializes the component data to the specified json object
  50509. * @param serializationObject The object to serialize to
  50510. */
  50511. serialize(serializationObject: any): void;
  50512. /**
  50513. * Disposes the component and the associated ressources.
  50514. */
  50515. dispose(): void;
  50516. private _draw;
  50517. }
  50518. }
  50519. declare module "babylonjs/LensFlares/index" {
  50520. export * from "babylonjs/LensFlares/lensFlare";
  50521. export * from "babylonjs/LensFlares/lensFlareSystem";
  50522. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  50523. }
  50524. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  50525. import { Scene } from "babylonjs/scene";
  50526. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50527. import { AbstractScene } from "babylonjs/abstractScene";
  50528. /**
  50529. * Defines the shadow generator component responsible to manage any shadow generators
  50530. * in a given scene.
  50531. */
  50532. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50533. /**
  50534. * The component name helpfull to identify the component in the list of scene components.
  50535. */
  50536. readonly name: string;
  50537. /**
  50538. * The scene the component belongs to.
  50539. */
  50540. scene: Scene;
  50541. /**
  50542. * Creates a new instance of the component for the given scene
  50543. * @param scene Defines the scene to register the component in
  50544. */
  50545. constructor(scene: Scene);
  50546. /**
  50547. * Registers the component in a given scene
  50548. */
  50549. register(): void;
  50550. /**
  50551. * Rebuilds the elements related to this component in case of
  50552. * context lost for instance.
  50553. */
  50554. rebuild(): void;
  50555. /**
  50556. * Serializes the component data to the specified json object
  50557. * @param serializationObject The object to serialize to
  50558. */
  50559. serialize(serializationObject: any): void;
  50560. /**
  50561. * Adds all the elements from the container to the scene
  50562. * @param container the container holding the elements
  50563. */
  50564. addFromContainer(container: AbstractScene): void;
  50565. /**
  50566. * Removes all the elements in the container from the scene
  50567. * @param container contains the elements to remove
  50568. * @param dispose if the removed element should be disposed (default: false)
  50569. */
  50570. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50571. /**
  50572. * Rebuilds the elements related to this component in case of
  50573. * context lost for instance.
  50574. */
  50575. dispose(): void;
  50576. private _gatherRenderTargets;
  50577. }
  50578. }
  50579. declare module "babylonjs/Lights/Shadows/index" {
  50580. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50581. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50582. }
  50583. declare module "babylonjs/Lights/pointLight" {
  50584. import { Scene } from "babylonjs/scene";
  50585. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50587. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50588. import { Effect } from "babylonjs/Materials/effect";
  50589. /**
  50590. * A point light is a light defined by an unique point in world space.
  50591. * The light is emitted in every direction from this point.
  50592. * A good example of a point light is a standard light bulb.
  50593. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50594. */
  50595. export class PointLight extends ShadowLight {
  50596. private _shadowAngle;
  50597. /**
  50598. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50599. * This specifies what angle the shadow will use to be created.
  50600. *
  50601. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50602. */
  50603. /**
  50604. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50605. * This specifies what angle the shadow will use to be created.
  50606. *
  50607. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50608. */
  50609. shadowAngle: number;
  50610. /**
  50611. * Gets the direction if it has been set.
  50612. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50613. */
  50614. /**
  50615. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50616. */
  50617. direction: Vector3;
  50618. /**
  50619. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50620. * A PointLight emits the light in every direction.
  50621. * It can cast shadows.
  50622. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50623. * ```javascript
  50624. * var pointLight = new PointLight("pl", camera.position, scene);
  50625. * ```
  50626. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50627. * @param name The light friendly name
  50628. * @param position The position of the point light in the scene
  50629. * @param scene The scene the lights belongs to
  50630. */
  50631. constructor(name: string, position: Vector3, scene: Scene);
  50632. /**
  50633. * Returns the string "PointLight"
  50634. * @returns the class name
  50635. */
  50636. getClassName(): string;
  50637. /**
  50638. * Returns the integer 0.
  50639. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50640. */
  50641. getTypeID(): number;
  50642. /**
  50643. * Specifies wether or not the shadowmap should be a cube texture.
  50644. * @returns true if the shadowmap needs to be a cube texture.
  50645. */
  50646. needCube(): boolean;
  50647. /**
  50648. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50649. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50650. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50651. */
  50652. getShadowDirection(faceIndex?: number): Vector3;
  50653. /**
  50654. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50655. * - fov = PI / 2
  50656. * - aspect ratio : 1.0
  50657. * - z-near and far equal to the active camera minZ and maxZ.
  50658. * Returns the PointLight.
  50659. */
  50660. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50661. protected _buildUniformLayout(): void;
  50662. /**
  50663. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50664. * @param effect The effect to update
  50665. * @param lightIndex The index of the light in the effect to update
  50666. * @returns The point light
  50667. */
  50668. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50669. /**
  50670. * Prepares the list of defines specific to the light type.
  50671. * @param defines the list of defines
  50672. * @param lightIndex defines the index of the light for the effect
  50673. */
  50674. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50675. }
  50676. }
  50677. declare module "babylonjs/Lights/index" {
  50678. export * from "babylonjs/Lights/light";
  50679. export * from "babylonjs/Lights/shadowLight";
  50680. export * from "babylonjs/Lights/Shadows/index";
  50681. export * from "babylonjs/Lights/directionalLight";
  50682. export * from "babylonjs/Lights/hemisphericLight";
  50683. export * from "babylonjs/Lights/pointLight";
  50684. export * from "babylonjs/Lights/spotLight";
  50685. }
  50686. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50687. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50688. /**
  50689. * Header information of HDR texture files.
  50690. */
  50691. export interface HDRInfo {
  50692. /**
  50693. * The height of the texture in pixels.
  50694. */
  50695. height: number;
  50696. /**
  50697. * The width of the texture in pixels.
  50698. */
  50699. width: number;
  50700. /**
  50701. * The index of the beginning of the data in the binary file.
  50702. */
  50703. dataPosition: number;
  50704. }
  50705. /**
  50706. * This groups tools to convert HDR texture to native colors array.
  50707. */
  50708. export class HDRTools {
  50709. private static Ldexp;
  50710. private static Rgbe2float;
  50711. private static readStringLine;
  50712. /**
  50713. * Reads header information from an RGBE texture stored in a native array.
  50714. * More information on this format are available here:
  50715. * https://en.wikipedia.org/wiki/RGBE_image_format
  50716. *
  50717. * @param uint8array The binary file stored in native array.
  50718. * @return The header information.
  50719. */
  50720. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50721. /**
  50722. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50723. * This RGBE texture needs to store the information as a panorama.
  50724. *
  50725. * More information on this format are available here:
  50726. * https://en.wikipedia.org/wiki/RGBE_image_format
  50727. *
  50728. * @param buffer The binary file stored in an array buffer.
  50729. * @param size The expected size of the extracted cubemap.
  50730. * @return The Cube Map information.
  50731. */
  50732. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50733. /**
  50734. * Returns the pixels data extracted from an RGBE texture.
  50735. * This pixels will be stored left to right up to down in the R G B order in one array.
  50736. *
  50737. * More information on this format are available here:
  50738. * https://en.wikipedia.org/wiki/RGBE_image_format
  50739. *
  50740. * @param uint8array The binary file stored in an array buffer.
  50741. * @param hdrInfo The header information of the file.
  50742. * @return The pixels data in RGB right to left up to down order.
  50743. */
  50744. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50745. private static RGBE_ReadPixels_RLE;
  50746. }
  50747. }
  50748. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50749. import { Nullable } from "babylonjs/types";
  50750. import { Scene } from "babylonjs/scene";
  50751. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50752. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50753. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50754. /**
  50755. * This represents a texture coming from an HDR input.
  50756. *
  50757. * The only supported format is currently panorama picture stored in RGBE format.
  50758. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50759. */
  50760. export class HDRCubeTexture extends BaseTexture {
  50761. private static _facesMapping;
  50762. private _generateHarmonics;
  50763. private _noMipmap;
  50764. private _textureMatrix;
  50765. private _size;
  50766. private _onLoad;
  50767. private _onError;
  50768. /**
  50769. * The texture URL.
  50770. */
  50771. url: string;
  50772. /**
  50773. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50774. */
  50775. coordinatesMode: number;
  50776. protected _isBlocking: boolean;
  50777. /**
  50778. * Sets wether or not the texture is blocking during loading.
  50779. */
  50780. /**
  50781. * Gets wether or not the texture is blocking during loading.
  50782. */
  50783. isBlocking: boolean;
  50784. protected _rotationY: number;
  50785. /**
  50786. * Sets texture matrix rotation angle around Y axis in radians.
  50787. */
  50788. /**
  50789. * Gets texture matrix rotation angle around Y axis radians.
  50790. */
  50791. rotationY: number;
  50792. /**
  50793. * Gets or sets the center of the bounding box associated with the cube texture
  50794. * It must define where the camera used to render the texture was set
  50795. */
  50796. boundingBoxPosition: Vector3;
  50797. private _boundingBoxSize;
  50798. /**
  50799. * Gets or sets the size of the bounding box associated with the cube texture
  50800. * When defined, the cubemap will switch to local mode
  50801. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50802. * @example https://www.babylonjs-playground.com/#RNASML
  50803. */
  50804. boundingBoxSize: Vector3;
  50805. /**
  50806. * Instantiates an HDRTexture from the following parameters.
  50807. *
  50808. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50809. * @param scene The scene the texture will be used in
  50810. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50811. * @param noMipmap Forces to not generate the mipmap if true
  50812. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50813. * @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)
  50814. * @param reserved Reserved flag for internal use.
  50815. */
  50816. 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>);
  50817. /**
  50818. * Get the current class name of the texture useful for serialization or dynamic coding.
  50819. * @returns "HDRCubeTexture"
  50820. */
  50821. getClassName(): string;
  50822. /**
  50823. * Occurs when the file is raw .hdr file.
  50824. */
  50825. private loadTexture;
  50826. clone(): HDRCubeTexture;
  50827. delayLoad(): void;
  50828. /**
  50829. * Get the texture reflection matrix used to rotate/transform the reflection.
  50830. * @returns the reflection matrix
  50831. */
  50832. getReflectionTextureMatrix(): Matrix;
  50833. /**
  50834. * Set the texture reflection matrix used to rotate/transform the reflection.
  50835. * @param value Define the reflection matrix to set
  50836. */
  50837. setReflectionTextureMatrix(value: Matrix): void;
  50838. /**
  50839. * Parses a JSON representation of an HDR Texture in order to create the texture
  50840. * @param parsedTexture Define the JSON representation
  50841. * @param scene Define the scene the texture should be created in
  50842. * @param rootUrl Define the root url in case we need to load relative dependencies
  50843. * @returns the newly created texture after parsing
  50844. */
  50845. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50846. serialize(): any;
  50847. }
  50848. }
  50849. declare module "babylonjs/Physics/physicsEngine" {
  50850. import { Nullable } from "babylonjs/types";
  50851. import { Vector3 } from "babylonjs/Maths/math";
  50852. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50853. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50854. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50855. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50856. /**
  50857. * Class used to control physics engine
  50858. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50859. */
  50860. export class PhysicsEngine implements IPhysicsEngine {
  50861. private _physicsPlugin;
  50862. /**
  50863. * Global value used to control the smallest number supported by the simulation
  50864. */
  50865. static Epsilon: number;
  50866. private _impostors;
  50867. private _joints;
  50868. /**
  50869. * Gets the gravity vector used by the simulation
  50870. */
  50871. gravity: Vector3;
  50872. /**
  50873. * Factory used to create the default physics plugin.
  50874. * @returns The default physics plugin
  50875. */
  50876. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50877. /**
  50878. * Creates a new Physics Engine
  50879. * @param gravity defines the gravity vector used by the simulation
  50880. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50881. */
  50882. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50883. /**
  50884. * Sets the gravity vector used by the simulation
  50885. * @param gravity defines the gravity vector to use
  50886. */
  50887. setGravity(gravity: Vector3): void;
  50888. /**
  50889. * Set the time step of the physics engine.
  50890. * Default is 1/60.
  50891. * To slow it down, enter 1/600 for example.
  50892. * To speed it up, 1/30
  50893. * @param newTimeStep defines the new timestep to apply to this world.
  50894. */
  50895. setTimeStep(newTimeStep?: number): void;
  50896. /**
  50897. * Get the time step of the physics engine.
  50898. * @returns the current time step
  50899. */
  50900. getTimeStep(): number;
  50901. /**
  50902. * Release all resources
  50903. */
  50904. dispose(): void;
  50905. /**
  50906. * Gets the name of the current physics plugin
  50907. * @returns the name of the plugin
  50908. */
  50909. getPhysicsPluginName(): string;
  50910. /**
  50911. * Adding a new impostor for the impostor tracking.
  50912. * This will be done by the impostor itself.
  50913. * @param impostor the impostor to add
  50914. */
  50915. addImpostor(impostor: PhysicsImpostor): void;
  50916. /**
  50917. * Remove an impostor from the engine.
  50918. * This impostor and its mesh will not longer be updated by the physics engine.
  50919. * @param impostor the impostor to remove
  50920. */
  50921. removeImpostor(impostor: PhysicsImpostor): void;
  50922. /**
  50923. * Add a joint to the physics engine
  50924. * @param mainImpostor defines the main impostor to which the joint is added.
  50925. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50926. * @param joint defines the joint that will connect both impostors.
  50927. */
  50928. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50929. /**
  50930. * Removes a joint from the simulation
  50931. * @param mainImpostor defines the impostor used with the joint
  50932. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50933. * @param joint defines the joint to remove
  50934. */
  50935. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50936. /**
  50937. * Called by the scene. No need to call it.
  50938. * @param delta defines the timespam between frames
  50939. */
  50940. _step(delta: number): void;
  50941. /**
  50942. * Gets the current plugin used to run the simulation
  50943. * @returns current plugin
  50944. */
  50945. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50946. /**
  50947. * Gets the list of physic impostors
  50948. * @returns an array of PhysicsImpostor
  50949. */
  50950. getImpostors(): Array<PhysicsImpostor>;
  50951. /**
  50952. * Gets the impostor for a physics enabled object
  50953. * @param object defines the object impersonated by the impostor
  50954. * @returns the PhysicsImpostor or null if not found
  50955. */
  50956. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50957. /**
  50958. * Gets the impostor for a physics body object
  50959. * @param body defines physics body used by the impostor
  50960. * @returns the PhysicsImpostor or null if not found
  50961. */
  50962. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50963. /**
  50964. * Does a raycast in the physics world
  50965. * @param from when should the ray start?
  50966. * @param to when should the ray end?
  50967. * @returns PhysicsRaycastResult
  50968. */
  50969. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50970. }
  50971. }
  50972. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  50973. import { Nullable } from "babylonjs/types";
  50974. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50976. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50977. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50978. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50979. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50980. /** @hidden */
  50981. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50982. private _useDeltaForWorldStep;
  50983. world: any;
  50984. name: string;
  50985. private _physicsMaterials;
  50986. private _fixedTimeStep;
  50987. private _cannonRaycastResult;
  50988. private _raycastResult;
  50989. private _removeAfterStep;
  50990. BJSCANNON: any;
  50991. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50992. setGravity(gravity: Vector3): void;
  50993. setTimeStep(timeStep: number): void;
  50994. getTimeStep(): number;
  50995. executeStep(delta: number): void;
  50996. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50997. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50998. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50999. private _processChildMeshes;
  51000. removePhysicsBody(impostor: PhysicsImpostor): void;
  51001. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51002. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51003. private _addMaterial;
  51004. private _checkWithEpsilon;
  51005. private _createShape;
  51006. private _createHeightmap;
  51007. private _minus90X;
  51008. private _plus90X;
  51009. private _tmpPosition;
  51010. private _tmpDeltaPosition;
  51011. private _tmpUnityRotation;
  51012. private _updatePhysicsBodyTransformation;
  51013. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51014. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51015. isSupported(): boolean;
  51016. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51017. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51018. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51019. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51020. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51021. getBodyMass(impostor: PhysicsImpostor): number;
  51022. getBodyFriction(impostor: PhysicsImpostor): number;
  51023. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51024. getBodyRestitution(impostor: PhysicsImpostor): number;
  51025. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51026. sleepBody(impostor: PhysicsImpostor): void;
  51027. wakeUpBody(impostor: PhysicsImpostor): void;
  51028. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51029. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51030. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51031. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51032. getRadius(impostor: PhysicsImpostor): number;
  51033. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51034. dispose(): void;
  51035. private _extendNamespace;
  51036. /**
  51037. * Does a raycast in the physics world
  51038. * @param from when should the ray start?
  51039. * @param to when should the ray end?
  51040. * @returns PhysicsRaycastResult
  51041. */
  51042. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51043. }
  51044. }
  51045. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51046. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51047. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51048. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51050. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51051. import { Nullable } from "babylonjs/types";
  51052. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51053. /** @hidden */
  51054. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51055. world: any;
  51056. name: string;
  51057. BJSOIMO: any;
  51058. private _raycastResult;
  51059. constructor(iterations?: number, oimoInjection?: any);
  51060. setGravity(gravity: Vector3): void;
  51061. setTimeStep(timeStep: number): void;
  51062. getTimeStep(): number;
  51063. private _tmpImpostorsArray;
  51064. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51065. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51066. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51067. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51068. private _tmpPositionVector;
  51069. removePhysicsBody(impostor: PhysicsImpostor): void;
  51070. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51071. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51072. isSupported(): boolean;
  51073. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51074. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51075. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51076. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51077. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51078. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51079. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51080. getBodyMass(impostor: PhysicsImpostor): number;
  51081. getBodyFriction(impostor: PhysicsImpostor): number;
  51082. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51083. getBodyRestitution(impostor: PhysicsImpostor): number;
  51084. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51085. sleepBody(impostor: PhysicsImpostor): void;
  51086. wakeUpBody(impostor: PhysicsImpostor): void;
  51087. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51088. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51089. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51090. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51091. getRadius(impostor: PhysicsImpostor): number;
  51092. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51093. dispose(): void;
  51094. /**
  51095. * Does a raycast in the physics world
  51096. * @param from when should the ray start?
  51097. * @param to when should the ray end?
  51098. * @returns PhysicsRaycastResult
  51099. */
  51100. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51101. }
  51102. }
  51103. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51104. import { Nullable } from "babylonjs/types";
  51105. import { Scene } from "babylonjs/scene";
  51106. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  51107. import { Mesh } from "babylonjs/Meshes/mesh";
  51108. /**
  51109. * Class containing static functions to help procedurally build meshes
  51110. */
  51111. export class RibbonBuilder {
  51112. /**
  51113. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51114. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51115. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51116. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51117. * * 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
  51118. * * 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
  51119. * * 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
  51120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51121. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51122. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51123. * * 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
  51124. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51125. * * 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
  51126. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51128. * @param name defines the name of the mesh
  51129. * @param options defines the options used to create the mesh
  51130. * @param scene defines the hosting scene
  51131. * @returns the ribbon mesh
  51132. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51133. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51134. */
  51135. static CreateRibbon(name: string, options: {
  51136. pathArray: Vector3[][];
  51137. closeArray?: boolean;
  51138. closePath?: boolean;
  51139. offset?: number;
  51140. updatable?: boolean;
  51141. sideOrientation?: number;
  51142. frontUVs?: Vector4;
  51143. backUVs?: Vector4;
  51144. instance?: Mesh;
  51145. invertUV?: boolean;
  51146. uvs?: Vector2[];
  51147. colors?: Color4[];
  51148. }, scene?: Nullable<Scene>): Mesh;
  51149. }
  51150. }
  51151. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51152. import { Nullable } from "babylonjs/types";
  51153. import { Scene } from "babylonjs/scene";
  51154. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51155. import { Mesh } from "babylonjs/Meshes/mesh";
  51156. /**
  51157. * Class containing static functions to help procedurally build meshes
  51158. */
  51159. export class ShapeBuilder {
  51160. /**
  51161. * 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.
  51162. * * 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.
  51163. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51164. * * 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.
  51165. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51166. * * 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
  51167. * * 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
  51168. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51170. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51171. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51173. * @param name defines the name of the mesh
  51174. * @param options defines the options used to create the mesh
  51175. * @param scene defines the hosting scene
  51176. * @returns the extruded shape mesh
  51177. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51178. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51179. */
  51180. static ExtrudeShape(name: string, options: {
  51181. shape: Vector3[];
  51182. path: Vector3[];
  51183. scale?: number;
  51184. rotation?: number;
  51185. cap?: number;
  51186. updatable?: boolean;
  51187. sideOrientation?: number;
  51188. frontUVs?: Vector4;
  51189. backUVs?: Vector4;
  51190. instance?: Mesh;
  51191. invertUV?: boolean;
  51192. }, scene?: Nullable<Scene>): Mesh;
  51193. /**
  51194. * Creates an custom extruded shape mesh.
  51195. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51196. * * 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.
  51197. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51198. * * 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
  51199. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51200. * * 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
  51201. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51202. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51203. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51204. * * 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
  51205. * * 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
  51206. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51209. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51211. * @param name defines the name of the mesh
  51212. * @param options defines the options used to create the mesh
  51213. * @param scene defines the hosting scene
  51214. * @returns the custom extruded shape mesh
  51215. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51216. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51217. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51218. */
  51219. static ExtrudeShapeCustom(name: string, options: {
  51220. shape: Vector3[];
  51221. path: Vector3[];
  51222. scaleFunction?: any;
  51223. rotationFunction?: any;
  51224. ribbonCloseArray?: boolean;
  51225. ribbonClosePath?: boolean;
  51226. cap?: number;
  51227. updatable?: boolean;
  51228. sideOrientation?: number;
  51229. frontUVs?: Vector4;
  51230. backUVs?: Vector4;
  51231. instance?: Mesh;
  51232. invertUV?: boolean;
  51233. }, scene?: Nullable<Scene>): Mesh;
  51234. private static _ExtrudeShapeGeneric;
  51235. }
  51236. }
  51237. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51238. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51239. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51240. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51241. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51242. import { Nullable } from "babylonjs/types";
  51243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51244. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51245. /**
  51246. * AmmoJS Physics plugin
  51247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51248. * @see https://github.com/kripken/ammo.js/
  51249. */
  51250. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51251. private _useDeltaForWorldStep;
  51252. /**
  51253. * Reference to the Ammo library
  51254. */
  51255. bjsAMMO: any;
  51256. /**
  51257. * Created ammoJS world which physics bodies are added to
  51258. */
  51259. world: any;
  51260. /**
  51261. * Name of the plugin
  51262. */
  51263. name: string;
  51264. private _timeStep;
  51265. private _fixedTimeStep;
  51266. private _maxSteps;
  51267. private _tmpQuaternion;
  51268. private _tmpAmmoTransform;
  51269. private _tmpAmmoQuaternion;
  51270. private _tmpAmmoConcreteContactResultCallback;
  51271. private _collisionConfiguration;
  51272. private _dispatcher;
  51273. private _overlappingPairCache;
  51274. private _solver;
  51275. private _softBodySolver;
  51276. private _tmpAmmoVectorA;
  51277. private _tmpAmmoVectorB;
  51278. private _tmpAmmoVectorC;
  51279. private _tmpAmmoVectorD;
  51280. private _tmpContactCallbackResult;
  51281. private _tmpAmmoVectorRCA;
  51282. private _tmpAmmoVectorRCB;
  51283. private _raycastResult;
  51284. private static readonly DISABLE_COLLISION_FLAG;
  51285. private static readonly KINEMATIC_FLAG;
  51286. private static readonly DISABLE_DEACTIVATION_FLAG;
  51287. /**
  51288. * Initializes the ammoJS plugin
  51289. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51290. * @param ammoInjection can be used to inject your own ammo reference
  51291. */
  51292. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  51293. /**
  51294. * Sets the gravity of the physics world (m/(s^2))
  51295. * @param gravity Gravity to set
  51296. */
  51297. setGravity(gravity: Vector3): void;
  51298. /**
  51299. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51300. * @param timeStep timestep to use in seconds
  51301. */
  51302. setTimeStep(timeStep: number): void;
  51303. /**
  51304. * 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)
  51305. * @param fixedTimeStep fixedTimeStep to use in seconds
  51306. */
  51307. setFixedTimeStep(fixedTimeStep: number): void;
  51308. /**
  51309. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51310. * @param maxSteps the maximum number of steps by the physics engine per frame
  51311. */
  51312. setMaxSteps(maxSteps: number): void;
  51313. /**
  51314. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51315. * @returns the current timestep in seconds
  51316. */
  51317. getTimeStep(): number;
  51318. private _isImpostorInContact;
  51319. private _isImpostorPairInContact;
  51320. private _stepSimulation;
  51321. /**
  51322. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51323. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51324. * After the step the babylon meshes are set to the position of the physics imposters
  51325. * @param delta amount of time to step forward
  51326. * @param impostors array of imposters to update before/after the step
  51327. */
  51328. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51329. /**
  51330. * Update babylon mesh to match physics world object
  51331. * @param impostor imposter to match
  51332. */
  51333. private _afterSoftStep;
  51334. /**
  51335. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51336. * @param impostor imposter to match
  51337. */
  51338. private _ropeStep;
  51339. /**
  51340. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51341. * @param impostor imposter to match
  51342. */
  51343. private _softbodyOrClothStep;
  51344. private _tmpVector;
  51345. private _tmpMatrix;
  51346. /**
  51347. * Applies an impulse on the imposter
  51348. * @param impostor imposter to apply impulse to
  51349. * @param force amount of force to be applied to the imposter
  51350. * @param contactPoint the location to apply the impulse on the imposter
  51351. */
  51352. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51353. /**
  51354. * Applies a force on the imposter
  51355. * @param impostor imposter to apply force
  51356. * @param force amount of force to be applied to the imposter
  51357. * @param contactPoint the location to apply the force on the imposter
  51358. */
  51359. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51360. /**
  51361. * Creates a physics body using the plugin
  51362. * @param impostor the imposter to create the physics body on
  51363. */
  51364. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51365. /**
  51366. * Removes the physics body from the imposter and disposes of the body's memory
  51367. * @param impostor imposter to remove the physics body from
  51368. */
  51369. removePhysicsBody(impostor: PhysicsImpostor): void;
  51370. /**
  51371. * Generates a joint
  51372. * @param impostorJoint the imposter joint to create the joint with
  51373. */
  51374. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51375. /**
  51376. * Removes a joint
  51377. * @param impostorJoint the imposter joint to remove the joint from
  51378. */
  51379. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51380. private _addMeshVerts;
  51381. /**
  51382. * Initialise the soft body vertices to match its object's (mesh) vertices
  51383. * Softbody vertices (nodes) are in world space and to match this
  51384. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51385. * @param impostor to create the softbody for
  51386. */
  51387. private _softVertexData;
  51388. /**
  51389. * Create an impostor's soft body
  51390. * @param impostor to create the softbody for
  51391. */
  51392. private _createSoftbody;
  51393. /**
  51394. * Create cloth for an impostor
  51395. * @param impostor to create the softbody for
  51396. */
  51397. private _createCloth;
  51398. /**
  51399. * Create rope for an impostor
  51400. * @param impostor to create the softbody for
  51401. */
  51402. private _createRope;
  51403. private _addHullVerts;
  51404. private _createShape;
  51405. /**
  51406. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51407. * @param impostor imposter containing the physics body and babylon object
  51408. */
  51409. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51410. /**
  51411. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51412. * @param impostor imposter containing the physics body and babylon object
  51413. * @param newPosition new position
  51414. * @param newRotation new rotation
  51415. */
  51416. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51417. /**
  51418. * If this plugin is supported
  51419. * @returns true if its supported
  51420. */
  51421. isSupported(): boolean;
  51422. /**
  51423. * Sets the linear velocity of the physics body
  51424. * @param impostor imposter to set the velocity on
  51425. * @param velocity velocity to set
  51426. */
  51427. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51428. /**
  51429. * Sets the angular velocity of the physics body
  51430. * @param impostor imposter to set the velocity on
  51431. * @param velocity velocity to set
  51432. */
  51433. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51434. /**
  51435. * gets the linear velocity
  51436. * @param impostor imposter to get linear velocity from
  51437. * @returns linear velocity
  51438. */
  51439. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51440. /**
  51441. * gets the angular velocity
  51442. * @param impostor imposter to get angular velocity from
  51443. * @returns angular velocity
  51444. */
  51445. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51446. /**
  51447. * Sets the mass of physics body
  51448. * @param impostor imposter to set the mass on
  51449. * @param mass mass to set
  51450. */
  51451. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51452. /**
  51453. * Gets the mass of the physics body
  51454. * @param impostor imposter to get the mass from
  51455. * @returns mass
  51456. */
  51457. getBodyMass(impostor: PhysicsImpostor): number;
  51458. /**
  51459. * Gets friction of the impostor
  51460. * @param impostor impostor to get friction from
  51461. * @returns friction value
  51462. */
  51463. getBodyFriction(impostor: PhysicsImpostor): number;
  51464. /**
  51465. * Sets friction of the impostor
  51466. * @param impostor impostor to set friction on
  51467. * @param friction friction value
  51468. */
  51469. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51470. /**
  51471. * Gets restitution of the impostor
  51472. * @param impostor impostor to get restitution from
  51473. * @returns restitution value
  51474. */
  51475. getBodyRestitution(impostor: PhysicsImpostor): number;
  51476. /**
  51477. * Sets resitution of the impostor
  51478. * @param impostor impostor to set resitution on
  51479. * @param restitution resitution value
  51480. */
  51481. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51482. /**
  51483. * Gets pressure inside the impostor
  51484. * @param impostor impostor to get pressure from
  51485. * @returns pressure value
  51486. */
  51487. getBodyPressure(impostor: PhysicsImpostor): number;
  51488. /**
  51489. * Sets pressure inside a soft body impostor
  51490. * Cloth and rope must remain 0 pressure
  51491. * @param impostor impostor to set pressure on
  51492. * @param pressure pressure value
  51493. */
  51494. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51495. /**
  51496. * Gets stiffness of the impostor
  51497. * @param impostor impostor to get stiffness from
  51498. * @returns pressure value
  51499. */
  51500. getBodyStiffness(impostor: PhysicsImpostor): number;
  51501. /**
  51502. * Sets stiffness of the impostor
  51503. * @param impostor impostor to set stiffness on
  51504. * @param stiffness stiffness value from 0 to 1
  51505. */
  51506. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51507. /**
  51508. * Gets velocityIterations of the impostor
  51509. * @param impostor impostor to get velocity iterations from
  51510. * @returns velocityIterations value
  51511. */
  51512. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51513. /**
  51514. * Sets velocityIterations of the impostor
  51515. * @param impostor impostor to set velocity iterations on
  51516. * @param velocityIterations velocityIterations value
  51517. */
  51518. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51519. /**
  51520. * Gets positionIterations of the impostor
  51521. * @param impostor impostor to get position iterations from
  51522. * @returns positionIterations value
  51523. */
  51524. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51525. /**
  51526. * Sets positionIterations of the impostor
  51527. * @param impostor impostor to set position on
  51528. * @param positionIterations positionIterations value
  51529. */
  51530. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51531. /**
  51532. * Append an anchor to a cloth object
  51533. * @param impostor is the cloth impostor to add anchor to
  51534. * @param otherImpostor is the rigid impostor to anchor to
  51535. * @param width ratio across width from 0 to 1
  51536. * @param height ratio up height from 0 to 1
  51537. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51538. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51539. */
  51540. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51541. /**
  51542. * Append an hook to a rope object
  51543. * @param impostor is the rope impostor to add hook to
  51544. * @param otherImpostor is the rigid impostor to hook to
  51545. * @param length ratio along the rope from 0 to 1
  51546. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51547. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51548. */
  51549. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51550. /**
  51551. * Sleeps the physics body and stops it from being active
  51552. * @param impostor impostor to sleep
  51553. */
  51554. sleepBody(impostor: PhysicsImpostor): void;
  51555. /**
  51556. * Activates the physics body
  51557. * @param impostor impostor to activate
  51558. */
  51559. wakeUpBody(impostor: PhysicsImpostor): void;
  51560. /**
  51561. * Updates the distance parameters of the joint
  51562. * @param joint joint to update
  51563. * @param maxDistance maximum distance of the joint
  51564. * @param minDistance minimum distance of the joint
  51565. */
  51566. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51567. /**
  51568. * Sets a motor on the joint
  51569. * @param joint joint to set motor on
  51570. * @param speed speed of the motor
  51571. * @param maxForce maximum force of the motor
  51572. * @param motorIndex index of the motor
  51573. */
  51574. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51575. /**
  51576. * Sets the motors limit
  51577. * @param joint joint to set limit on
  51578. * @param upperLimit upper limit
  51579. * @param lowerLimit lower limit
  51580. */
  51581. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51582. /**
  51583. * Syncs the position and rotation of a mesh with the impostor
  51584. * @param mesh mesh to sync
  51585. * @param impostor impostor to update the mesh with
  51586. */
  51587. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51588. /**
  51589. * Gets the radius of the impostor
  51590. * @param impostor impostor to get radius from
  51591. * @returns the radius
  51592. */
  51593. getRadius(impostor: PhysicsImpostor): number;
  51594. /**
  51595. * Gets the box size of the impostor
  51596. * @param impostor impostor to get box size from
  51597. * @param result the resulting box size
  51598. */
  51599. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51600. /**
  51601. * Disposes of the impostor
  51602. */
  51603. dispose(): void;
  51604. /**
  51605. * Does a raycast in the physics world
  51606. * @param from when should the ray start?
  51607. * @param to when should the ray end?
  51608. * @returns PhysicsRaycastResult
  51609. */
  51610. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51611. }
  51612. }
  51613. declare module "babylonjs/Probes/reflectionProbe" {
  51614. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51615. import { Vector3 } from "babylonjs/Maths/math";
  51616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51617. import { Nullable } from "babylonjs/types";
  51618. import { Scene } from "babylonjs/scene";
  51619. module "babylonjs/abstractScene" {
  51620. interface AbstractScene {
  51621. /**
  51622. * The list of reflection probes added to the scene
  51623. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51624. */
  51625. reflectionProbes: Array<ReflectionProbe>;
  51626. /**
  51627. * Removes the given reflection probe from this scene.
  51628. * @param toRemove The reflection probe to remove
  51629. * @returns The index of the removed reflection probe
  51630. */
  51631. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51632. /**
  51633. * Adds the given reflection probe to this scene.
  51634. * @param newReflectionProbe The reflection probe to add
  51635. */
  51636. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51637. }
  51638. }
  51639. /**
  51640. * Class used to generate realtime reflection / refraction cube textures
  51641. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51642. */
  51643. export class ReflectionProbe {
  51644. /** defines the name of the probe */
  51645. name: string;
  51646. private _scene;
  51647. private _renderTargetTexture;
  51648. private _projectionMatrix;
  51649. private _viewMatrix;
  51650. private _target;
  51651. private _add;
  51652. private _attachedMesh;
  51653. private _invertYAxis;
  51654. /** Gets or sets probe position (center of the cube map) */
  51655. position: Vector3;
  51656. /**
  51657. * Creates a new reflection probe
  51658. * @param name defines the name of the probe
  51659. * @param size defines the texture resolution (for each face)
  51660. * @param scene defines the hosting scene
  51661. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51662. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51663. */
  51664. constructor(
  51665. /** defines the name of the probe */
  51666. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51667. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51668. samples: number;
  51669. /** Gets or sets the refresh rate to use (on every frame by default) */
  51670. refreshRate: number;
  51671. /**
  51672. * Gets the hosting scene
  51673. * @returns a Scene
  51674. */
  51675. getScene(): Scene;
  51676. /** Gets the internal CubeTexture used to render to */
  51677. readonly cubeTexture: RenderTargetTexture;
  51678. /** Gets the list of meshes to render */
  51679. readonly renderList: Nullable<AbstractMesh[]>;
  51680. /**
  51681. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51682. * @param mesh defines the mesh to attach to
  51683. */
  51684. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51685. /**
  51686. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51687. * @param renderingGroupId The rendering group id corresponding to its index
  51688. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51689. */
  51690. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51691. /**
  51692. * Clean all associated resources
  51693. */
  51694. dispose(): void;
  51695. /**
  51696. * Converts the reflection probe information to a readable string for debug purpose.
  51697. * @param fullDetails Supports for multiple levels of logging within scene loading
  51698. * @returns the human readable reflection probe info
  51699. */
  51700. toString(fullDetails?: boolean): string;
  51701. /**
  51702. * Get the class name of the relfection probe.
  51703. * @returns "ReflectionProbe"
  51704. */
  51705. getClassName(): string;
  51706. /**
  51707. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51708. * @returns The JSON representation of the texture
  51709. */
  51710. serialize(): any;
  51711. /**
  51712. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51713. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51714. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51715. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51716. * @returns The parsed reflection probe if successful
  51717. */
  51718. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51719. }
  51720. }
  51721. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51722. /** @hidden */
  51723. export var _BabylonLoaderRegistered: boolean;
  51724. }
  51725. declare module "babylonjs/Loading/Plugins/index" {
  51726. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51727. }
  51728. declare module "babylonjs/Loading/index" {
  51729. export * from "babylonjs/Loading/loadingScreen";
  51730. export * from "babylonjs/Loading/Plugins/index";
  51731. export * from "babylonjs/Loading/sceneLoader";
  51732. export * from "babylonjs/Loading/sceneLoaderFlags";
  51733. }
  51734. declare module "babylonjs/Materials/Background/index" {
  51735. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51736. }
  51737. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51738. import { Scene } from "babylonjs/scene";
  51739. import { Color3 } from "babylonjs/Maths/math";
  51740. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51741. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51742. /**
  51743. * The Physically based simple base material of BJS.
  51744. *
  51745. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51746. * It is used as the base class for both the specGloss and metalRough conventions.
  51747. */
  51748. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51749. /**
  51750. * Number of Simultaneous lights allowed on the material.
  51751. */
  51752. maxSimultaneousLights: number;
  51753. /**
  51754. * If sets to true, disables all the lights affecting the material.
  51755. */
  51756. disableLighting: boolean;
  51757. /**
  51758. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51759. */
  51760. environmentTexture: BaseTexture;
  51761. /**
  51762. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51763. */
  51764. invertNormalMapX: boolean;
  51765. /**
  51766. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51767. */
  51768. invertNormalMapY: boolean;
  51769. /**
  51770. * Normal map used in the model.
  51771. */
  51772. normalTexture: BaseTexture;
  51773. /**
  51774. * Emissivie color used to self-illuminate the model.
  51775. */
  51776. emissiveColor: Color3;
  51777. /**
  51778. * Emissivie texture used to self-illuminate the model.
  51779. */
  51780. emissiveTexture: BaseTexture;
  51781. /**
  51782. * Occlusion Channel Strenght.
  51783. */
  51784. occlusionStrength: number;
  51785. /**
  51786. * Occlusion Texture of the material (adding extra occlusion effects).
  51787. */
  51788. occlusionTexture: BaseTexture;
  51789. /**
  51790. * Defines the alpha limits in alpha test mode.
  51791. */
  51792. alphaCutOff: number;
  51793. /**
  51794. * Gets the current double sided mode.
  51795. */
  51796. /**
  51797. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51798. */
  51799. doubleSided: boolean;
  51800. /**
  51801. * Stores the pre-calculated light information of a mesh in a texture.
  51802. */
  51803. lightmapTexture: BaseTexture;
  51804. /**
  51805. * If true, the light map contains occlusion information instead of lighting info.
  51806. */
  51807. useLightmapAsShadowmap: boolean;
  51808. /**
  51809. * Instantiates a new PBRMaterial instance.
  51810. *
  51811. * @param name The material name
  51812. * @param scene The scene the material will be use in.
  51813. */
  51814. constructor(name: string, scene: Scene);
  51815. getClassName(): string;
  51816. }
  51817. }
  51818. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51819. import { Scene } from "babylonjs/scene";
  51820. import { Color3 } from "babylonjs/Maths/math";
  51821. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51822. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51823. /**
  51824. * The PBR material of BJS following the metal roughness convention.
  51825. *
  51826. * This fits to the PBR convention in the GLTF definition:
  51827. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51828. */
  51829. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51830. /**
  51831. * The base color has two different interpretations depending on the value of metalness.
  51832. * When the material is a metal, the base color is the specific measured reflectance value
  51833. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51834. * of the material.
  51835. */
  51836. baseColor: Color3;
  51837. /**
  51838. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51839. * well as opacity information in the alpha channel.
  51840. */
  51841. baseTexture: BaseTexture;
  51842. /**
  51843. * Specifies the metallic scalar value of the material.
  51844. * Can also be used to scale the metalness values of the metallic texture.
  51845. */
  51846. metallic: number;
  51847. /**
  51848. * Specifies the roughness scalar value of the material.
  51849. * Can also be used to scale the roughness values of the metallic texture.
  51850. */
  51851. roughness: number;
  51852. /**
  51853. * Texture containing both the metallic value in the B channel and the
  51854. * roughness value in the G channel to keep better precision.
  51855. */
  51856. metallicRoughnessTexture: BaseTexture;
  51857. /**
  51858. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51859. *
  51860. * @param name The material name
  51861. * @param scene The scene the material will be use in.
  51862. */
  51863. constructor(name: string, scene: Scene);
  51864. /**
  51865. * Return the currrent class name of the material.
  51866. */
  51867. getClassName(): string;
  51868. /**
  51869. * Makes a duplicate of the current material.
  51870. * @param name - name to use for the new material.
  51871. */
  51872. clone(name: string): PBRMetallicRoughnessMaterial;
  51873. /**
  51874. * Serialize the material to a parsable JSON object.
  51875. */
  51876. serialize(): any;
  51877. /**
  51878. * Parses a JSON object correponding to the serialize function.
  51879. */
  51880. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51881. }
  51882. }
  51883. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51884. import { Scene } from "babylonjs/scene";
  51885. import { Color3 } from "babylonjs/Maths/math";
  51886. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51887. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51888. /**
  51889. * The PBR material of BJS following the specular glossiness convention.
  51890. *
  51891. * This fits to the PBR convention in the GLTF definition:
  51892. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51893. */
  51894. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51895. /**
  51896. * Specifies the diffuse color of the material.
  51897. */
  51898. diffuseColor: Color3;
  51899. /**
  51900. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51901. * channel.
  51902. */
  51903. diffuseTexture: BaseTexture;
  51904. /**
  51905. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51906. */
  51907. specularColor: Color3;
  51908. /**
  51909. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51910. */
  51911. glossiness: number;
  51912. /**
  51913. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51914. */
  51915. specularGlossinessTexture: BaseTexture;
  51916. /**
  51917. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51918. *
  51919. * @param name The material name
  51920. * @param scene The scene the material will be use in.
  51921. */
  51922. constructor(name: string, scene: Scene);
  51923. /**
  51924. * Return the currrent class name of the material.
  51925. */
  51926. getClassName(): string;
  51927. /**
  51928. * Makes a duplicate of the current material.
  51929. * @param name - name to use for the new material.
  51930. */
  51931. clone(name: string): PBRSpecularGlossinessMaterial;
  51932. /**
  51933. * Serialize the material to a parsable JSON object.
  51934. */
  51935. serialize(): any;
  51936. /**
  51937. * Parses a JSON object correponding to the serialize function.
  51938. */
  51939. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51940. }
  51941. }
  51942. declare module "babylonjs/Materials/PBR/index" {
  51943. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51944. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51945. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51946. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51947. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51948. }
  51949. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51950. import { Nullable } from "babylonjs/types";
  51951. import { Scene } from "babylonjs/scene";
  51952. import { Matrix } from "babylonjs/Maths/math";
  51953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51954. /**
  51955. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51956. * It can help converting any input color in a desired output one. This can then be used to create effects
  51957. * from sepia, black and white to sixties or futuristic rendering...
  51958. *
  51959. * The only supported format is currently 3dl.
  51960. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51961. */
  51962. export class ColorGradingTexture extends BaseTexture {
  51963. /**
  51964. * The current texture matrix. (will always be identity in color grading texture)
  51965. */
  51966. private _textureMatrix;
  51967. /**
  51968. * The texture URL.
  51969. */
  51970. url: string;
  51971. /**
  51972. * Empty line regex stored for GC.
  51973. */
  51974. private static _noneEmptyLineRegex;
  51975. private _engine;
  51976. /**
  51977. * Instantiates a ColorGradingTexture from the following parameters.
  51978. *
  51979. * @param url The location of the color gradind data (currently only supporting 3dl)
  51980. * @param scene The scene the texture will be used in
  51981. */
  51982. constructor(url: string, scene: Scene);
  51983. /**
  51984. * Returns the texture matrix used in most of the material.
  51985. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51986. */
  51987. getTextureMatrix(): Matrix;
  51988. /**
  51989. * Occurs when the file being loaded is a .3dl LUT file.
  51990. */
  51991. private load3dlTexture;
  51992. /**
  51993. * Starts the loading process of the texture.
  51994. */
  51995. private loadTexture;
  51996. /**
  51997. * Clones the color gradind texture.
  51998. */
  51999. clone(): ColorGradingTexture;
  52000. /**
  52001. * Called during delayed load for textures.
  52002. */
  52003. delayLoad(): void;
  52004. /**
  52005. * Parses a color grading texture serialized by Babylon.
  52006. * @param parsedTexture The texture information being parsedTexture
  52007. * @param scene The scene to load the texture in
  52008. * @param rootUrl The root url of the data assets to load
  52009. * @return A color gradind texture
  52010. */
  52011. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52012. /**
  52013. * Serializes the LUT texture to json format.
  52014. */
  52015. serialize(): any;
  52016. }
  52017. }
  52018. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52020. import { Scene } from "babylonjs/scene";
  52021. import { Nullable } from "babylonjs/types";
  52022. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52023. /**
  52024. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52025. */
  52026. export class EquiRectangularCubeTexture extends BaseTexture {
  52027. /** The six faces of the cube. */
  52028. private static _FacesMapping;
  52029. private _noMipmap;
  52030. private _onLoad;
  52031. private _onError;
  52032. /** The size of the cubemap. */
  52033. private _size;
  52034. /** The buffer of the image. */
  52035. private _buffer;
  52036. /** The width of the input image. */
  52037. private _width;
  52038. /** The height of the input image. */
  52039. private _height;
  52040. /** The URL to the image. */
  52041. url: string;
  52042. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52043. coordinatesMode: number;
  52044. /**
  52045. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52046. * @param url The location of the image
  52047. * @param scene The scene the texture will be used in
  52048. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52049. * @param noMipmap Forces to not generate the mipmap if true
  52050. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52051. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52052. * @param onLoad — defines a callback called when texture is loaded
  52053. * @param onError — defines a callback called if there is an error
  52054. */
  52055. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52056. /**
  52057. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52058. */
  52059. private loadImage;
  52060. /**
  52061. * Convert the image buffer into a cubemap and create a CubeTexture.
  52062. */
  52063. private loadTexture;
  52064. /**
  52065. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52066. * @param buffer The ArrayBuffer that should be converted.
  52067. * @returns The buffer as Float32Array.
  52068. */
  52069. private getFloat32ArrayFromArrayBuffer;
  52070. /**
  52071. * Get the current class name of the texture useful for serialization or dynamic coding.
  52072. * @returns "EquiRectangularCubeTexture"
  52073. */
  52074. getClassName(): string;
  52075. /**
  52076. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52077. * @returns A clone of the current EquiRectangularCubeTexture.
  52078. */
  52079. clone(): EquiRectangularCubeTexture;
  52080. }
  52081. }
  52082. declare module "babylonjs/Misc/tga" {
  52083. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52084. /**
  52085. * Based on jsTGALoader - Javascript loader for TGA file
  52086. * By Vincent Thibault
  52087. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52088. */
  52089. export class TGATools {
  52090. private static _TYPE_INDEXED;
  52091. private static _TYPE_RGB;
  52092. private static _TYPE_GREY;
  52093. private static _TYPE_RLE_INDEXED;
  52094. private static _TYPE_RLE_RGB;
  52095. private static _TYPE_RLE_GREY;
  52096. private static _ORIGIN_MASK;
  52097. private static _ORIGIN_SHIFT;
  52098. private static _ORIGIN_BL;
  52099. private static _ORIGIN_BR;
  52100. private static _ORIGIN_UL;
  52101. private static _ORIGIN_UR;
  52102. /**
  52103. * Gets the header of a TGA file
  52104. * @param data defines the TGA data
  52105. * @returns the header
  52106. */
  52107. static GetTGAHeader(data: Uint8Array): any;
  52108. /**
  52109. * Uploads TGA content to a Babylon Texture
  52110. * @hidden
  52111. */
  52112. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52113. /** @hidden */
  52114. 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;
  52115. /** @hidden */
  52116. 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;
  52117. /** @hidden */
  52118. 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;
  52119. /** @hidden */
  52120. 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;
  52121. /** @hidden */
  52122. 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;
  52123. /** @hidden */
  52124. 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;
  52125. }
  52126. }
  52127. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52128. import { Nullable } from "babylonjs/types";
  52129. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52130. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52131. /**
  52132. * Implementation of the TGA Texture Loader.
  52133. * @hidden
  52134. */
  52135. export class _TGATextureLoader implements IInternalTextureLoader {
  52136. /**
  52137. * Defines wether the loader supports cascade loading the different faces.
  52138. */
  52139. readonly supportCascades: boolean;
  52140. /**
  52141. * This returns if the loader support the current file information.
  52142. * @param extension defines the file extension of the file being loaded
  52143. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52144. * @param fallback defines the fallback internal texture if any
  52145. * @param isBase64 defines whether the texture is encoded as a base64
  52146. * @param isBuffer defines whether the texture data are stored as a buffer
  52147. * @returns true if the loader can load the specified file
  52148. */
  52149. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52150. /**
  52151. * Transform the url before loading if required.
  52152. * @param rootUrl the url of the texture
  52153. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52154. * @returns the transformed texture
  52155. */
  52156. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52157. /**
  52158. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52159. * @param rootUrl the url of the texture
  52160. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52161. * @returns the fallback texture
  52162. */
  52163. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52164. /**
  52165. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52166. * @param data contains the texture data
  52167. * @param texture defines the BabylonJS internal texture
  52168. * @param createPolynomials will be true if polynomials have been requested
  52169. * @param onLoad defines the callback to trigger once the texture is ready
  52170. * @param onError defines the callback to trigger in case of error
  52171. */
  52172. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52173. /**
  52174. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52175. * @param data contains the texture data
  52176. * @param texture defines the BabylonJS internal texture
  52177. * @param callback defines the method to call once ready to upload
  52178. */
  52179. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52180. }
  52181. }
  52182. declare module "babylonjs/Materials/Textures/Loaders/index" {
  52183. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52184. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52185. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52186. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  52187. }
  52188. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  52189. import { Scene } from "babylonjs/scene";
  52190. import { Texture } from "babylonjs/Materials/Textures/texture";
  52191. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52192. /**
  52193. * 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.
  52194. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52195. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52196. */
  52197. export class CustomProceduralTexture extends ProceduralTexture {
  52198. private _animate;
  52199. private _time;
  52200. private _config;
  52201. private _texturePath;
  52202. /**
  52203. * Instantiates a new Custom Procedural Texture.
  52204. * 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.
  52205. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52206. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52207. * @param name Define the name of the texture
  52208. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52209. * @param size Define the size of the texture to create
  52210. * @param scene Define the scene the texture belongs to
  52211. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52212. * @param generateMipMaps Define if the texture should creates mip maps or not
  52213. */
  52214. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52215. private _loadJson;
  52216. /**
  52217. * Is the texture ready to be used ? (rendered at least once)
  52218. * @returns true if ready, otherwise, false.
  52219. */
  52220. isReady(): boolean;
  52221. /**
  52222. * Render the texture to its associated render target.
  52223. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52224. */
  52225. render(useCameraPostProcess?: boolean): void;
  52226. /**
  52227. * Update the list of dependant textures samplers in the shader.
  52228. */
  52229. updateTextures(): void;
  52230. /**
  52231. * Update the uniform values of the procedural texture in the shader.
  52232. */
  52233. updateShaderUniforms(): void;
  52234. /**
  52235. * Define if the texture animates or not.
  52236. */
  52237. animate: boolean;
  52238. }
  52239. }
  52240. declare module "babylonjs/Shaders/noise.fragment" {
  52241. /** @hidden */
  52242. export var noisePixelShader: {
  52243. name: string;
  52244. shader: string;
  52245. };
  52246. }
  52247. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  52248. import { Nullable } from "babylonjs/types";
  52249. import { Scene } from "babylonjs/scene";
  52250. import { Texture } from "babylonjs/Materials/Textures/texture";
  52251. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52252. import "babylonjs/Shaders/noise.fragment";
  52253. /**
  52254. * Class used to generate noise procedural textures
  52255. */
  52256. export class NoiseProceduralTexture extends ProceduralTexture {
  52257. private _time;
  52258. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52259. brightness: number;
  52260. /** Defines the number of octaves to process */
  52261. octaves: number;
  52262. /** Defines the level of persistence (0.8 by default) */
  52263. persistence: number;
  52264. /** Gets or sets animation speed factor (default is 1) */
  52265. animationSpeedFactor: number;
  52266. /**
  52267. * Creates a new NoiseProceduralTexture
  52268. * @param name defines the name fo the texture
  52269. * @param size defines the size of the texture (default is 256)
  52270. * @param scene defines the hosting scene
  52271. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52272. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52273. */
  52274. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52275. private _updateShaderUniforms;
  52276. protected _getDefines(): string;
  52277. /** Generate the current state of the procedural texture */
  52278. render(useCameraPostProcess?: boolean): void;
  52279. /**
  52280. * Serializes this noise procedural texture
  52281. * @returns a serialized noise procedural texture object
  52282. */
  52283. serialize(): any;
  52284. /**
  52285. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52286. * @param parsedTexture defines parsed texture data
  52287. * @param scene defines the current scene
  52288. * @param rootUrl defines the root URL containing noise procedural texture information
  52289. * @returns a parsed NoiseProceduralTexture
  52290. */
  52291. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52292. }
  52293. }
  52294. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  52295. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  52296. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  52297. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52298. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  52299. }
  52300. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  52301. import { Nullable } from "babylonjs/types";
  52302. import { Scene } from "babylonjs/scene";
  52303. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52304. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52305. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52306. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52307. /**
  52308. * Raw cube texture where the raw buffers are passed in
  52309. */
  52310. export class RawCubeTexture extends CubeTexture {
  52311. /**
  52312. * Creates a cube texture where the raw buffers are passed in.
  52313. * @param scene defines the scene the texture is attached to
  52314. * @param data defines the array of data to use to create each face
  52315. * @param size defines the size of the textures
  52316. * @param format defines the format of the data
  52317. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52318. * @param generateMipMaps defines if the engine should generate the mip levels
  52319. * @param invertY defines if data must be stored with Y axis inverted
  52320. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52321. * @param compression defines the compression used (null by default)
  52322. */
  52323. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52324. /**
  52325. * Updates the raw cube texture.
  52326. * @param data defines the data to store
  52327. * @param format defines the data format
  52328. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52329. * @param invertY defines if data must be stored with Y axis inverted
  52330. * @param compression defines the compression used (null by default)
  52331. * @param level defines which level of the texture to update
  52332. */
  52333. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52334. /**
  52335. * Updates a raw cube texture with RGBD encoded data.
  52336. * @param data defines the array of data [mipmap][face] to use to create each face
  52337. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52338. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52339. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52340. * @returns a promsie that resolves when the operation is complete
  52341. */
  52342. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52343. /**
  52344. * Clones the raw cube texture.
  52345. * @return a new cube texture
  52346. */
  52347. clone(): CubeTexture;
  52348. /** @hidden */
  52349. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52350. }
  52351. }
  52352. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  52353. import { Scene } from "babylonjs/scene";
  52354. import { Texture } from "babylonjs/Materials/Textures/texture";
  52355. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52356. /**
  52357. * Class used to store 3D textures containing user data
  52358. */
  52359. export class RawTexture3D extends Texture {
  52360. /** Gets or sets the texture format to use */
  52361. format: number;
  52362. private _engine;
  52363. /**
  52364. * Create a new RawTexture3D
  52365. * @param data defines the data of the texture
  52366. * @param width defines the width of the texture
  52367. * @param height defines the height of the texture
  52368. * @param depth defines the depth of the texture
  52369. * @param format defines the texture format to use
  52370. * @param scene defines the hosting scene
  52371. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52372. * @param invertY defines if texture must be stored with Y axis inverted
  52373. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52374. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52375. */
  52376. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52377. /** Gets or sets the texture format to use */
  52378. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52379. /**
  52380. * Update the texture with new data
  52381. * @param data defines the data to store in the texture
  52382. */
  52383. update(data: ArrayBufferView): void;
  52384. }
  52385. }
  52386. declare module "babylonjs/Materials/Textures/refractionTexture" {
  52387. import { Scene } from "babylonjs/scene";
  52388. import { Plane } from "babylonjs/Maths/math";
  52389. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52390. /**
  52391. * Creates a refraction texture used by refraction channel of the standard material.
  52392. * It is like a mirror but to see through a material.
  52393. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52394. */
  52395. export class RefractionTexture extends RenderTargetTexture {
  52396. /**
  52397. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52398. * 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.
  52399. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52400. */
  52401. refractionPlane: Plane;
  52402. /**
  52403. * Define how deep under the surface we should see.
  52404. */
  52405. depth: number;
  52406. /**
  52407. * Creates a refraction texture used by refraction channel of the standard material.
  52408. * It is like a mirror but to see through a material.
  52409. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52410. * @param name Define the texture name
  52411. * @param size Define the size of the underlying texture
  52412. * @param scene Define the scene the refraction belongs to
  52413. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52414. */
  52415. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52416. /**
  52417. * Clone the refraction texture.
  52418. * @returns the cloned texture
  52419. */
  52420. clone(): RefractionTexture;
  52421. /**
  52422. * Serialize the texture to a JSON representation you could use in Parse later on
  52423. * @returns the serialized JSON representation
  52424. */
  52425. serialize(): any;
  52426. }
  52427. }
  52428. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  52429. import { Nullable } from "babylonjs/types";
  52430. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52431. import { Matrix } from "babylonjs/Maths/math";
  52432. import { Engine } from "babylonjs/Engines/engine";
  52433. import { Scene } from "babylonjs/scene";
  52434. /**
  52435. * Defines the options related to the creation of an HtmlElementTexture
  52436. */
  52437. export interface IHtmlElementTextureOptions {
  52438. /**
  52439. * Defines wether mip maps should be created or not.
  52440. */
  52441. generateMipMaps?: boolean;
  52442. /**
  52443. * Defines the sampling mode of the texture.
  52444. */
  52445. samplingMode?: number;
  52446. /**
  52447. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52448. */
  52449. engine: Nullable<Engine>;
  52450. /**
  52451. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52452. */
  52453. scene: Nullable<Scene>;
  52454. }
  52455. /**
  52456. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52457. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52458. * is automatically managed.
  52459. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52460. * in your application.
  52461. *
  52462. * As the update is not automatic, you need to call them manually.
  52463. */
  52464. export class HtmlElementTexture extends BaseTexture {
  52465. /**
  52466. * The texture URL.
  52467. */
  52468. element: HTMLVideoElement | HTMLCanvasElement;
  52469. private static readonly DefaultOptions;
  52470. private _textureMatrix;
  52471. private _engine;
  52472. private _isVideo;
  52473. private _generateMipMaps;
  52474. private _samplingMode;
  52475. /**
  52476. * Instantiates a HtmlElementTexture from the following parameters.
  52477. *
  52478. * @param name Defines the name of the texture
  52479. * @param element Defines the video or canvas the texture is filled with
  52480. * @param options Defines the other none mandatory texture creation options
  52481. */
  52482. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52483. private _createInternalTexture;
  52484. /**
  52485. * Returns the texture matrix used in most of the material.
  52486. */
  52487. getTextureMatrix(): Matrix;
  52488. /**
  52489. * Updates the content of the texture.
  52490. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52491. */
  52492. update(invertY?: Nullable<boolean>): void;
  52493. }
  52494. }
  52495. declare module "babylonjs/Materials/Textures/index" {
  52496. export * from "babylonjs/Materials/Textures/baseTexture";
  52497. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  52498. export * from "babylonjs/Materials/Textures/cubeTexture";
  52499. export * from "babylonjs/Materials/Textures/dynamicTexture";
  52500. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  52501. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  52502. export * from "babylonjs/Materials/Textures/internalTexture";
  52503. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  52504. export * from "babylonjs/Materials/Textures/Loaders/index";
  52505. export * from "babylonjs/Materials/Textures/mirrorTexture";
  52506. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  52507. export * from "babylonjs/Materials/Textures/Procedurals/index";
  52508. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  52509. export * from "babylonjs/Materials/Textures/rawTexture";
  52510. export * from "babylonjs/Materials/Textures/rawTexture3D";
  52511. export * from "babylonjs/Materials/Textures/refractionTexture";
  52512. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  52513. export * from "babylonjs/Materials/Textures/texture";
  52514. export * from "babylonjs/Materials/Textures/videoTexture";
  52515. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  52516. }
  52517. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  52518. /**
  52519. * Enum used to define the target of a block
  52520. */
  52521. export enum NodeMaterialBlockTargets {
  52522. /** Vertex shader */
  52523. Vertex = 1,
  52524. /** Fragment shader */
  52525. Fragment = 2,
  52526. /** Vertex and Fragment */
  52527. VertexAndFragment = 3
  52528. }
  52529. }
  52530. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  52531. /**
  52532. * Defines the kind of connection point for node based material
  52533. */
  52534. export enum NodeMaterialBlockConnectionPointTypes {
  52535. /** Float */
  52536. Float = 1,
  52537. /** Int */
  52538. Int = 2,
  52539. /** Vector2 */
  52540. Vector2 = 4,
  52541. /** Vector3 */
  52542. Vector3 = 8,
  52543. /** Vector4 */
  52544. Vector4 = 16,
  52545. /** Color3 */
  52546. Color3 = 32,
  52547. /** Color4 */
  52548. Color4 = 64,
  52549. /** Matrix */
  52550. Matrix = 128,
  52551. /** Texture */
  52552. Texture = 256,
  52553. /** Texture3D */
  52554. Texture3D = 512,
  52555. /** Vector3 or Color3 */
  52556. Vector3OrColor3 = 40,
  52557. /** Vector3 or Vector4 */
  52558. Vector3OrVector4 = 24,
  52559. /** Vector4 or Color4 */
  52560. Vector4OrColor4 = 80,
  52561. /** Color3 or Color4 */
  52562. Color3OrColor4 = 96,
  52563. /** Vector3 or Color3 */
  52564. Vector3OrColor3OrVector4OrColor4 = 120
  52565. }
  52566. }
  52567. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  52568. /**
  52569. * Enum used to define well known values e.g. values automatically provided by the system
  52570. */
  52571. export enum NodeMaterialWellKnownValues {
  52572. /** World */
  52573. World = 1,
  52574. /** View */
  52575. View = 2,
  52576. /** Projection */
  52577. Projection = 3,
  52578. /** ViewProjection */
  52579. ViewProjection = 4,
  52580. /** WorldView */
  52581. WorldView = 5,
  52582. /** WorldViewProjection */
  52583. WorldViewProjection = 6,
  52584. /** Will be filled by the block itself */
  52585. Automatic = 7
  52586. }
  52587. }
  52588. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  52589. /**
  52590. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52591. */
  52592. export enum NodeMaterialBlockConnectionPointMode {
  52593. /** Value is an uniform */
  52594. Uniform = 0,
  52595. /** Value is a mesh attribute */
  52596. Attribute = 1,
  52597. /** Value is a varying between vertex and fragment shaders */
  52598. Varying = 2,
  52599. /** Mode is undefined */
  52600. Undefined = 3
  52601. }
  52602. }
  52603. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  52604. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52605. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52606. /**
  52607. * Class used to store shared data between 2 NodeMaterialBuildState
  52608. */
  52609. export class NodeMaterialBuildStateSharedData {
  52610. /**
  52611. * Gets the list of emitted varyings
  52612. */
  52613. varyings: string[];
  52614. /**
  52615. * Gets the varying declaration string
  52616. */
  52617. varyingDeclaration: string;
  52618. /**
  52619. * Uniform connection points
  52620. */
  52621. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  52622. /**
  52623. * Bindable blocks (Blocks that need to set data to the effect)
  52624. */
  52625. bindableBlocks: NodeMaterialBlock[];
  52626. /**
  52627. * List of blocks that can provide a compilation fallback
  52628. */
  52629. blocksWithFallbacks: NodeMaterialBlock[];
  52630. /**
  52631. * List of blocks that can provide a define update
  52632. */
  52633. blocksWithDefines: NodeMaterialBlock[];
  52634. /**
  52635. * List of blocks that can provide a repeatable content
  52636. */
  52637. repeatableContentBlocks: NodeMaterialBlock[];
  52638. /**
  52639. * List of blocks that can block the isReady function for the material
  52640. */
  52641. blockingBlocks: NodeMaterialBlock[];
  52642. /**
  52643. * Build Id used to avoid multiple recompilations
  52644. */
  52645. buildId: number;
  52646. /** List of emitted variables */
  52647. variableNames: {
  52648. [key: string]: number;
  52649. };
  52650. /** List of emitted defines */
  52651. defineNames: {
  52652. [key: string]: number;
  52653. };
  52654. /** Should emit comments? */
  52655. emitComments: boolean;
  52656. /** Emit build activity */
  52657. verbose: boolean;
  52658. /**
  52659. * Gets the compilation hints emitted at compilation time
  52660. */
  52661. hints: {
  52662. needWorldViewMatrix: boolean;
  52663. needWorldViewProjectionMatrix: boolean;
  52664. needAlphaBlending: boolean;
  52665. needAlphaTesting: boolean;
  52666. };
  52667. /**
  52668. * List of compilation checks
  52669. */
  52670. checks: {
  52671. emitVertex: boolean;
  52672. emitFragment: boolean;
  52673. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52674. };
  52675. /** Creates a new shared data */
  52676. constructor();
  52677. /**
  52678. * Emits console errors and exceptions if there is a failing check
  52679. */
  52680. emitErrors(): void;
  52681. }
  52682. }
  52683. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  52684. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52685. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  52686. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  52687. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  52688. /**
  52689. * Class used to store node based material build state
  52690. */
  52691. export class NodeMaterialBuildState {
  52692. /**
  52693. * Gets the list of emitted attributes
  52694. */
  52695. attributes: string[];
  52696. /**
  52697. * Gets the list of emitted uniforms
  52698. */
  52699. uniforms: string[];
  52700. /**
  52701. * Gets the list of emitted samplers
  52702. */
  52703. samplers: string[];
  52704. /**
  52705. * Gets the list of emitted functions
  52706. */
  52707. functions: {
  52708. [key: string]: string;
  52709. };
  52710. /**
  52711. * Gets the target of the compilation state
  52712. */
  52713. target: NodeMaterialBlockTargets;
  52714. /**
  52715. * Shared data between multiple NodeMaterialBuildState instances
  52716. */
  52717. sharedData: NodeMaterialBuildStateSharedData;
  52718. /** @hidden */
  52719. _vertexState: NodeMaterialBuildState;
  52720. private _attributeDeclaration;
  52721. private _uniformDeclaration;
  52722. private _samplerDeclaration;
  52723. private _varyingTransfer;
  52724. private _repeatableContentAnchorIndex;
  52725. /** @hidden */
  52726. _builtCompilationString: string;
  52727. /**
  52728. * Gets the emitted compilation strings
  52729. */
  52730. compilationString: string;
  52731. /**
  52732. * Finalize the compilation strings
  52733. * @param state defines the current compilation state
  52734. */
  52735. finalize(state: NodeMaterialBuildState): void;
  52736. /** @hidden */
  52737. readonly _repeatableContentAnchor: string;
  52738. /** @hidden */
  52739. _getFreeVariableName(prefix: string): string;
  52740. /** @hidden */
  52741. _getFreeDefineName(prefix: string): string;
  52742. /** @hidden */
  52743. _excludeVariableName(name: string): void;
  52744. /** @hidden */
  52745. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52746. /** @hidden */
  52747. _emitFunction(name: string, code: string, comments: string): void;
  52748. /** @hidden */
  52749. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52750. replaceStrings?: {
  52751. search: RegExp;
  52752. replace: string;
  52753. }[];
  52754. }): string;
  52755. /** @hidden */
  52756. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52757. repeatKey?: string;
  52758. removeAttributes?: boolean;
  52759. removeUniforms?: boolean;
  52760. removeVaryings?: boolean;
  52761. removeIfDef?: boolean;
  52762. replaceStrings?: {
  52763. search: RegExp;
  52764. replace: string;
  52765. }[];
  52766. }): void;
  52767. /** @hidden */
  52768. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  52769. private _emitDefine;
  52770. /** @hidden */
  52771. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  52772. }
  52773. }
  52774. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  52775. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52776. /**
  52777. * Root class for all node material optimizers
  52778. */
  52779. export class NodeMaterialOptimizer {
  52780. /**
  52781. * Function used to optimize a NodeMaterial graph
  52782. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52783. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52784. */
  52785. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52786. }
  52787. }
  52788. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  52789. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52790. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  52791. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52792. /**
  52793. * Block used to transform a vector4 with a matrix
  52794. */
  52795. export class Vector4TransformBlock extends NodeMaterialBlock {
  52796. /**
  52797. * Defines the value to use to complement Vector3 to transform it to a Vector4
  52798. */
  52799. complementW: number;
  52800. /**
  52801. * Creates a new Vector4TransformBlock
  52802. * @param name defines the block name
  52803. */
  52804. constructor(name: string);
  52805. /**
  52806. * Gets the current class name
  52807. * @returns the class name
  52808. */
  52809. getClassName(): string;
  52810. /**
  52811. * Gets the vector input
  52812. */
  52813. readonly vector: NodeMaterialConnectionPoint;
  52814. /**
  52815. * Gets the matrix transform input
  52816. */
  52817. readonly transform: NodeMaterialConnectionPoint;
  52818. protected _buildBlock(state: NodeMaterialBuildState): this;
  52819. }
  52820. }
  52821. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  52822. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52823. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  52824. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52825. /**
  52826. * Block used to output the vertex position
  52827. */
  52828. export class VertexOutputBlock extends NodeMaterialBlock {
  52829. /**
  52830. * Creates a new VertexOutputBlock
  52831. * @param name defines the block name
  52832. */
  52833. constructor(name: string);
  52834. /**
  52835. * Gets the current class name
  52836. * @returns the class name
  52837. */
  52838. getClassName(): string;
  52839. /**
  52840. * Gets the vector input component
  52841. */
  52842. readonly vector: NodeMaterialConnectionPoint;
  52843. protected _buildBlock(state: NodeMaterialBuildState): this;
  52844. }
  52845. }
  52846. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  52847. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52848. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  52849. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52850. /**
  52851. * Block used to output the final color
  52852. */
  52853. export class FragmentOutputBlock extends NodeMaterialBlock {
  52854. /**
  52855. * Gets or sets a boolean indicating if this block will output an alpha value
  52856. */
  52857. alphaBlendingEnabled: boolean;
  52858. /**
  52859. * Create a new FragmentOutputBlock
  52860. * @param name defines the block name
  52861. */
  52862. constructor(name: string);
  52863. /**
  52864. * Gets the current class name
  52865. * @returns the class name
  52866. */
  52867. getClassName(): string;
  52868. /**
  52869. * Gets the color input component
  52870. */
  52871. readonly color: NodeMaterialConnectionPoint;
  52872. protected _buildBlock(state: NodeMaterialBuildState): this;
  52873. }
  52874. }
  52875. declare module "babylonjs/Materials/Node/nodeMaterial" {
  52876. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52877. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52878. import { Scene } from "babylonjs/scene";
  52879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52880. import { Matrix } from "babylonjs/Maths/math";
  52881. import { Mesh } from "babylonjs/Meshes/mesh";
  52882. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52883. import { Observable } from "babylonjs/Misc/observable";
  52884. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52885. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52886. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  52887. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52888. import { Nullable } from "babylonjs/types";
  52889. /**
  52890. * Interface used to configure the node material editor
  52891. */
  52892. export interface INodeMaterialEditorOptions {
  52893. /** Define the URl to load node editor script */
  52894. editorURL?: string;
  52895. }
  52896. /** @hidden */
  52897. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52898. /** BONES */
  52899. NUM_BONE_INFLUENCERS: number;
  52900. BonesPerMesh: number;
  52901. BONETEXTURE: boolean;
  52902. /** MORPH TARGETS */
  52903. MORPHTARGETS: boolean;
  52904. MORPHTARGETS_NORMAL: boolean;
  52905. MORPHTARGETS_TANGENT: boolean;
  52906. NUM_MORPH_INFLUENCERS: number;
  52907. /** IMAGE PROCESSING */
  52908. IMAGEPROCESSING: boolean;
  52909. VIGNETTE: boolean;
  52910. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52911. VIGNETTEBLENDMODEOPAQUE: boolean;
  52912. TONEMAPPING: boolean;
  52913. TONEMAPPING_ACES: boolean;
  52914. CONTRAST: boolean;
  52915. EXPOSURE: boolean;
  52916. COLORCURVES: boolean;
  52917. COLORGRADING: boolean;
  52918. COLORGRADING3D: boolean;
  52919. SAMPLER3DGREENDEPTH: boolean;
  52920. SAMPLER3DBGRMAP: boolean;
  52921. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52922. constructor();
  52923. setValue(name: string, value: boolean): void;
  52924. }
  52925. /**
  52926. * Class used to configure NodeMaterial
  52927. */
  52928. export interface INodeMaterialOptions {
  52929. /**
  52930. * Defines if blocks should emit comments
  52931. */
  52932. emitComments: boolean;
  52933. }
  52934. /**
  52935. * Class used to create a node based material built by assembling shader blocks
  52936. */
  52937. export class NodeMaterial extends PushMaterial {
  52938. private _options;
  52939. private _vertexCompilationState;
  52940. private _fragmentCompilationState;
  52941. private _sharedData;
  52942. private _buildId;
  52943. private _buildWasSuccessful;
  52944. private _cachedWorldViewMatrix;
  52945. private _cachedWorldViewProjectionMatrix;
  52946. private _textureConnectionPoints;
  52947. private _optimizers;
  52948. /** Define the URl to load node editor script */
  52949. static EditorURL: string;
  52950. private BJSNODEMATERIALEDITOR;
  52951. /** Get the inspector from bundle or global */
  52952. private _getGlobalNodeMaterialEditor;
  52953. /**
  52954. * Defines the maximum number of lights that can be used in the material
  52955. */
  52956. maxSimultaneousLights: number;
  52957. /**
  52958. * Observable raised when the material is built
  52959. */
  52960. onBuildObservable: Observable<NodeMaterial>;
  52961. /**
  52962. * Gets or sets the root nodes of the material vertex shader
  52963. */
  52964. _vertexOutputNodes: NodeMaterialBlock[];
  52965. /**
  52966. * Gets or sets the root nodes of the material fragment (pixel) shader
  52967. */
  52968. _fragmentOutputNodes: NodeMaterialBlock[];
  52969. /** Gets or sets options to control the node material overall behavior */
  52970. options: INodeMaterialOptions;
  52971. /**
  52972. * Default configuration related to image processing available in the standard Material.
  52973. */
  52974. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52975. /**
  52976. * Gets the image processing configuration used either in this material.
  52977. */
  52978. /**
  52979. * Sets the Default image processing configuration used either in the this material.
  52980. *
  52981. * If sets to null, the scene one is in use.
  52982. */
  52983. imageProcessingConfiguration: ImageProcessingConfiguration;
  52984. /**
  52985. * Create a new node based material
  52986. * @param name defines the material name
  52987. * @param scene defines the hosting scene
  52988. * @param options defines creation option
  52989. */
  52990. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52991. /**
  52992. * Gets the current class name of the material e.g. "NodeMaterial"
  52993. * @returns the class name
  52994. */
  52995. getClassName(): string;
  52996. /**
  52997. * Keep track of the image processing observer to allow dispose and replace.
  52998. */
  52999. private _imageProcessingObserver;
  53000. /**
  53001. * Attaches a new image processing configuration to the Standard Material.
  53002. * @param configuration
  53003. */
  53004. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53005. /**
  53006. * Adds a new optimizer to the list of optimizers
  53007. * @param optimizer defines the optimizers to add
  53008. * @returns the current material
  53009. */
  53010. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53011. /**
  53012. * Remove an optimizer from the list of optimizers
  53013. * @param optimizer defines the optimizers to remove
  53014. * @returns the current material
  53015. */
  53016. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53017. /**
  53018. * Add a new block to the list of output nodes
  53019. * @param node defines the node to add
  53020. * @returns the current material
  53021. */
  53022. addOutputNode(node: NodeMaterialBlock): this;
  53023. /**
  53024. * Remove a block from the list of root nodes
  53025. * @param node defines the node to remove
  53026. * @returns the current material
  53027. */
  53028. removeOutputNode(node: NodeMaterialBlock): this;
  53029. private _addVertexOutputNode;
  53030. private _removeVertexOutputNode;
  53031. private _addFragmentOutputNode;
  53032. private _removeFragmentOutputNode;
  53033. /**
  53034. * Specifies if the material will require alpha blending
  53035. * @returns a boolean specifying if alpha blending is needed
  53036. */
  53037. needAlphaBlending(): boolean;
  53038. /**
  53039. * Specifies if this material should be rendered in alpha test mode
  53040. * @returns a boolean specifying if an alpha test is needed.
  53041. */
  53042. needAlphaTesting(): boolean;
  53043. private _initializeBlock;
  53044. private _resetDualBlocks;
  53045. /**
  53046. * Build the material and generates the inner effect
  53047. * @param verbose defines if the build should log activity
  53048. */
  53049. build(verbose?: boolean): void;
  53050. /**
  53051. * Runs an otpimization phase to try to improve the shader code
  53052. */
  53053. optimize(): void;
  53054. private _prepareDefinesForAttributes;
  53055. /**
  53056. * Get if the submesh is ready to be used and all its information available.
  53057. * Child classes can use it to update shaders
  53058. * @param mesh defines the mesh to check
  53059. * @param subMesh defines which submesh to check
  53060. * @param useInstances specifies that instances should be used
  53061. * @returns a boolean indicating that the submesh is ready or not
  53062. */
  53063. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53064. /**
  53065. * Binds the world matrix to the material
  53066. * @param world defines the world transformation matrix
  53067. */
  53068. bindOnlyWorldMatrix(world: Matrix): void;
  53069. /**
  53070. * Binds the submesh to this material by preparing the effect and shader to draw
  53071. * @param world defines the world transformation matrix
  53072. * @param mesh defines the mesh containing the submesh
  53073. * @param subMesh defines the submesh to bind the material to
  53074. */
  53075. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53076. /**
  53077. * Gets the active textures from the material
  53078. * @returns an array of textures
  53079. */
  53080. getActiveTextures(): BaseTexture[];
  53081. /**
  53082. * Specifies if the material uses a texture
  53083. * @param texture defines the texture to check against the material
  53084. * @returns a boolean specifying if the material uses the texture
  53085. */
  53086. hasTexture(texture: BaseTexture): boolean;
  53087. /**
  53088. * Disposes the material
  53089. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53090. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53091. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53092. */
  53093. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53094. /** Creates the node editor window. */
  53095. private _createNodeEditor;
  53096. /**
  53097. * Launch the node material editor
  53098. * @param config Define the configuration of the editor
  53099. * @return a promise fulfilled when the node editor is visible
  53100. */
  53101. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53102. /**
  53103. * Clear the current material
  53104. */
  53105. clear(): void;
  53106. /**
  53107. * Clear the current material and set it to a default state
  53108. */
  53109. setToDefault(): void;
  53110. }
  53111. }
  53112. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  53113. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53114. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53115. import { Nullable } from "babylonjs/types";
  53116. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53117. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53118. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53120. import { Mesh } from "babylonjs/Meshes/mesh";
  53121. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53122. /**
  53123. * Defines a block that can be used inside a node based material
  53124. */
  53125. export class NodeMaterialBlock {
  53126. private _buildId;
  53127. private _target;
  53128. private _isFinalMerger;
  53129. /** @hidden */
  53130. _inputs: NodeMaterialConnectionPoint[];
  53131. /** @hidden */
  53132. _outputs: NodeMaterialConnectionPoint[];
  53133. /**
  53134. * Gets or sets the name of the block
  53135. */
  53136. name: string;
  53137. /**
  53138. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53139. */
  53140. readonly isFinalMerger: boolean;
  53141. /**
  53142. * Gets or sets the build Id
  53143. */
  53144. buildId: number;
  53145. /**
  53146. * Gets or sets the target of the block
  53147. */
  53148. target: NodeMaterialBlockTargets;
  53149. /**
  53150. * Gets the list of input points
  53151. */
  53152. readonly inputs: NodeMaterialConnectionPoint[];
  53153. /** Gets the list of output points */
  53154. readonly outputs: NodeMaterialConnectionPoint[];
  53155. /**
  53156. * Find an input by its name
  53157. * @param name defines the name of the input to look for
  53158. * @returns the input or null if not found
  53159. */
  53160. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53161. /**
  53162. * Find an output by its name
  53163. * @param name defines the name of the outputto look for
  53164. * @returns the output or null if not found
  53165. */
  53166. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53167. /**
  53168. * Creates a new NodeMaterialBlock
  53169. * @param name defines the block name
  53170. * @param target defines the target of that block (Vertex by default)
  53171. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53172. */
  53173. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  53174. /**
  53175. * Initialize the block and prepare the context for build
  53176. * @param state defines the state that will be used for the build
  53177. */
  53178. initialize(state: NodeMaterialBuildState): void;
  53179. /**
  53180. * Bind data to effect. Will only be called for blocks with isBindable === true
  53181. * @param effect defines the effect to bind data to
  53182. * @param nodeMaterial defines the hosting NodeMaterial
  53183. * @param mesh defines the mesh that will be rendered
  53184. */
  53185. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53186. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53187. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53188. protected _writeFloat(value: number): string;
  53189. /**
  53190. * Gets the current class name e.g. "NodeMaterialBlock"
  53191. * @returns the class name
  53192. */
  53193. getClassName(): string;
  53194. /**
  53195. * Register a new input. Must be called inside a block constructor
  53196. * @param name defines the connection point name
  53197. * @param type defines the connection point type
  53198. * @param isOptional defines a boolean indicating that this input can be omitted
  53199. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53200. * @returns the current block
  53201. */
  53202. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53203. /**
  53204. * Register a new output. Must be called inside a block constructor
  53205. * @param name defines the connection point name
  53206. * @param type defines the connection point type
  53207. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53208. * @returns the current block
  53209. */
  53210. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53211. /**
  53212. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53213. * @param forOutput defines an optional connection point to check compatibility with
  53214. * @returns the first available input or null
  53215. */
  53216. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53217. /**
  53218. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53219. * @param forBlock defines an optional block to check compatibility with
  53220. * @returns the first available input or null
  53221. */
  53222. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53223. /**
  53224. * Connect current block with another block
  53225. * @param other defines the block to connect with
  53226. * @param options define the various options to help pick the right connections
  53227. * @returns the current block
  53228. */
  53229. connectTo(other: NodeMaterialBlock, options?: {
  53230. input?: string;
  53231. output?: string;
  53232. outputSwizzle?: string;
  53233. }): this | undefined;
  53234. protected _buildBlock(state: NodeMaterialBuildState): void;
  53235. /**
  53236. * Add potential fallbacks if shader compilation fails
  53237. * @param mesh defines the mesh to be rendered
  53238. * @param fallbacks defines the current prioritized list of fallbacks
  53239. */
  53240. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53241. /**
  53242. * Update defines for shader compilation
  53243. * @param mesh defines the mesh to be rendered
  53244. * @param nodeMaterial defines the node material requesting the update
  53245. * @param defines defines the material defines to update
  53246. * @param useInstances specifies that instances should be used
  53247. */
  53248. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53249. /**
  53250. * Lets the block try to connect some inputs automatically
  53251. */
  53252. autoConfigure(): void;
  53253. /**
  53254. * Function called when a block is declared as repeatable content generator
  53255. * @param vertexShaderState defines the current compilation state for the vertex shader
  53256. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53257. * @param mesh defines the mesh to be rendered
  53258. * @param defines defines the material defines to update
  53259. */
  53260. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53261. /**
  53262. * Checks if the block is ready
  53263. * @param mesh defines the mesh to be rendered
  53264. * @param nodeMaterial defines the node material requesting the update
  53265. * @param defines defines the material defines to update
  53266. * @param useInstances specifies that instances should be used
  53267. * @returns true if the block is ready
  53268. */
  53269. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53270. /**
  53271. * Compile the current node and generate the shader code
  53272. * @param state defines the current compilation state (uniforms, samplers, current string)
  53273. * @returns the current block
  53274. */
  53275. build(state: NodeMaterialBuildState): this | undefined;
  53276. }
  53277. }
  53278. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  53279. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53280. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53281. import { Nullable } from "babylonjs/types";
  53282. import { Effect } from "babylonjs/Materials/effect";
  53283. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  53284. import { Scene } from "babylonjs/scene";
  53285. import { Matrix } from "babylonjs/Maths/math";
  53286. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53287. /**
  53288. * Defines a connection point for a block
  53289. */
  53290. export class NodeMaterialConnectionPoint {
  53291. /** @hidden */
  53292. _ownerBlock: NodeMaterialBlock;
  53293. /** @hidden */
  53294. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53295. private _associatedVariableName;
  53296. private _endpoints;
  53297. private _storedValue;
  53298. private _valueCallback;
  53299. private _mode;
  53300. /** @hidden */
  53301. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53302. /** @hidden */
  53303. _needToEmitVarying: boolean;
  53304. /**
  53305. * Gets or sets the connection point type (default is float)
  53306. */
  53307. type: NodeMaterialBlockConnectionPointTypes;
  53308. /**
  53309. * Gets or sets the connection point name
  53310. */
  53311. name: string;
  53312. /**
  53313. * Gets or sets the swizzle to apply to this connection point when reading or writing
  53314. */
  53315. swizzle: string;
  53316. /**
  53317. * Gets or sets a boolean indicating that this connection point can be omitted
  53318. */
  53319. isOptional: boolean;
  53320. /**
  53321. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53322. */
  53323. define: string;
  53324. /** Gets or sets the target of that connection point */
  53325. target: NodeMaterialBlockTargets;
  53326. /**
  53327. * Gets or sets the value of that point.
  53328. * Please note that this value will be ignored if valueCallback is defined
  53329. */
  53330. value: any;
  53331. /**
  53332. * Gets or sets a callback used to get the value of that point.
  53333. * Please note that setting this value will force the connection point to ignore the value property
  53334. */
  53335. valueCallback: () => any;
  53336. /**
  53337. * Gets or sets the associated variable name in the shader
  53338. */
  53339. associatedVariableName: string;
  53340. /**
  53341. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53342. * In this case the connection point name must be the name of the uniform to use.
  53343. * Can only be set on inputs
  53344. */
  53345. isUniform: boolean;
  53346. /**
  53347. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53348. * In this case the connection point name must be the name of the attribute to use
  53349. * Can only be set on inputs
  53350. */
  53351. isAttribute: boolean;
  53352. /**
  53353. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53354. * Can only be set on exit points
  53355. */
  53356. isVarying: boolean;
  53357. /** Get the other side of the connection (if any) */
  53358. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53359. /** Get the block that owns this connection point */
  53360. readonly ownerBlock: NodeMaterialBlock;
  53361. /** Get the block connected on the other side of this connection (if any) */
  53362. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53363. /** Get the block connected on the endpoints of this connection (if any) */
  53364. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53365. /**
  53366. * Creates a new connection point
  53367. * @param name defines the connection point name
  53368. * @param ownerBlock defines the block hosting this connection point
  53369. */
  53370. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53371. /**
  53372. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53373. * @returns the class name
  53374. */
  53375. getClassName(): string;
  53376. /**
  53377. * Set the source of this connection point to a vertex attribute
  53378. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53379. * @returns the current connection point
  53380. */
  53381. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  53382. /**
  53383. * Set the source of this connection point to a well known value
  53384. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  53385. * @returns the current connection point
  53386. */
  53387. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  53388. /**
  53389. * Gets a boolean indicating that the current connection point is a well known value
  53390. */
  53391. readonly isWellKnownValue: boolean;
  53392. /**
  53393. * Gets or sets the current well known value or null if not defined as well know value
  53394. */
  53395. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53396. private _getTypeLength;
  53397. /**
  53398. * Connect this point to another connection point
  53399. * @param connectionPoint defines the other connection point
  53400. * @returns the current connection point
  53401. */
  53402. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53403. /**
  53404. * Disconnect this point from one of his endpoint
  53405. * @param endpoint defines the other connection point
  53406. * @returns the current connection point
  53407. */
  53408. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53409. /**
  53410. * When connection point is an uniform, this function will send its value to the effect
  53411. * @param effect defines the effect to transmit value to
  53412. * @param world defines the world matrix
  53413. * @param worldView defines the worldxview matrix
  53414. * @param worldViewProjection defines the worldxviewxprojection matrix
  53415. */
  53416. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53417. /**
  53418. * When connection point is an uniform, this function will send its value to the effect
  53419. * @param effect defines the effect to transmit value to
  53420. * @param scene defines the hosting scene
  53421. */
  53422. transmit(effect: Effect, scene: Scene): void;
  53423. }
  53424. }
  53425. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  53426. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53427. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53429. import { Mesh } from "babylonjs/Meshes/mesh";
  53430. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53432. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53433. /**
  53434. * Block used to add support for vertex skinning (bones)
  53435. */
  53436. export class BonesBlock extends NodeMaterialBlock {
  53437. /**
  53438. * Creates a new BonesBlock
  53439. * @param name defines the block name
  53440. */
  53441. constructor(name: string);
  53442. /**
  53443. * Initialize the block and prepare the context for build
  53444. * @param state defines the state that will be used for the build
  53445. */
  53446. initialize(state: NodeMaterialBuildState): void;
  53447. /**
  53448. * Gets the current class name
  53449. * @returns the class name
  53450. */
  53451. getClassName(): string;
  53452. /**
  53453. * Gets the matrix indices input component
  53454. */
  53455. readonly matricesIndices: NodeMaterialConnectionPoint;
  53456. /**
  53457. * Gets the matrix weights input component
  53458. */
  53459. readonly matricesWeights: NodeMaterialConnectionPoint;
  53460. /**
  53461. * Gets the extra matrix indices input component
  53462. */
  53463. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53464. /**
  53465. * Gets the extra matrix weights input component
  53466. */
  53467. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53468. /**
  53469. * Gets the world input component
  53470. */
  53471. readonly world: NodeMaterialConnectionPoint;
  53472. autoConfigure(): void;
  53473. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53474. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53475. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53476. protected _buildBlock(state: NodeMaterialBuildState): this;
  53477. }
  53478. }
  53479. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  53480. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53481. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53482. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53484. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53485. /**
  53486. * Block used to add support for instances
  53487. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53488. */
  53489. export class InstancesBlock extends NodeMaterialBlock {
  53490. /**
  53491. * Creates a new InstancesBlock
  53492. * @param name defines the block name
  53493. */
  53494. constructor(name: string);
  53495. /**
  53496. * Gets the current class name
  53497. * @returns the class name
  53498. */
  53499. getClassName(): string;
  53500. /**
  53501. * Gets the first world row input component
  53502. */
  53503. readonly world0: NodeMaterialConnectionPoint;
  53504. /**
  53505. * Gets the second world row input component
  53506. */
  53507. readonly world1: NodeMaterialConnectionPoint;
  53508. /**
  53509. * Gets the third world row input component
  53510. */
  53511. readonly world2: NodeMaterialConnectionPoint;
  53512. /**
  53513. * Gets the forth world row input component
  53514. */
  53515. readonly world3: NodeMaterialConnectionPoint;
  53516. /**
  53517. * Gets the world input component
  53518. */
  53519. readonly world: NodeMaterialConnectionPoint;
  53520. /**
  53521. * Gets the output component
  53522. */
  53523. readonly output: NodeMaterialConnectionPoint;
  53524. autoConfigure(): void;
  53525. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53526. protected _buildBlock(state: NodeMaterialBuildState): this;
  53527. }
  53528. }
  53529. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  53530. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53531. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53532. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53534. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53535. import { Effect } from "babylonjs/Materials/effect";
  53536. import { Mesh } from "babylonjs/Meshes/mesh";
  53537. /**
  53538. * Block used to add morph targets support to vertex shader
  53539. */
  53540. export class MorphTargetsBlock extends NodeMaterialBlock {
  53541. private _repeatableContentAnchor;
  53542. private _repeatebleContentGenerated;
  53543. /**
  53544. * Create a new MorphTargetsBlock
  53545. * @param name defines the block name
  53546. */
  53547. constructor(name: string);
  53548. /**
  53549. * Gets the current class name
  53550. * @returns the class name
  53551. */
  53552. getClassName(): string;
  53553. /**
  53554. * Gets the position input component
  53555. */
  53556. readonly position: NodeMaterialConnectionPoint;
  53557. /**
  53558. * Gets the normal input component
  53559. */
  53560. readonly normal: NodeMaterialConnectionPoint;
  53561. /**
  53562. * Gets the tangent input component
  53563. */
  53564. readonly tangent: NodeMaterialConnectionPoint;
  53565. /**
  53566. * Gets the position output component
  53567. */
  53568. readonly positionOutput: NodeMaterialConnectionPoint;
  53569. /**
  53570. * Gets the normal output component
  53571. */
  53572. readonly normalOutput: NodeMaterialConnectionPoint;
  53573. /**
  53574. * Gets the tangent output component
  53575. */
  53576. readonly tangentOutput: NodeMaterialConnectionPoint;
  53577. initialize(state: NodeMaterialBuildState): void;
  53578. autoConfigure(): void;
  53579. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53580. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53581. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53582. protected _buildBlock(state: NodeMaterialBuildState): this;
  53583. }
  53584. }
  53585. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  53586. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  53587. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  53588. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  53589. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  53590. }
  53591. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  53592. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53593. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53594. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53595. /**
  53596. * Block used to add an alpha test in the fragment shader
  53597. */
  53598. export class AlphaTestBlock extends NodeMaterialBlock {
  53599. /**
  53600. * Gets or sets the alpha value where alpha testing happens
  53601. */
  53602. alphaCutOff: number;
  53603. /**
  53604. * Create a new AlphaTestBlock
  53605. * @param name defines the block name
  53606. */
  53607. constructor(name: string);
  53608. /**
  53609. * Gets the current class name
  53610. * @returns the class name
  53611. */
  53612. getClassName(): string;
  53613. /**
  53614. * Gets the color input component
  53615. */
  53616. readonly color: NodeMaterialConnectionPoint;
  53617. protected _buildBlock(state: NodeMaterialBuildState): this;
  53618. }
  53619. }
  53620. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  53621. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53622. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53623. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53624. /**
  53625. * Block used to create a Color4 out of 4 inputs (one for each component)
  53626. */
  53627. export class RGBAMergerBlock extends NodeMaterialBlock {
  53628. /**
  53629. * Create a new RGBAMergerBlock
  53630. * @param name defines the block name
  53631. */
  53632. constructor(name: string);
  53633. /**
  53634. * Gets the current class name
  53635. * @returns the class name
  53636. */
  53637. getClassName(): string;
  53638. /**
  53639. * Gets the R input component
  53640. */
  53641. readonly r: NodeMaterialConnectionPoint;
  53642. /**
  53643. * Gets the G input component
  53644. */
  53645. readonly g: NodeMaterialConnectionPoint;
  53646. /**
  53647. * Gets the B input component
  53648. */
  53649. readonly b: NodeMaterialConnectionPoint;
  53650. /**
  53651. * Gets the RGB input component
  53652. */
  53653. readonly rgb: NodeMaterialConnectionPoint;
  53654. /**
  53655. * Gets the R input component
  53656. */
  53657. readonly a: NodeMaterialConnectionPoint;
  53658. protected _buildBlock(state: NodeMaterialBuildState): this;
  53659. }
  53660. }
  53661. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  53662. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53663. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53664. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53665. /**
  53666. * Block used to create a Color3 out of 3 inputs (one for each component)
  53667. */
  53668. export class RGBMergerBlock extends NodeMaterialBlock {
  53669. /**
  53670. * Create a new RGBMergerBlock
  53671. * @param name defines the block name
  53672. */
  53673. constructor(name: string);
  53674. /**
  53675. * Gets the current class name
  53676. * @returns the class name
  53677. */
  53678. getClassName(): string;
  53679. /**
  53680. * Gets the R component input
  53681. */
  53682. readonly r: NodeMaterialConnectionPoint;
  53683. /**
  53684. * Gets the G component input
  53685. */
  53686. readonly g: NodeMaterialConnectionPoint;
  53687. /**
  53688. * Gets the B component input
  53689. */
  53690. readonly b: NodeMaterialConnectionPoint;
  53691. protected _buildBlock(state: NodeMaterialBuildState): this;
  53692. }
  53693. }
  53694. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  53695. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53696. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53697. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53698. /**
  53699. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  53700. */
  53701. export class RGBASplitterBlock extends NodeMaterialBlock {
  53702. /**
  53703. * Create a new RGBASplitterBlock
  53704. * @param name defines the block name
  53705. */
  53706. constructor(name: string);
  53707. /**
  53708. * Gets the current class name
  53709. * @returns the class name
  53710. */
  53711. getClassName(): string;
  53712. /**
  53713. * Gets the input component
  53714. */
  53715. readonly input: NodeMaterialConnectionPoint;
  53716. protected _buildBlock(state: NodeMaterialBuildState): this;
  53717. }
  53718. }
  53719. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  53720. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53721. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53722. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53723. /**
  53724. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  53725. */
  53726. export class RGBSplitterBlock extends NodeMaterialBlock {
  53727. /**
  53728. * Create a new RGBSplitterBlock
  53729. * @param name defines the block name
  53730. */
  53731. constructor(name: string);
  53732. /**
  53733. * Gets the current class name
  53734. * @returns the class name
  53735. */
  53736. getClassName(): string;
  53737. /**
  53738. * Gets the input component
  53739. */
  53740. readonly input: NodeMaterialConnectionPoint;
  53741. protected _buildBlock(state: NodeMaterialBuildState): this;
  53742. }
  53743. }
  53744. declare module "babylonjs/Materials/Node/Blocks/Fragment/textureBlock" {
  53745. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53746. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53747. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53749. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53750. /**
  53751. * Block used to read a texture from a sampler
  53752. */
  53753. export class TextureBlock extends NodeMaterialBlock {
  53754. private _defineName;
  53755. /**
  53756. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  53757. */
  53758. autoConnectTextureMatrix: boolean;
  53759. /**
  53760. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  53761. */
  53762. autoSelectUV: boolean;
  53763. /**
  53764. * Create a new TextureBlock
  53765. * @param name defines the block name
  53766. */
  53767. constructor(name: string);
  53768. /**
  53769. * Gets the current class name
  53770. * @returns the class name
  53771. */
  53772. getClassName(): string;
  53773. /**
  53774. * Gets the uv input component
  53775. */
  53776. readonly uv: NodeMaterialConnectionPoint;
  53777. /**
  53778. * Gets the texture information input component
  53779. */
  53780. readonly textureInfo: NodeMaterialConnectionPoint;
  53781. /**
  53782. * Gets the transformed uv input component
  53783. */
  53784. readonly transformedUV: NodeMaterialConnectionPoint;
  53785. /**
  53786. * Gets the texture input component
  53787. */
  53788. readonly texture: NodeMaterialConnectionPoint;
  53789. /**
  53790. * Gets the texture transform input component
  53791. */
  53792. readonly textureTransform: NodeMaterialConnectionPoint;
  53793. autoConfigure(): void;
  53794. initialize(state: NodeMaterialBuildState): void;
  53795. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53796. isReady(): boolean;
  53797. private _injectVertexCode;
  53798. protected _buildBlock(state: NodeMaterialBuildState): this;
  53799. }
  53800. }
  53801. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  53802. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53803. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53804. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53806. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53807. import { Effect } from "babylonjs/Materials/effect";
  53808. import { Mesh } from "babylonjs/Meshes/mesh";
  53809. /**
  53810. * Block used to add image processing support to fragment shader
  53811. */
  53812. export class ImageProcessingBlock extends NodeMaterialBlock {
  53813. /**
  53814. * Create a new ImageProcessingBlock
  53815. * @param name defines the block name
  53816. */
  53817. constructor(name: string);
  53818. /**
  53819. * Gets the current class name
  53820. * @returns the class name
  53821. */
  53822. getClassName(): string;
  53823. /**
  53824. * Gets the color input component
  53825. */
  53826. readonly color: NodeMaterialConnectionPoint;
  53827. /**
  53828. * Initialize the block and prepare the context for build
  53829. * @param state defines the state that will be used for the build
  53830. */
  53831. initialize(state: NodeMaterialBuildState): void;
  53832. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53833. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53834. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53835. protected _buildBlock(state: NodeMaterialBuildState): this;
  53836. }
  53837. }
  53838. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  53839. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  53840. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  53841. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  53842. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  53843. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  53844. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  53845. export * from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  53846. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  53847. }
  53848. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  53849. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53850. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53851. import { Mesh } from "babylonjs/Meshes/mesh";
  53852. import { Effect } from "babylonjs/Materials/effect";
  53853. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53855. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53856. /**
  53857. * Block used to add support for scene fog
  53858. */
  53859. export class FogBlock extends NodeMaterialBlock {
  53860. /**
  53861. * Create a new FogBlock
  53862. * @param name defines the block name
  53863. */
  53864. constructor(name: string);
  53865. /**
  53866. * Gets the current class name
  53867. * @returns the class name
  53868. */
  53869. getClassName(): string;
  53870. /**
  53871. * Gets the world position input component
  53872. */
  53873. readonly worldPosition: NodeMaterialConnectionPoint;
  53874. /**
  53875. * Gets the view input component
  53876. */
  53877. readonly view: NodeMaterialConnectionPoint;
  53878. /**
  53879. * Gets the color input component
  53880. */
  53881. readonly color: NodeMaterialConnectionPoint;
  53882. /**
  53883. * Gets the fog color input component
  53884. */
  53885. readonly fogColor: NodeMaterialConnectionPoint;
  53886. /**
  53887. * Gets the for parameter input component
  53888. */
  53889. readonly fogParameters: NodeMaterialConnectionPoint;
  53890. autoConfigure(): void;
  53891. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53892. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53893. protected _buildBlock(state: NodeMaterialBuildState): this;
  53894. }
  53895. }
  53896. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  53897. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  53898. }
  53899. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  53900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53903. /**
  53904. * Block used to multiply 2 vector4
  53905. */
  53906. export class MultiplyBlock extends NodeMaterialBlock {
  53907. /**
  53908. * Creates a new MultiplyBlock
  53909. * @param name defines the block name
  53910. */
  53911. constructor(name: string);
  53912. /**
  53913. * Gets the current class name
  53914. * @returns the class name
  53915. */
  53916. getClassName(): string;
  53917. /**
  53918. * Gets the left operand input component
  53919. */
  53920. readonly left: NodeMaterialConnectionPoint;
  53921. /**
  53922. * Gets the right operand input component
  53923. */
  53924. readonly right: NodeMaterialConnectionPoint;
  53925. protected _buildBlock(state: NodeMaterialBuildState): this;
  53926. }
  53927. }
  53928. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  53929. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53930. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53931. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53932. /**
  53933. * Block used to add 2 vector4
  53934. */
  53935. export class AddBlock extends NodeMaterialBlock {
  53936. /**
  53937. * Creates a new AddBlock
  53938. * @param name defines the block name
  53939. */
  53940. constructor(name: string);
  53941. /**
  53942. * Gets the current class name
  53943. * @returns the class name
  53944. */
  53945. getClassName(): string;
  53946. /**
  53947. * Gets the left operand input component
  53948. */
  53949. readonly left: NodeMaterialConnectionPoint;
  53950. /**
  53951. * Gets the right operand input component
  53952. */
  53953. readonly right: NodeMaterialConnectionPoint;
  53954. protected _buildBlock(state: NodeMaterialBuildState): this;
  53955. }
  53956. }
  53957. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  53958. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53959. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53960. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53961. /**
  53962. * Block used to clamp a float
  53963. */
  53964. export class ClampBlock extends NodeMaterialBlock {
  53965. /** Gets or sets the minimum range */
  53966. minimum: number;
  53967. /** Gets or sets the maximum range */
  53968. maximum: number;
  53969. /**
  53970. * Creates a new ClampBlock
  53971. * @param name defines the block name
  53972. */
  53973. constructor(name: string);
  53974. /**
  53975. * Gets the current class name
  53976. * @returns the class name
  53977. */
  53978. getClassName(): string;
  53979. /**
  53980. * Gets the value input component
  53981. */
  53982. readonly value: NodeMaterialConnectionPoint;
  53983. protected _buildBlock(state: NodeMaterialBuildState): this;
  53984. }
  53985. }
  53986. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  53987. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53988. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53989. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53990. /**
  53991. * Block used to transform a vector2 with a matrix
  53992. */
  53993. export class Vector2TransformBlock extends NodeMaterialBlock {
  53994. /**
  53995. * Defines the value to use to complement Vector2 to transform it to a Vector4
  53996. */
  53997. complementZ: number;
  53998. /**
  53999. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54000. */
  54001. complementW: number;
  54002. /**
  54003. * Creates a new Vector2TransformBlock
  54004. * @param name defines the block name
  54005. */
  54006. constructor(name: string);
  54007. /**
  54008. * Gets the vector input
  54009. */
  54010. readonly vector: NodeMaterialConnectionPoint;
  54011. /**
  54012. * Gets the matrix transform input
  54013. */
  54014. readonly transform: NodeMaterialConnectionPoint;
  54015. /**
  54016. * Gets the current class name
  54017. * @returns the class name
  54018. */
  54019. getClassName(): string;
  54020. protected _buildBlock(state: NodeMaterialBuildState): this;
  54021. }
  54022. }
  54023. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  54024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54027. /**
  54028. * Block used to transform a vector3 with a matrix
  54029. */
  54030. export class Vector3TransformBlock extends NodeMaterialBlock {
  54031. /**
  54032. * Defines the value to use to complement Vector3 to transform it to a Vector4
  54033. */
  54034. complement: number;
  54035. /**
  54036. * Creates a new Vector3TransformBlock
  54037. * @param name defines the block name
  54038. */
  54039. constructor(name: string);
  54040. /**
  54041. * Gets the vector input
  54042. */
  54043. readonly vector: NodeMaterialConnectionPoint;
  54044. /**
  54045. * Gets the matrix transform input
  54046. */
  54047. readonly transform: NodeMaterialConnectionPoint;
  54048. /**
  54049. * Gets the current class name
  54050. * @returns the class name
  54051. */
  54052. getClassName(): string;
  54053. protected _buildBlock(state: NodeMaterialBuildState): this;
  54054. }
  54055. }
  54056. declare module "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock" {
  54057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54060. /**
  54061. * Block used to multiply two matrices
  54062. */
  54063. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  54064. /**
  54065. * Creates a new MatrixMultiplicationBlock
  54066. * @param name defines the block name
  54067. */
  54068. constructor(name: string);
  54069. /**
  54070. * Gets the left operand
  54071. */
  54072. readonly left: NodeMaterialConnectionPoint;
  54073. /**
  54074. * Gets the right operand
  54075. */
  54076. readonly right: NodeMaterialConnectionPoint;
  54077. /**
  54078. * Gets the current class name
  54079. * @returns the class name
  54080. */
  54081. getClassName(): string;
  54082. protected _buildBlock(state: NodeMaterialBuildState): this;
  54083. }
  54084. }
  54085. declare module "babylonjs/Materials/Node/Blocks/index" {
  54086. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  54087. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  54088. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  54089. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  54090. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  54091. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  54092. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  54093. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  54094. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  54095. export * from "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock";
  54096. }
  54097. declare module "babylonjs/Materials/Node/Optimizers/index" {
  54098. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54099. }
  54100. declare module "babylonjs/Materials/Node/index" {
  54101. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54102. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54103. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54104. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  54105. export * from "babylonjs/Materials/Node/nodeMaterial";
  54106. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54107. export * from "babylonjs/Materials/Node/Blocks/index";
  54108. export * from "babylonjs/Materials/Node/Optimizers/index";
  54109. }
  54110. declare module "babylonjs/Materials/index" {
  54111. export * from "babylonjs/Materials/Background/index";
  54112. export * from "babylonjs/Materials/colorCurves";
  54113. export * from "babylonjs/Materials/effect";
  54114. export * from "babylonjs/Materials/fresnelParameters";
  54115. export * from "babylonjs/Materials/imageProcessingConfiguration";
  54116. export * from "babylonjs/Materials/material";
  54117. export * from "babylonjs/Materials/materialDefines";
  54118. export * from "babylonjs/Materials/materialHelper";
  54119. export * from "babylonjs/Materials/multiMaterial";
  54120. export * from "babylonjs/Materials/PBR/index";
  54121. export * from "babylonjs/Materials/pushMaterial";
  54122. export * from "babylonjs/Materials/shaderMaterial";
  54123. export * from "babylonjs/Materials/standardMaterial";
  54124. export * from "babylonjs/Materials/Textures/index";
  54125. export * from "babylonjs/Materials/uniformBuffer";
  54126. export * from "babylonjs/Materials/materialFlags";
  54127. export * from "babylonjs/Materials/Node/index";
  54128. }
  54129. declare module "babylonjs/Maths/index" {
  54130. export * from "babylonjs/Maths/math.scalar";
  54131. export * from "babylonjs/Maths/math";
  54132. export * from "babylonjs/Maths/sphericalPolynomial";
  54133. }
  54134. declare module "babylonjs/Misc/workerPool" {
  54135. import { IDisposable } from "babylonjs/scene";
  54136. /**
  54137. * Helper class to push actions to a pool of workers.
  54138. */
  54139. export class WorkerPool implements IDisposable {
  54140. private _workerInfos;
  54141. private _pendingActions;
  54142. /**
  54143. * Constructor
  54144. * @param workers Array of workers to use for actions
  54145. */
  54146. constructor(workers: Array<Worker>);
  54147. /**
  54148. * Terminates all workers and clears any pending actions.
  54149. */
  54150. dispose(): void;
  54151. /**
  54152. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54153. * pended until a worker has completed its action.
  54154. * @param action The action to perform. Call onComplete when the action is complete.
  54155. */
  54156. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54157. private _execute;
  54158. }
  54159. }
  54160. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  54161. import { IDisposable } from "babylonjs/scene";
  54162. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54163. /**
  54164. * Configuration for Draco compression
  54165. */
  54166. export interface IDracoCompressionConfiguration {
  54167. /**
  54168. * Configuration for the decoder.
  54169. */
  54170. decoder: {
  54171. /**
  54172. * The url to the WebAssembly module.
  54173. */
  54174. wasmUrl?: string;
  54175. /**
  54176. * The url to the WebAssembly binary.
  54177. */
  54178. wasmBinaryUrl?: string;
  54179. /**
  54180. * The url to the fallback JavaScript module.
  54181. */
  54182. fallbackUrl?: string;
  54183. };
  54184. }
  54185. /**
  54186. * Draco compression (https://google.github.io/draco/)
  54187. *
  54188. * This class wraps the Draco module.
  54189. *
  54190. * **Encoder**
  54191. *
  54192. * The encoder is not currently implemented.
  54193. *
  54194. * **Decoder**
  54195. *
  54196. * 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.
  54197. *
  54198. * To update the configuration, use the following code:
  54199. * ```javascript
  54200. * DracoCompression.Configuration = {
  54201. * decoder: {
  54202. * wasmUrl: "<url to the WebAssembly library>",
  54203. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54204. * fallbackUrl: "<url to the fallback JavaScript library>",
  54205. * }
  54206. * };
  54207. * ```
  54208. *
  54209. * 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.
  54210. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54211. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54212. *
  54213. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54214. * ```javascript
  54215. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54216. * ```
  54217. *
  54218. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54219. */
  54220. export class DracoCompression implements IDisposable {
  54221. private _workerPoolPromise?;
  54222. private _decoderModulePromise?;
  54223. /**
  54224. * The configuration. Defaults to the following urls:
  54225. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54226. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54227. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54228. */
  54229. static Configuration: IDracoCompressionConfiguration;
  54230. /**
  54231. * Returns true if the decoder configuration is available.
  54232. */
  54233. static readonly DecoderAvailable: boolean;
  54234. /**
  54235. * Default number of workers to create when creating the draco compression object.
  54236. */
  54237. static DefaultNumWorkers: number;
  54238. private static GetDefaultNumWorkers;
  54239. private static _Default;
  54240. /**
  54241. * Default instance for the draco compression object.
  54242. */
  54243. static readonly Default: DracoCompression;
  54244. /**
  54245. * Constructor
  54246. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54247. */
  54248. constructor(numWorkers?: number);
  54249. /**
  54250. * Stop all async operations and release resources.
  54251. */
  54252. dispose(): void;
  54253. /**
  54254. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54255. * @returns a promise that resolves when ready
  54256. */
  54257. whenReadyAsync(): Promise<void>;
  54258. /**
  54259. * Decode Draco compressed mesh data to vertex data.
  54260. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54261. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54262. * @returns A promise that resolves with the decoded vertex data
  54263. */
  54264. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54265. [kind: string]: number;
  54266. }): Promise<VertexData>;
  54267. }
  54268. }
  54269. declare module "babylonjs/Meshes/Compression/index" {
  54270. export * from "babylonjs/Meshes/Compression/dracoCompression";
  54271. }
  54272. declare module "babylonjs/Meshes/csg" {
  54273. import { Nullable } from "babylonjs/types";
  54274. import { Scene } from "babylonjs/scene";
  54275. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  54276. import { Mesh } from "babylonjs/Meshes/mesh";
  54277. import { Material } from "babylonjs/Materials/material";
  54278. /**
  54279. * Class for building Constructive Solid Geometry
  54280. */
  54281. export class CSG {
  54282. private polygons;
  54283. /**
  54284. * The world matrix
  54285. */
  54286. matrix: Matrix;
  54287. /**
  54288. * Stores the position
  54289. */
  54290. position: Vector3;
  54291. /**
  54292. * Stores the rotation
  54293. */
  54294. rotation: Vector3;
  54295. /**
  54296. * Stores the rotation quaternion
  54297. */
  54298. rotationQuaternion: Nullable<Quaternion>;
  54299. /**
  54300. * Stores the scaling vector
  54301. */
  54302. scaling: Vector3;
  54303. /**
  54304. * Convert the Mesh to CSG
  54305. * @param mesh The Mesh to convert to CSG
  54306. * @returns A new CSG from the Mesh
  54307. */
  54308. static FromMesh(mesh: Mesh): CSG;
  54309. /**
  54310. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54311. * @param polygons Polygons used to construct a CSG solid
  54312. */
  54313. private static FromPolygons;
  54314. /**
  54315. * Clones, or makes a deep copy, of the CSG
  54316. * @returns A new CSG
  54317. */
  54318. clone(): CSG;
  54319. /**
  54320. * Unions this CSG with another CSG
  54321. * @param csg The CSG to union against this CSG
  54322. * @returns The unioned CSG
  54323. */
  54324. union(csg: CSG): CSG;
  54325. /**
  54326. * Unions this CSG with another CSG in place
  54327. * @param csg The CSG to union against this CSG
  54328. */
  54329. unionInPlace(csg: CSG): void;
  54330. /**
  54331. * Subtracts this CSG with another CSG
  54332. * @param csg The CSG to subtract against this CSG
  54333. * @returns A new CSG
  54334. */
  54335. subtract(csg: CSG): CSG;
  54336. /**
  54337. * Subtracts this CSG with another CSG in place
  54338. * @param csg The CSG to subtact against this CSG
  54339. */
  54340. subtractInPlace(csg: CSG): void;
  54341. /**
  54342. * Intersect this CSG with another CSG
  54343. * @param csg The CSG to intersect against this CSG
  54344. * @returns A new CSG
  54345. */
  54346. intersect(csg: CSG): CSG;
  54347. /**
  54348. * Intersects this CSG with another CSG in place
  54349. * @param csg The CSG to intersect against this CSG
  54350. */
  54351. intersectInPlace(csg: CSG): void;
  54352. /**
  54353. * Return a new CSG solid with solid and empty space switched. This solid is
  54354. * not modified.
  54355. * @returns A new CSG solid with solid and empty space switched
  54356. */
  54357. inverse(): CSG;
  54358. /**
  54359. * Inverses the CSG in place
  54360. */
  54361. inverseInPlace(): void;
  54362. /**
  54363. * This is used to keep meshes transformations so they can be restored
  54364. * when we build back a Babylon Mesh
  54365. * NB : All CSG operations are performed in world coordinates
  54366. * @param csg The CSG to copy the transform attributes from
  54367. * @returns This CSG
  54368. */
  54369. copyTransformAttributes(csg: CSG): CSG;
  54370. /**
  54371. * Build Raw mesh from CSG
  54372. * Coordinates here are in world space
  54373. * @param name The name of the mesh geometry
  54374. * @param scene The Scene
  54375. * @param keepSubMeshes Specifies if the submeshes should be kept
  54376. * @returns A new Mesh
  54377. */
  54378. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  54379. /**
  54380. * Build Mesh from CSG taking material and transforms into account
  54381. * @param name The name of the Mesh
  54382. * @param material The material of the Mesh
  54383. * @param scene The Scene
  54384. * @param keepSubMeshes Specifies if submeshes should be kept
  54385. * @returns The new Mesh
  54386. */
  54387. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  54388. }
  54389. }
  54390. declare module "babylonjs/Meshes/trailMesh" {
  54391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54392. import { Mesh } from "babylonjs/Meshes/mesh";
  54393. import { Scene } from "babylonjs/scene";
  54394. /**
  54395. * Class used to create a trail following a mesh
  54396. */
  54397. export class TrailMesh extends Mesh {
  54398. private _generator;
  54399. private _autoStart;
  54400. private _running;
  54401. private _diameter;
  54402. private _length;
  54403. private _sectionPolygonPointsCount;
  54404. private _sectionVectors;
  54405. private _sectionNormalVectors;
  54406. private _beforeRenderObserver;
  54407. /**
  54408. * @constructor
  54409. * @param name The value used by scene.getMeshByName() to do a lookup.
  54410. * @param generator The mesh to generate a trail.
  54411. * @param scene The scene to add this mesh to.
  54412. * @param diameter Diameter of trailing mesh. Default is 1.
  54413. * @param length Length of trailing mesh. Default is 60.
  54414. * @param autoStart Automatically start trailing mesh. Default true.
  54415. */
  54416. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54417. /**
  54418. * "TrailMesh"
  54419. * @returns "TrailMesh"
  54420. */
  54421. getClassName(): string;
  54422. private _createMesh;
  54423. /**
  54424. * Start trailing mesh.
  54425. */
  54426. start(): void;
  54427. /**
  54428. * Stop trailing mesh.
  54429. */
  54430. stop(): void;
  54431. /**
  54432. * Update trailing mesh geometry.
  54433. */
  54434. update(): void;
  54435. /**
  54436. * Returns a new TrailMesh object.
  54437. * @param name is a string, the name given to the new mesh
  54438. * @param newGenerator use new generator object for cloned trail mesh
  54439. * @returns a new mesh
  54440. */
  54441. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54442. /**
  54443. * Serializes this trail mesh
  54444. * @param serializationObject object to write serialization to
  54445. */
  54446. serialize(serializationObject: any): void;
  54447. /**
  54448. * Parses a serialized trail mesh
  54449. * @param parsedMesh the serialized mesh
  54450. * @param scene the scene to create the trail mesh in
  54451. * @returns the created trail mesh
  54452. */
  54453. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54454. }
  54455. }
  54456. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  54457. import { Nullable } from "babylonjs/types";
  54458. import { Scene } from "babylonjs/scene";
  54459. import { Vector4, Color4 } from "babylonjs/Maths/math";
  54460. import { Mesh } from "babylonjs/Meshes/mesh";
  54461. /**
  54462. * Class containing static functions to help procedurally build meshes
  54463. */
  54464. export class TiledBoxBuilder {
  54465. /**
  54466. * Creates a box mesh
  54467. * faceTiles sets the pattern, tile size and number of tiles for a face * * 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)
  54468. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54470. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54472. * @param name defines the name of the mesh
  54473. * @param options defines the options used to create the mesh
  54474. * @param scene defines the hosting scene
  54475. * @returns the box mesh
  54476. */
  54477. static CreateTiledBox(name: string, options: {
  54478. pattern?: number;
  54479. width?: number;
  54480. height?: number;
  54481. depth?: number;
  54482. tileSize?: number;
  54483. tileWidth?: number;
  54484. tileHeight?: number;
  54485. alignHorizontal?: number;
  54486. alignVertical?: number;
  54487. faceUV?: Vector4[];
  54488. faceColors?: Color4[];
  54489. sideOrientation?: number;
  54490. updatable?: boolean;
  54491. }, scene?: Nullable<Scene>): Mesh;
  54492. }
  54493. }
  54494. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  54495. import { Vector4 } from "babylonjs/Maths/math";
  54496. import { Mesh } from "babylonjs/Meshes/mesh";
  54497. /**
  54498. * Class containing static functions to help procedurally build meshes
  54499. */
  54500. export class TorusKnotBuilder {
  54501. /**
  54502. * Creates a torus knot mesh
  54503. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54504. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54505. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54506. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54510. * @param name defines the name of the mesh
  54511. * @param options defines the options used to create the mesh
  54512. * @param scene defines the hosting scene
  54513. * @returns the torus knot mesh
  54514. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54515. */
  54516. static CreateTorusKnot(name: string, options: {
  54517. radius?: number;
  54518. tube?: number;
  54519. radialSegments?: number;
  54520. tubularSegments?: number;
  54521. p?: number;
  54522. q?: number;
  54523. updatable?: boolean;
  54524. sideOrientation?: number;
  54525. frontUVs?: Vector4;
  54526. backUVs?: Vector4;
  54527. }, scene: any): Mesh;
  54528. }
  54529. }
  54530. declare module "babylonjs/Meshes/polygonMesh" {
  54531. import { Scene } from "babylonjs/scene";
  54532. import { Vector2, Path2 } from "babylonjs/Maths/math";
  54533. import { Mesh } from "babylonjs/Meshes/mesh";
  54534. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54535. /**
  54536. * Polygon
  54537. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54538. */
  54539. export class Polygon {
  54540. /**
  54541. * Creates a rectangle
  54542. * @param xmin bottom X coord
  54543. * @param ymin bottom Y coord
  54544. * @param xmax top X coord
  54545. * @param ymax top Y coord
  54546. * @returns points that make the resulting rectation
  54547. */
  54548. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54549. /**
  54550. * Creates a circle
  54551. * @param radius radius of circle
  54552. * @param cx scale in x
  54553. * @param cy scale in y
  54554. * @param numberOfSides number of sides that make up the circle
  54555. * @returns points that make the resulting circle
  54556. */
  54557. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54558. /**
  54559. * Creates a polygon from input string
  54560. * @param input Input polygon data
  54561. * @returns the parsed points
  54562. */
  54563. static Parse(input: string): Vector2[];
  54564. /**
  54565. * Starts building a polygon from x and y coordinates
  54566. * @param x x coordinate
  54567. * @param y y coordinate
  54568. * @returns the started path2
  54569. */
  54570. static StartingAt(x: number, y: number): Path2;
  54571. }
  54572. /**
  54573. * Builds a polygon
  54574. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54575. */
  54576. export class PolygonMeshBuilder {
  54577. private _points;
  54578. private _outlinepoints;
  54579. private _holes;
  54580. private _name;
  54581. private _scene;
  54582. private _epoints;
  54583. private _eholes;
  54584. private _addToepoint;
  54585. /**
  54586. * Babylon reference to the earcut plugin.
  54587. */
  54588. bjsEarcut: any;
  54589. /**
  54590. * Creates a PolygonMeshBuilder
  54591. * @param name name of the builder
  54592. * @param contours Path of the polygon
  54593. * @param scene scene to add to when creating the mesh
  54594. * @param earcutInjection can be used to inject your own earcut reference
  54595. */
  54596. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54597. /**
  54598. * Adds a whole within the polygon
  54599. * @param hole Array of points defining the hole
  54600. * @returns this
  54601. */
  54602. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54603. /**
  54604. * Creates the polygon
  54605. * @param updatable If the mesh should be updatable
  54606. * @param depth The depth of the mesh created
  54607. * @returns the created mesh
  54608. */
  54609. build(updatable?: boolean, depth?: number): Mesh;
  54610. /**
  54611. * Creates the polygon
  54612. * @param depth The depth of the mesh created
  54613. * @returns the created VertexData
  54614. */
  54615. buildVertexData(depth?: number): VertexData;
  54616. /**
  54617. * Adds a side to the polygon
  54618. * @param positions points that make the polygon
  54619. * @param normals normals of the polygon
  54620. * @param uvs uvs of the polygon
  54621. * @param indices indices of the polygon
  54622. * @param bounds bounds of the polygon
  54623. * @param points points of the polygon
  54624. * @param depth depth of the polygon
  54625. * @param flip flip of the polygon
  54626. */
  54627. private addSide;
  54628. }
  54629. }
  54630. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  54631. import { Scene } from "babylonjs/scene";
  54632. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  54633. import { Mesh } from "babylonjs/Meshes/mesh";
  54634. import { Nullable } from "babylonjs/types";
  54635. /**
  54636. * Class containing static functions to help procedurally build meshes
  54637. */
  54638. export class PolygonBuilder {
  54639. /**
  54640. * Creates a polygon mesh
  54641. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54642. * * 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
  54643. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54645. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  54646. * * Remember you can only change the shape positions, not their number when updating a polygon
  54647. * @param name defines the name of the mesh
  54648. * @param options defines the options used to create the mesh
  54649. * @param scene defines the hosting scene
  54650. * @param earcutInjection can be used to inject your own earcut reference
  54651. * @returns the polygon mesh
  54652. */
  54653. static CreatePolygon(name: string, options: {
  54654. shape: Vector3[];
  54655. holes?: Vector3[][];
  54656. depth?: number;
  54657. faceUV?: Vector4[];
  54658. faceColors?: Color4[];
  54659. updatable?: boolean;
  54660. sideOrientation?: number;
  54661. frontUVs?: Vector4;
  54662. backUVs?: Vector4;
  54663. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54664. /**
  54665. * Creates an extruded polygon mesh, with depth in the Y direction.
  54666. * * 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)
  54667. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54668. * @param name defines the name of the mesh
  54669. * @param options defines the options used to create the mesh
  54670. * @param scene defines the hosting scene
  54671. * @param earcutInjection can be used to inject your own earcut reference
  54672. * @returns the polygon mesh
  54673. */
  54674. static ExtrudePolygon(name: string, options: {
  54675. shape: Vector3[];
  54676. holes?: Vector3[][];
  54677. depth?: number;
  54678. faceUV?: Vector4[];
  54679. faceColors?: Color4[];
  54680. updatable?: boolean;
  54681. sideOrientation?: number;
  54682. frontUVs?: Vector4;
  54683. backUVs?: Vector4;
  54684. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54685. }
  54686. }
  54687. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  54688. import { Scene } from "babylonjs/scene";
  54689. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  54690. import { Mesh } from "babylonjs/Meshes/mesh";
  54691. import { Nullable } from "babylonjs/types";
  54692. /**
  54693. * Class containing static functions to help procedurally build meshes
  54694. */
  54695. export class LatheBuilder {
  54696. /**
  54697. * Creates lathe mesh.
  54698. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54699. * * 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
  54700. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54701. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54702. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54703. * * 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
  54704. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54705. * * 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
  54706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54708. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54710. * @param name defines the name of the mesh
  54711. * @param options defines the options used to create the mesh
  54712. * @param scene defines the hosting scene
  54713. * @returns the lathe mesh
  54714. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54715. */
  54716. static CreateLathe(name: string, options: {
  54717. shape: Vector3[];
  54718. radius?: number;
  54719. tessellation?: number;
  54720. clip?: number;
  54721. arc?: number;
  54722. closed?: boolean;
  54723. updatable?: boolean;
  54724. sideOrientation?: number;
  54725. frontUVs?: Vector4;
  54726. backUVs?: Vector4;
  54727. cap?: number;
  54728. invertUV?: boolean;
  54729. }, scene?: Nullable<Scene>): Mesh;
  54730. }
  54731. }
  54732. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  54733. import { Nullable } from "babylonjs/types";
  54734. import { Scene } from "babylonjs/scene";
  54735. import { Vector4 } from "babylonjs/Maths/math";
  54736. import { Mesh } from "babylonjs/Meshes/mesh";
  54737. /**
  54738. * Class containing static functions to help procedurally build meshes
  54739. */
  54740. export class TiledPlaneBuilder {
  54741. /**
  54742. * Creates a tiled plane mesh
  54743. * * The parameter `pattern` will, depending on value, do nothing or
  54744. * * * flip (reflect about central vertical) alternate tiles across and up
  54745. * * * flip every tile on alternate rows
  54746. * * * rotate (180 degs) alternate tiles across and up
  54747. * * * rotate every tile on alternate rows
  54748. * * * flip and rotate alternate tiles across and up
  54749. * * * flip and rotate every tile on alternate rows
  54750. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  54751. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  54752. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54753. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54754. * * 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)
  54755. * * 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)
  54756. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54757. * @param name defines the name of the mesh
  54758. * @param options defines the options used to create the mesh
  54759. * @param scene defines the hosting scene
  54760. * @returns the box mesh
  54761. */
  54762. static CreateTiledPlane(name: string, options: {
  54763. pattern?: number;
  54764. tileSize?: number;
  54765. tileWidth?: number;
  54766. tileHeight?: number;
  54767. size?: number;
  54768. width?: number;
  54769. height?: number;
  54770. alignHorizontal?: number;
  54771. alignVertical?: number;
  54772. sideOrientation?: number;
  54773. frontUVs?: Vector4;
  54774. backUVs?: Vector4;
  54775. updatable?: boolean;
  54776. }, scene?: Nullable<Scene>): Mesh;
  54777. }
  54778. }
  54779. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  54780. import { Nullable } from "babylonjs/types";
  54781. import { Scene } from "babylonjs/scene";
  54782. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  54783. import { Mesh } from "babylonjs/Meshes/mesh";
  54784. /**
  54785. * Class containing static functions to help procedurally build meshes
  54786. */
  54787. export class TubeBuilder {
  54788. /**
  54789. * Creates a tube mesh.
  54790. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54791. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54792. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54793. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54794. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54795. * * 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)
  54796. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54797. * * 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
  54798. * * 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
  54799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54800. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54801. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54803. * @param name defines the name of the mesh
  54804. * @param options defines the options used to create the mesh
  54805. * @param scene defines the hosting scene
  54806. * @returns the tube mesh
  54807. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54808. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54809. */
  54810. static CreateTube(name: string, options: {
  54811. path: Vector3[];
  54812. radius?: number;
  54813. tessellation?: number;
  54814. radiusFunction?: {
  54815. (i: number, distance: number): number;
  54816. };
  54817. cap?: number;
  54818. arc?: number;
  54819. updatable?: boolean;
  54820. sideOrientation?: number;
  54821. frontUVs?: Vector4;
  54822. backUVs?: Vector4;
  54823. instance?: Mesh;
  54824. invertUV?: boolean;
  54825. }, scene?: Nullable<Scene>): Mesh;
  54826. }
  54827. }
  54828. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  54829. import { Scene } from "babylonjs/scene";
  54830. import { Vector4 } from "babylonjs/Maths/math";
  54831. import { Mesh } from "babylonjs/Meshes/mesh";
  54832. import { Nullable } from "babylonjs/types";
  54833. /**
  54834. * Class containing static functions to help procedurally build meshes
  54835. */
  54836. export class IcoSphereBuilder {
  54837. /**
  54838. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54839. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54840. * * 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`)
  54841. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54842. * * 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
  54843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54846. * @param name defines the name of the mesh
  54847. * @param options defines the options used to create the mesh
  54848. * @param scene defines the hosting scene
  54849. * @returns the icosahedron mesh
  54850. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54851. */
  54852. static CreateIcoSphere(name: string, options: {
  54853. radius?: number;
  54854. radiusX?: number;
  54855. radiusY?: number;
  54856. radiusZ?: number;
  54857. flat?: boolean;
  54858. subdivisions?: number;
  54859. sideOrientation?: number;
  54860. frontUVs?: Vector4;
  54861. backUVs?: Vector4;
  54862. updatable?: boolean;
  54863. }, scene?: Nullable<Scene>): Mesh;
  54864. }
  54865. }
  54866. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  54867. import { Vector3 } from "babylonjs/Maths/math";
  54868. import { Mesh } from "babylonjs/Meshes/mesh";
  54869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54870. /**
  54871. * Class containing static functions to help procedurally build meshes
  54872. */
  54873. export class DecalBuilder {
  54874. /**
  54875. * Creates a decal mesh.
  54876. * 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
  54877. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54878. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54879. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54880. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54881. * @param name defines the name of the mesh
  54882. * @param sourceMesh defines the mesh where the decal must be applied
  54883. * @param options defines the options used to create the mesh
  54884. * @param scene defines the hosting scene
  54885. * @returns the decal mesh
  54886. * @see https://doc.babylonjs.com/how_to/decals
  54887. */
  54888. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54889. position?: Vector3;
  54890. normal?: Vector3;
  54891. size?: Vector3;
  54892. angle?: number;
  54893. }): Mesh;
  54894. }
  54895. }
  54896. declare module "babylonjs/Meshes/meshBuilder" {
  54897. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  54898. import { Nullable } from "babylonjs/types";
  54899. import { Scene } from "babylonjs/scene";
  54900. import { Mesh } from "babylonjs/Meshes/mesh";
  54901. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54902. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  54903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54904. /**
  54905. * Class containing static functions to help procedurally build meshes
  54906. */
  54907. export class MeshBuilder {
  54908. /**
  54909. * Creates a box mesh
  54910. * * The parameter `size` sets the size (float) of each box side (default 1)
  54911. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54912. * * 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)
  54913. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54917. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54918. * @param name defines the name of the mesh
  54919. * @param options defines the options used to create the mesh
  54920. * @param scene defines the hosting scene
  54921. * @returns the box mesh
  54922. */
  54923. static CreateBox(name: string, options: {
  54924. size?: number;
  54925. width?: number;
  54926. height?: number;
  54927. depth?: number;
  54928. faceUV?: Vector4[];
  54929. faceColors?: Color4[];
  54930. sideOrientation?: number;
  54931. frontUVs?: Vector4;
  54932. backUVs?: Vector4;
  54933. updatable?: boolean;
  54934. }, scene?: Nullable<Scene>): Mesh;
  54935. /**
  54936. * Creates a tiled box mesh
  54937. * * faceTiles sets the pattern, tile size and number of tiles for a face
  54938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54939. * @param name defines the name of the mesh
  54940. * @param options defines the options used to create the mesh
  54941. * @param scene defines the hosting scene
  54942. * @returns the tiled box mesh
  54943. */
  54944. static CreateTiledBox(name: string, options: {
  54945. pattern?: number;
  54946. size?: number;
  54947. width?: number;
  54948. height?: number;
  54949. depth: number;
  54950. tileSize?: number;
  54951. tileWidth?: number;
  54952. tileHeight?: number;
  54953. faceUV?: Vector4[];
  54954. faceColors?: Color4[];
  54955. alignHorizontal?: number;
  54956. alignVertical?: number;
  54957. sideOrientation?: number;
  54958. updatable?: boolean;
  54959. }, scene?: Nullable<Scene>): Mesh;
  54960. /**
  54961. * Creates a sphere mesh
  54962. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54963. * * 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`)
  54964. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54965. * * 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
  54966. * * 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)
  54967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54968. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54970. * @param name defines the name of the mesh
  54971. * @param options defines the options used to create the mesh
  54972. * @param scene defines the hosting scene
  54973. * @returns the sphere mesh
  54974. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54975. */
  54976. static CreateSphere(name: string, options: {
  54977. segments?: number;
  54978. diameter?: number;
  54979. diameterX?: number;
  54980. diameterY?: number;
  54981. diameterZ?: number;
  54982. arc?: number;
  54983. slice?: number;
  54984. sideOrientation?: number;
  54985. frontUVs?: Vector4;
  54986. backUVs?: Vector4;
  54987. updatable?: boolean;
  54988. }, scene?: Nullable<Scene>): Mesh;
  54989. /**
  54990. * Creates a plane polygonal mesh. By default, this is a disc
  54991. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  54992. * * 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
  54993. * * 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
  54994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54995. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54997. * @param name defines the name of the mesh
  54998. * @param options defines the options used to create the mesh
  54999. * @param scene defines the hosting scene
  55000. * @returns the plane polygonal mesh
  55001. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55002. */
  55003. static CreateDisc(name: string, options: {
  55004. radius?: number;
  55005. tessellation?: number;
  55006. arc?: number;
  55007. updatable?: boolean;
  55008. sideOrientation?: number;
  55009. frontUVs?: Vector4;
  55010. backUVs?: Vector4;
  55011. }, scene?: Nullable<Scene>): Mesh;
  55012. /**
  55013. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55014. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55015. * * 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`)
  55016. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55017. * * 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
  55018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55021. * @param name defines the name of the mesh
  55022. * @param options defines the options used to create the mesh
  55023. * @param scene defines the hosting scene
  55024. * @returns the icosahedron mesh
  55025. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55026. */
  55027. static CreateIcoSphere(name: string, options: {
  55028. radius?: number;
  55029. radiusX?: number;
  55030. radiusY?: number;
  55031. radiusZ?: number;
  55032. flat?: boolean;
  55033. subdivisions?: number;
  55034. sideOrientation?: number;
  55035. frontUVs?: Vector4;
  55036. backUVs?: Vector4;
  55037. updatable?: boolean;
  55038. }, scene?: Nullable<Scene>): Mesh;
  55039. /**
  55040. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55041. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55042. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55043. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55044. * * 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
  55045. * * 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
  55046. * * 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
  55047. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55048. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55049. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55050. * * 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
  55051. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55052. * * 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
  55053. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55055. * @param name defines the name of the mesh
  55056. * @param options defines the options used to create the mesh
  55057. * @param scene defines the hosting scene
  55058. * @returns the ribbon mesh
  55059. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55060. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55061. */
  55062. static CreateRibbon(name: string, options: {
  55063. pathArray: Vector3[][];
  55064. closeArray?: boolean;
  55065. closePath?: boolean;
  55066. offset?: number;
  55067. updatable?: boolean;
  55068. sideOrientation?: number;
  55069. frontUVs?: Vector4;
  55070. backUVs?: Vector4;
  55071. instance?: Mesh;
  55072. invertUV?: boolean;
  55073. uvs?: Vector2[];
  55074. colors?: Color4[];
  55075. }, scene?: Nullable<Scene>): Mesh;
  55076. /**
  55077. * Creates a cylinder or a cone mesh
  55078. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55079. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55080. * * 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.
  55081. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55082. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55083. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55084. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55085. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  55086. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55087. * * 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).
  55088. * * 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
  55089. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55090. * * 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
  55091. * * 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.
  55092. * * If `enclose` is false, a ring surface is one element.
  55093. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55094. * * 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
  55095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55098. * @param name defines the name of the mesh
  55099. * @param options defines the options used to create the mesh
  55100. * @param scene defines the hosting scene
  55101. * @returns the cylinder mesh
  55102. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55103. */
  55104. static CreateCylinder(name: string, options: {
  55105. height?: number;
  55106. diameterTop?: number;
  55107. diameterBottom?: number;
  55108. diameter?: number;
  55109. tessellation?: number;
  55110. subdivisions?: number;
  55111. arc?: number;
  55112. faceColors?: Color4[];
  55113. faceUV?: Vector4[];
  55114. updatable?: boolean;
  55115. hasRings?: boolean;
  55116. enclose?: boolean;
  55117. cap?: number;
  55118. sideOrientation?: number;
  55119. frontUVs?: Vector4;
  55120. backUVs?: Vector4;
  55121. }, scene?: Nullable<Scene>): Mesh;
  55122. /**
  55123. * Creates a torus mesh
  55124. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55125. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55126. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55130. * @param name defines the name of the mesh
  55131. * @param options defines the options used to create the mesh
  55132. * @param scene defines the hosting scene
  55133. * @returns the torus mesh
  55134. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55135. */
  55136. static CreateTorus(name: string, options: {
  55137. diameter?: number;
  55138. thickness?: number;
  55139. tessellation?: number;
  55140. updatable?: boolean;
  55141. sideOrientation?: number;
  55142. frontUVs?: Vector4;
  55143. backUVs?: Vector4;
  55144. }, scene?: Nullable<Scene>): Mesh;
  55145. /**
  55146. * Creates a torus knot mesh
  55147. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55148. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55149. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55150. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55154. * @param name defines the name of the mesh
  55155. * @param options defines the options used to create the mesh
  55156. * @param scene defines the hosting scene
  55157. * @returns the torus knot mesh
  55158. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55159. */
  55160. static CreateTorusKnot(name: string, options: {
  55161. radius?: number;
  55162. tube?: number;
  55163. radialSegments?: number;
  55164. tubularSegments?: number;
  55165. p?: number;
  55166. q?: number;
  55167. updatable?: boolean;
  55168. sideOrientation?: number;
  55169. frontUVs?: Vector4;
  55170. backUVs?: Vector4;
  55171. }, scene?: Nullable<Scene>): Mesh;
  55172. /**
  55173. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55174. * * 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
  55175. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55176. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55177. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55178. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55179. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55180. * * 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
  55181. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55183. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55184. * @param name defines the name of the new line system
  55185. * @param options defines the options used to create the line system
  55186. * @param scene defines the hosting scene
  55187. * @returns a new line system mesh
  55188. */
  55189. static CreateLineSystem(name: string, options: {
  55190. lines: Vector3[][];
  55191. updatable?: boolean;
  55192. instance?: Nullable<LinesMesh>;
  55193. colors?: Nullable<Color4[][]>;
  55194. useVertexAlpha?: boolean;
  55195. }, scene: Nullable<Scene>): LinesMesh;
  55196. /**
  55197. * Creates a line mesh
  55198. * 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
  55199. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55200. * * The parameter `points` is an array successive Vector3
  55201. * * 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
  55202. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55203. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55204. * * When updating an instance, remember that only point positions can change, not the number of points
  55205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55206. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55207. * @param name defines the name of the new line system
  55208. * @param options defines the options used to create the line system
  55209. * @param scene defines the hosting scene
  55210. * @returns a new line mesh
  55211. */
  55212. static CreateLines(name: string, options: {
  55213. points: Vector3[];
  55214. updatable?: boolean;
  55215. instance?: Nullable<LinesMesh>;
  55216. colors?: Color4[];
  55217. useVertexAlpha?: boolean;
  55218. }, scene?: Nullable<Scene>): LinesMesh;
  55219. /**
  55220. * Creates a dashed line mesh
  55221. * * 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
  55222. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55223. * * The parameter `points` is an array successive Vector3
  55224. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55225. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55226. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55227. * * 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
  55228. * * When updating an instance, remember that only point positions can change, not the number of points
  55229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55230. * @param name defines the name of the mesh
  55231. * @param options defines the options used to create the mesh
  55232. * @param scene defines the hosting scene
  55233. * @returns the dashed line mesh
  55234. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55235. */
  55236. static CreateDashedLines(name: string, options: {
  55237. points: Vector3[];
  55238. dashSize?: number;
  55239. gapSize?: number;
  55240. dashNb?: number;
  55241. updatable?: boolean;
  55242. instance?: LinesMesh;
  55243. }, scene?: Nullable<Scene>): LinesMesh;
  55244. /**
  55245. * 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.
  55246. * * 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.
  55247. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55248. * * 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.
  55249. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55250. * * 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
  55251. * * 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
  55252. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55255. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55257. * @param name defines the name of the mesh
  55258. * @param options defines the options used to create the mesh
  55259. * @param scene defines the hosting scene
  55260. * @returns the extruded shape mesh
  55261. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55263. */
  55264. static ExtrudeShape(name: string, options: {
  55265. shape: Vector3[];
  55266. path: Vector3[];
  55267. scale?: number;
  55268. rotation?: number;
  55269. cap?: number;
  55270. updatable?: boolean;
  55271. sideOrientation?: number;
  55272. frontUVs?: Vector4;
  55273. backUVs?: Vector4;
  55274. instance?: Mesh;
  55275. invertUV?: boolean;
  55276. }, scene?: Nullable<Scene>): Mesh;
  55277. /**
  55278. * Creates an custom extruded shape mesh.
  55279. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55280. * * 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.
  55281. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55282. * * 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
  55283. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55284. * * 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
  55285. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55286. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55287. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55288. * * 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
  55289. * * 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
  55290. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55292. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55293. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55295. * @param name defines the name of the mesh
  55296. * @param options defines the options used to create the mesh
  55297. * @param scene defines the hosting scene
  55298. * @returns the custom extruded shape mesh
  55299. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55300. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55302. */
  55303. static ExtrudeShapeCustom(name: string, options: {
  55304. shape: Vector3[];
  55305. path: Vector3[];
  55306. scaleFunction?: any;
  55307. rotationFunction?: any;
  55308. ribbonCloseArray?: boolean;
  55309. ribbonClosePath?: boolean;
  55310. cap?: number;
  55311. updatable?: boolean;
  55312. sideOrientation?: number;
  55313. frontUVs?: Vector4;
  55314. backUVs?: Vector4;
  55315. instance?: Mesh;
  55316. invertUV?: boolean;
  55317. }, scene?: Nullable<Scene>): Mesh;
  55318. /**
  55319. * Creates lathe mesh.
  55320. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55321. * * 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
  55322. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55323. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55324. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55325. * * 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
  55326. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55327. * * 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
  55328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55330. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55332. * @param name defines the name of the mesh
  55333. * @param options defines the options used to create the mesh
  55334. * @param scene defines the hosting scene
  55335. * @returns the lathe mesh
  55336. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55337. */
  55338. static CreateLathe(name: string, options: {
  55339. shape: Vector3[];
  55340. radius?: number;
  55341. tessellation?: number;
  55342. clip?: number;
  55343. arc?: number;
  55344. closed?: boolean;
  55345. updatable?: boolean;
  55346. sideOrientation?: number;
  55347. frontUVs?: Vector4;
  55348. backUVs?: Vector4;
  55349. cap?: number;
  55350. invertUV?: boolean;
  55351. }, scene?: Nullable<Scene>): Mesh;
  55352. /**
  55353. * Creates a tiled plane mesh
  55354. * * You can set a limited pattern arrangement with the tiles
  55355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55356. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55358. * @param name defines the name of the mesh
  55359. * @param options defines the options used to create the mesh
  55360. * @param scene defines the hosting scene
  55361. * @returns the plane mesh
  55362. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55363. */
  55364. static CreateTiledPlane(name: string, options: {
  55365. pattern?: number;
  55366. tileSize?: number;
  55367. tileWidth?: number;
  55368. tileHeight?: number;
  55369. size?: number;
  55370. width?: number;
  55371. height?: number;
  55372. alignHorizontal?: number;
  55373. alignVertical?: number;
  55374. sideOrientation?: number;
  55375. frontUVs?: Vector4;
  55376. backUVs?: Vector4;
  55377. updatable?: boolean;
  55378. }, scene?: Nullable<Scene>): Mesh;
  55379. /**
  55380. * Creates a plane mesh
  55381. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55382. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55383. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55385. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55387. * @param name defines the name of the mesh
  55388. * @param options defines the options used to create the mesh
  55389. * @param scene defines the hosting scene
  55390. * @returns the plane mesh
  55391. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55392. */
  55393. static CreatePlane(name: string, options: {
  55394. size?: number;
  55395. width?: number;
  55396. height?: number;
  55397. sideOrientation?: number;
  55398. frontUVs?: Vector4;
  55399. backUVs?: Vector4;
  55400. updatable?: boolean;
  55401. sourcePlane?: Plane;
  55402. }, scene?: Nullable<Scene>): Mesh;
  55403. /**
  55404. * Creates a ground mesh
  55405. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55406. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55408. * @param name defines the name of the mesh
  55409. * @param options defines the options used to create the mesh
  55410. * @param scene defines the hosting scene
  55411. * @returns the ground mesh
  55412. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55413. */
  55414. static CreateGround(name: string, options: {
  55415. width?: number;
  55416. height?: number;
  55417. subdivisions?: number;
  55418. subdivisionsX?: number;
  55419. subdivisionsY?: number;
  55420. updatable?: boolean;
  55421. }, scene?: Nullable<Scene>): Mesh;
  55422. /**
  55423. * Creates a tiled ground mesh
  55424. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55425. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55426. * * 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
  55427. * * 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
  55428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55429. * @param name defines the name of the mesh
  55430. * @param options defines the options used to create the mesh
  55431. * @param scene defines the hosting scene
  55432. * @returns the tiled ground mesh
  55433. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55434. */
  55435. static CreateTiledGround(name: string, options: {
  55436. xmin: number;
  55437. zmin: number;
  55438. xmax: number;
  55439. zmax: number;
  55440. subdivisions?: {
  55441. w: number;
  55442. h: number;
  55443. };
  55444. precision?: {
  55445. w: number;
  55446. h: number;
  55447. };
  55448. updatable?: boolean;
  55449. }, scene?: Nullable<Scene>): Mesh;
  55450. /**
  55451. * Creates a ground mesh from a height map
  55452. * * The parameter `url` sets the URL of the height map image resource.
  55453. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55454. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55455. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55456. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55457. * * 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.
  55458. * * 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).
  55459. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55461. * @param name defines the name of the mesh
  55462. * @param url defines the url to the height map
  55463. * @param options defines the options used to create the mesh
  55464. * @param scene defines the hosting scene
  55465. * @returns the ground mesh
  55466. * @see https://doc.babylonjs.com/babylon101/height_map
  55467. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55468. */
  55469. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55470. width?: number;
  55471. height?: number;
  55472. subdivisions?: number;
  55473. minHeight?: number;
  55474. maxHeight?: number;
  55475. colorFilter?: Color3;
  55476. alphaFilter?: number;
  55477. updatable?: boolean;
  55478. onReady?: (mesh: GroundMesh) => void;
  55479. }, scene?: Nullable<Scene>): GroundMesh;
  55480. /**
  55481. * Creates a polygon mesh
  55482. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55483. * * 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
  55484. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55487. * * Remember you can only change the shape positions, not their number when updating a polygon
  55488. * @param name defines the name of the mesh
  55489. * @param options defines the options used to create the mesh
  55490. * @param scene defines the hosting scene
  55491. * @param earcutInjection can be used to inject your own earcut reference
  55492. * @returns the polygon mesh
  55493. */
  55494. static CreatePolygon(name: string, options: {
  55495. shape: Vector3[];
  55496. holes?: Vector3[][];
  55497. depth?: number;
  55498. faceUV?: Vector4[];
  55499. faceColors?: Color4[];
  55500. updatable?: boolean;
  55501. sideOrientation?: number;
  55502. frontUVs?: Vector4;
  55503. backUVs?: Vector4;
  55504. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55505. /**
  55506. * Creates an extruded polygon mesh, with depth in the Y direction.
  55507. * * 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)
  55508. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55509. * @param name defines the name of the mesh
  55510. * @param options defines the options used to create the mesh
  55511. * @param scene defines the hosting scene
  55512. * @param earcutInjection can be used to inject your own earcut reference
  55513. * @returns the polygon mesh
  55514. */
  55515. static ExtrudePolygon(name: string, options: {
  55516. shape: Vector3[];
  55517. holes?: Vector3[][];
  55518. depth?: number;
  55519. faceUV?: Vector4[];
  55520. faceColors?: Color4[];
  55521. updatable?: boolean;
  55522. sideOrientation?: number;
  55523. frontUVs?: Vector4;
  55524. backUVs?: Vector4;
  55525. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55526. /**
  55527. * Creates a tube mesh.
  55528. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55529. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55530. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55531. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55532. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55533. * * 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)
  55534. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55535. * * 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
  55536. * * 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
  55537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55539. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55541. * @param name defines the name of the mesh
  55542. * @param options defines the options used to create the mesh
  55543. * @param scene defines the hosting scene
  55544. * @returns the tube mesh
  55545. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55546. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55547. */
  55548. static CreateTube(name: string, options: {
  55549. path: Vector3[];
  55550. radius?: number;
  55551. tessellation?: number;
  55552. radiusFunction?: {
  55553. (i: number, distance: number): number;
  55554. };
  55555. cap?: number;
  55556. arc?: number;
  55557. updatable?: boolean;
  55558. sideOrientation?: number;
  55559. frontUVs?: Vector4;
  55560. backUVs?: Vector4;
  55561. instance?: Mesh;
  55562. invertUV?: boolean;
  55563. }, scene?: Nullable<Scene>): Mesh;
  55564. /**
  55565. * Creates a polyhedron mesh
  55566. * * 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
  55567. * * The parameter `size` (positive float, default 1) sets the polygon size
  55568. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55569. * * 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`
  55570. * * 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
  55571. * * 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)`)
  55572. * * 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
  55573. * * 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
  55574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55577. * @param name defines the name of the mesh
  55578. * @param options defines the options used to create the mesh
  55579. * @param scene defines the hosting scene
  55580. * @returns the polyhedron mesh
  55581. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55582. */
  55583. static CreatePolyhedron(name: string, options: {
  55584. type?: number;
  55585. size?: number;
  55586. sizeX?: number;
  55587. sizeY?: number;
  55588. sizeZ?: number;
  55589. custom?: any;
  55590. faceUV?: Vector4[];
  55591. faceColors?: Color4[];
  55592. flat?: boolean;
  55593. updatable?: boolean;
  55594. sideOrientation?: number;
  55595. frontUVs?: Vector4;
  55596. backUVs?: Vector4;
  55597. }, scene?: Nullable<Scene>): Mesh;
  55598. /**
  55599. * Creates a decal mesh.
  55600. * 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
  55601. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55602. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55603. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55604. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55605. * @param name defines the name of the mesh
  55606. * @param sourceMesh defines the mesh where the decal must be applied
  55607. * @param options defines the options used to create the mesh
  55608. * @param scene defines the hosting scene
  55609. * @returns the decal mesh
  55610. * @see https://doc.babylonjs.com/how_to/decals
  55611. */
  55612. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55613. position?: Vector3;
  55614. normal?: Vector3;
  55615. size?: Vector3;
  55616. angle?: number;
  55617. }): Mesh;
  55618. }
  55619. }
  55620. declare module "babylonjs/Meshes/meshSimplification" {
  55621. import { Mesh } from "babylonjs/Meshes/mesh";
  55622. /**
  55623. * A simplifier interface for future simplification implementations
  55624. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55625. */
  55626. export interface ISimplifier {
  55627. /**
  55628. * Simplification of a given mesh according to the given settings.
  55629. * Since this requires computation, it is assumed that the function runs async.
  55630. * @param settings The settings of the simplification, including quality and distance
  55631. * @param successCallback A callback that will be called after the mesh was simplified.
  55632. * @param errorCallback in case of an error, this callback will be called. optional.
  55633. */
  55634. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55635. }
  55636. /**
  55637. * Expected simplification settings.
  55638. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55639. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55640. */
  55641. export interface ISimplificationSettings {
  55642. /**
  55643. * Gets or sets the expected quality
  55644. */
  55645. quality: number;
  55646. /**
  55647. * Gets or sets the distance when this optimized version should be used
  55648. */
  55649. distance: number;
  55650. /**
  55651. * Gets an already optimized mesh
  55652. */
  55653. optimizeMesh?: boolean;
  55654. }
  55655. /**
  55656. * Class used to specify simplification options
  55657. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55658. */
  55659. export class SimplificationSettings implements ISimplificationSettings {
  55660. /** expected quality */
  55661. quality: number;
  55662. /** distance when this optimized version should be used */
  55663. distance: number;
  55664. /** already optimized mesh */
  55665. optimizeMesh?: boolean | undefined;
  55666. /**
  55667. * Creates a SimplificationSettings
  55668. * @param quality expected quality
  55669. * @param distance distance when this optimized version should be used
  55670. * @param optimizeMesh already optimized mesh
  55671. */
  55672. constructor(
  55673. /** expected quality */
  55674. quality: number,
  55675. /** distance when this optimized version should be used */
  55676. distance: number,
  55677. /** already optimized mesh */
  55678. optimizeMesh?: boolean | undefined);
  55679. }
  55680. /**
  55681. * Interface used to define a simplification task
  55682. */
  55683. export interface ISimplificationTask {
  55684. /**
  55685. * Array of settings
  55686. */
  55687. settings: Array<ISimplificationSettings>;
  55688. /**
  55689. * Simplification type
  55690. */
  55691. simplificationType: SimplificationType;
  55692. /**
  55693. * Mesh to simplify
  55694. */
  55695. mesh: Mesh;
  55696. /**
  55697. * Callback called on success
  55698. */
  55699. successCallback?: () => void;
  55700. /**
  55701. * Defines if parallel processing can be used
  55702. */
  55703. parallelProcessing: boolean;
  55704. }
  55705. /**
  55706. * Queue used to order the simplification tasks
  55707. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55708. */
  55709. export class SimplificationQueue {
  55710. private _simplificationArray;
  55711. /**
  55712. * Gets a boolean indicating that the process is still running
  55713. */
  55714. running: boolean;
  55715. /**
  55716. * Creates a new queue
  55717. */
  55718. constructor();
  55719. /**
  55720. * Adds a new simplification task
  55721. * @param task defines a task to add
  55722. */
  55723. addTask(task: ISimplificationTask): void;
  55724. /**
  55725. * Execute next task
  55726. */
  55727. executeNext(): void;
  55728. /**
  55729. * Execute a simplification task
  55730. * @param task defines the task to run
  55731. */
  55732. runSimplification(task: ISimplificationTask): void;
  55733. private getSimplifier;
  55734. }
  55735. /**
  55736. * The implemented types of simplification
  55737. * At the moment only Quadratic Error Decimation is implemented
  55738. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55739. */
  55740. export enum SimplificationType {
  55741. /** Quadratic error decimation */
  55742. QUADRATIC = 0
  55743. }
  55744. }
  55745. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  55746. import { Scene } from "babylonjs/scene";
  55747. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  55748. import { ISceneComponent } from "babylonjs/sceneComponent";
  55749. module "babylonjs/scene" {
  55750. interface Scene {
  55751. /** @hidden (Backing field) */
  55752. _simplificationQueue: SimplificationQueue;
  55753. /**
  55754. * Gets or sets the simplification queue attached to the scene
  55755. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55756. */
  55757. simplificationQueue: SimplificationQueue;
  55758. }
  55759. }
  55760. module "babylonjs/Meshes/mesh" {
  55761. interface Mesh {
  55762. /**
  55763. * Simplify the mesh according to the given array of settings.
  55764. * Function will return immediately and will simplify async
  55765. * @param settings a collection of simplification settings
  55766. * @param parallelProcessing should all levels calculate parallel or one after the other
  55767. * @param simplificationType the type of simplification to run
  55768. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  55769. * @returns the current mesh
  55770. */
  55771. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  55772. }
  55773. }
  55774. /**
  55775. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  55776. * created in a scene
  55777. */
  55778. export class SimplicationQueueSceneComponent implements ISceneComponent {
  55779. /**
  55780. * The component name helpfull to identify the component in the list of scene components.
  55781. */
  55782. readonly name: string;
  55783. /**
  55784. * The scene the component belongs to.
  55785. */
  55786. scene: Scene;
  55787. /**
  55788. * Creates a new instance of the component for the given scene
  55789. * @param scene Defines the scene to register the component in
  55790. */
  55791. constructor(scene: Scene);
  55792. /**
  55793. * Registers the component in a given scene
  55794. */
  55795. register(): void;
  55796. /**
  55797. * Rebuilds the elements related to this component in case of
  55798. * context lost for instance.
  55799. */
  55800. rebuild(): void;
  55801. /**
  55802. * Disposes the component and the associated ressources
  55803. */
  55804. dispose(): void;
  55805. private _beforeCameraUpdate;
  55806. }
  55807. }
  55808. declare module "babylonjs/Meshes/Builders/index" {
  55809. export * from "babylonjs/Meshes/Builders/boxBuilder";
  55810. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  55811. export * from "babylonjs/Meshes/Builders/discBuilder";
  55812. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  55813. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  55814. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  55815. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  55816. export * from "babylonjs/Meshes/Builders/torusBuilder";
  55817. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  55818. export * from "babylonjs/Meshes/Builders/linesBuilder";
  55819. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  55820. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  55821. export * from "babylonjs/Meshes/Builders/latheBuilder";
  55822. export * from "babylonjs/Meshes/Builders/planeBuilder";
  55823. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  55824. export * from "babylonjs/Meshes/Builders/groundBuilder";
  55825. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  55826. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  55827. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  55828. export * from "babylonjs/Meshes/Builders/decalBuilder";
  55829. }
  55830. declare module "babylonjs/Meshes/index" {
  55831. export * from "babylonjs/Meshes/abstractMesh";
  55832. export * from "babylonjs/Meshes/buffer";
  55833. export * from "babylonjs/Meshes/Compression/index";
  55834. export * from "babylonjs/Meshes/csg";
  55835. export * from "babylonjs/Meshes/geometry";
  55836. export * from "babylonjs/Meshes/groundMesh";
  55837. export * from "babylonjs/Meshes/trailMesh";
  55838. export * from "babylonjs/Meshes/instancedMesh";
  55839. export * from "babylonjs/Meshes/linesMesh";
  55840. export * from "babylonjs/Meshes/mesh";
  55841. export * from "babylonjs/Meshes/mesh.vertexData";
  55842. export * from "babylonjs/Meshes/meshBuilder";
  55843. export * from "babylonjs/Meshes/meshSimplification";
  55844. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  55845. export * from "babylonjs/Meshes/polygonMesh";
  55846. export * from "babylonjs/Meshes/subMesh";
  55847. export * from "babylonjs/Meshes/meshLODLevel";
  55848. export * from "babylonjs/Meshes/transformNode";
  55849. export * from "babylonjs/Meshes/Builders/index";
  55850. export * from "babylonjs/Meshes/dataBuffer";
  55851. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  55852. }
  55853. declare module "babylonjs/Morph/index" {
  55854. export * from "babylonjs/Morph/morphTarget";
  55855. export * from "babylonjs/Morph/morphTargetManager";
  55856. }
  55857. declare module "babylonjs/Offline/database" {
  55858. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  55859. /**
  55860. * Class used to enable access to IndexedDB
  55861. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  55862. */
  55863. export class Database implements IOfflineProvider {
  55864. private _callbackManifestChecked;
  55865. private _currentSceneUrl;
  55866. private _db;
  55867. private _enableSceneOffline;
  55868. private _enableTexturesOffline;
  55869. private _manifestVersionFound;
  55870. private _mustUpdateRessources;
  55871. private _hasReachedQuota;
  55872. private _isSupported;
  55873. private _idbFactory;
  55874. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  55875. private static IsUASupportingBlobStorage;
  55876. /**
  55877. * Gets a boolean indicating if Database storate is enabled (off by default)
  55878. */
  55879. static IDBStorageEnabled: boolean;
  55880. /**
  55881. * Gets a boolean indicating if scene must be saved in the database
  55882. */
  55883. readonly enableSceneOffline: boolean;
  55884. /**
  55885. * Gets a boolean indicating if textures must be saved in the database
  55886. */
  55887. readonly enableTexturesOffline: boolean;
  55888. /**
  55889. * Creates a new Database
  55890. * @param urlToScene defines the url to load the scene
  55891. * @param callbackManifestChecked defines the callback to use when manifest is checked
  55892. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  55893. */
  55894. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  55895. private static _ParseURL;
  55896. private static _ReturnFullUrlLocation;
  55897. private _checkManifestFile;
  55898. /**
  55899. * Open the database and make it available
  55900. * @param successCallback defines the callback to call on success
  55901. * @param errorCallback defines the callback to call on error
  55902. */
  55903. open(successCallback: () => void, errorCallback: () => void): void;
  55904. /**
  55905. * Loads an image from the database
  55906. * @param url defines the url to load from
  55907. * @param image defines the target DOM image
  55908. */
  55909. loadImage(url: string, image: HTMLImageElement): void;
  55910. private _loadImageFromDBAsync;
  55911. private _saveImageIntoDBAsync;
  55912. private _checkVersionFromDB;
  55913. private _loadVersionFromDBAsync;
  55914. private _saveVersionIntoDBAsync;
  55915. /**
  55916. * Loads a file from database
  55917. * @param url defines the URL to load from
  55918. * @param sceneLoaded defines a callback to call on success
  55919. * @param progressCallBack defines a callback to call when progress changed
  55920. * @param errorCallback defines a callback to call on error
  55921. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  55922. */
  55923. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  55924. private _loadFileAsync;
  55925. private _saveFileAsync;
  55926. /**
  55927. * Validates if xhr data is correct
  55928. * @param xhr defines the request to validate
  55929. * @param dataType defines the expected data type
  55930. * @returns true if data is correct
  55931. */
  55932. private static _ValidateXHRData;
  55933. }
  55934. }
  55935. declare module "babylonjs/Offline/index" {
  55936. export * from "babylonjs/Offline/database";
  55937. export * from "babylonjs/Offline/IOfflineProvider";
  55938. }
  55939. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  55940. /** @hidden */
  55941. export var gpuUpdateParticlesPixelShader: {
  55942. name: string;
  55943. shader: string;
  55944. };
  55945. }
  55946. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  55947. /** @hidden */
  55948. export var gpuUpdateParticlesVertexShader: {
  55949. name: string;
  55950. shader: string;
  55951. };
  55952. }
  55953. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  55954. /** @hidden */
  55955. export var clipPlaneFragmentDeclaration2: {
  55956. name: string;
  55957. shader: string;
  55958. };
  55959. }
  55960. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  55961. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  55962. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  55963. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55964. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  55965. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  55966. /** @hidden */
  55967. export var gpuRenderParticlesPixelShader: {
  55968. name: string;
  55969. shader: string;
  55970. };
  55971. }
  55972. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  55973. /** @hidden */
  55974. export var clipPlaneVertexDeclaration2: {
  55975. name: string;
  55976. shader: string;
  55977. };
  55978. }
  55979. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  55980. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  55981. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  55982. /** @hidden */
  55983. export var gpuRenderParticlesVertexShader: {
  55984. name: string;
  55985. shader: string;
  55986. };
  55987. }
  55988. declare module "babylonjs/Particles/gpuParticleSystem" {
  55989. import { Nullable } from "babylonjs/types";
  55990. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  55991. import { Observable } from "babylonjs/Misc/observable";
  55992. import { Color4, Color3 } from "babylonjs/Maths/math";
  55993. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55994. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  55995. import { Scene, IDisposable } from "babylonjs/scene";
  55996. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  55997. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  55998. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  55999. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  56000. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  56001. /**
  56002. * This represents a GPU particle system in Babylon
  56003. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56004. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56005. */
  56006. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56007. /**
  56008. * The layer mask we are rendering the particles through.
  56009. */
  56010. layerMask: number;
  56011. private _capacity;
  56012. private _activeCount;
  56013. private _currentActiveCount;
  56014. private _accumulatedCount;
  56015. private _renderEffect;
  56016. private _updateEffect;
  56017. private _buffer0;
  56018. private _buffer1;
  56019. private _spriteBuffer;
  56020. private _updateVAO;
  56021. private _renderVAO;
  56022. private _targetIndex;
  56023. private _sourceBuffer;
  56024. private _targetBuffer;
  56025. private _engine;
  56026. private _currentRenderId;
  56027. private _started;
  56028. private _stopped;
  56029. private _timeDelta;
  56030. private _randomTexture;
  56031. private _randomTexture2;
  56032. private _attributesStrideSize;
  56033. private _updateEffectOptions;
  56034. private _randomTextureSize;
  56035. private _actualFrame;
  56036. private readonly _rawTextureWidth;
  56037. /**
  56038. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56039. */
  56040. static readonly IsSupported: boolean;
  56041. /**
  56042. * An event triggered when the system is disposed.
  56043. */
  56044. onDisposeObservable: Observable<GPUParticleSystem>;
  56045. /**
  56046. * Gets the maximum number of particles active at the same time.
  56047. * @returns The max number of active particles.
  56048. */
  56049. getCapacity(): number;
  56050. /**
  56051. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56052. * to override the particles.
  56053. */
  56054. forceDepthWrite: boolean;
  56055. /**
  56056. * Gets or set the number of active particles
  56057. */
  56058. activeParticleCount: number;
  56059. private _preWarmDone;
  56060. /**
  56061. * Is this system ready to be used/rendered
  56062. * @return true if the system is ready
  56063. */
  56064. isReady(): boolean;
  56065. /**
  56066. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56067. * @returns True if it has been started, otherwise false.
  56068. */
  56069. isStarted(): boolean;
  56070. /**
  56071. * Starts the particle system and begins to emit
  56072. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56073. */
  56074. start(delay?: number): void;
  56075. /**
  56076. * Stops the particle system.
  56077. */
  56078. stop(): void;
  56079. /**
  56080. * Remove all active particles
  56081. */
  56082. reset(): void;
  56083. /**
  56084. * Returns the string "GPUParticleSystem"
  56085. * @returns a string containing the class name
  56086. */
  56087. getClassName(): string;
  56088. private _colorGradientsTexture;
  56089. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56090. /**
  56091. * Adds a new color gradient
  56092. * @param gradient defines the gradient to use (between 0 and 1)
  56093. * @param color1 defines the color to affect to the specified gradient
  56094. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56095. * @returns the current particle system
  56096. */
  56097. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56098. /**
  56099. * Remove a specific color gradient
  56100. * @param gradient defines the gradient to remove
  56101. * @returns the current particle system
  56102. */
  56103. removeColorGradient(gradient: number): GPUParticleSystem;
  56104. private _angularSpeedGradientsTexture;
  56105. private _sizeGradientsTexture;
  56106. private _velocityGradientsTexture;
  56107. private _limitVelocityGradientsTexture;
  56108. private _dragGradientsTexture;
  56109. private _addFactorGradient;
  56110. /**
  56111. * Adds a new size gradient
  56112. * @param gradient defines the gradient to use (between 0 and 1)
  56113. * @param factor defines the size factor to affect to the specified gradient
  56114. * @returns the current particle system
  56115. */
  56116. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56117. /**
  56118. * Remove a specific size gradient
  56119. * @param gradient defines the gradient to remove
  56120. * @returns the current particle system
  56121. */
  56122. removeSizeGradient(gradient: number): GPUParticleSystem;
  56123. /**
  56124. * Adds a new angular speed gradient
  56125. * @param gradient defines the gradient to use (between 0 and 1)
  56126. * @param factor defines the angular speed to affect to the specified gradient
  56127. * @returns the current particle system
  56128. */
  56129. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56130. /**
  56131. * Remove a specific angular speed gradient
  56132. * @param gradient defines the gradient to remove
  56133. * @returns the current particle system
  56134. */
  56135. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56136. /**
  56137. * Adds a new velocity gradient
  56138. * @param gradient defines the gradient to use (between 0 and 1)
  56139. * @param factor defines the velocity to affect to the specified gradient
  56140. * @returns the current particle system
  56141. */
  56142. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56143. /**
  56144. * Remove a specific velocity gradient
  56145. * @param gradient defines the gradient to remove
  56146. * @returns the current particle system
  56147. */
  56148. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56149. /**
  56150. * Adds a new limit velocity gradient
  56151. * @param gradient defines the gradient to use (between 0 and 1)
  56152. * @param factor defines the limit velocity value to affect to the specified gradient
  56153. * @returns the current particle system
  56154. */
  56155. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56156. /**
  56157. * Remove a specific limit velocity gradient
  56158. * @param gradient defines the gradient to remove
  56159. * @returns the current particle system
  56160. */
  56161. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56162. /**
  56163. * Adds a new drag gradient
  56164. * @param gradient defines the gradient to use (between 0 and 1)
  56165. * @param factor defines the drag value to affect to the specified gradient
  56166. * @returns the current particle system
  56167. */
  56168. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56169. /**
  56170. * Remove a specific drag gradient
  56171. * @param gradient defines the gradient to remove
  56172. * @returns the current particle system
  56173. */
  56174. removeDragGradient(gradient: number): GPUParticleSystem;
  56175. /**
  56176. * Not supported by GPUParticleSystem
  56177. * @param gradient defines the gradient to use (between 0 and 1)
  56178. * @param factor defines the emit rate value to affect to the specified gradient
  56179. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56180. * @returns the current particle system
  56181. */
  56182. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56183. /**
  56184. * Not supported by GPUParticleSystem
  56185. * @param gradient defines the gradient to remove
  56186. * @returns the current particle system
  56187. */
  56188. removeEmitRateGradient(gradient: number): IParticleSystem;
  56189. /**
  56190. * Not supported by GPUParticleSystem
  56191. * @param gradient defines the gradient to use (between 0 and 1)
  56192. * @param factor defines the start size value to affect to the specified gradient
  56193. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56194. * @returns the current particle system
  56195. */
  56196. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56197. /**
  56198. * Not supported by GPUParticleSystem
  56199. * @param gradient defines the gradient to remove
  56200. * @returns the current particle system
  56201. */
  56202. removeStartSizeGradient(gradient: number): IParticleSystem;
  56203. /**
  56204. * Not supported by GPUParticleSystem
  56205. * @param gradient defines the gradient to use (between 0 and 1)
  56206. * @param min defines the color remap minimal range
  56207. * @param max defines the color remap maximal range
  56208. * @returns the current particle system
  56209. */
  56210. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56211. /**
  56212. * Not supported by GPUParticleSystem
  56213. * @param gradient defines the gradient to remove
  56214. * @returns the current particle system
  56215. */
  56216. removeColorRemapGradient(): IParticleSystem;
  56217. /**
  56218. * Not supported by GPUParticleSystem
  56219. * @param gradient defines the gradient to use (between 0 and 1)
  56220. * @param min defines the alpha remap minimal range
  56221. * @param max defines the alpha remap maximal range
  56222. * @returns the current particle system
  56223. */
  56224. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56225. /**
  56226. * Not supported by GPUParticleSystem
  56227. * @param gradient defines the gradient to remove
  56228. * @returns the current particle system
  56229. */
  56230. removeAlphaRemapGradient(): IParticleSystem;
  56231. /**
  56232. * Not supported by GPUParticleSystem
  56233. * @param gradient defines the gradient to use (between 0 and 1)
  56234. * @param color defines the color to affect to the specified gradient
  56235. * @returns the current particle system
  56236. */
  56237. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56238. /**
  56239. * Not supported by GPUParticleSystem
  56240. * @param gradient defines the gradient to remove
  56241. * @returns the current particle system
  56242. */
  56243. removeRampGradient(): IParticleSystem;
  56244. /**
  56245. * Not supported by GPUParticleSystem
  56246. * @returns the list of ramp gradients
  56247. */
  56248. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56249. /**
  56250. * Not supported by GPUParticleSystem
  56251. * Gets or sets a boolean indicating that ramp gradients must be used
  56252. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56253. */
  56254. useRampGradients: boolean;
  56255. /**
  56256. * Not supported by GPUParticleSystem
  56257. * @param gradient defines the gradient to use (between 0 and 1)
  56258. * @param factor defines the life time factor to affect to the specified gradient
  56259. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56260. * @returns the current particle system
  56261. */
  56262. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56263. /**
  56264. * Not supported by GPUParticleSystem
  56265. * @param gradient defines the gradient to remove
  56266. * @returns the current particle system
  56267. */
  56268. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56269. /**
  56270. * Instantiates a GPU particle system.
  56271. * 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.
  56272. * @param name The name of the particle system
  56273. * @param options The options used to create the system
  56274. * @param scene The scene the particle system belongs to
  56275. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56276. */
  56277. constructor(name: string, options: Partial<{
  56278. capacity: number;
  56279. randomTextureSize: number;
  56280. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56281. protected _reset(): void;
  56282. private _createUpdateVAO;
  56283. private _createRenderVAO;
  56284. private _initialize;
  56285. /** @hidden */
  56286. _recreateUpdateEffect(): void;
  56287. /** @hidden */
  56288. _recreateRenderEffect(): void;
  56289. /**
  56290. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56291. * @param preWarm defines if we are in the pre-warmimg phase
  56292. */
  56293. animate(preWarm?: boolean): void;
  56294. private _createFactorGradientTexture;
  56295. private _createSizeGradientTexture;
  56296. private _createAngularSpeedGradientTexture;
  56297. private _createVelocityGradientTexture;
  56298. private _createLimitVelocityGradientTexture;
  56299. private _createDragGradientTexture;
  56300. private _createColorGradientTexture;
  56301. /**
  56302. * Renders the particle system in its current state
  56303. * @param preWarm defines if the system should only update the particles but not render them
  56304. * @returns the current number of particles
  56305. */
  56306. render(preWarm?: boolean): number;
  56307. /**
  56308. * Rebuilds the particle system
  56309. */
  56310. rebuild(): void;
  56311. private _releaseBuffers;
  56312. private _releaseVAOs;
  56313. /**
  56314. * Disposes the particle system and free the associated resources
  56315. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56316. */
  56317. dispose(disposeTexture?: boolean): void;
  56318. /**
  56319. * Clones the particle system.
  56320. * @param name The name of the cloned object
  56321. * @param newEmitter The new emitter to use
  56322. * @returns the cloned particle system
  56323. */
  56324. clone(name: string, newEmitter: any): GPUParticleSystem;
  56325. /**
  56326. * Serializes the particle system to a JSON object.
  56327. * @returns the JSON object
  56328. */
  56329. serialize(): any;
  56330. /**
  56331. * Parses a JSON object to create a GPU particle system.
  56332. * @param parsedParticleSystem The JSON object to parse
  56333. * @param scene The scene to create the particle system in
  56334. * @param rootUrl The root url to use to load external dependencies like texture
  56335. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56336. * @returns the parsed GPU particle system
  56337. */
  56338. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56339. }
  56340. }
  56341. declare module "babylonjs/Particles/particleSystemSet" {
  56342. import { Nullable } from "babylonjs/types";
  56343. import { Color3 } from "babylonjs/Maths/math";
  56344. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56346. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56347. import { Scene, IDisposable } from "babylonjs/scene";
  56348. /**
  56349. * Represents a set of particle systems working together to create a specific effect
  56350. */
  56351. export class ParticleSystemSet implements IDisposable {
  56352. private _emitterCreationOptions;
  56353. private _emitterNode;
  56354. /**
  56355. * Gets the particle system list
  56356. */
  56357. systems: IParticleSystem[];
  56358. /**
  56359. * Gets the emitter node used with this set
  56360. */
  56361. readonly emitterNode: Nullable<TransformNode>;
  56362. /**
  56363. * Creates a new emitter mesh as a sphere
  56364. * @param options defines the options used to create the sphere
  56365. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56366. * @param scene defines the hosting scene
  56367. */
  56368. setEmitterAsSphere(options: {
  56369. diameter: number;
  56370. segments: number;
  56371. color: Color3;
  56372. }, renderingGroupId: number, scene: Scene): void;
  56373. /**
  56374. * Starts all particle systems of the set
  56375. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56376. */
  56377. start(emitter?: AbstractMesh): void;
  56378. /**
  56379. * Release all associated resources
  56380. */
  56381. dispose(): void;
  56382. /**
  56383. * Serialize the set into a JSON compatible object
  56384. * @returns a JSON compatible representation of the set
  56385. */
  56386. serialize(): any;
  56387. /**
  56388. * Parse a new ParticleSystemSet from a serialized source
  56389. * @param data defines a JSON compatible representation of the set
  56390. * @param scene defines the hosting scene
  56391. * @param gpu defines if we want GPU particles or CPU particles
  56392. * @returns a new ParticleSystemSet
  56393. */
  56394. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56395. }
  56396. }
  56397. declare module "babylonjs/Particles/particleHelper" {
  56398. import { Nullable } from "babylonjs/types";
  56399. import { Scene } from "babylonjs/scene";
  56400. import { Vector3 } from "babylonjs/Maths/math";
  56401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56402. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56403. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  56404. /**
  56405. * This class is made for on one-liner static method to help creating particle system set.
  56406. */
  56407. export class ParticleHelper {
  56408. /**
  56409. * Gets or sets base Assets URL
  56410. */
  56411. static BaseAssetsUrl: string;
  56412. /**
  56413. * Create a default particle system that you can tweak
  56414. * @param emitter defines the emitter to use
  56415. * @param capacity defines the system capacity (default is 500 particles)
  56416. * @param scene defines the hosting scene
  56417. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56418. * @returns the new Particle system
  56419. */
  56420. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56421. /**
  56422. * This is the main static method (one-liner) of this helper to create different particle systems
  56423. * @param type This string represents the type to the particle system to create
  56424. * @param scene The scene where the particle system should live
  56425. * @param gpu If the system will use gpu
  56426. * @returns the ParticleSystemSet created
  56427. */
  56428. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56429. /**
  56430. * Static function used to export a particle system to a ParticleSystemSet variable.
  56431. * Please note that the emitter shape is not exported
  56432. * @param systems defines the particle systems to export
  56433. * @returns the created particle system set
  56434. */
  56435. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  56436. }
  56437. }
  56438. declare module "babylonjs/Particles/particleSystemComponent" {
  56439. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56440. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  56441. import "babylonjs/Shaders/particles.vertex";
  56442. module "babylonjs/Engines/engine" {
  56443. interface Engine {
  56444. /**
  56445. * Create an effect to use with particle systems.
  56446. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  56447. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  56448. * @param uniformsNames defines a list of attribute names
  56449. * @param samplers defines an array of string used to represent textures
  56450. * @param defines defines the string containing the defines to use to compile the shaders
  56451. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  56452. * @param onCompiled defines a function to call when the effect creation is successful
  56453. * @param onError defines a function to call when the effect creation has failed
  56454. * @returns the new Effect
  56455. */
  56456. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  56457. }
  56458. }
  56459. module "babylonjs/Meshes/mesh" {
  56460. interface Mesh {
  56461. /**
  56462. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  56463. * @returns an array of IParticleSystem
  56464. */
  56465. getEmittedParticleSystems(): IParticleSystem[];
  56466. /**
  56467. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  56468. * @returns an array of IParticleSystem
  56469. */
  56470. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  56471. }
  56472. }
  56473. /**
  56474. * @hidden
  56475. */
  56476. export var _IDoNeedToBeInTheBuild: number;
  56477. }
  56478. declare module "babylonjs/Particles/index" {
  56479. export * from "babylonjs/Particles/baseParticleSystem";
  56480. export * from "babylonjs/Particles/EmitterTypes/index";
  56481. export * from "babylonjs/Particles/gpuParticleSystem";
  56482. export * from "babylonjs/Particles/IParticleSystem";
  56483. export * from "babylonjs/Particles/particle";
  56484. export * from "babylonjs/Particles/particleHelper";
  56485. export * from "babylonjs/Particles/particleSystem";
  56486. export * from "babylonjs/Particles/particleSystemComponent";
  56487. export * from "babylonjs/Particles/particleSystemSet";
  56488. export * from "babylonjs/Particles/solidParticle";
  56489. export * from "babylonjs/Particles/solidParticleSystem";
  56490. export * from "babylonjs/Particles/subEmitter";
  56491. }
  56492. declare module "babylonjs/Physics/physicsEngineComponent" {
  56493. import { Nullable } from "babylonjs/types";
  56494. import { Observable, Observer } from "babylonjs/Misc/observable";
  56495. import { Vector3 } from "babylonjs/Maths/math";
  56496. import { Mesh } from "babylonjs/Meshes/mesh";
  56497. import { ISceneComponent } from "babylonjs/sceneComponent";
  56498. import { Scene } from "babylonjs/scene";
  56499. import { Node } from "babylonjs/node";
  56500. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56501. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56502. module "babylonjs/scene" {
  56503. interface Scene {
  56504. /** @hidden (Backing field) */
  56505. _physicsEngine: Nullable<IPhysicsEngine>;
  56506. /**
  56507. * Gets the current physics engine
  56508. * @returns a IPhysicsEngine or null if none attached
  56509. */
  56510. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  56511. /**
  56512. * Enables physics to the current scene
  56513. * @param gravity defines the scene's gravity for the physics engine
  56514. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  56515. * @return a boolean indicating if the physics engine was initialized
  56516. */
  56517. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  56518. /**
  56519. * Disables and disposes the physics engine associated with the scene
  56520. */
  56521. disablePhysicsEngine(): void;
  56522. /**
  56523. * Gets a boolean indicating if there is an active physics engine
  56524. * @returns a boolean indicating if there is an active physics engine
  56525. */
  56526. isPhysicsEnabled(): boolean;
  56527. /**
  56528. * Deletes a physics compound impostor
  56529. * @param compound defines the compound to delete
  56530. */
  56531. deleteCompoundImpostor(compound: any): void;
  56532. /**
  56533. * An event triggered when physic simulation is about to be run
  56534. */
  56535. onBeforePhysicsObservable: Observable<Scene>;
  56536. /**
  56537. * An event triggered when physic simulation has been done
  56538. */
  56539. onAfterPhysicsObservable: Observable<Scene>;
  56540. }
  56541. }
  56542. module "babylonjs/Meshes/abstractMesh" {
  56543. interface AbstractMesh {
  56544. /** @hidden */
  56545. _physicsImpostor: Nullable<PhysicsImpostor>;
  56546. /**
  56547. * Gets or sets impostor used for physic simulation
  56548. * @see http://doc.babylonjs.com/features/physics_engine
  56549. */
  56550. physicsImpostor: Nullable<PhysicsImpostor>;
  56551. /**
  56552. * Gets the current physics impostor
  56553. * @see http://doc.babylonjs.com/features/physics_engine
  56554. * @returns a physics impostor or null
  56555. */
  56556. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56557. /** Apply a physic impulse to the mesh
  56558. * @param force defines the force to apply
  56559. * @param contactPoint defines where to apply the force
  56560. * @returns the current mesh
  56561. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56562. */
  56563. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56564. /**
  56565. * Creates a physic joint between two meshes
  56566. * @param otherMesh defines the other mesh to use
  56567. * @param pivot1 defines the pivot to use on this mesh
  56568. * @param pivot2 defines the pivot to use on the other mesh
  56569. * @param options defines additional options (can be plugin dependent)
  56570. * @returns the current mesh
  56571. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56572. */
  56573. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56574. /** @hidden */
  56575. _disposePhysicsObserver: Nullable<Observer<Node>>;
  56576. }
  56577. }
  56578. /**
  56579. * Defines the physics engine scene component responsible to manage a physics engine
  56580. */
  56581. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56582. /**
  56583. * The component name helpful to identify the component in the list of scene components.
  56584. */
  56585. readonly name: string;
  56586. /**
  56587. * The scene the component belongs to.
  56588. */
  56589. scene: Scene;
  56590. /**
  56591. * Creates a new instance of the component for the given scene
  56592. * @param scene Defines the scene to register the component in
  56593. */
  56594. constructor(scene: Scene);
  56595. /**
  56596. * Registers the component in a given scene
  56597. */
  56598. register(): void;
  56599. /**
  56600. * Rebuilds the elements related to this component in case of
  56601. * context lost for instance.
  56602. */
  56603. rebuild(): void;
  56604. /**
  56605. * Disposes the component and the associated ressources
  56606. */
  56607. dispose(): void;
  56608. }
  56609. }
  56610. declare module "babylonjs/Physics/physicsHelper" {
  56611. import { Nullable } from "babylonjs/types";
  56612. import { Vector3 } from "babylonjs/Maths/math";
  56613. import { Mesh } from "babylonjs/Meshes/mesh";
  56614. import { Scene } from "babylonjs/scene";
  56615. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56616. /**
  56617. * A helper for physics simulations
  56618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56619. */
  56620. export class PhysicsHelper {
  56621. private _scene;
  56622. private _physicsEngine;
  56623. /**
  56624. * Initializes the Physics helper
  56625. * @param scene Babylon.js scene
  56626. */
  56627. constructor(scene: Scene);
  56628. /**
  56629. * Applies a radial explosion impulse
  56630. * @param origin the origin of the explosion
  56631. * @param radiusOrEventOptions the radius or the options of radial explosion
  56632. * @param strength the explosion strength
  56633. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56634. * @returns A physics radial explosion event, or null
  56635. */
  56636. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56637. /**
  56638. * Applies a radial explosion force
  56639. * @param origin the origin of the explosion
  56640. * @param radiusOrEventOptions the radius or the options of radial explosion
  56641. * @param strength the explosion strength
  56642. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56643. * @returns A physics radial explosion event, or null
  56644. */
  56645. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56646. /**
  56647. * Creates a gravitational field
  56648. * @param origin the origin of the explosion
  56649. * @param radiusOrEventOptions the radius or the options of radial explosion
  56650. * @param strength the explosion strength
  56651. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56652. * @returns A physics gravitational field event, or null
  56653. */
  56654. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56655. /**
  56656. * Creates a physics updraft event
  56657. * @param origin the origin of the updraft
  56658. * @param radiusOrEventOptions the radius or the options of the updraft
  56659. * @param strength the strength of the updraft
  56660. * @param height the height of the updraft
  56661. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56662. * @returns A physics updraft event, or null
  56663. */
  56664. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56665. /**
  56666. * Creates a physics vortex event
  56667. * @param origin the of the vortex
  56668. * @param radiusOrEventOptions the radius or the options of the vortex
  56669. * @param strength the strength of the vortex
  56670. * @param height the height of the vortex
  56671. * @returns a Physics vortex event, or null
  56672. * A physics vortex event or null
  56673. */
  56674. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56675. }
  56676. /**
  56677. * Represents a physics radial explosion event
  56678. */
  56679. class PhysicsRadialExplosionEvent {
  56680. private _scene;
  56681. private _options;
  56682. private _sphere;
  56683. private _dataFetched;
  56684. /**
  56685. * Initializes a radial explosioin event
  56686. * @param _scene BabylonJS scene
  56687. * @param _options The options for the vortex event
  56688. */
  56689. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56690. /**
  56691. * Returns the data related to the radial explosion event (sphere).
  56692. * @returns The radial explosion event data
  56693. */
  56694. getData(): PhysicsRadialExplosionEventData;
  56695. /**
  56696. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56697. * @param impostor A physics imposter
  56698. * @param origin the origin of the explosion
  56699. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56700. */
  56701. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56702. /**
  56703. * Triggers affecterd impostors callbacks
  56704. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56705. */
  56706. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56707. /**
  56708. * Disposes the sphere.
  56709. * @param force Specifies if the sphere should be disposed by force
  56710. */
  56711. dispose(force?: boolean): void;
  56712. /*** Helpers ***/
  56713. private _prepareSphere;
  56714. private _intersectsWithSphere;
  56715. }
  56716. /**
  56717. * Represents a gravitational field event
  56718. */
  56719. class PhysicsGravitationalFieldEvent {
  56720. private _physicsHelper;
  56721. private _scene;
  56722. private _origin;
  56723. private _options;
  56724. private _tickCallback;
  56725. private _sphere;
  56726. private _dataFetched;
  56727. /**
  56728. * Initializes the physics gravitational field event
  56729. * @param _physicsHelper A physics helper
  56730. * @param _scene BabylonJS scene
  56731. * @param _origin The origin position of the gravitational field event
  56732. * @param _options The options for the vortex event
  56733. */
  56734. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56735. /**
  56736. * Returns the data related to the gravitational field event (sphere).
  56737. * @returns A gravitational field event
  56738. */
  56739. getData(): PhysicsGravitationalFieldEventData;
  56740. /**
  56741. * Enables the gravitational field.
  56742. */
  56743. enable(): void;
  56744. /**
  56745. * Disables the gravitational field.
  56746. */
  56747. disable(): void;
  56748. /**
  56749. * Disposes the sphere.
  56750. * @param force The force to dispose from the gravitational field event
  56751. */
  56752. dispose(force?: boolean): void;
  56753. private _tick;
  56754. }
  56755. /**
  56756. * Represents a physics updraft event
  56757. */
  56758. class PhysicsUpdraftEvent {
  56759. private _scene;
  56760. private _origin;
  56761. private _options;
  56762. private _physicsEngine;
  56763. private _originTop;
  56764. private _originDirection;
  56765. private _tickCallback;
  56766. private _cylinder;
  56767. private _cylinderPosition;
  56768. private _dataFetched;
  56769. /**
  56770. * Initializes the physics updraft event
  56771. * @param _scene BabylonJS scene
  56772. * @param _origin The origin position of the updraft
  56773. * @param _options The options for the updraft event
  56774. */
  56775. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  56776. /**
  56777. * Returns the data related to the updraft event (cylinder).
  56778. * @returns A physics updraft event
  56779. */
  56780. getData(): PhysicsUpdraftEventData;
  56781. /**
  56782. * Enables the updraft.
  56783. */
  56784. enable(): void;
  56785. /**
  56786. * Disables the updraft.
  56787. */
  56788. disable(): void;
  56789. /**
  56790. * Disposes the cylinder.
  56791. * @param force Specifies if the updraft should be disposed by force
  56792. */
  56793. dispose(force?: boolean): void;
  56794. private getImpostorHitData;
  56795. private _tick;
  56796. /*** Helpers ***/
  56797. private _prepareCylinder;
  56798. private _intersectsWithCylinder;
  56799. }
  56800. /**
  56801. * Represents a physics vortex event
  56802. */
  56803. class PhysicsVortexEvent {
  56804. private _scene;
  56805. private _origin;
  56806. private _options;
  56807. private _physicsEngine;
  56808. private _originTop;
  56809. private _tickCallback;
  56810. private _cylinder;
  56811. private _cylinderPosition;
  56812. private _dataFetched;
  56813. /**
  56814. * Initializes the physics vortex event
  56815. * @param _scene The BabylonJS scene
  56816. * @param _origin The origin position of the vortex
  56817. * @param _options The options for the vortex event
  56818. */
  56819. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  56820. /**
  56821. * Returns the data related to the vortex event (cylinder).
  56822. * @returns The physics vortex event data
  56823. */
  56824. getData(): PhysicsVortexEventData;
  56825. /**
  56826. * Enables the vortex.
  56827. */
  56828. enable(): void;
  56829. /**
  56830. * Disables the cortex.
  56831. */
  56832. disable(): void;
  56833. /**
  56834. * Disposes the sphere.
  56835. * @param force
  56836. */
  56837. dispose(force?: boolean): void;
  56838. private getImpostorHitData;
  56839. private _tick;
  56840. /*** Helpers ***/
  56841. private _prepareCylinder;
  56842. private _intersectsWithCylinder;
  56843. }
  56844. /**
  56845. * Options fot the radial explosion event
  56846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56847. */
  56848. export class PhysicsRadialExplosionEventOptions {
  56849. /**
  56850. * The radius of the sphere for the radial explosion.
  56851. */
  56852. radius: number;
  56853. /**
  56854. * The strenth of the explosion.
  56855. */
  56856. strength: number;
  56857. /**
  56858. * The strenght of the force in correspondence to the distance of the affected object
  56859. */
  56860. falloff: PhysicsRadialImpulseFalloff;
  56861. /**
  56862. * Sphere options for the radial explosion.
  56863. */
  56864. sphere: {
  56865. segments: number;
  56866. diameter: number;
  56867. };
  56868. /**
  56869. * Sphere options for the radial explosion.
  56870. */
  56871. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  56872. }
  56873. /**
  56874. * Options fot the updraft event
  56875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56876. */
  56877. export class PhysicsUpdraftEventOptions {
  56878. /**
  56879. * The radius of the cylinder for the vortex
  56880. */
  56881. radius: number;
  56882. /**
  56883. * The strenth of the updraft.
  56884. */
  56885. strength: number;
  56886. /**
  56887. * The height of the cylinder for the updraft.
  56888. */
  56889. height: number;
  56890. /**
  56891. * The mode for the the updraft.
  56892. */
  56893. updraftMode: PhysicsUpdraftMode;
  56894. }
  56895. /**
  56896. * Options fot the vortex event
  56897. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56898. */
  56899. export class PhysicsVortexEventOptions {
  56900. /**
  56901. * The radius of the cylinder for the vortex
  56902. */
  56903. radius: number;
  56904. /**
  56905. * The strenth of the vortex.
  56906. */
  56907. strength: number;
  56908. /**
  56909. * The height of the cylinder for the vortex.
  56910. */
  56911. height: number;
  56912. /**
  56913. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  56914. */
  56915. centripetalForceThreshold: number;
  56916. /**
  56917. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  56918. */
  56919. centripetalForceMultiplier: number;
  56920. /**
  56921. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  56922. */
  56923. centrifugalForceMultiplier: number;
  56924. /**
  56925. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  56926. */
  56927. updraftForceMultiplier: number;
  56928. }
  56929. /**
  56930. * The strenght of the force in correspondence to the distance of the affected object
  56931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56932. */
  56933. export enum PhysicsRadialImpulseFalloff {
  56934. /** Defines that impulse is constant in strength across it's whole radius */
  56935. Constant = 0,
  56936. /** Defines that impulse gets weaker if it's further from the origin */
  56937. Linear = 1
  56938. }
  56939. /**
  56940. * The strength of the force in correspondence to the distance of the affected object
  56941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56942. */
  56943. export enum PhysicsUpdraftMode {
  56944. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  56945. Center = 0,
  56946. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  56947. Perpendicular = 1
  56948. }
  56949. /**
  56950. * Interface for a physics hit data
  56951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56952. */
  56953. export interface PhysicsHitData {
  56954. /**
  56955. * The force applied at the contact point
  56956. */
  56957. force: Vector3;
  56958. /**
  56959. * The contact point
  56960. */
  56961. contactPoint: Vector3;
  56962. /**
  56963. * The distance from the origin to the contact point
  56964. */
  56965. distanceFromOrigin: number;
  56966. }
  56967. /**
  56968. * Interface for radial explosion event data
  56969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56970. */
  56971. export interface PhysicsRadialExplosionEventData {
  56972. /**
  56973. * A sphere used for the radial explosion event
  56974. */
  56975. sphere: Mesh;
  56976. }
  56977. /**
  56978. * Interface for gravitational field event data
  56979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56980. */
  56981. export interface PhysicsGravitationalFieldEventData {
  56982. /**
  56983. * A sphere mesh used for the gravitational field event
  56984. */
  56985. sphere: Mesh;
  56986. }
  56987. /**
  56988. * Interface for updraft event data
  56989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56990. */
  56991. export interface PhysicsUpdraftEventData {
  56992. /**
  56993. * A cylinder used for the updraft event
  56994. */
  56995. cylinder: Mesh;
  56996. }
  56997. /**
  56998. * Interface for vortex event data
  56999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57000. */
  57001. export interface PhysicsVortexEventData {
  57002. /**
  57003. * A cylinder used for the vortex event
  57004. */
  57005. cylinder: Mesh;
  57006. }
  57007. /**
  57008. * Interface for an affected physics impostor
  57009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57010. */
  57011. export interface PhysicsAffectedImpostorWithData {
  57012. /**
  57013. * The impostor affected by the effect
  57014. */
  57015. impostor: PhysicsImpostor;
  57016. /**
  57017. * The data about the hit/horce from the explosion
  57018. */
  57019. hitData: PhysicsHitData;
  57020. }
  57021. }
  57022. declare module "babylonjs/Physics/Plugins/index" {
  57023. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  57024. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  57025. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  57026. }
  57027. declare module "babylonjs/Physics/index" {
  57028. export * from "babylonjs/Physics/IPhysicsEngine";
  57029. export * from "babylonjs/Physics/physicsEngine";
  57030. export * from "babylonjs/Physics/physicsEngineComponent";
  57031. export * from "babylonjs/Physics/physicsHelper";
  57032. export * from "babylonjs/Physics/physicsImpostor";
  57033. export * from "babylonjs/Physics/physicsJoint";
  57034. export * from "babylonjs/Physics/Plugins/index";
  57035. }
  57036. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  57037. /** @hidden */
  57038. export var blackAndWhitePixelShader: {
  57039. name: string;
  57040. shader: string;
  57041. };
  57042. }
  57043. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  57044. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57045. import { Camera } from "babylonjs/Cameras/camera";
  57046. import { Engine } from "babylonjs/Engines/engine";
  57047. import "babylonjs/Shaders/blackAndWhite.fragment";
  57048. /**
  57049. * Post process used to render in black and white
  57050. */
  57051. export class BlackAndWhitePostProcess extends PostProcess {
  57052. /**
  57053. * Linear about to convert he result to black and white (default: 1)
  57054. */
  57055. degree: number;
  57056. /**
  57057. * Creates a black and white post process
  57058. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57059. * @param name The name of the effect.
  57060. * @param options The required width/height ratio to downsize to before computing the render pass.
  57061. * @param camera The camera to apply the render pass to.
  57062. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57063. * @param engine The engine which the post process will be applied. (default: current engine)
  57064. * @param reusable If the post process can be reused on the same frame. (default: false)
  57065. */
  57066. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57067. }
  57068. }
  57069. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  57070. import { Nullable } from "babylonjs/types";
  57071. import { Camera } from "babylonjs/Cameras/camera";
  57072. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57073. import { Engine } from "babylonjs/Engines/engine";
  57074. /**
  57075. * This represents a set of one or more post processes in Babylon.
  57076. * A post process can be used to apply a shader to a texture after it is rendered.
  57077. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57078. */
  57079. export class PostProcessRenderEffect {
  57080. private _postProcesses;
  57081. private _getPostProcesses;
  57082. private _singleInstance;
  57083. private _cameras;
  57084. private _indicesForCamera;
  57085. /**
  57086. * Name of the effect
  57087. * @hidden
  57088. */
  57089. _name: string;
  57090. /**
  57091. * Instantiates a post process render effect.
  57092. * A post process can be used to apply a shader to a texture after it is rendered.
  57093. * @param engine The engine the effect is tied to
  57094. * @param name The name of the effect
  57095. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57096. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57097. */
  57098. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57099. /**
  57100. * Checks if all the post processes in the effect are supported.
  57101. */
  57102. readonly isSupported: boolean;
  57103. /**
  57104. * Updates the current state of the effect
  57105. * @hidden
  57106. */
  57107. _update(): void;
  57108. /**
  57109. * Attaches the effect on cameras
  57110. * @param cameras The camera to attach to.
  57111. * @hidden
  57112. */
  57113. _attachCameras(cameras: Camera): void;
  57114. /**
  57115. * Attaches the effect on cameras
  57116. * @param cameras The camera to attach to.
  57117. * @hidden
  57118. */
  57119. _attachCameras(cameras: Camera[]): void;
  57120. /**
  57121. * Detaches the effect on cameras
  57122. * @param cameras The camera to detatch from.
  57123. * @hidden
  57124. */
  57125. _detachCameras(cameras: Camera): void;
  57126. /**
  57127. * Detatches the effect on cameras
  57128. * @param cameras The camera to detatch from.
  57129. * @hidden
  57130. */
  57131. _detachCameras(cameras: Camera[]): void;
  57132. /**
  57133. * Enables the effect on given cameras
  57134. * @param cameras The camera to enable.
  57135. * @hidden
  57136. */
  57137. _enable(cameras: Camera): void;
  57138. /**
  57139. * Enables the effect on given cameras
  57140. * @param cameras The camera to enable.
  57141. * @hidden
  57142. */
  57143. _enable(cameras: Nullable<Camera[]>): void;
  57144. /**
  57145. * Disables the effect on the given cameras
  57146. * @param cameras The camera to disable.
  57147. * @hidden
  57148. */
  57149. _disable(cameras: Camera): void;
  57150. /**
  57151. * Disables the effect on the given cameras
  57152. * @param cameras The camera to disable.
  57153. * @hidden
  57154. */
  57155. _disable(cameras: Nullable<Camera[]>): void;
  57156. /**
  57157. * Gets a list of the post processes contained in the effect.
  57158. * @param camera The camera to get the post processes on.
  57159. * @returns The list of the post processes in the effect.
  57160. */
  57161. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57162. }
  57163. }
  57164. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  57165. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57166. /** @hidden */
  57167. export var extractHighlightsPixelShader: {
  57168. name: string;
  57169. shader: string;
  57170. };
  57171. }
  57172. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  57173. import { Nullable } from "babylonjs/types";
  57174. import { Camera } from "babylonjs/Cameras/camera";
  57175. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57176. import { Engine } from "babylonjs/Engines/engine";
  57177. import "babylonjs/Shaders/extractHighlights.fragment";
  57178. /**
  57179. * 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.
  57180. */
  57181. export class ExtractHighlightsPostProcess extends PostProcess {
  57182. /**
  57183. * The luminance threshold, pixels below this value will be set to black.
  57184. */
  57185. threshold: number;
  57186. /** @hidden */
  57187. _exposure: number;
  57188. /**
  57189. * Post process which has the input texture to be used when performing highlight extraction
  57190. * @hidden
  57191. */
  57192. _inputPostProcess: Nullable<PostProcess>;
  57193. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57194. }
  57195. }
  57196. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  57197. /** @hidden */
  57198. export var bloomMergePixelShader: {
  57199. name: string;
  57200. shader: string;
  57201. };
  57202. }
  57203. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  57204. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57205. import { Nullable } from "babylonjs/types";
  57206. import { Engine } from "babylonjs/Engines/engine";
  57207. import { Camera } from "babylonjs/Cameras/camera";
  57208. import "babylonjs/Shaders/bloomMerge.fragment";
  57209. /**
  57210. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57211. */
  57212. export class BloomMergePostProcess extends PostProcess {
  57213. /** Weight of the bloom to be added to the original input. */
  57214. weight: number;
  57215. /**
  57216. * Creates a new instance of @see BloomMergePostProcess
  57217. * @param name The name of the effect.
  57218. * @param originalFromInput Post process which's input will be used for the merge.
  57219. * @param blurred Blurred highlights post process which's output will be used.
  57220. * @param weight Weight of the bloom to be added to the original input.
  57221. * @param options The required width/height ratio to downsize to before computing the render pass.
  57222. * @param camera The camera to apply the render pass to.
  57223. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57224. * @param engine The engine which the post process will be applied. (default: current engine)
  57225. * @param reusable If the post process can be reused on the same frame. (default: false)
  57226. * @param textureType Type of textures used when performing the post process. (default: 0)
  57227. * @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)
  57228. */
  57229. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57230. /** Weight of the bloom to be added to the original input. */
  57231. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57232. }
  57233. }
  57234. declare module "babylonjs/PostProcesses/bloomEffect" {
  57235. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57236. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57237. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57238. import { Camera } from "babylonjs/Cameras/camera";
  57239. import { Scene } from "babylonjs/scene";
  57240. /**
  57241. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57242. */
  57243. export class BloomEffect extends PostProcessRenderEffect {
  57244. private bloomScale;
  57245. /**
  57246. * @hidden Internal
  57247. */
  57248. _effects: Array<PostProcess>;
  57249. /**
  57250. * @hidden Internal
  57251. */
  57252. _downscale: ExtractHighlightsPostProcess;
  57253. private _blurX;
  57254. private _blurY;
  57255. private _merge;
  57256. /**
  57257. * The luminance threshold to find bright areas of the image to bloom.
  57258. */
  57259. threshold: number;
  57260. /**
  57261. * The strength of the bloom.
  57262. */
  57263. weight: number;
  57264. /**
  57265. * Specifies the size of the bloom blur kernel, relative to the final output size
  57266. */
  57267. kernel: number;
  57268. /**
  57269. * Creates a new instance of @see BloomEffect
  57270. * @param scene The scene the effect belongs to.
  57271. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57272. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57273. * @param bloomWeight The the strength of bloom.
  57274. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57275. * @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)
  57276. */
  57277. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57278. /**
  57279. * Disposes each of the internal effects for a given camera.
  57280. * @param camera The camera to dispose the effect on.
  57281. */
  57282. disposeEffects(camera: Camera): void;
  57283. /**
  57284. * @hidden Internal
  57285. */
  57286. _updateEffects(): void;
  57287. /**
  57288. * Internal
  57289. * @returns if all the contained post processes are ready.
  57290. * @hidden
  57291. */
  57292. _isReady(): boolean;
  57293. }
  57294. }
  57295. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  57296. /** @hidden */
  57297. export var chromaticAberrationPixelShader: {
  57298. name: string;
  57299. shader: string;
  57300. };
  57301. }
  57302. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  57303. import { Vector2 } from "babylonjs/Maths/math";
  57304. import { Nullable } from "babylonjs/types";
  57305. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57306. import { Camera } from "babylonjs/Cameras/camera";
  57307. import { Engine } from "babylonjs/Engines/engine";
  57308. import "babylonjs/Shaders/chromaticAberration.fragment";
  57309. /**
  57310. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57311. */
  57312. export class ChromaticAberrationPostProcess extends PostProcess {
  57313. /**
  57314. * The amount of seperation of rgb channels (default: 30)
  57315. */
  57316. aberrationAmount: number;
  57317. /**
  57318. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57319. */
  57320. radialIntensity: number;
  57321. /**
  57322. * 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))
  57323. */
  57324. direction: Vector2;
  57325. /**
  57326. * 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))
  57327. */
  57328. centerPosition: Vector2;
  57329. /**
  57330. * Creates a new instance ChromaticAberrationPostProcess
  57331. * @param name The name of the effect.
  57332. * @param screenWidth The width of the screen to apply the effect on.
  57333. * @param screenHeight The height of the screen to apply the effect on.
  57334. * @param options The required width/height ratio to downsize to before computing the render pass.
  57335. * @param camera The camera to apply the render pass to.
  57336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57337. * @param engine The engine which the post process will be applied. (default: current engine)
  57338. * @param reusable If the post process can be reused on the same frame. (default: false)
  57339. * @param textureType Type of textures used when performing the post process. (default: 0)
  57340. * @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)
  57341. */
  57342. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57343. }
  57344. }
  57345. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  57346. /** @hidden */
  57347. export var circleOfConfusionPixelShader: {
  57348. name: string;
  57349. shader: string;
  57350. };
  57351. }
  57352. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  57353. import { Nullable } from "babylonjs/types";
  57354. import { Engine } from "babylonjs/Engines/engine";
  57355. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57356. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57357. import { Camera } from "babylonjs/Cameras/camera";
  57358. import "babylonjs/Shaders/circleOfConfusion.fragment";
  57359. /**
  57360. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57361. */
  57362. export class CircleOfConfusionPostProcess extends PostProcess {
  57363. /**
  57364. * 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.
  57365. */
  57366. lensSize: number;
  57367. /**
  57368. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57369. */
  57370. fStop: number;
  57371. /**
  57372. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57373. */
  57374. focusDistance: number;
  57375. /**
  57376. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57377. */
  57378. focalLength: number;
  57379. private _depthTexture;
  57380. /**
  57381. * Creates a new instance CircleOfConfusionPostProcess
  57382. * @param name The name of the effect.
  57383. * @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.
  57384. * @param options The required width/height ratio to downsize to before computing the render pass.
  57385. * @param camera The camera to apply the render pass to.
  57386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57387. * @param engine The engine which the post process will be applied. (default: current engine)
  57388. * @param reusable If the post process can be reused on the same frame. (default: false)
  57389. * @param textureType Type of textures used when performing the post process. (default: 0)
  57390. * @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)
  57391. */
  57392. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57393. /**
  57394. * 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.
  57395. */
  57396. depthTexture: RenderTargetTexture;
  57397. }
  57398. }
  57399. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  57400. /** @hidden */
  57401. export var colorCorrectionPixelShader: {
  57402. name: string;
  57403. shader: string;
  57404. };
  57405. }
  57406. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  57407. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57408. import { Engine } from "babylonjs/Engines/engine";
  57409. import { Camera } from "babylonjs/Cameras/camera";
  57410. import "babylonjs/Shaders/colorCorrection.fragment";
  57411. /**
  57412. *
  57413. * This post-process allows the modification of rendered colors by using
  57414. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57415. *
  57416. * The object needs to be provided an url to a texture containing the color
  57417. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57418. * Use an image editing software to tweak the LUT to match your needs.
  57419. *
  57420. * For an example of a color LUT, see here:
  57421. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57422. * For explanations on color grading, see here:
  57423. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57424. *
  57425. */
  57426. export class ColorCorrectionPostProcess extends PostProcess {
  57427. private _colorTableTexture;
  57428. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57429. }
  57430. }
  57431. declare module "babylonjs/Shaders/convolution.fragment" {
  57432. /** @hidden */
  57433. export var convolutionPixelShader: {
  57434. name: string;
  57435. shader: string;
  57436. };
  57437. }
  57438. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  57439. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57440. import { Nullable } from "babylonjs/types";
  57441. import { Camera } from "babylonjs/Cameras/camera";
  57442. import { Engine } from "babylonjs/Engines/engine";
  57443. import "babylonjs/Shaders/convolution.fragment";
  57444. /**
  57445. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57446. * input texture to perform effects such as edge detection or sharpening
  57447. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57448. */
  57449. export class ConvolutionPostProcess extends PostProcess {
  57450. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  57451. kernel: number[];
  57452. /**
  57453. * Creates a new instance ConvolutionPostProcess
  57454. * @param name The name of the effect.
  57455. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  57456. * @param options The required width/height ratio to downsize to before computing the render pass.
  57457. * @param camera The camera to apply the render pass to.
  57458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57459. * @param engine The engine which the post process will be applied. (default: current engine)
  57460. * @param reusable If the post process can be reused on the same frame. (default: false)
  57461. * @param textureType Type of textures used when performing the post process. (default: 0)
  57462. */
  57463. constructor(name: string,
  57464. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  57465. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57466. /**
  57467. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57468. */
  57469. static EdgeDetect0Kernel: number[];
  57470. /**
  57471. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57472. */
  57473. static EdgeDetect1Kernel: number[];
  57474. /**
  57475. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57476. */
  57477. static EdgeDetect2Kernel: number[];
  57478. /**
  57479. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57480. */
  57481. static SharpenKernel: number[];
  57482. /**
  57483. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57484. */
  57485. static EmbossKernel: number[];
  57486. /**
  57487. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57488. */
  57489. static GaussianKernel: number[];
  57490. }
  57491. }
  57492. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  57493. import { Nullable } from "babylonjs/types";
  57494. import { Vector2 } from "babylonjs/Maths/math";
  57495. import { Camera } from "babylonjs/Cameras/camera";
  57496. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57497. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  57498. import { Engine } from "babylonjs/Engines/engine";
  57499. import { Scene } from "babylonjs/scene";
  57500. /**
  57501. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57502. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57503. * based on samples that have a large difference in distance than the center pixel.
  57504. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57505. */
  57506. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57507. direction: Vector2;
  57508. /**
  57509. * Creates a new instance CircleOfConfusionPostProcess
  57510. * @param name The name of the effect.
  57511. * @param scene The scene the effect belongs to.
  57512. * @param direction The direction the blur should be applied.
  57513. * @param kernel The size of the kernel used to blur.
  57514. * @param options The required width/height ratio to downsize to before computing the render pass.
  57515. * @param camera The camera to apply the render pass to.
  57516. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57517. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57518. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57519. * @param engine The engine which the post process will be applied. (default: current engine)
  57520. * @param reusable If the post process can be reused on the same frame. (default: false)
  57521. * @param textureType Type of textures used when performing the post process. (default: 0)
  57522. * @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)
  57523. */
  57524. 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);
  57525. }
  57526. }
  57527. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  57528. /** @hidden */
  57529. export var depthOfFieldMergePixelShader: {
  57530. name: string;
  57531. shader: string;
  57532. };
  57533. }
  57534. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  57535. import { Nullable } from "babylonjs/types";
  57536. import { Camera } from "babylonjs/Cameras/camera";
  57537. import { Effect } from "babylonjs/Materials/effect";
  57538. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57539. import { Engine } from "babylonjs/Engines/engine";
  57540. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  57541. /**
  57542. * Options to be set when merging outputs from the default pipeline.
  57543. */
  57544. export class DepthOfFieldMergePostProcessOptions {
  57545. /**
  57546. * The original image to merge on top of
  57547. */
  57548. originalFromInput: PostProcess;
  57549. /**
  57550. * Parameters to perform the merge of the depth of field effect
  57551. */
  57552. depthOfField?: {
  57553. circleOfConfusion: PostProcess;
  57554. blurSteps: Array<PostProcess>;
  57555. };
  57556. /**
  57557. * Parameters to perform the merge of bloom effect
  57558. */
  57559. bloom?: {
  57560. blurred: PostProcess;
  57561. weight: number;
  57562. };
  57563. }
  57564. /**
  57565. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57566. */
  57567. export class DepthOfFieldMergePostProcess extends PostProcess {
  57568. private blurSteps;
  57569. /**
  57570. * Creates a new instance of DepthOfFieldMergePostProcess
  57571. * @param name The name of the effect.
  57572. * @param originalFromInput Post process which's input will be used for the merge.
  57573. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  57574. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  57575. * @param options The required width/height ratio to downsize to before computing the render pass.
  57576. * @param camera The camera to apply the render pass to.
  57577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57578. * @param engine The engine which the post process will be applied. (default: current engine)
  57579. * @param reusable If the post process can be reused on the same frame. (default: false)
  57580. * @param textureType Type of textures used when performing the post process. (default: 0)
  57581. * @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)
  57582. */
  57583. 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);
  57584. /**
  57585. * Updates the effect with the current post process compile time values and recompiles the shader.
  57586. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  57587. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  57588. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  57589. * @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
  57590. * @param onCompiled Called when the shader has been compiled.
  57591. * @param onError Called if there is an error when compiling a shader.
  57592. */
  57593. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  57594. }
  57595. }
  57596. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  57597. import { Nullable } from "babylonjs/types";
  57598. import { Camera } from "babylonjs/Cameras/camera";
  57599. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57600. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57601. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57602. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57603. import { Scene } from "babylonjs/scene";
  57604. /**
  57605. * Specifies the level of max blur that should be applied when using the depth of field effect
  57606. */
  57607. export enum DepthOfFieldEffectBlurLevel {
  57608. /**
  57609. * Subtle blur
  57610. */
  57611. Low = 0,
  57612. /**
  57613. * Medium blur
  57614. */
  57615. Medium = 1,
  57616. /**
  57617. * Large blur
  57618. */
  57619. High = 2
  57620. }
  57621. /**
  57622. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57623. */
  57624. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57625. private _circleOfConfusion;
  57626. /**
  57627. * @hidden Internal, blurs from high to low
  57628. */
  57629. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57630. private _depthOfFieldBlurY;
  57631. private _dofMerge;
  57632. /**
  57633. * @hidden Internal post processes in depth of field effect
  57634. */
  57635. _effects: Array<PostProcess>;
  57636. /**
  57637. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57638. */
  57639. focalLength: number;
  57640. /**
  57641. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57642. */
  57643. fStop: number;
  57644. /**
  57645. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57646. */
  57647. focusDistance: number;
  57648. /**
  57649. * 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.
  57650. */
  57651. lensSize: number;
  57652. /**
  57653. * Creates a new instance DepthOfFieldEffect
  57654. * @param scene The scene the effect belongs to.
  57655. * @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.
  57656. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57657. * @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)
  57658. */
  57659. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57660. /**
  57661. * Get the current class name of the current effet
  57662. * @returns "DepthOfFieldEffect"
  57663. */
  57664. getClassName(): string;
  57665. /**
  57666. * 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.
  57667. */
  57668. depthTexture: RenderTargetTexture;
  57669. /**
  57670. * Disposes each of the internal effects for a given camera.
  57671. * @param camera The camera to dispose the effect on.
  57672. */
  57673. disposeEffects(camera: Camera): void;
  57674. /**
  57675. * @hidden Internal
  57676. */
  57677. _updateEffects(): void;
  57678. /**
  57679. * Internal
  57680. * @returns if all the contained post processes are ready.
  57681. * @hidden
  57682. */
  57683. _isReady(): boolean;
  57684. }
  57685. }
  57686. declare module "babylonjs/Shaders/displayPass.fragment" {
  57687. /** @hidden */
  57688. export var displayPassPixelShader: {
  57689. name: string;
  57690. shader: string;
  57691. };
  57692. }
  57693. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  57694. import { Nullable } from "babylonjs/types";
  57695. import { Camera } from "babylonjs/Cameras/camera";
  57696. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57697. import { Engine } from "babylonjs/Engines/engine";
  57698. import "babylonjs/Shaders/displayPass.fragment";
  57699. /**
  57700. * DisplayPassPostProcess which produces an output the same as it's input
  57701. */
  57702. export class DisplayPassPostProcess extends PostProcess {
  57703. /**
  57704. * Creates the DisplayPassPostProcess
  57705. * @param name The name of the effect.
  57706. * @param options The required width/height ratio to downsize to before computing the render pass.
  57707. * @param camera The camera to apply the render pass to.
  57708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57709. * @param engine The engine which the post process will be applied. (default: current engine)
  57710. * @param reusable If the post process can be reused on the same frame. (default: false)
  57711. */
  57712. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57713. }
  57714. }
  57715. declare module "babylonjs/Shaders/filter.fragment" {
  57716. /** @hidden */
  57717. export var filterPixelShader: {
  57718. name: string;
  57719. shader: string;
  57720. };
  57721. }
  57722. declare module "babylonjs/PostProcesses/filterPostProcess" {
  57723. import { Nullable } from "babylonjs/types";
  57724. import { Matrix } from "babylonjs/Maths/math";
  57725. import { Camera } from "babylonjs/Cameras/camera";
  57726. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57727. import { Engine } from "babylonjs/Engines/engine";
  57728. import "babylonjs/Shaders/filter.fragment";
  57729. /**
  57730. * Applies a kernel filter to the image
  57731. */
  57732. export class FilterPostProcess extends PostProcess {
  57733. /** The matrix to be applied to the image */
  57734. kernelMatrix: Matrix;
  57735. /**
  57736. *
  57737. * @param name The name of the effect.
  57738. * @param kernelMatrix The matrix to be applied to the image
  57739. * @param options The required width/height ratio to downsize to before computing the render pass.
  57740. * @param camera The camera to apply the render pass to.
  57741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57742. * @param engine The engine which the post process will be applied. (default: current engine)
  57743. * @param reusable If the post process can be reused on the same frame. (default: false)
  57744. */
  57745. constructor(name: string,
  57746. /** The matrix to be applied to the image */
  57747. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57748. }
  57749. }
  57750. declare module "babylonjs/Shaders/fxaa.fragment" {
  57751. /** @hidden */
  57752. export var fxaaPixelShader: {
  57753. name: string;
  57754. shader: string;
  57755. };
  57756. }
  57757. declare module "babylonjs/Shaders/fxaa.vertex" {
  57758. /** @hidden */
  57759. export var fxaaVertexShader: {
  57760. name: string;
  57761. shader: string;
  57762. };
  57763. }
  57764. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  57765. import { Nullable } from "babylonjs/types";
  57766. import { Camera } from "babylonjs/Cameras/camera";
  57767. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57768. import { Engine } from "babylonjs/Engines/engine";
  57769. import "babylonjs/Shaders/fxaa.fragment";
  57770. import "babylonjs/Shaders/fxaa.vertex";
  57771. /**
  57772. * Fxaa post process
  57773. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  57774. */
  57775. export class FxaaPostProcess extends PostProcess {
  57776. /** @hidden */
  57777. texelWidth: number;
  57778. /** @hidden */
  57779. texelHeight: number;
  57780. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57781. private _getDefines;
  57782. }
  57783. }
  57784. declare module "babylonjs/Shaders/grain.fragment" {
  57785. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57786. /** @hidden */
  57787. export var grainPixelShader: {
  57788. name: string;
  57789. shader: string;
  57790. };
  57791. }
  57792. declare module "babylonjs/PostProcesses/grainPostProcess" {
  57793. import { Nullable } from "babylonjs/types";
  57794. import { Camera } from "babylonjs/Cameras/camera";
  57795. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57796. import { Engine } from "babylonjs/Engines/engine";
  57797. import "babylonjs/Shaders/grain.fragment";
  57798. /**
  57799. * The GrainPostProcess adds noise to the image at mid luminance levels
  57800. */
  57801. export class GrainPostProcess extends PostProcess {
  57802. /**
  57803. * The intensity of the grain added (default: 30)
  57804. */
  57805. intensity: number;
  57806. /**
  57807. * If the grain should be randomized on every frame
  57808. */
  57809. animated: boolean;
  57810. /**
  57811. * Creates a new instance of @see GrainPostProcess
  57812. * @param name The name of the effect.
  57813. * @param options The required width/height ratio to downsize to before computing the render pass.
  57814. * @param camera The camera to apply the render pass to.
  57815. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57816. * @param engine The engine which the post process will be applied. (default: current engine)
  57817. * @param reusable If the post process can be reused on the same frame. (default: false)
  57818. * @param textureType Type of textures used when performing the post process. (default: 0)
  57819. * @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)
  57820. */
  57821. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57822. }
  57823. }
  57824. declare module "babylonjs/Shaders/highlights.fragment" {
  57825. /** @hidden */
  57826. export var highlightsPixelShader: {
  57827. name: string;
  57828. shader: string;
  57829. };
  57830. }
  57831. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  57832. import { Nullable } from "babylonjs/types";
  57833. import { Camera } from "babylonjs/Cameras/camera";
  57834. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57835. import { Engine } from "babylonjs/Engines/engine";
  57836. import "babylonjs/Shaders/highlights.fragment";
  57837. /**
  57838. * Extracts highlights from the image
  57839. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57840. */
  57841. export class HighlightsPostProcess extends PostProcess {
  57842. /**
  57843. * Extracts highlights from the image
  57844. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57845. * @param name The name of the effect.
  57846. * @param options The required width/height ratio to downsize to before computing the render pass.
  57847. * @param camera The camera to apply the render pass to.
  57848. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57849. * @param engine The engine which the post process will be applied. (default: current engine)
  57850. * @param reusable If the post process can be reused on the same frame. (default: false)
  57851. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  57852. */
  57853. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57854. }
  57855. }
  57856. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  57857. /** @hidden */
  57858. export var mrtFragmentDeclaration: {
  57859. name: string;
  57860. shader: string;
  57861. };
  57862. }
  57863. declare module "babylonjs/Shaders/geometry.fragment" {
  57864. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  57865. /** @hidden */
  57866. export var geometryPixelShader: {
  57867. name: string;
  57868. shader: string;
  57869. };
  57870. }
  57871. declare module "babylonjs/Shaders/geometry.vertex" {
  57872. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57873. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57874. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57875. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57876. /** @hidden */
  57877. export var geometryVertexShader: {
  57878. name: string;
  57879. shader: string;
  57880. };
  57881. }
  57882. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  57883. import { Matrix } from "babylonjs/Maths/math";
  57884. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57885. import { Mesh } from "babylonjs/Meshes/mesh";
  57886. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  57887. import { Effect } from "babylonjs/Materials/effect";
  57888. import { Scene } from "babylonjs/scene";
  57889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57890. import "babylonjs/Shaders/geometry.fragment";
  57891. import "babylonjs/Shaders/geometry.vertex";
  57892. /** @hidden */
  57893. interface ISavedTransformationMatrix {
  57894. world: Matrix;
  57895. viewProjection: Matrix;
  57896. }
  57897. /**
  57898. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  57899. */
  57900. export class GeometryBufferRenderer {
  57901. /**
  57902. * Constant used to retrieve the position texture index in the G-Buffer textures array
  57903. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  57904. */
  57905. static readonly POSITION_TEXTURE_TYPE: number;
  57906. /**
  57907. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  57908. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  57909. */
  57910. static readonly VELOCITY_TEXTURE_TYPE: number;
  57911. /**
  57912. * Dictionary used to store the previous transformation matrices of each rendered mesh
  57913. * in order to compute objects velocities when enableVelocity is set to "true"
  57914. * @hidden
  57915. */
  57916. _previousTransformationMatrices: {
  57917. [index: number]: ISavedTransformationMatrix;
  57918. };
  57919. /**
  57920. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  57921. * in order to compute objects velocities when enableVelocity is set to "true"
  57922. * @hidden
  57923. */
  57924. _previousBonesTransformationMatrices: {
  57925. [index: number]: Float32Array;
  57926. };
  57927. /**
  57928. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  57929. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  57930. */
  57931. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  57932. private _scene;
  57933. private _multiRenderTarget;
  57934. private _ratio;
  57935. private _enablePosition;
  57936. private _enableVelocity;
  57937. private _positionIndex;
  57938. private _velocityIndex;
  57939. protected _effect: Effect;
  57940. protected _cachedDefines: string;
  57941. /**
  57942. * Set the render list (meshes to be rendered) used in the G buffer.
  57943. */
  57944. renderList: Mesh[];
  57945. /**
  57946. * Gets wether or not G buffer are supported by the running hardware.
  57947. * This requires draw buffer supports
  57948. */
  57949. readonly isSupported: boolean;
  57950. /**
  57951. * Returns the index of the given texture type in the G-Buffer textures array
  57952. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  57953. * @returns the index of the given texture type in the G-Buffer textures array
  57954. */
  57955. getTextureIndex(textureType: number): number;
  57956. /**
  57957. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  57958. */
  57959. /**
  57960. * Sets whether or not objects positions are enabled for the G buffer.
  57961. */
  57962. enablePosition: boolean;
  57963. /**
  57964. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  57965. */
  57966. /**
  57967. * Sets wether or not objects velocities are enabled for the G buffer.
  57968. */
  57969. enableVelocity: boolean;
  57970. /**
  57971. * Gets the scene associated with the buffer.
  57972. */
  57973. readonly scene: Scene;
  57974. /**
  57975. * Gets the ratio used by the buffer during its creation.
  57976. * How big is the buffer related to the main canvas.
  57977. */
  57978. readonly ratio: number;
  57979. /** @hidden */
  57980. static _SceneComponentInitialization: (scene: Scene) => void;
  57981. /**
  57982. * Creates a new G Buffer for the scene
  57983. * @param scene The scene the buffer belongs to
  57984. * @param ratio How big is the buffer related to the main canvas.
  57985. */
  57986. constructor(scene: Scene, ratio?: number);
  57987. /**
  57988. * Checks wether everything is ready to render a submesh to the G buffer.
  57989. * @param subMesh the submesh to check readiness for
  57990. * @param useInstances is the mesh drawn using instance or not
  57991. * @returns true if ready otherwise false
  57992. */
  57993. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57994. /**
  57995. * Gets the current underlying G Buffer.
  57996. * @returns the buffer
  57997. */
  57998. getGBuffer(): MultiRenderTarget;
  57999. /**
  58000. * Gets the number of samples used to render the buffer (anti aliasing).
  58001. */
  58002. /**
  58003. * Sets the number of samples used to render the buffer (anti aliasing).
  58004. */
  58005. samples: number;
  58006. /**
  58007. * Disposes the renderer and frees up associated resources.
  58008. */
  58009. dispose(): void;
  58010. protected _createRenderTargets(): void;
  58011. private _copyBonesTransformationMatrices;
  58012. }
  58013. }
  58014. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  58015. import { Nullable } from "babylonjs/types";
  58016. import { Scene } from "babylonjs/scene";
  58017. import { ISceneComponent } from "babylonjs/sceneComponent";
  58018. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  58019. module "babylonjs/scene" {
  58020. interface Scene {
  58021. /** @hidden (Backing field) */
  58022. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58023. /**
  58024. * Gets or Sets the current geometry buffer associated to the scene.
  58025. */
  58026. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58027. /**
  58028. * Enables a GeometryBufferRender and associates it with the scene
  58029. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58030. * @returns the GeometryBufferRenderer
  58031. */
  58032. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58033. /**
  58034. * Disables the GeometryBufferRender associated with the scene
  58035. */
  58036. disableGeometryBufferRenderer(): void;
  58037. }
  58038. }
  58039. /**
  58040. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58041. * in several rendering techniques.
  58042. */
  58043. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58044. /**
  58045. * The component name helpful to identify the component in the list of scene components.
  58046. */
  58047. readonly name: string;
  58048. /**
  58049. * The scene the component belongs to.
  58050. */
  58051. scene: Scene;
  58052. /**
  58053. * Creates a new instance of the component for the given scene
  58054. * @param scene Defines the scene to register the component in
  58055. */
  58056. constructor(scene: Scene);
  58057. /**
  58058. * Registers the component in a given scene
  58059. */
  58060. register(): void;
  58061. /**
  58062. * Rebuilds the elements related to this component in case of
  58063. * context lost for instance.
  58064. */
  58065. rebuild(): void;
  58066. /**
  58067. * Disposes the component and the associated ressources
  58068. */
  58069. dispose(): void;
  58070. private _gatherRenderTargets;
  58071. }
  58072. }
  58073. declare module "babylonjs/Shaders/motionBlur.fragment" {
  58074. /** @hidden */
  58075. export var motionBlurPixelShader: {
  58076. name: string;
  58077. shader: string;
  58078. };
  58079. }
  58080. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  58081. import { Nullable } from "babylonjs/types";
  58082. import { Camera } from "babylonjs/Cameras/camera";
  58083. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58084. import { Scene } from "babylonjs/scene";
  58085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58086. import "babylonjs/Animations/animatable";
  58087. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  58088. import "babylonjs/Shaders/motionBlur.fragment";
  58089. import { Engine } from "babylonjs/Engines/engine";
  58090. /**
  58091. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58092. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58093. * As an example, all you have to do is to create the post-process:
  58094. * var mb = new BABYLON.MotionBlurPostProcess(
  58095. * 'mb', // The name of the effect.
  58096. * scene, // The scene containing the objects to blur according to their velocity.
  58097. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58098. * camera // The camera to apply the render pass to.
  58099. * );
  58100. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58101. */
  58102. export class MotionBlurPostProcess extends PostProcess {
  58103. /**
  58104. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58105. */
  58106. motionStrength: number;
  58107. /**
  58108. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58109. */
  58110. /**
  58111. * Sets the number of iterations to be used for motion blur quality
  58112. */
  58113. motionBlurSamples: number;
  58114. private _motionBlurSamples;
  58115. private _geometryBufferRenderer;
  58116. /**
  58117. * Creates a new instance MotionBlurPostProcess
  58118. * @param name The name of the effect.
  58119. * @param scene The scene containing the objects to blur according to their velocity.
  58120. * @param options The required width/height ratio to downsize to before computing the render pass.
  58121. * @param camera The camera to apply the render pass to.
  58122. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58123. * @param engine The engine which the post process will be applied. (default: current engine)
  58124. * @param reusable If the post process can be reused on the same frame. (default: false)
  58125. * @param textureType Type of textures used when performing the post process. (default: 0)
  58126. * @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)
  58127. */
  58128. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58129. /**
  58130. * Excludes the given skinned mesh from computing bones velocities.
  58131. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  58132. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58133. */
  58134. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58135. /**
  58136. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58137. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58138. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58139. */
  58140. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58141. /**
  58142. * Disposes the post process.
  58143. * @param camera The camera to dispose the post process on.
  58144. */
  58145. dispose(camera?: Camera): void;
  58146. }
  58147. }
  58148. declare module "babylonjs/Shaders/refraction.fragment" {
  58149. /** @hidden */
  58150. export var refractionPixelShader: {
  58151. name: string;
  58152. shader: string;
  58153. };
  58154. }
  58155. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  58156. import { Color3 } from "babylonjs/Maths/math";
  58157. import { Camera } from "babylonjs/Cameras/camera";
  58158. import { Texture } from "babylonjs/Materials/Textures/texture";
  58159. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58160. import { Engine } from "babylonjs/Engines/engine";
  58161. import "babylonjs/Shaders/refraction.fragment";
  58162. /**
  58163. * Post process which applies a refractin texture
  58164. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58165. */
  58166. export class RefractionPostProcess extends PostProcess {
  58167. /** the base color of the refraction (used to taint the rendering) */
  58168. color: Color3;
  58169. /** simulated refraction depth */
  58170. depth: number;
  58171. /** the coefficient of the base color (0 to remove base color tainting) */
  58172. colorLevel: number;
  58173. private _refTexture;
  58174. private _ownRefractionTexture;
  58175. /**
  58176. * Gets or sets the refraction texture
  58177. * Please note that you are responsible for disposing the texture if you set it manually
  58178. */
  58179. refractionTexture: Texture;
  58180. /**
  58181. * Initializes the RefractionPostProcess
  58182. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58183. * @param name The name of the effect.
  58184. * @param refractionTextureUrl Url of the refraction texture to use
  58185. * @param color the base color of the refraction (used to taint the rendering)
  58186. * @param depth simulated refraction depth
  58187. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58188. * @param camera The camera to apply the render pass to.
  58189. * @param options The required width/height ratio to downsize to before computing the render pass.
  58190. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58191. * @param engine The engine which the post process will be applied. (default: current engine)
  58192. * @param reusable If the post process can be reused on the same frame. (default: false)
  58193. */
  58194. constructor(name: string, refractionTextureUrl: string,
  58195. /** the base color of the refraction (used to taint the rendering) */
  58196. color: Color3,
  58197. /** simulated refraction depth */
  58198. depth: number,
  58199. /** the coefficient of the base color (0 to remove base color tainting) */
  58200. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58201. /**
  58202. * Disposes of the post process
  58203. * @param camera Camera to dispose post process on
  58204. */
  58205. dispose(camera: Camera): void;
  58206. }
  58207. }
  58208. declare module "babylonjs/Shaders/sharpen.fragment" {
  58209. /** @hidden */
  58210. export var sharpenPixelShader: {
  58211. name: string;
  58212. shader: string;
  58213. };
  58214. }
  58215. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  58216. import { Nullable } from "babylonjs/types";
  58217. import { Camera } from "babylonjs/Cameras/camera";
  58218. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58219. import "babylonjs/Shaders/sharpen.fragment";
  58220. import { Engine } from "babylonjs/Engines/engine";
  58221. /**
  58222. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58223. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58224. */
  58225. export class SharpenPostProcess extends PostProcess {
  58226. /**
  58227. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58228. */
  58229. colorAmount: number;
  58230. /**
  58231. * How much sharpness should be applied (default: 0.3)
  58232. */
  58233. edgeAmount: number;
  58234. /**
  58235. * Creates a new instance ConvolutionPostProcess
  58236. * @param name The name of the effect.
  58237. * @param options The required width/height ratio to downsize to before computing the render pass.
  58238. * @param camera The camera to apply the render pass to.
  58239. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58240. * @param engine The engine which the post process will be applied. (default: current engine)
  58241. * @param reusable If the post process can be reused on the same frame. (default: false)
  58242. * @param textureType Type of textures used when performing the post process. (default: 0)
  58243. * @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)
  58244. */
  58245. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58246. }
  58247. }
  58248. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  58249. import { Nullable } from "babylonjs/types";
  58250. import { Camera } from "babylonjs/Cameras/camera";
  58251. import { Engine } from "babylonjs/Engines/engine";
  58252. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58253. import { IInspectable } from "babylonjs/Misc/iInspectable";
  58254. /**
  58255. * PostProcessRenderPipeline
  58256. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58257. */
  58258. export class PostProcessRenderPipeline {
  58259. private engine;
  58260. private _renderEffects;
  58261. private _renderEffectsForIsolatedPass;
  58262. /**
  58263. * List of inspectable custom properties (used by the Inspector)
  58264. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58265. */
  58266. inspectableCustomProperties: IInspectable[];
  58267. /**
  58268. * @hidden
  58269. */
  58270. protected _cameras: Camera[];
  58271. /** @hidden */
  58272. _name: string;
  58273. /**
  58274. * Gets pipeline name
  58275. */
  58276. readonly name: string;
  58277. /**
  58278. * Initializes a PostProcessRenderPipeline
  58279. * @param engine engine to add the pipeline to
  58280. * @param name name of the pipeline
  58281. */
  58282. constructor(engine: Engine, name: string);
  58283. /**
  58284. * Gets the class name
  58285. * @returns "PostProcessRenderPipeline"
  58286. */
  58287. getClassName(): string;
  58288. /**
  58289. * If all the render effects in the pipeline are supported
  58290. */
  58291. readonly isSupported: boolean;
  58292. /**
  58293. * Adds an effect to the pipeline
  58294. * @param renderEffect the effect to add
  58295. */
  58296. addEffect(renderEffect: PostProcessRenderEffect): void;
  58297. /** @hidden */
  58298. _rebuild(): void;
  58299. /** @hidden */
  58300. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58301. /** @hidden */
  58302. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58303. /** @hidden */
  58304. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58305. /** @hidden */
  58306. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58307. /** @hidden */
  58308. _attachCameras(cameras: Camera, unique: boolean): void;
  58309. /** @hidden */
  58310. _attachCameras(cameras: Camera[], unique: boolean): void;
  58311. /** @hidden */
  58312. _detachCameras(cameras: Camera): void;
  58313. /** @hidden */
  58314. _detachCameras(cameras: Nullable<Camera[]>): void;
  58315. /** @hidden */
  58316. _update(): void;
  58317. /** @hidden */
  58318. _reset(): void;
  58319. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58320. /**
  58321. * Disposes of the pipeline
  58322. */
  58323. dispose(): void;
  58324. }
  58325. }
  58326. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  58327. import { Camera } from "babylonjs/Cameras/camera";
  58328. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58329. /**
  58330. * PostProcessRenderPipelineManager class
  58331. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58332. */
  58333. export class PostProcessRenderPipelineManager {
  58334. private _renderPipelines;
  58335. /**
  58336. * Initializes a PostProcessRenderPipelineManager
  58337. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58338. */
  58339. constructor();
  58340. /**
  58341. * Gets the list of supported render pipelines
  58342. */
  58343. readonly supportedPipelines: PostProcessRenderPipeline[];
  58344. /**
  58345. * Adds a pipeline to the manager
  58346. * @param renderPipeline The pipeline to add
  58347. */
  58348. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58349. /**
  58350. * Attaches a camera to the pipeline
  58351. * @param renderPipelineName The name of the pipeline to attach to
  58352. * @param cameras the camera to attach
  58353. * @param unique if the camera can be attached multiple times to the pipeline
  58354. */
  58355. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58356. /**
  58357. * Detaches a camera from the pipeline
  58358. * @param renderPipelineName The name of the pipeline to detach from
  58359. * @param cameras the camera to detach
  58360. */
  58361. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58362. /**
  58363. * Enables an effect by name on a pipeline
  58364. * @param renderPipelineName the name of the pipeline to enable the effect in
  58365. * @param renderEffectName the name of the effect to enable
  58366. * @param cameras the cameras that the effect should be enabled on
  58367. */
  58368. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58369. /**
  58370. * Disables an effect by name on a pipeline
  58371. * @param renderPipelineName the name of the pipeline to disable the effect in
  58372. * @param renderEffectName the name of the effect to disable
  58373. * @param cameras the cameras that the effect should be disabled on
  58374. */
  58375. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58376. /**
  58377. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58378. */
  58379. update(): void;
  58380. /** @hidden */
  58381. _rebuild(): void;
  58382. /**
  58383. * Disposes of the manager and pipelines
  58384. */
  58385. dispose(): void;
  58386. }
  58387. }
  58388. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  58389. import { ISceneComponent } from "babylonjs/sceneComponent";
  58390. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  58391. import { Scene } from "babylonjs/scene";
  58392. module "babylonjs/scene" {
  58393. interface Scene {
  58394. /** @hidden (Backing field) */
  58395. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58396. /**
  58397. * Gets the postprocess render pipeline manager
  58398. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58399. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58400. */
  58401. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58402. }
  58403. }
  58404. /**
  58405. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58406. */
  58407. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58408. /**
  58409. * The component name helpfull to identify the component in the list of scene components.
  58410. */
  58411. readonly name: string;
  58412. /**
  58413. * The scene the component belongs to.
  58414. */
  58415. scene: Scene;
  58416. /**
  58417. * Creates a new instance of the component for the given scene
  58418. * @param scene Defines the scene to register the component in
  58419. */
  58420. constructor(scene: Scene);
  58421. /**
  58422. * Registers the component in a given scene
  58423. */
  58424. register(): void;
  58425. /**
  58426. * Rebuilds the elements related to this component in case of
  58427. * context lost for instance.
  58428. */
  58429. rebuild(): void;
  58430. /**
  58431. * Disposes the component and the associated ressources
  58432. */
  58433. dispose(): void;
  58434. private _gatherRenderTargets;
  58435. }
  58436. }
  58437. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  58438. import { Nullable } from "babylonjs/types";
  58439. import { IAnimatable } from "babylonjs/Misc/tools";
  58440. import { Camera } from "babylonjs/Cameras/camera";
  58441. import { IDisposable } from "babylonjs/scene";
  58442. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  58443. import { Scene } from "babylonjs/scene";
  58444. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  58445. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  58446. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  58447. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  58448. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  58449. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58450. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  58451. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  58452. import { Animation } from "babylonjs/Animations/animation";
  58453. /**
  58454. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58455. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58456. */
  58457. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58458. private _scene;
  58459. private _camerasToBeAttached;
  58460. /**
  58461. * ID of the sharpen post process,
  58462. */
  58463. private readonly SharpenPostProcessId;
  58464. /**
  58465. * @ignore
  58466. * ID of the image processing post process;
  58467. */
  58468. readonly ImageProcessingPostProcessId: string;
  58469. /**
  58470. * @ignore
  58471. * ID of the Fast Approximate Anti-Aliasing post process;
  58472. */
  58473. readonly FxaaPostProcessId: string;
  58474. /**
  58475. * ID of the chromatic aberration post process,
  58476. */
  58477. private readonly ChromaticAberrationPostProcessId;
  58478. /**
  58479. * ID of the grain post process
  58480. */
  58481. private readonly GrainPostProcessId;
  58482. /**
  58483. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58484. */
  58485. sharpen: SharpenPostProcess;
  58486. private _sharpenEffect;
  58487. private bloom;
  58488. /**
  58489. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58490. */
  58491. depthOfField: DepthOfFieldEffect;
  58492. /**
  58493. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58494. */
  58495. fxaa: FxaaPostProcess;
  58496. /**
  58497. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58498. */
  58499. imageProcessing: ImageProcessingPostProcess;
  58500. /**
  58501. * Chromatic aberration post process which will shift rgb colors in the image
  58502. */
  58503. chromaticAberration: ChromaticAberrationPostProcess;
  58504. private _chromaticAberrationEffect;
  58505. /**
  58506. * Grain post process which add noise to the image
  58507. */
  58508. grain: GrainPostProcess;
  58509. private _grainEffect;
  58510. /**
  58511. * Glow post process which adds a glow to emissive areas of the image
  58512. */
  58513. private _glowLayer;
  58514. /**
  58515. * Animations which can be used to tweak settings over a period of time
  58516. */
  58517. animations: Animation[];
  58518. private _imageProcessingConfigurationObserver;
  58519. private _sharpenEnabled;
  58520. private _bloomEnabled;
  58521. private _depthOfFieldEnabled;
  58522. private _depthOfFieldBlurLevel;
  58523. private _fxaaEnabled;
  58524. private _imageProcessingEnabled;
  58525. private _defaultPipelineTextureType;
  58526. private _bloomScale;
  58527. private _chromaticAberrationEnabled;
  58528. private _grainEnabled;
  58529. private _buildAllowed;
  58530. /**
  58531. * Gets active scene
  58532. */
  58533. readonly scene: Scene;
  58534. /**
  58535. * Enable or disable the sharpen process from the pipeline
  58536. */
  58537. sharpenEnabled: boolean;
  58538. private _resizeObserver;
  58539. private _hardwareScaleLevel;
  58540. private _bloomKernel;
  58541. /**
  58542. * Specifies the size of the bloom blur kernel, relative to the final output size
  58543. */
  58544. bloomKernel: number;
  58545. /**
  58546. * Specifies the weight of the bloom in the final rendering
  58547. */
  58548. private _bloomWeight;
  58549. /**
  58550. * Specifies the luma threshold for the area that will be blurred by the bloom
  58551. */
  58552. private _bloomThreshold;
  58553. private _hdr;
  58554. /**
  58555. * The strength of the bloom.
  58556. */
  58557. bloomWeight: number;
  58558. /**
  58559. * The strength of the bloom.
  58560. */
  58561. bloomThreshold: number;
  58562. /**
  58563. * The scale of the bloom, lower value will provide better performance.
  58564. */
  58565. bloomScale: number;
  58566. /**
  58567. * Enable or disable the bloom from the pipeline
  58568. */
  58569. bloomEnabled: boolean;
  58570. private _rebuildBloom;
  58571. /**
  58572. * If the depth of field is enabled.
  58573. */
  58574. depthOfFieldEnabled: boolean;
  58575. /**
  58576. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58577. */
  58578. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58579. /**
  58580. * If the anti aliasing is enabled.
  58581. */
  58582. fxaaEnabled: boolean;
  58583. private _samples;
  58584. /**
  58585. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58586. */
  58587. samples: number;
  58588. /**
  58589. * If image processing is enabled.
  58590. */
  58591. imageProcessingEnabled: boolean;
  58592. /**
  58593. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58594. */
  58595. glowLayerEnabled: boolean;
  58596. /**
  58597. * Gets the glow layer (or null if not defined)
  58598. */
  58599. readonly glowLayer: Nullable<GlowLayer>;
  58600. /**
  58601. * Enable or disable the chromaticAberration process from the pipeline
  58602. */
  58603. chromaticAberrationEnabled: boolean;
  58604. /**
  58605. * Enable or disable the grain process from the pipeline
  58606. */
  58607. grainEnabled: boolean;
  58608. /**
  58609. * @constructor
  58610. * @param name - The rendering pipeline name (default: "")
  58611. * @param hdr - If high dynamic range textures should be used (default: true)
  58612. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58613. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58614. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58615. */
  58616. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58617. /**
  58618. * Get the class name
  58619. * @returns "DefaultRenderingPipeline"
  58620. */
  58621. getClassName(): string;
  58622. /**
  58623. * Force the compilation of the entire pipeline.
  58624. */
  58625. prepare(): void;
  58626. private _hasCleared;
  58627. private _prevPostProcess;
  58628. private _prevPrevPostProcess;
  58629. private _setAutoClearAndTextureSharing;
  58630. private _depthOfFieldSceneObserver;
  58631. private _buildPipeline;
  58632. private _disposePostProcesses;
  58633. /**
  58634. * Adds a camera to the pipeline
  58635. * @param camera the camera to be added
  58636. */
  58637. addCamera(camera: Camera): void;
  58638. /**
  58639. * Removes a camera from the pipeline
  58640. * @param camera the camera to remove
  58641. */
  58642. removeCamera(camera: Camera): void;
  58643. /**
  58644. * Dispose of the pipeline and stop all post processes
  58645. */
  58646. dispose(): void;
  58647. /**
  58648. * Serialize the rendering pipeline (Used when exporting)
  58649. * @returns the serialized object
  58650. */
  58651. serialize(): any;
  58652. /**
  58653. * Parse the serialized pipeline
  58654. * @param source Source pipeline.
  58655. * @param scene The scene to load the pipeline to.
  58656. * @param rootUrl The URL of the serialized pipeline.
  58657. * @returns An instantiated pipeline from the serialized object.
  58658. */
  58659. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58660. }
  58661. }
  58662. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  58663. /** @hidden */
  58664. export var lensHighlightsPixelShader: {
  58665. name: string;
  58666. shader: string;
  58667. };
  58668. }
  58669. declare module "babylonjs/Shaders/depthOfField.fragment" {
  58670. /** @hidden */
  58671. export var depthOfFieldPixelShader: {
  58672. name: string;
  58673. shader: string;
  58674. };
  58675. }
  58676. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  58677. import { Camera } from "babylonjs/Cameras/camera";
  58678. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58679. import { Scene } from "babylonjs/scene";
  58680. import "babylonjs/Shaders/chromaticAberration.fragment";
  58681. import "babylonjs/Shaders/lensHighlights.fragment";
  58682. import "babylonjs/Shaders/depthOfField.fragment";
  58683. /**
  58684. * BABYLON.JS Chromatic Aberration GLSL Shader
  58685. * Author: Olivier Guyot
  58686. * Separates very slightly R, G and B colors on the edges of the screen
  58687. * Inspired by Francois Tarlier & Martins Upitis
  58688. */
  58689. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  58690. /**
  58691. * @ignore
  58692. * The chromatic aberration PostProcess id in the pipeline
  58693. */
  58694. LensChromaticAberrationEffect: string;
  58695. /**
  58696. * @ignore
  58697. * The highlights enhancing PostProcess id in the pipeline
  58698. */
  58699. HighlightsEnhancingEffect: string;
  58700. /**
  58701. * @ignore
  58702. * The depth-of-field PostProcess id in the pipeline
  58703. */
  58704. LensDepthOfFieldEffect: string;
  58705. private _scene;
  58706. private _depthTexture;
  58707. private _grainTexture;
  58708. private _chromaticAberrationPostProcess;
  58709. private _highlightsPostProcess;
  58710. private _depthOfFieldPostProcess;
  58711. private _edgeBlur;
  58712. private _grainAmount;
  58713. private _chromaticAberration;
  58714. private _distortion;
  58715. private _highlightsGain;
  58716. private _highlightsThreshold;
  58717. private _dofDistance;
  58718. private _dofAperture;
  58719. private _dofDarken;
  58720. private _dofPentagon;
  58721. private _blurNoise;
  58722. /**
  58723. * @constructor
  58724. *
  58725. * Effect parameters are as follow:
  58726. * {
  58727. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58728. * edge_blur: number; // from 0 to x (1 for realism)
  58729. * distortion: number; // from 0 to x (1 for realism)
  58730. * grain_amount: number; // from 0 to 1
  58731. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58732. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58733. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58734. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58735. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58736. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  58737. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  58738. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  58739. * }
  58740. * Note: if an effect parameter is unset, effect is disabled
  58741. *
  58742. * @param name The rendering pipeline name
  58743. * @param parameters - An object containing all parameters (see above)
  58744. * @param scene The scene linked to this pipeline
  58745. * @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)
  58746. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58747. */
  58748. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  58749. /**
  58750. * Get the class name
  58751. * @returns "LensRenderingPipeline"
  58752. */
  58753. getClassName(): string;
  58754. /**
  58755. * Gets associated scene
  58756. */
  58757. readonly scene: Scene;
  58758. /**
  58759. * Gets or sets the edge blur
  58760. */
  58761. edgeBlur: number;
  58762. /**
  58763. * Gets or sets the grain amount
  58764. */
  58765. grainAmount: number;
  58766. /**
  58767. * Gets or sets the chromatic aberration amount
  58768. */
  58769. chromaticAberration: number;
  58770. /**
  58771. * Gets or sets the depth of field aperture
  58772. */
  58773. dofAperture: number;
  58774. /**
  58775. * Gets or sets the edge distortion
  58776. */
  58777. edgeDistortion: number;
  58778. /**
  58779. * Gets or sets the depth of field distortion
  58780. */
  58781. dofDistortion: number;
  58782. /**
  58783. * Gets or sets the darken out of focus amount
  58784. */
  58785. darkenOutOfFocus: number;
  58786. /**
  58787. * Gets or sets a boolean indicating if blur noise is enabled
  58788. */
  58789. blurNoise: boolean;
  58790. /**
  58791. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  58792. */
  58793. pentagonBokeh: boolean;
  58794. /**
  58795. * Gets or sets the highlight grain amount
  58796. */
  58797. highlightsGain: number;
  58798. /**
  58799. * Gets or sets the highlight threshold
  58800. */
  58801. highlightsThreshold: number;
  58802. /**
  58803. * Sets the amount of blur at the edges
  58804. * @param amount blur amount
  58805. */
  58806. setEdgeBlur(amount: number): void;
  58807. /**
  58808. * Sets edge blur to 0
  58809. */
  58810. disableEdgeBlur(): void;
  58811. /**
  58812. * Sets the amout of grain
  58813. * @param amount Amount of grain
  58814. */
  58815. setGrainAmount(amount: number): void;
  58816. /**
  58817. * Set grain amount to 0
  58818. */
  58819. disableGrain(): void;
  58820. /**
  58821. * Sets the chromatic aberration amount
  58822. * @param amount amount of chromatic aberration
  58823. */
  58824. setChromaticAberration(amount: number): void;
  58825. /**
  58826. * Sets chromatic aberration amount to 0
  58827. */
  58828. disableChromaticAberration(): void;
  58829. /**
  58830. * Sets the EdgeDistortion amount
  58831. * @param amount amount of EdgeDistortion
  58832. */
  58833. setEdgeDistortion(amount: number): void;
  58834. /**
  58835. * Sets edge distortion to 0
  58836. */
  58837. disableEdgeDistortion(): void;
  58838. /**
  58839. * Sets the FocusDistance amount
  58840. * @param amount amount of FocusDistance
  58841. */
  58842. setFocusDistance(amount: number): void;
  58843. /**
  58844. * Disables depth of field
  58845. */
  58846. disableDepthOfField(): void;
  58847. /**
  58848. * Sets the Aperture amount
  58849. * @param amount amount of Aperture
  58850. */
  58851. setAperture(amount: number): void;
  58852. /**
  58853. * Sets the DarkenOutOfFocus amount
  58854. * @param amount amount of DarkenOutOfFocus
  58855. */
  58856. setDarkenOutOfFocus(amount: number): void;
  58857. private _pentagonBokehIsEnabled;
  58858. /**
  58859. * Creates a pentagon bokeh effect
  58860. */
  58861. enablePentagonBokeh(): void;
  58862. /**
  58863. * Disables the pentagon bokeh effect
  58864. */
  58865. disablePentagonBokeh(): void;
  58866. /**
  58867. * Enables noise blur
  58868. */
  58869. enableNoiseBlur(): void;
  58870. /**
  58871. * Disables noise blur
  58872. */
  58873. disableNoiseBlur(): void;
  58874. /**
  58875. * Sets the HighlightsGain amount
  58876. * @param amount amount of HighlightsGain
  58877. */
  58878. setHighlightsGain(amount: number): void;
  58879. /**
  58880. * Sets the HighlightsThreshold amount
  58881. * @param amount amount of HighlightsThreshold
  58882. */
  58883. setHighlightsThreshold(amount: number): void;
  58884. /**
  58885. * Disables highlights
  58886. */
  58887. disableHighlights(): void;
  58888. /**
  58889. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  58890. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  58891. */
  58892. dispose(disableDepthRender?: boolean): void;
  58893. private _createChromaticAberrationPostProcess;
  58894. private _createHighlightsPostProcess;
  58895. private _createDepthOfFieldPostProcess;
  58896. private _createGrainTexture;
  58897. }
  58898. }
  58899. declare module "babylonjs/Shaders/ssao2.fragment" {
  58900. /** @hidden */
  58901. export var ssao2PixelShader: {
  58902. name: string;
  58903. shader: string;
  58904. };
  58905. }
  58906. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  58907. /** @hidden */
  58908. export var ssaoCombinePixelShader: {
  58909. name: string;
  58910. shader: string;
  58911. };
  58912. }
  58913. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  58914. import { Camera } from "babylonjs/Cameras/camera";
  58915. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58916. import { Scene } from "babylonjs/scene";
  58917. import "babylonjs/Shaders/ssao2.fragment";
  58918. import "babylonjs/Shaders/ssaoCombine.fragment";
  58919. /**
  58920. * Render pipeline to produce ssao effect
  58921. */
  58922. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  58923. /**
  58924. * @ignore
  58925. * The PassPostProcess id in the pipeline that contains the original scene color
  58926. */
  58927. SSAOOriginalSceneColorEffect: string;
  58928. /**
  58929. * @ignore
  58930. * The SSAO PostProcess id in the pipeline
  58931. */
  58932. SSAORenderEffect: string;
  58933. /**
  58934. * @ignore
  58935. * The horizontal blur PostProcess id in the pipeline
  58936. */
  58937. SSAOBlurHRenderEffect: string;
  58938. /**
  58939. * @ignore
  58940. * The vertical blur PostProcess id in the pipeline
  58941. */
  58942. SSAOBlurVRenderEffect: string;
  58943. /**
  58944. * @ignore
  58945. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58946. */
  58947. SSAOCombineRenderEffect: string;
  58948. /**
  58949. * The output strength of the SSAO post-process. Default value is 1.0.
  58950. */
  58951. totalStrength: number;
  58952. /**
  58953. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  58954. */
  58955. maxZ: number;
  58956. /**
  58957. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  58958. */
  58959. minZAspect: number;
  58960. private _samples;
  58961. /**
  58962. * Number of samples used for the SSAO calculations. Default value is 8
  58963. */
  58964. samples: number;
  58965. private _textureSamples;
  58966. /**
  58967. * Number of samples to use for antialiasing
  58968. */
  58969. textureSamples: number;
  58970. /**
  58971. * Ratio object used for SSAO ratio and blur ratio
  58972. */
  58973. private _ratio;
  58974. /**
  58975. * Dynamically generated sphere sampler.
  58976. */
  58977. private _sampleSphere;
  58978. /**
  58979. * Blur filter offsets
  58980. */
  58981. private _samplerOffsets;
  58982. private _expensiveBlur;
  58983. /**
  58984. * If bilateral blur should be used
  58985. */
  58986. expensiveBlur: boolean;
  58987. /**
  58988. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  58989. */
  58990. radius: number;
  58991. /**
  58992. * The base color of the SSAO post-process
  58993. * The final result is "base + ssao" between [0, 1]
  58994. */
  58995. base: number;
  58996. /**
  58997. * Support test.
  58998. */
  58999. static readonly IsSupported: boolean;
  59000. private _scene;
  59001. private _depthTexture;
  59002. private _normalTexture;
  59003. private _randomTexture;
  59004. private _originalColorPostProcess;
  59005. private _ssaoPostProcess;
  59006. private _blurHPostProcess;
  59007. private _blurVPostProcess;
  59008. private _ssaoCombinePostProcess;
  59009. private _firstUpdate;
  59010. /**
  59011. * Gets active scene
  59012. */
  59013. readonly scene: Scene;
  59014. /**
  59015. * @constructor
  59016. * @param name The rendering pipeline name
  59017. * @param scene The scene linked to this pipeline
  59018. * @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 }
  59019. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59020. */
  59021. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59022. /**
  59023. * Get the class name
  59024. * @returns "SSAO2RenderingPipeline"
  59025. */
  59026. getClassName(): string;
  59027. /**
  59028. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59029. */
  59030. dispose(disableGeometryBufferRenderer?: boolean): void;
  59031. private _createBlurPostProcess;
  59032. /** @hidden */
  59033. _rebuild(): void;
  59034. private _bits;
  59035. private _radicalInverse_VdC;
  59036. private _hammersley;
  59037. private _hemisphereSample_uniform;
  59038. private _generateHemisphere;
  59039. private _createSSAOPostProcess;
  59040. private _createSSAOCombinePostProcess;
  59041. private _createRandomTexture;
  59042. /**
  59043. * Serialize the rendering pipeline (Used when exporting)
  59044. * @returns the serialized object
  59045. */
  59046. serialize(): any;
  59047. /**
  59048. * Parse the serialized pipeline
  59049. * @param source Source pipeline.
  59050. * @param scene The scene to load the pipeline to.
  59051. * @param rootUrl The URL of the serialized pipeline.
  59052. * @returns An instantiated pipeline from the serialized object.
  59053. */
  59054. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59055. }
  59056. }
  59057. declare module "babylonjs/Shaders/ssao.fragment" {
  59058. /** @hidden */
  59059. export var ssaoPixelShader: {
  59060. name: string;
  59061. shader: string;
  59062. };
  59063. }
  59064. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  59065. import { Camera } from "babylonjs/Cameras/camera";
  59066. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59067. import { Scene } from "babylonjs/scene";
  59068. import "babylonjs/Shaders/ssao.fragment";
  59069. import "babylonjs/Shaders/ssaoCombine.fragment";
  59070. /**
  59071. * Render pipeline to produce ssao effect
  59072. */
  59073. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59074. /**
  59075. * @ignore
  59076. * The PassPostProcess id in the pipeline that contains the original scene color
  59077. */
  59078. SSAOOriginalSceneColorEffect: string;
  59079. /**
  59080. * @ignore
  59081. * The SSAO PostProcess id in the pipeline
  59082. */
  59083. SSAORenderEffect: string;
  59084. /**
  59085. * @ignore
  59086. * The horizontal blur PostProcess id in the pipeline
  59087. */
  59088. SSAOBlurHRenderEffect: string;
  59089. /**
  59090. * @ignore
  59091. * The vertical blur PostProcess id in the pipeline
  59092. */
  59093. SSAOBlurVRenderEffect: string;
  59094. /**
  59095. * @ignore
  59096. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59097. */
  59098. SSAOCombineRenderEffect: string;
  59099. /**
  59100. * The output strength of the SSAO post-process. Default value is 1.0.
  59101. */
  59102. totalStrength: number;
  59103. /**
  59104. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59105. */
  59106. radius: number;
  59107. /**
  59108. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59109. * Must not be equal to fallOff and superior to fallOff.
  59110. * Default value is 0.0075
  59111. */
  59112. area: number;
  59113. /**
  59114. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59115. * Must not be equal to area and inferior to area.
  59116. * Default value is 0.000001
  59117. */
  59118. fallOff: number;
  59119. /**
  59120. * The base color of the SSAO post-process
  59121. * The final result is "base + ssao" between [0, 1]
  59122. */
  59123. base: number;
  59124. private _scene;
  59125. private _depthTexture;
  59126. private _randomTexture;
  59127. private _originalColorPostProcess;
  59128. private _ssaoPostProcess;
  59129. private _blurHPostProcess;
  59130. private _blurVPostProcess;
  59131. private _ssaoCombinePostProcess;
  59132. private _firstUpdate;
  59133. /**
  59134. * Gets active scene
  59135. */
  59136. readonly scene: Scene;
  59137. /**
  59138. * @constructor
  59139. * @param name - The rendering pipeline name
  59140. * @param scene - The scene linked to this pipeline
  59141. * @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 }
  59142. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59143. */
  59144. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59145. /**
  59146. * Get the class name
  59147. * @returns "SSAORenderingPipeline"
  59148. */
  59149. getClassName(): string;
  59150. /**
  59151. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59152. */
  59153. dispose(disableDepthRender?: boolean): void;
  59154. private _createBlurPostProcess;
  59155. /** @hidden */
  59156. _rebuild(): void;
  59157. private _createSSAOPostProcess;
  59158. private _createSSAOCombinePostProcess;
  59159. private _createRandomTexture;
  59160. }
  59161. }
  59162. declare module "babylonjs/Shaders/standard.fragment" {
  59163. /** @hidden */
  59164. export var standardPixelShader: {
  59165. name: string;
  59166. shader: string;
  59167. };
  59168. }
  59169. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  59170. import { Nullable } from "babylonjs/types";
  59171. import { IAnimatable } from "babylonjs/Misc/tools";
  59172. import { Camera } from "babylonjs/Cameras/camera";
  59173. import { Texture } from "babylonjs/Materials/Textures/texture";
  59174. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59175. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59176. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59177. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59178. import { IDisposable } from "babylonjs/scene";
  59179. import { SpotLight } from "babylonjs/Lights/spotLight";
  59180. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  59181. import { Scene } from "babylonjs/scene";
  59182. import { Animation } from "babylonjs/Animations/animation";
  59183. import "babylonjs/Shaders/standard.fragment";
  59184. /**
  59185. * Standard rendering pipeline
  59186. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59187. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59188. */
  59189. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59190. /**
  59191. * Public members
  59192. */
  59193. /**
  59194. * Post-process which contains the original scene color before the pipeline applies all the effects
  59195. */
  59196. originalPostProcess: Nullable<PostProcess>;
  59197. /**
  59198. * Post-process used to down scale an image x4
  59199. */
  59200. downSampleX4PostProcess: Nullable<PostProcess>;
  59201. /**
  59202. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59203. */
  59204. brightPassPostProcess: Nullable<PostProcess>;
  59205. /**
  59206. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59207. */
  59208. blurHPostProcesses: PostProcess[];
  59209. /**
  59210. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59211. */
  59212. blurVPostProcesses: PostProcess[];
  59213. /**
  59214. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59215. */
  59216. textureAdderPostProcess: Nullable<PostProcess>;
  59217. /**
  59218. * Post-process used to create volumetric lighting effect
  59219. */
  59220. volumetricLightPostProcess: Nullable<PostProcess>;
  59221. /**
  59222. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59223. */
  59224. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59225. /**
  59226. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59227. */
  59228. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59229. /**
  59230. * Post-process used to merge the volumetric light effect and the real scene color
  59231. */
  59232. volumetricLightMergePostProces: Nullable<PostProcess>;
  59233. /**
  59234. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59235. */
  59236. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59237. /**
  59238. * Base post-process used to calculate the average luminance of the final image for HDR
  59239. */
  59240. luminancePostProcess: Nullable<PostProcess>;
  59241. /**
  59242. * Post-processes used to create down sample post-processes in order to get
  59243. * the average luminance of the final image for HDR
  59244. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59245. */
  59246. luminanceDownSamplePostProcesses: PostProcess[];
  59247. /**
  59248. * Post-process used to create a HDR effect (light adaptation)
  59249. */
  59250. hdrPostProcess: Nullable<PostProcess>;
  59251. /**
  59252. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59253. */
  59254. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59255. /**
  59256. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59257. */
  59258. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59259. /**
  59260. * Post-process used to merge the final HDR post-process and the real scene color
  59261. */
  59262. hdrFinalPostProcess: Nullable<PostProcess>;
  59263. /**
  59264. * Post-process used to create a lens flare effect
  59265. */
  59266. lensFlarePostProcess: Nullable<PostProcess>;
  59267. /**
  59268. * Post-process that merges the result of the lens flare post-process and the real scene color
  59269. */
  59270. lensFlareComposePostProcess: Nullable<PostProcess>;
  59271. /**
  59272. * Post-process used to create a motion blur effect
  59273. */
  59274. motionBlurPostProcess: Nullable<PostProcess>;
  59275. /**
  59276. * Post-process used to create a depth of field effect
  59277. */
  59278. depthOfFieldPostProcess: Nullable<PostProcess>;
  59279. /**
  59280. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59281. */
  59282. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59283. /**
  59284. * Represents the brightness threshold in order to configure the illuminated surfaces
  59285. */
  59286. brightThreshold: number;
  59287. /**
  59288. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59289. */
  59290. blurWidth: number;
  59291. /**
  59292. * Sets if the blur for highlighted surfaces must be only horizontal
  59293. */
  59294. horizontalBlur: boolean;
  59295. /**
  59296. * Gets the overall exposure used by the pipeline
  59297. */
  59298. /**
  59299. * Sets the overall exposure used by the pipeline
  59300. */
  59301. exposure: number;
  59302. /**
  59303. * Texture used typically to simulate "dirty" on camera lens
  59304. */
  59305. lensTexture: Nullable<Texture>;
  59306. /**
  59307. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59308. */
  59309. volumetricLightCoefficient: number;
  59310. /**
  59311. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59312. */
  59313. volumetricLightPower: number;
  59314. /**
  59315. * Used the set the blur intensity to smooth the volumetric lights
  59316. */
  59317. volumetricLightBlurScale: number;
  59318. /**
  59319. * Light (spot or directional) used to generate the volumetric lights rays
  59320. * The source light must have a shadow generate so the pipeline can get its
  59321. * depth map
  59322. */
  59323. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59324. /**
  59325. * For eye adaptation, represents the minimum luminance the eye can see
  59326. */
  59327. hdrMinimumLuminance: number;
  59328. /**
  59329. * For eye adaptation, represents the decrease luminance speed
  59330. */
  59331. hdrDecreaseRate: number;
  59332. /**
  59333. * For eye adaptation, represents the increase luminance speed
  59334. */
  59335. hdrIncreaseRate: number;
  59336. /**
  59337. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59338. */
  59339. /**
  59340. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59341. */
  59342. hdrAutoExposure: boolean;
  59343. /**
  59344. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59345. */
  59346. lensColorTexture: Nullable<Texture>;
  59347. /**
  59348. * The overall strengh for the lens flare effect
  59349. */
  59350. lensFlareStrength: number;
  59351. /**
  59352. * Dispersion coefficient for lens flare ghosts
  59353. */
  59354. lensFlareGhostDispersal: number;
  59355. /**
  59356. * Main lens flare halo width
  59357. */
  59358. lensFlareHaloWidth: number;
  59359. /**
  59360. * Based on the lens distortion effect, defines how much the lens flare result
  59361. * is distorted
  59362. */
  59363. lensFlareDistortionStrength: number;
  59364. /**
  59365. * Lens star texture must be used to simulate rays on the flares and is available
  59366. * in the documentation
  59367. */
  59368. lensStarTexture: Nullable<Texture>;
  59369. /**
  59370. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59371. * flare effect by taking account of the dirt texture
  59372. */
  59373. lensFlareDirtTexture: Nullable<Texture>;
  59374. /**
  59375. * Represents the focal length for the depth of field effect
  59376. */
  59377. depthOfFieldDistance: number;
  59378. /**
  59379. * Represents the blur intensity for the blurred part of the depth of field effect
  59380. */
  59381. depthOfFieldBlurWidth: number;
  59382. /**
  59383. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59384. */
  59385. /**
  59386. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59387. */
  59388. motionStrength: number;
  59389. /**
  59390. * Gets wether or not the motion blur post-process is object based or screen based.
  59391. */
  59392. /**
  59393. * Sets wether or not the motion blur post-process should be object based or screen based
  59394. */
  59395. objectBasedMotionBlur: boolean;
  59396. /**
  59397. * List of animations for the pipeline (IAnimatable implementation)
  59398. */
  59399. animations: Animation[];
  59400. /**
  59401. * Private members
  59402. */
  59403. private _scene;
  59404. private _currentDepthOfFieldSource;
  59405. private _basePostProcess;
  59406. private _fixedExposure;
  59407. private _currentExposure;
  59408. private _hdrAutoExposure;
  59409. private _hdrCurrentLuminance;
  59410. private _motionStrength;
  59411. private _isObjectBasedMotionBlur;
  59412. private _floatTextureType;
  59413. private _ratio;
  59414. private _bloomEnabled;
  59415. private _depthOfFieldEnabled;
  59416. private _vlsEnabled;
  59417. private _lensFlareEnabled;
  59418. private _hdrEnabled;
  59419. private _motionBlurEnabled;
  59420. private _fxaaEnabled;
  59421. private _motionBlurSamples;
  59422. private _volumetricLightStepsCount;
  59423. private _samples;
  59424. /**
  59425. * @ignore
  59426. * Specifies if the bloom pipeline is enabled
  59427. */
  59428. BloomEnabled: boolean;
  59429. /**
  59430. * @ignore
  59431. * Specifies if the depth of field pipeline is enabed
  59432. */
  59433. DepthOfFieldEnabled: boolean;
  59434. /**
  59435. * @ignore
  59436. * Specifies if the lens flare pipeline is enabed
  59437. */
  59438. LensFlareEnabled: boolean;
  59439. /**
  59440. * @ignore
  59441. * Specifies if the HDR pipeline is enabled
  59442. */
  59443. HDREnabled: boolean;
  59444. /**
  59445. * @ignore
  59446. * Specifies if the volumetric lights scattering effect is enabled
  59447. */
  59448. VLSEnabled: boolean;
  59449. /**
  59450. * @ignore
  59451. * Specifies if the motion blur effect is enabled
  59452. */
  59453. MotionBlurEnabled: boolean;
  59454. /**
  59455. * Specifies if anti-aliasing is enabled
  59456. */
  59457. fxaaEnabled: boolean;
  59458. /**
  59459. * Specifies the number of steps used to calculate the volumetric lights
  59460. * Typically in interval [50, 200]
  59461. */
  59462. volumetricLightStepsCount: number;
  59463. /**
  59464. * Specifies the number of samples used for the motion blur effect
  59465. * Typically in interval [16, 64]
  59466. */
  59467. motionBlurSamples: number;
  59468. /**
  59469. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59470. */
  59471. samples: number;
  59472. /**
  59473. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59474. * @constructor
  59475. * @param name The rendering pipeline name
  59476. * @param scene The scene linked to this pipeline
  59477. * @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)
  59478. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59479. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59480. */
  59481. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59482. private _buildPipeline;
  59483. private _createDownSampleX4PostProcess;
  59484. private _createBrightPassPostProcess;
  59485. private _createBlurPostProcesses;
  59486. private _createTextureAdderPostProcess;
  59487. private _createVolumetricLightPostProcess;
  59488. private _createLuminancePostProcesses;
  59489. private _createHdrPostProcess;
  59490. private _createLensFlarePostProcess;
  59491. private _createDepthOfFieldPostProcess;
  59492. private _createMotionBlurPostProcess;
  59493. private _getDepthTexture;
  59494. private _disposePostProcesses;
  59495. /**
  59496. * Dispose of the pipeline and stop all post processes
  59497. */
  59498. dispose(): void;
  59499. /**
  59500. * Serialize the rendering pipeline (Used when exporting)
  59501. * @returns the serialized object
  59502. */
  59503. serialize(): any;
  59504. /**
  59505. * Parse the serialized pipeline
  59506. * @param source Source pipeline.
  59507. * @param scene The scene to load the pipeline to.
  59508. * @param rootUrl The URL of the serialized pipeline.
  59509. * @returns An instantiated pipeline from the serialized object.
  59510. */
  59511. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59512. /**
  59513. * Luminance steps
  59514. */
  59515. static LuminanceSteps: number;
  59516. }
  59517. }
  59518. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  59519. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  59520. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  59521. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  59522. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  59523. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  59524. }
  59525. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  59526. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  59527. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59528. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59529. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  59530. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59531. }
  59532. declare module "babylonjs/Shaders/tonemap.fragment" {
  59533. /** @hidden */
  59534. export var tonemapPixelShader: {
  59535. name: string;
  59536. shader: string;
  59537. };
  59538. }
  59539. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  59540. import { Camera } from "babylonjs/Cameras/camera";
  59541. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59542. import "babylonjs/Shaders/tonemap.fragment";
  59543. import { Engine } from "babylonjs/Engines/engine";
  59544. /** Defines operator used for tonemapping */
  59545. export enum TonemappingOperator {
  59546. /** Hable */
  59547. Hable = 0,
  59548. /** Reinhard */
  59549. Reinhard = 1,
  59550. /** HejiDawson */
  59551. HejiDawson = 2,
  59552. /** Photographic */
  59553. Photographic = 3
  59554. }
  59555. /**
  59556. * Defines a post process to apply tone mapping
  59557. */
  59558. export class TonemapPostProcess extends PostProcess {
  59559. private _operator;
  59560. /** Defines the required exposure adjustement */
  59561. exposureAdjustment: number;
  59562. /**
  59563. * Creates a new TonemapPostProcess
  59564. * @param name defines the name of the postprocess
  59565. * @param _operator defines the operator to use
  59566. * @param exposureAdjustment defines the required exposure adjustement
  59567. * @param camera defines the camera to use (can be null)
  59568. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59569. * @param engine defines the hosting engine (can be ignore if camera is set)
  59570. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59571. */
  59572. constructor(name: string, _operator: TonemappingOperator,
  59573. /** Defines the required exposure adjustement */
  59574. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59575. }
  59576. }
  59577. declare module "babylonjs/Shaders/depth.vertex" {
  59578. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59579. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59580. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59581. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59582. /** @hidden */
  59583. export var depthVertexShader: {
  59584. name: string;
  59585. shader: string;
  59586. };
  59587. }
  59588. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  59589. /** @hidden */
  59590. export var volumetricLightScatteringPixelShader: {
  59591. name: string;
  59592. shader: string;
  59593. };
  59594. }
  59595. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  59596. /** @hidden */
  59597. export var volumetricLightScatteringPassPixelShader: {
  59598. name: string;
  59599. shader: string;
  59600. };
  59601. }
  59602. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  59603. import { Vector3 } from "babylonjs/Maths/math";
  59604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59605. import { Mesh } from "babylonjs/Meshes/mesh";
  59606. import { Camera } from "babylonjs/Cameras/camera";
  59607. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59608. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59609. import { Scene } from "babylonjs/scene";
  59610. import "babylonjs/Meshes/Builders/planeBuilder";
  59611. import "babylonjs/Shaders/depth.vertex";
  59612. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  59613. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  59614. import { Engine } from "babylonjs/Engines/engine";
  59615. /**
  59616. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59617. */
  59618. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59619. private _volumetricLightScatteringPass;
  59620. private _volumetricLightScatteringRTT;
  59621. private _viewPort;
  59622. private _screenCoordinates;
  59623. private _cachedDefines;
  59624. /**
  59625. * If not undefined, the mesh position is computed from the attached node position
  59626. */
  59627. attachedNode: {
  59628. position: Vector3;
  59629. };
  59630. /**
  59631. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59632. */
  59633. customMeshPosition: Vector3;
  59634. /**
  59635. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59636. */
  59637. useCustomMeshPosition: boolean;
  59638. /**
  59639. * If the post-process should inverse the light scattering direction
  59640. */
  59641. invert: boolean;
  59642. /**
  59643. * The internal mesh used by the post-process
  59644. */
  59645. mesh: Mesh;
  59646. /**
  59647. * @hidden
  59648. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59649. */
  59650. useDiffuseColor: boolean;
  59651. /**
  59652. * Array containing the excluded meshes not rendered in the internal pass
  59653. */
  59654. excludedMeshes: AbstractMesh[];
  59655. /**
  59656. * Controls the overall intensity of the post-process
  59657. */
  59658. exposure: number;
  59659. /**
  59660. * Dissipates each sample's contribution in range [0, 1]
  59661. */
  59662. decay: number;
  59663. /**
  59664. * Controls the overall intensity of each sample
  59665. */
  59666. weight: number;
  59667. /**
  59668. * Controls the density of each sample
  59669. */
  59670. density: number;
  59671. /**
  59672. * @constructor
  59673. * @param name The post-process name
  59674. * @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)
  59675. * @param camera The camera that the post-process will be attached to
  59676. * @param mesh The mesh used to create the light scattering
  59677. * @param samples The post-process quality, default 100
  59678. * @param samplingModeThe post-process filtering mode
  59679. * @param engine The babylon engine
  59680. * @param reusable If the post-process is reusable
  59681. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59682. */
  59683. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59684. /**
  59685. * Returns the string "VolumetricLightScatteringPostProcess"
  59686. * @returns "VolumetricLightScatteringPostProcess"
  59687. */
  59688. getClassName(): string;
  59689. private _isReady;
  59690. /**
  59691. * Sets the new light position for light scattering effect
  59692. * @param position The new custom light position
  59693. */
  59694. setCustomMeshPosition(position: Vector3): void;
  59695. /**
  59696. * Returns the light position for light scattering effect
  59697. * @return Vector3 The custom light position
  59698. */
  59699. getCustomMeshPosition(): Vector3;
  59700. /**
  59701. * Disposes the internal assets and detaches the post-process from the camera
  59702. */
  59703. dispose(camera: Camera): void;
  59704. /**
  59705. * Returns the render target texture used by the post-process
  59706. * @return the render target texture used by the post-process
  59707. */
  59708. getPass(): RenderTargetTexture;
  59709. private _meshExcluded;
  59710. private _createPass;
  59711. private _updateMeshScreenCoordinates;
  59712. /**
  59713. * Creates a default mesh for the Volumeric Light Scattering post-process
  59714. * @param name The mesh name
  59715. * @param scene The scene where to create the mesh
  59716. * @return the default mesh
  59717. */
  59718. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59719. }
  59720. }
  59721. declare module "babylonjs/PostProcesses/index" {
  59722. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  59723. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  59724. export * from "babylonjs/PostProcesses/bloomEffect";
  59725. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  59726. export * from "babylonjs/PostProcesses/blurPostProcess";
  59727. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59728. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  59729. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  59730. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  59731. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  59732. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  59733. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  59734. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  59735. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59736. export * from "babylonjs/PostProcesses/filterPostProcess";
  59737. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  59738. export * from "babylonjs/PostProcesses/grainPostProcess";
  59739. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  59740. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  59741. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  59742. export * from "babylonjs/PostProcesses/passPostProcess";
  59743. export * from "babylonjs/PostProcesses/postProcess";
  59744. export * from "babylonjs/PostProcesses/postProcessManager";
  59745. export * from "babylonjs/PostProcesses/refractionPostProcess";
  59746. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  59747. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  59748. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  59749. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  59750. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  59751. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  59752. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  59753. }
  59754. declare module "babylonjs/Probes/index" {
  59755. export * from "babylonjs/Probes/reflectionProbe";
  59756. }
  59757. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  59758. import { Scene } from "babylonjs/scene";
  59759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59760. import { Color3 } from "babylonjs/Maths/math";
  59761. import { SmartArray } from "babylonjs/Misc/smartArray";
  59762. import { ISceneComponent } from "babylonjs/sceneComponent";
  59763. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  59764. import "babylonjs/Meshes/Builders/boxBuilder";
  59765. import "babylonjs/Shaders/color.fragment";
  59766. import "babylonjs/Shaders/color.vertex";
  59767. module "babylonjs/scene" {
  59768. interface Scene {
  59769. /** @hidden (Backing field) */
  59770. _boundingBoxRenderer: BoundingBoxRenderer;
  59771. /** @hidden (Backing field) */
  59772. _forceShowBoundingBoxes: boolean;
  59773. /**
  59774. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  59775. */
  59776. forceShowBoundingBoxes: boolean;
  59777. /**
  59778. * Gets the bounding box renderer associated with the scene
  59779. * @returns a BoundingBoxRenderer
  59780. */
  59781. getBoundingBoxRenderer(): BoundingBoxRenderer;
  59782. }
  59783. }
  59784. module "babylonjs/Meshes/abstractMesh" {
  59785. interface AbstractMesh {
  59786. /** @hidden (Backing field) */
  59787. _showBoundingBox: boolean;
  59788. /**
  59789. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  59790. */
  59791. showBoundingBox: boolean;
  59792. }
  59793. }
  59794. /**
  59795. * Component responsible of rendering the bounding box of the meshes in a scene.
  59796. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  59797. */
  59798. export class BoundingBoxRenderer implements ISceneComponent {
  59799. /**
  59800. * The component name helpfull to identify the component in the list of scene components.
  59801. */
  59802. readonly name: string;
  59803. /**
  59804. * The scene the component belongs to.
  59805. */
  59806. scene: Scene;
  59807. /**
  59808. * Color of the bounding box lines placed in front of an object
  59809. */
  59810. frontColor: Color3;
  59811. /**
  59812. * Color of the bounding box lines placed behind an object
  59813. */
  59814. backColor: Color3;
  59815. /**
  59816. * Defines if the renderer should show the back lines or not
  59817. */
  59818. showBackLines: boolean;
  59819. /**
  59820. * @hidden
  59821. */
  59822. renderList: SmartArray<BoundingBox>;
  59823. private _colorShader;
  59824. private _vertexBuffers;
  59825. private _indexBuffer;
  59826. private _fillIndexBuffer;
  59827. private _fillIndexData;
  59828. /**
  59829. * Instantiates a new bounding box renderer in a scene.
  59830. * @param scene the scene the renderer renders in
  59831. */
  59832. constructor(scene: Scene);
  59833. /**
  59834. * Registers the component in a given scene
  59835. */
  59836. register(): void;
  59837. private _evaluateSubMesh;
  59838. private _activeMesh;
  59839. private _prepareRessources;
  59840. private _createIndexBuffer;
  59841. /**
  59842. * Rebuilds the elements related to this component in case of
  59843. * context lost for instance.
  59844. */
  59845. rebuild(): void;
  59846. /**
  59847. * @hidden
  59848. */
  59849. reset(): void;
  59850. /**
  59851. * Render the bounding boxes of a specific rendering group
  59852. * @param renderingGroupId defines the rendering group to render
  59853. */
  59854. render(renderingGroupId: number): void;
  59855. /**
  59856. * In case of occlusion queries, we can render the occlusion bounding box through this method
  59857. * @param mesh Define the mesh to render the occlusion bounding box for
  59858. */
  59859. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  59860. /**
  59861. * Dispose and release the resources attached to this renderer.
  59862. */
  59863. dispose(): void;
  59864. }
  59865. }
  59866. declare module "babylonjs/Shaders/depth.fragment" {
  59867. /** @hidden */
  59868. export var depthPixelShader: {
  59869. name: string;
  59870. shader: string;
  59871. };
  59872. }
  59873. declare module "babylonjs/Rendering/depthRenderer" {
  59874. import { Nullable } from "babylonjs/types";
  59875. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59876. import { Scene } from "babylonjs/scene";
  59877. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59878. import { Camera } from "babylonjs/Cameras/camera";
  59879. import "babylonjs/Shaders/depth.fragment";
  59880. import "babylonjs/Shaders/depth.vertex";
  59881. /**
  59882. * This represents a depth renderer in Babylon.
  59883. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59884. */
  59885. export class DepthRenderer {
  59886. private _scene;
  59887. private _depthMap;
  59888. private _effect;
  59889. private _cachedDefines;
  59890. private _camera;
  59891. /**
  59892. * Specifiess that the depth renderer will only be used within
  59893. * the camera it is created for.
  59894. * This can help forcing its rendering during the camera processing.
  59895. */
  59896. useOnlyInActiveCamera: boolean;
  59897. /** @hidden */
  59898. static _SceneComponentInitialization: (scene: Scene) => void;
  59899. /**
  59900. * Instantiates a depth renderer
  59901. * @param scene The scene the renderer belongs to
  59902. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59903. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59904. */
  59905. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  59906. /**
  59907. * Creates the depth rendering effect and checks if the effect is ready.
  59908. * @param subMesh The submesh to be used to render the depth map of
  59909. * @param useInstances If multiple world instances should be used
  59910. * @returns if the depth renderer is ready to render the depth map
  59911. */
  59912. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59913. /**
  59914. * Gets the texture which the depth map will be written to.
  59915. * @returns The depth map texture
  59916. */
  59917. getDepthMap(): RenderTargetTexture;
  59918. /**
  59919. * Disposes of the depth renderer.
  59920. */
  59921. dispose(): void;
  59922. }
  59923. }
  59924. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  59925. import { Nullable } from "babylonjs/types";
  59926. import { Scene } from "babylonjs/scene";
  59927. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  59928. import { Camera } from "babylonjs/Cameras/camera";
  59929. import { ISceneComponent } from "babylonjs/sceneComponent";
  59930. module "babylonjs/scene" {
  59931. interface Scene {
  59932. /** @hidden (Backing field) */
  59933. _depthRenderer: {
  59934. [id: string]: DepthRenderer;
  59935. };
  59936. /**
  59937. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  59938. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  59939. * @returns the created depth renderer
  59940. */
  59941. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  59942. /**
  59943. * Disables a depth renderer for a given camera
  59944. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  59945. */
  59946. disableDepthRenderer(camera?: Nullable<Camera>): void;
  59947. }
  59948. }
  59949. /**
  59950. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  59951. * in several rendering techniques.
  59952. */
  59953. export class DepthRendererSceneComponent implements ISceneComponent {
  59954. /**
  59955. * The component name helpfull to identify the component in the list of scene components.
  59956. */
  59957. readonly name: string;
  59958. /**
  59959. * The scene the component belongs to.
  59960. */
  59961. scene: Scene;
  59962. /**
  59963. * Creates a new instance of the component for the given scene
  59964. * @param scene Defines the scene to register the component in
  59965. */
  59966. constructor(scene: Scene);
  59967. /**
  59968. * Registers the component in a given scene
  59969. */
  59970. register(): void;
  59971. /**
  59972. * Rebuilds the elements related to this component in case of
  59973. * context lost for instance.
  59974. */
  59975. rebuild(): void;
  59976. /**
  59977. * Disposes the component and the associated ressources
  59978. */
  59979. dispose(): void;
  59980. private _gatherRenderTargets;
  59981. private _gatherActiveCameraRenderTargets;
  59982. }
  59983. }
  59984. declare module "babylonjs/Shaders/outline.fragment" {
  59985. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59986. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  59987. /** @hidden */
  59988. export var outlinePixelShader: {
  59989. name: string;
  59990. shader: string;
  59991. };
  59992. }
  59993. declare module "babylonjs/Shaders/outline.vertex" {
  59994. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59995. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59996. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59997. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59998. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59999. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  60000. /** @hidden */
  60001. export var outlineVertexShader: {
  60002. name: string;
  60003. shader: string;
  60004. };
  60005. }
  60006. declare module "babylonjs/Rendering/outlineRenderer" {
  60007. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60008. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  60009. import { Scene } from "babylonjs/scene";
  60010. import { ISceneComponent } from "babylonjs/sceneComponent";
  60011. import "babylonjs/Shaders/outline.fragment";
  60012. import "babylonjs/Shaders/outline.vertex";
  60013. module "babylonjs/scene" {
  60014. interface Scene {
  60015. /** @hidden */
  60016. _outlineRenderer: OutlineRenderer;
  60017. /**
  60018. * Gets the outline renderer associated with the scene
  60019. * @returns a OutlineRenderer
  60020. */
  60021. getOutlineRenderer(): OutlineRenderer;
  60022. }
  60023. }
  60024. module "babylonjs/Meshes/abstractMesh" {
  60025. interface AbstractMesh {
  60026. /** @hidden (Backing field) */
  60027. _renderOutline: boolean;
  60028. /**
  60029. * Gets or sets a boolean indicating if the outline must be rendered as well
  60030. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60031. */
  60032. renderOutline: boolean;
  60033. /** @hidden (Backing field) */
  60034. _renderOverlay: boolean;
  60035. /**
  60036. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60037. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60038. */
  60039. renderOverlay: boolean;
  60040. }
  60041. }
  60042. /**
  60043. * This class is responsible to draw bothe outline/overlay of meshes.
  60044. * It should not be used directly but through the available method on mesh.
  60045. */
  60046. export class OutlineRenderer implements ISceneComponent {
  60047. /**
  60048. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60049. */
  60050. private static _StencilReference;
  60051. /**
  60052. * The name of the component. Each component must have a unique name.
  60053. */
  60054. name: string;
  60055. /**
  60056. * The scene the component belongs to.
  60057. */
  60058. scene: Scene;
  60059. /**
  60060. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60061. */
  60062. zOffset: number;
  60063. private _engine;
  60064. private _effect;
  60065. private _cachedDefines;
  60066. private _savedDepthWrite;
  60067. /**
  60068. * Instantiates a new outline renderer. (There could be only one per scene).
  60069. * @param scene Defines the scene it belongs to
  60070. */
  60071. constructor(scene: Scene);
  60072. /**
  60073. * Register the component to one instance of a scene.
  60074. */
  60075. register(): void;
  60076. /**
  60077. * Rebuilds the elements related to this component in case of
  60078. * context lost for instance.
  60079. */
  60080. rebuild(): void;
  60081. /**
  60082. * Disposes the component and the associated ressources.
  60083. */
  60084. dispose(): void;
  60085. /**
  60086. * Renders the outline in the canvas.
  60087. * @param subMesh Defines the sumesh to render
  60088. * @param batch Defines the batch of meshes in case of instances
  60089. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60090. */
  60091. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60092. /**
  60093. * Returns whether or not the outline renderer is ready for a given submesh.
  60094. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60095. * @param subMesh Defines the submesh to check readyness for
  60096. * @param useInstances Defines wheter wee are trying to render instances or not
  60097. * @returns true if ready otherwise false
  60098. */
  60099. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60100. private _beforeRenderingMesh;
  60101. private _afterRenderingMesh;
  60102. }
  60103. }
  60104. declare module "babylonjs/Rendering/index" {
  60105. export * from "babylonjs/Rendering/boundingBoxRenderer";
  60106. export * from "babylonjs/Rendering/depthRenderer";
  60107. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  60108. export * from "babylonjs/Rendering/edgesRenderer";
  60109. export * from "babylonjs/Rendering/geometryBufferRenderer";
  60110. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60111. export * from "babylonjs/Rendering/outlineRenderer";
  60112. export * from "babylonjs/Rendering/renderingGroup";
  60113. export * from "babylonjs/Rendering/renderingManager";
  60114. export * from "babylonjs/Rendering/utilityLayerRenderer";
  60115. }
  60116. declare module "babylonjs/Sprites/index" {
  60117. export * from "babylonjs/Sprites/sprite";
  60118. export * from "babylonjs/Sprites/spriteManager";
  60119. export * from "babylonjs/Sprites/spriteSceneComponent";
  60120. }
  60121. declare module "babylonjs/Misc/assetsManager" {
  60122. import { Scene } from "babylonjs/scene";
  60123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60124. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60125. import { Skeleton } from "babylonjs/Bones/skeleton";
  60126. import { Observable } from "babylonjs/Misc/observable";
  60127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60128. import { Texture } from "babylonjs/Materials/Textures/texture";
  60129. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  60130. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  60131. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60132. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  60133. /**
  60134. * Defines the list of states available for a task inside a AssetsManager
  60135. */
  60136. export enum AssetTaskState {
  60137. /**
  60138. * Initialization
  60139. */
  60140. INIT = 0,
  60141. /**
  60142. * Running
  60143. */
  60144. RUNNING = 1,
  60145. /**
  60146. * Done
  60147. */
  60148. DONE = 2,
  60149. /**
  60150. * Error
  60151. */
  60152. ERROR = 3
  60153. }
  60154. /**
  60155. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60156. */
  60157. export abstract class AbstractAssetTask {
  60158. /**
  60159. * Task name
  60160. */ name: string;
  60161. /**
  60162. * Callback called when the task is successful
  60163. */
  60164. onSuccess: (task: any) => void;
  60165. /**
  60166. * Callback called when the task is not successful
  60167. */
  60168. onError: (task: any, message?: string, exception?: any) => void;
  60169. /**
  60170. * Creates a new AssetsManager
  60171. * @param name defines the name of the task
  60172. */
  60173. constructor(
  60174. /**
  60175. * Task name
  60176. */ name: string);
  60177. private _isCompleted;
  60178. private _taskState;
  60179. private _errorObject;
  60180. /**
  60181. * Get if the task is completed
  60182. */
  60183. readonly isCompleted: boolean;
  60184. /**
  60185. * Gets the current state of the task
  60186. */
  60187. readonly taskState: AssetTaskState;
  60188. /**
  60189. * Gets the current error object (if task is in error)
  60190. */
  60191. readonly errorObject: {
  60192. message?: string;
  60193. exception?: any;
  60194. };
  60195. /**
  60196. * Internal only
  60197. * @hidden
  60198. */
  60199. _setErrorObject(message?: string, exception?: any): void;
  60200. /**
  60201. * Execute the current task
  60202. * @param scene defines the scene where you want your assets to be loaded
  60203. * @param onSuccess is a callback called when the task is successfully executed
  60204. * @param onError is a callback called if an error occurs
  60205. */
  60206. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60207. /**
  60208. * Execute the current task
  60209. * @param scene defines the scene where you want your assets to be loaded
  60210. * @param onSuccess is a callback called when the task is successfully executed
  60211. * @param onError is a callback called if an error occurs
  60212. */
  60213. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60214. /**
  60215. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60216. * This can be used with failed tasks that have the reason for failure fixed.
  60217. */
  60218. reset(): void;
  60219. private onErrorCallback;
  60220. private onDoneCallback;
  60221. }
  60222. /**
  60223. * Define the interface used by progress events raised during assets loading
  60224. */
  60225. export interface IAssetsProgressEvent {
  60226. /**
  60227. * Defines the number of remaining tasks to process
  60228. */
  60229. remainingCount: number;
  60230. /**
  60231. * Defines the total number of tasks
  60232. */
  60233. totalCount: number;
  60234. /**
  60235. * Defines the task that was just processed
  60236. */
  60237. task: AbstractAssetTask;
  60238. }
  60239. /**
  60240. * Class used to share progress information about assets loading
  60241. */
  60242. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60243. /**
  60244. * Defines the number of remaining tasks to process
  60245. */
  60246. remainingCount: number;
  60247. /**
  60248. * Defines the total number of tasks
  60249. */
  60250. totalCount: number;
  60251. /**
  60252. * Defines the task that was just processed
  60253. */
  60254. task: AbstractAssetTask;
  60255. /**
  60256. * Creates a AssetsProgressEvent
  60257. * @param remainingCount defines the number of remaining tasks to process
  60258. * @param totalCount defines the total number of tasks
  60259. * @param task defines the task that was just processed
  60260. */
  60261. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60262. }
  60263. /**
  60264. * Define a task used by AssetsManager to load meshes
  60265. */
  60266. export class MeshAssetTask extends AbstractAssetTask {
  60267. /**
  60268. * Defines the name of the task
  60269. */
  60270. name: string;
  60271. /**
  60272. * Defines the list of mesh's names you want to load
  60273. */
  60274. meshesNames: any;
  60275. /**
  60276. * Defines the root url to use as a base to load your meshes and associated resources
  60277. */
  60278. rootUrl: string;
  60279. /**
  60280. * Defines the filename of the scene to load from
  60281. */
  60282. sceneFilename: string;
  60283. /**
  60284. * Gets the list of loaded meshes
  60285. */
  60286. loadedMeshes: Array<AbstractMesh>;
  60287. /**
  60288. * Gets the list of loaded particle systems
  60289. */
  60290. loadedParticleSystems: Array<IParticleSystem>;
  60291. /**
  60292. * Gets the list of loaded skeletons
  60293. */
  60294. loadedSkeletons: Array<Skeleton>;
  60295. /**
  60296. * Gets the list of loaded animation groups
  60297. */
  60298. loadedAnimationGroups: Array<AnimationGroup>;
  60299. /**
  60300. * Callback called when the task is successful
  60301. */
  60302. onSuccess: (task: MeshAssetTask) => void;
  60303. /**
  60304. * Callback called when the task is successful
  60305. */
  60306. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60307. /**
  60308. * Creates a new MeshAssetTask
  60309. * @param name defines the name of the task
  60310. * @param meshesNames defines the list of mesh's names you want to load
  60311. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60312. * @param sceneFilename defines the filename of the scene to load from
  60313. */
  60314. constructor(
  60315. /**
  60316. * Defines the name of the task
  60317. */
  60318. name: string,
  60319. /**
  60320. * Defines the list of mesh's names you want to load
  60321. */
  60322. meshesNames: any,
  60323. /**
  60324. * Defines the root url to use as a base to load your meshes and associated resources
  60325. */
  60326. rootUrl: string,
  60327. /**
  60328. * Defines the filename of the scene to load from
  60329. */
  60330. sceneFilename: string);
  60331. /**
  60332. * Execute the current task
  60333. * @param scene defines the scene where you want your assets to be loaded
  60334. * @param onSuccess is a callback called when the task is successfully executed
  60335. * @param onError is a callback called if an error occurs
  60336. */
  60337. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60338. }
  60339. /**
  60340. * Define a task used by AssetsManager to load text content
  60341. */
  60342. export class TextFileAssetTask extends AbstractAssetTask {
  60343. /**
  60344. * Defines the name of the task
  60345. */
  60346. name: string;
  60347. /**
  60348. * Defines the location of the file to load
  60349. */
  60350. url: string;
  60351. /**
  60352. * Gets the loaded text string
  60353. */
  60354. text: string;
  60355. /**
  60356. * Callback called when the task is successful
  60357. */
  60358. onSuccess: (task: TextFileAssetTask) => void;
  60359. /**
  60360. * Callback called when the task is successful
  60361. */
  60362. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60363. /**
  60364. * Creates a new TextFileAssetTask object
  60365. * @param name defines the name of the task
  60366. * @param url defines the location of the file to load
  60367. */
  60368. constructor(
  60369. /**
  60370. * Defines the name of the task
  60371. */
  60372. name: string,
  60373. /**
  60374. * Defines the location of the file to load
  60375. */
  60376. url: string);
  60377. /**
  60378. * Execute the current task
  60379. * @param scene defines the scene where you want your assets to be loaded
  60380. * @param onSuccess is a callback called when the task is successfully executed
  60381. * @param onError is a callback called if an error occurs
  60382. */
  60383. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60384. }
  60385. /**
  60386. * Define a task used by AssetsManager to load binary data
  60387. */
  60388. export class BinaryFileAssetTask extends AbstractAssetTask {
  60389. /**
  60390. * Defines the name of the task
  60391. */
  60392. name: string;
  60393. /**
  60394. * Defines the location of the file to load
  60395. */
  60396. url: string;
  60397. /**
  60398. * Gets the lodaded data (as an array buffer)
  60399. */
  60400. data: ArrayBuffer;
  60401. /**
  60402. * Callback called when the task is successful
  60403. */
  60404. onSuccess: (task: BinaryFileAssetTask) => void;
  60405. /**
  60406. * Callback called when the task is successful
  60407. */
  60408. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60409. /**
  60410. * Creates a new BinaryFileAssetTask object
  60411. * @param name defines the name of the new task
  60412. * @param url defines the location of the file to load
  60413. */
  60414. constructor(
  60415. /**
  60416. * Defines the name of the task
  60417. */
  60418. name: string,
  60419. /**
  60420. * Defines the location of the file to load
  60421. */
  60422. url: string);
  60423. /**
  60424. * Execute the current task
  60425. * @param scene defines the scene where you want your assets to be loaded
  60426. * @param onSuccess is a callback called when the task is successfully executed
  60427. * @param onError is a callback called if an error occurs
  60428. */
  60429. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60430. }
  60431. /**
  60432. * Define a task used by AssetsManager to load images
  60433. */
  60434. export class ImageAssetTask extends AbstractAssetTask {
  60435. /**
  60436. * Defines the name of the task
  60437. */
  60438. name: string;
  60439. /**
  60440. * Defines the location of the image to load
  60441. */
  60442. url: string;
  60443. /**
  60444. * Gets the loaded images
  60445. */
  60446. image: HTMLImageElement;
  60447. /**
  60448. * Callback called when the task is successful
  60449. */
  60450. onSuccess: (task: ImageAssetTask) => void;
  60451. /**
  60452. * Callback called when the task is successful
  60453. */
  60454. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60455. /**
  60456. * Creates a new ImageAssetTask
  60457. * @param name defines the name of the task
  60458. * @param url defines the location of the image to load
  60459. */
  60460. constructor(
  60461. /**
  60462. * Defines the name of the task
  60463. */
  60464. name: string,
  60465. /**
  60466. * Defines the location of the image to load
  60467. */
  60468. url: string);
  60469. /**
  60470. * Execute the current task
  60471. * @param scene defines the scene where you want your assets to be loaded
  60472. * @param onSuccess is a callback called when the task is successfully executed
  60473. * @param onError is a callback called if an error occurs
  60474. */
  60475. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60476. }
  60477. /**
  60478. * Defines the interface used by texture loading tasks
  60479. */
  60480. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60481. /**
  60482. * Gets the loaded texture
  60483. */
  60484. texture: TEX;
  60485. }
  60486. /**
  60487. * Define a task used by AssetsManager to load 2D textures
  60488. */
  60489. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60490. /**
  60491. * Defines the name of the task
  60492. */
  60493. name: string;
  60494. /**
  60495. * Defines the location of the file to load
  60496. */
  60497. url: string;
  60498. /**
  60499. * Defines if mipmap should not be generated (default is false)
  60500. */
  60501. noMipmap?: boolean | undefined;
  60502. /**
  60503. * Defines if texture must be inverted on Y axis (default is false)
  60504. */
  60505. invertY?: boolean | undefined;
  60506. /**
  60507. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60508. */
  60509. samplingMode: number;
  60510. /**
  60511. * Gets the loaded texture
  60512. */
  60513. texture: Texture;
  60514. /**
  60515. * Callback called when the task is successful
  60516. */
  60517. onSuccess: (task: TextureAssetTask) => void;
  60518. /**
  60519. * Callback called when the task is successful
  60520. */
  60521. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60522. /**
  60523. * Creates a new TextureAssetTask object
  60524. * @param name defines the name of the task
  60525. * @param url defines the location of the file to load
  60526. * @param noMipmap defines if mipmap should not be generated (default is false)
  60527. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60528. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60529. */
  60530. constructor(
  60531. /**
  60532. * Defines the name of the task
  60533. */
  60534. name: string,
  60535. /**
  60536. * Defines the location of the file to load
  60537. */
  60538. url: string,
  60539. /**
  60540. * Defines if mipmap should not be generated (default is false)
  60541. */
  60542. noMipmap?: boolean | undefined,
  60543. /**
  60544. * Defines if texture must be inverted on Y axis (default is false)
  60545. */
  60546. invertY?: boolean | undefined,
  60547. /**
  60548. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60549. */
  60550. samplingMode?: number);
  60551. /**
  60552. * Execute the current task
  60553. * @param scene defines the scene where you want your assets to be loaded
  60554. * @param onSuccess is a callback called when the task is successfully executed
  60555. * @param onError is a callback called if an error occurs
  60556. */
  60557. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60558. }
  60559. /**
  60560. * Define a task used by AssetsManager to load cube textures
  60561. */
  60562. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60563. /**
  60564. * Defines the name of the task
  60565. */
  60566. name: string;
  60567. /**
  60568. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60569. */
  60570. url: string;
  60571. /**
  60572. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60573. */
  60574. extensions?: string[] | undefined;
  60575. /**
  60576. * Defines if mipmaps should not be generated (default is false)
  60577. */
  60578. noMipmap?: boolean | undefined;
  60579. /**
  60580. * Defines the explicit list of files (undefined by default)
  60581. */
  60582. files?: string[] | undefined;
  60583. /**
  60584. * Gets the loaded texture
  60585. */
  60586. texture: CubeTexture;
  60587. /**
  60588. * Callback called when the task is successful
  60589. */
  60590. onSuccess: (task: CubeTextureAssetTask) => void;
  60591. /**
  60592. * Callback called when the task is successful
  60593. */
  60594. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60595. /**
  60596. * Creates a new CubeTextureAssetTask
  60597. * @param name defines the name of the task
  60598. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60599. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60600. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60601. * @param files defines the explicit list of files (undefined by default)
  60602. */
  60603. constructor(
  60604. /**
  60605. * Defines the name of the task
  60606. */
  60607. name: string,
  60608. /**
  60609. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60610. */
  60611. url: string,
  60612. /**
  60613. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60614. */
  60615. extensions?: string[] | undefined,
  60616. /**
  60617. * Defines if mipmaps should not be generated (default is false)
  60618. */
  60619. noMipmap?: boolean | undefined,
  60620. /**
  60621. * Defines the explicit list of files (undefined by default)
  60622. */
  60623. files?: string[] | undefined);
  60624. /**
  60625. * Execute the current task
  60626. * @param scene defines the scene where you want your assets to be loaded
  60627. * @param onSuccess is a callback called when the task is successfully executed
  60628. * @param onError is a callback called if an error occurs
  60629. */
  60630. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60631. }
  60632. /**
  60633. * Define a task used by AssetsManager to load HDR cube textures
  60634. */
  60635. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60636. /**
  60637. * Defines the name of the task
  60638. */
  60639. name: string;
  60640. /**
  60641. * Defines the location of the file to load
  60642. */
  60643. url: string;
  60644. /**
  60645. * Defines the desired size (the more it increases the longer the generation will be)
  60646. */
  60647. size: number;
  60648. /**
  60649. * Defines if mipmaps should not be generated (default is false)
  60650. */
  60651. noMipmap: boolean;
  60652. /**
  60653. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60654. */
  60655. generateHarmonics: boolean;
  60656. /**
  60657. * 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)
  60658. */
  60659. gammaSpace: boolean;
  60660. /**
  60661. * Internal Use Only
  60662. */
  60663. reserved: boolean;
  60664. /**
  60665. * Gets the loaded texture
  60666. */
  60667. texture: HDRCubeTexture;
  60668. /**
  60669. * Callback called when the task is successful
  60670. */
  60671. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60672. /**
  60673. * Callback called when the task is successful
  60674. */
  60675. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60676. /**
  60677. * Creates a new HDRCubeTextureAssetTask object
  60678. * @param name defines the name of the task
  60679. * @param url defines the location of the file to load
  60680. * @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.
  60681. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60682. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60683. * @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)
  60684. * @param reserved Internal use only
  60685. */
  60686. constructor(
  60687. /**
  60688. * Defines the name of the task
  60689. */
  60690. name: string,
  60691. /**
  60692. * Defines the location of the file to load
  60693. */
  60694. url: string,
  60695. /**
  60696. * Defines the desired size (the more it increases the longer the generation will be)
  60697. */
  60698. size: number,
  60699. /**
  60700. * Defines if mipmaps should not be generated (default is false)
  60701. */
  60702. noMipmap?: boolean,
  60703. /**
  60704. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60705. */
  60706. generateHarmonics?: boolean,
  60707. /**
  60708. * 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)
  60709. */
  60710. gammaSpace?: boolean,
  60711. /**
  60712. * Internal Use Only
  60713. */
  60714. reserved?: boolean);
  60715. /**
  60716. * Execute the current task
  60717. * @param scene defines the scene where you want your assets to be loaded
  60718. * @param onSuccess is a callback called when the task is successfully executed
  60719. * @param onError is a callback called if an error occurs
  60720. */
  60721. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60722. }
  60723. /**
  60724. * Define a task used by AssetsManager to load Equirectangular cube textures
  60725. */
  60726. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60727. /**
  60728. * Defines the name of the task
  60729. */
  60730. name: string;
  60731. /**
  60732. * Defines the location of the file to load
  60733. */
  60734. url: string;
  60735. /**
  60736. * Defines the desired size (the more it increases the longer the generation will be)
  60737. */
  60738. size: number;
  60739. /**
  60740. * Defines if mipmaps should not be generated (default is false)
  60741. */
  60742. noMipmap: boolean;
  60743. /**
  60744. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60745. * but the standard material would require them in Gamma space) (default is true)
  60746. */
  60747. gammaSpace: boolean;
  60748. /**
  60749. * Gets the loaded texture
  60750. */
  60751. texture: EquiRectangularCubeTexture;
  60752. /**
  60753. * Callback called when the task is successful
  60754. */
  60755. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  60756. /**
  60757. * Callback called when the task is successful
  60758. */
  60759. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  60760. /**
  60761. * Creates a new EquiRectangularCubeTextureAssetTask object
  60762. * @param name defines the name of the task
  60763. * @param url defines the location of the file to load
  60764. * @param size defines the desired size (the more it increases the longer the generation will be)
  60765. * If the size is omitted this implies you are using a preprocessed cubemap.
  60766. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60767. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  60768. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  60769. * (default is true)
  60770. */
  60771. constructor(
  60772. /**
  60773. * Defines the name of the task
  60774. */
  60775. name: string,
  60776. /**
  60777. * Defines the location of the file to load
  60778. */
  60779. url: string,
  60780. /**
  60781. * Defines the desired size (the more it increases the longer the generation will be)
  60782. */
  60783. size: number,
  60784. /**
  60785. * Defines if mipmaps should not be generated (default is false)
  60786. */
  60787. noMipmap?: boolean,
  60788. /**
  60789. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60790. * but the standard material would require them in Gamma space) (default is true)
  60791. */
  60792. gammaSpace?: boolean);
  60793. /**
  60794. * Execute the current task
  60795. * @param scene defines the scene where you want your assets to be loaded
  60796. * @param onSuccess is a callback called when the task is successfully executed
  60797. * @param onError is a callback called if an error occurs
  60798. */
  60799. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60800. }
  60801. /**
  60802. * This class can be used to easily import assets into a scene
  60803. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  60804. */
  60805. export class AssetsManager {
  60806. private _scene;
  60807. private _isLoading;
  60808. protected _tasks: AbstractAssetTask[];
  60809. protected _waitingTasksCount: number;
  60810. protected _totalTasksCount: number;
  60811. /**
  60812. * Callback called when all tasks are processed
  60813. */
  60814. onFinish: (tasks: AbstractAssetTask[]) => void;
  60815. /**
  60816. * Callback called when a task is successful
  60817. */
  60818. onTaskSuccess: (task: AbstractAssetTask) => void;
  60819. /**
  60820. * Callback called when a task had an error
  60821. */
  60822. onTaskError: (task: AbstractAssetTask) => void;
  60823. /**
  60824. * Callback called when a task is done (whatever the result is)
  60825. */
  60826. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  60827. /**
  60828. * Observable called when all tasks are processed
  60829. */
  60830. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  60831. /**
  60832. * Observable called when a task had an error
  60833. */
  60834. onTaskErrorObservable: Observable<AbstractAssetTask>;
  60835. /**
  60836. * Observable called when all tasks were executed
  60837. */
  60838. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  60839. /**
  60840. * Observable called when a task is done (whatever the result is)
  60841. */
  60842. onProgressObservable: Observable<IAssetsProgressEvent>;
  60843. /**
  60844. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  60845. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  60846. */
  60847. useDefaultLoadingScreen: boolean;
  60848. /**
  60849. * Creates a new AssetsManager
  60850. * @param scene defines the scene to work on
  60851. */
  60852. constructor(scene: Scene);
  60853. /**
  60854. * Add a MeshAssetTask to the list of active tasks
  60855. * @param taskName defines the name of the new task
  60856. * @param meshesNames defines the name of meshes to load
  60857. * @param rootUrl defines the root url to use to locate files
  60858. * @param sceneFilename defines the filename of the scene file
  60859. * @returns a new MeshAssetTask object
  60860. */
  60861. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  60862. /**
  60863. * Add a TextFileAssetTask to the list of active tasks
  60864. * @param taskName defines the name of the new task
  60865. * @param url defines the url of the file to load
  60866. * @returns a new TextFileAssetTask object
  60867. */
  60868. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  60869. /**
  60870. * Add a BinaryFileAssetTask to the list of active tasks
  60871. * @param taskName defines the name of the new task
  60872. * @param url defines the url of the file to load
  60873. * @returns a new BinaryFileAssetTask object
  60874. */
  60875. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  60876. /**
  60877. * Add a ImageAssetTask to the list of active tasks
  60878. * @param taskName defines the name of the new task
  60879. * @param url defines the url of the file to load
  60880. * @returns a new ImageAssetTask object
  60881. */
  60882. addImageTask(taskName: string, url: string): ImageAssetTask;
  60883. /**
  60884. * Add a TextureAssetTask to the list of active tasks
  60885. * @param taskName defines the name of the new task
  60886. * @param url defines the url of the file to load
  60887. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60888. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  60889. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60890. * @returns a new TextureAssetTask object
  60891. */
  60892. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  60893. /**
  60894. * Add a CubeTextureAssetTask to the list of active tasks
  60895. * @param taskName defines the name of the new task
  60896. * @param url defines the url of the file to load
  60897. * @param extensions defines the extension to use to load the cube map (can be null)
  60898. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60899. * @param files defines the list of files to load (can be null)
  60900. * @returns a new CubeTextureAssetTask object
  60901. */
  60902. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  60903. /**
  60904. *
  60905. * Add a HDRCubeTextureAssetTask to the list of active tasks
  60906. * @param taskName defines the name of the new task
  60907. * @param url defines the url of the file to load
  60908. * @param size defines the size you want for the cubemap (can be null)
  60909. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60910. * @param generateHarmonics defines if you want to automatically generate (true by default)
  60911. * @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)
  60912. * @param reserved Internal use only
  60913. * @returns a new HDRCubeTextureAssetTask object
  60914. */
  60915. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  60916. /**
  60917. *
  60918. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  60919. * @param taskName defines the name of the new task
  60920. * @param url defines the url of the file to load
  60921. * @param size defines the size you want for the cubemap (can be null)
  60922. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60923. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60924. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60925. * @returns a new EquiRectangularCubeTextureAssetTask object
  60926. */
  60927. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  60928. /**
  60929. * Remove a task from the assets manager.
  60930. * @param task the task to remove
  60931. */
  60932. removeTask(task: AbstractAssetTask): void;
  60933. private _decreaseWaitingTasksCount;
  60934. private _runTask;
  60935. /**
  60936. * Reset the AssetsManager and remove all tasks
  60937. * @return the current instance of the AssetsManager
  60938. */
  60939. reset(): AssetsManager;
  60940. /**
  60941. * Start the loading process
  60942. * @return the current instance of the AssetsManager
  60943. */
  60944. load(): AssetsManager;
  60945. /**
  60946. * Start the loading process as an async operation
  60947. * @return a promise returning the list of failed tasks
  60948. */
  60949. loadAsync(): Promise<void>;
  60950. }
  60951. }
  60952. declare module "babylonjs/Misc/deferred" {
  60953. /**
  60954. * Wrapper class for promise with external resolve and reject.
  60955. */
  60956. export class Deferred<T> {
  60957. /**
  60958. * The promise associated with this deferred object.
  60959. */
  60960. readonly promise: Promise<T>;
  60961. private _resolve;
  60962. private _reject;
  60963. /**
  60964. * The resolve method of the promise associated with this deferred object.
  60965. */
  60966. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  60967. /**
  60968. * The reject method of the promise associated with this deferred object.
  60969. */
  60970. readonly reject: (reason?: any) => void;
  60971. /**
  60972. * Constructor for this deferred object.
  60973. */
  60974. constructor();
  60975. }
  60976. }
  60977. declare module "babylonjs/Misc/meshExploder" {
  60978. import { Mesh } from "babylonjs/Meshes/mesh";
  60979. /**
  60980. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  60981. */
  60982. export class MeshExploder {
  60983. private _centerMesh;
  60984. private _meshes;
  60985. private _meshesOrigins;
  60986. private _toCenterVectors;
  60987. private _scaledDirection;
  60988. private _newPosition;
  60989. private _centerPosition;
  60990. /**
  60991. * Explodes meshes from a center mesh.
  60992. * @param meshes The meshes to explode.
  60993. * @param centerMesh The mesh to be center of explosion.
  60994. */
  60995. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  60996. private _setCenterMesh;
  60997. /**
  60998. * Get class name
  60999. * @returns "MeshExploder"
  61000. */
  61001. getClassName(): string;
  61002. /**
  61003. * "Exploded meshes"
  61004. * @returns Array of meshes with the centerMesh at index 0.
  61005. */
  61006. getMeshes(): Array<Mesh>;
  61007. /**
  61008. * Explodes meshes giving a specific direction
  61009. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61010. */
  61011. explode(direction?: number): void;
  61012. }
  61013. }
  61014. declare module "babylonjs/Misc/filesInput" {
  61015. import { Engine } from "babylonjs/Engines/engine";
  61016. import { Scene } from "babylonjs/scene";
  61017. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  61018. /**
  61019. * Class used to help managing file picking and drag'n'drop
  61020. */
  61021. export class FilesInput {
  61022. /**
  61023. * List of files ready to be loaded
  61024. */
  61025. static readonly FilesToLoad: {
  61026. [key: string]: File;
  61027. };
  61028. /**
  61029. * Callback called when a file is processed
  61030. */
  61031. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61032. private _engine;
  61033. private _currentScene;
  61034. private _sceneLoadedCallback;
  61035. private _progressCallback;
  61036. private _additionalRenderLoopLogicCallback;
  61037. private _textureLoadingCallback;
  61038. private _startingProcessingFilesCallback;
  61039. private _onReloadCallback;
  61040. private _errorCallback;
  61041. private _elementToMonitor;
  61042. private _sceneFileToLoad;
  61043. private _filesToLoad;
  61044. /**
  61045. * Creates a new FilesInput
  61046. * @param engine defines the rendering engine
  61047. * @param scene defines the hosting scene
  61048. * @param sceneLoadedCallback callback called when scene is loaded
  61049. * @param progressCallback callback called to track progress
  61050. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61051. * @param textureLoadingCallback callback called when a texture is loading
  61052. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61053. * @param onReloadCallback callback called when a reload is requested
  61054. * @param errorCallback callback call if an error occurs
  61055. */
  61056. 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);
  61057. private _dragEnterHandler;
  61058. private _dragOverHandler;
  61059. private _dropHandler;
  61060. /**
  61061. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61062. * @param elementToMonitor defines the DOM element to track
  61063. */
  61064. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61065. /**
  61066. * Release all associated resources
  61067. */
  61068. dispose(): void;
  61069. private renderFunction;
  61070. private drag;
  61071. private drop;
  61072. private _traverseFolder;
  61073. private _processFiles;
  61074. /**
  61075. * Load files from a drop event
  61076. * @param event defines the drop event to use as source
  61077. */
  61078. loadFiles(event: any): void;
  61079. private _processReload;
  61080. /**
  61081. * Reload the current scene from the loaded files
  61082. */
  61083. reload(): void;
  61084. }
  61085. }
  61086. declare module "babylonjs/Misc/HighDynamicRange/index" {
  61087. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  61088. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  61089. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61090. }
  61091. declare module "babylonjs/Misc/sceneOptimizer" {
  61092. import { Scene, IDisposable } from "babylonjs/scene";
  61093. import { Observable } from "babylonjs/Misc/observable";
  61094. /**
  61095. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61096. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61097. */
  61098. export class SceneOptimization {
  61099. /**
  61100. * Defines the priority of this optimization (0 by default which means first in the list)
  61101. */
  61102. priority: number;
  61103. /**
  61104. * Gets a string describing the action executed by the current optimization
  61105. * @returns description string
  61106. */
  61107. getDescription(): string;
  61108. /**
  61109. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61110. * @param scene defines the current scene where to apply this optimization
  61111. * @param optimizer defines the current optimizer
  61112. * @returns true if everything that can be done was applied
  61113. */
  61114. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61115. /**
  61116. * Creates the SceneOptimization object
  61117. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61118. * @param desc defines the description associated with the optimization
  61119. */
  61120. constructor(
  61121. /**
  61122. * Defines the priority of this optimization (0 by default which means first in the list)
  61123. */
  61124. priority?: number);
  61125. }
  61126. /**
  61127. * Defines an optimization used to reduce the size of render target textures
  61128. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61129. */
  61130. export class TextureOptimization extends SceneOptimization {
  61131. /**
  61132. * Defines the priority of this optimization (0 by default which means first in the list)
  61133. */
  61134. priority: number;
  61135. /**
  61136. * 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
  61137. */
  61138. maximumSize: number;
  61139. /**
  61140. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61141. */
  61142. step: number;
  61143. /**
  61144. * Gets a string describing the action executed by the current optimization
  61145. * @returns description string
  61146. */
  61147. getDescription(): string;
  61148. /**
  61149. * Creates the TextureOptimization object
  61150. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61151. * @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
  61152. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61153. */
  61154. constructor(
  61155. /**
  61156. * Defines the priority of this optimization (0 by default which means first in the list)
  61157. */
  61158. priority?: number,
  61159. /**
  61160. * 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
  61161. */
  61162. maximumSize?: number,
  61163. /**
  61164. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61165. */
  61166. step?: number);
  61167. /**
  61168. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61169. * @param scene defines the current scene where to apply this optimization
  61170. * @param optimizer defines the current optimizer
  61171. * @returns true if everything that can be done was applied
  61172. */
  61173. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61174. }
  61175. /**
  61176. * Defines an optimization used to increase or decrease the rendering resolution
  61177. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61178. */
  61179. export class HardwareScalingOptimization extends SceneOptimization {
  61180. /**
  61181. * Defines the priority of this optimization (0 by default which means first in the list)
  61182. */
  61183. priority: number;
  61184. /**
  61185. * Defines the maximum scale to use (2 by default)
  61186. */
  61187. maximumScale: number;
  61188. /**
  61189. * Defines the step to use between two passes (0.5 by default)
  61190. */
  61191. step: number;
  61192. private _currentScale;
  61193. private _directionOffset;
  61194. /**
  61195. * Gets a string describing the action executed by the current optimization
  61196. * @return description string
  61197. */
  61198. getDescription(): string;
  61199. /**
  61200. * Creates the HardwareScalingOptimization object
  61201. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61202. * @param maximumScale defines the maximum scale to use (2 by default)
  61203. * @param step defines the step to use between two passes (0.5 by default)
  61204. */
  61205. constructor(
  61206. /**
  61207. * Defines the priority of this optimization (0 by default which means first in the list)
  61208. */
  61209. priority?: number,
  61210. /**
  61211. * Defines the maximum scale to use (2 by default)
  61212. */
  61213. maximumScale?: number,
  61214. /**
  61215. * Defines the step to use between two passes (0.5 by default)
  61216. */
  61217. step?: number);
  61218. /**
  61219. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61220. * @param scene defines the current scene where to apply this optimization
  61221. * @param optimizer defines the current optimizer
  61222. * @returns true if everything that can be done was applied
  61223. */
  61224. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61225. }
  61226. /**
  61227. * Defines an optimization used to remove shadows
  61228. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61229. */
  61230. export class ShadowsOptimization extends SceneOptimization {
  61231. /**
  61232. * Gets a string describing the action executed by the current optimization
  61233. * @return description string
  61234. */
  61235. getDescription(): string;
  61236. /**
  61237. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61238. * @param scene defines the current scene where to apply this optimization
  61239. * @param optimizer defines the current optimizer
  61240. * @returns true if everything that can be done was applied
  61241. */
  61242. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61243. }
  61244. /**
  61245. * Defines an optimization used to turn post-processes off
  61246. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61247. */
  61248. export class PostProcessesOptimization extends SceneOptimization {
  61249. /**
  61250. * Gets a string describing the action executed by the current optimization
  61251. * @return description string
  61252. */
  61253. getDescription(): string;
  61254. /**
  61255. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61256. * @param scene defines the current scene where to apply this optimization
  61257. * @param optimizer defines the current optimizer
  61258. * @returns true if everything that can be done was applied
  61259. */
  61260. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61261. }
  61262. /**
  61263. * Defines an optimization used to turn lens flares off
  61264. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61265. */
  61266. export class LensFlaresOptimization extends SceneOptimization {
  61267. /**
  61268. * Gets a string describing the action executed by the current optimization
  61269. * @return description string
  61270. */
  61271. getDescription(): string;
  61272. /**
  61273. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61274. * @param scene defines the current scene where to apply this optimization
  61275. * @param optimizer defines the current optimizer
  61276. * @returns true if everything that can be done was applied
  61277. */
  61278. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61279. }
  61280. /**
  61281. * Defines an optimization based on user defined callback.
  61282. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61283. */
  61284. export class CustomOptimization extends SceneOptimization {
  61285. /**
  61286. * Callback called to apply the custom optimization.
  61287. */
  61288. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61289. /**
  61290. * Callback called to get custom description
  61291. */
  61292. onGetDescription: () => string;
  61293. /**
  61294. * Gets a string describing the action executed by the current optimization
  61295. * @returns description string
  61296. */
  61297. getDescription(): string;
  61298. /**
  61299. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61300. * @param scene defines the current scene where to apply this optimization
  61301. * @param optimizer defines the current optimizer
  61302. * @returns true if everything that can be done was applied
  61303. */
  61304. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61305. }
  61306. /**
  61307. * Defines an optimization used to turn particles off
  61308. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61309. */
  61310. export class ParticlesOptimization extends SceneOptimization {
  61311. /**
  61312. * Gets a string describing the action executed by the current optimization
  61313. * @return description string
  61314. */
  61315. getDescription(): string;
  61316. /**
  61317. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61318. * @param scene defines the current scene where to apply this optimization
  61319. * @param optimizer defines the current optimizer
  61320. * @returns true if everything that can be done was applied
  61321. */
  61322. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61323. }
  61324. /**
  61325. * Defines an optimization used to turn render targets off
  61326. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61327. */
  61328. export class RenderTargetsOptimization extends SceneOptimization {
  61329. /**
  61330. * Gets a string describing the action executed by the current optimization
  61331. * @return description string
  61332. */
  61333. getDescription(): string;
  61334. /**
  61335. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61336. * @param scene defines the current scene where to apply this optimization
  61337. * @param optimizer defines the current optimizer
  61338. * @returns true if everything that can be done was applied
  61339. */
  61340. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61341. }
  61342. /**
  61343. * Defines an optimization used to merge meshes with compatible materials
  61344. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61345. */
  61346. export class MergeMeshesOptimization extends SceneOptimization {
  61347. private static _UpdateSelectionTree;
  61348. /**
  61349. * Gets or sets a boolean which defines if optimization octree has to be updated
  61350. */
  61351. /**
  61352. * Gets or sets a boolean which defines if optimization octree has to be updated
  61353. */
  61354. static UpdateSelectionTree: boolean;
  61355. /**
  61356. * Gets a string describing the action executed by the current optimization
  61357. * @return description string
  61358. */
  61359. getDescription(): string;
  61360. private _canBeMerged;
  61361. /**
  61362. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61363. * @param scene defines the current scene where to apply this optimization
  61364. * @param optimizer defines the current optimizer
  61365. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61366. * @returns true if everything that can be done was applied
  61367. */
  61368. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61369. }
  61370. /**
  61371. * Defines a list of options used by SceneOptimizer
  61372. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61373. */
  61374. export class SceneOptimizerOptions {
  61375. /**
  61376. * Defines the target frame rate to reach (60 by default)
  61377. */
  61378. targetFrameRate: number;
  61379. /**
  61380. * Defines the interval between two checkes (2000ms by default)
  61381. */
  61382. trackerDuration: number;
  61383. /**
  61384. * Gets the list of optimizations to apply
  61385. */
  61386. optimizations: SceneOptimization[];
  61387. /**
  61388. * Creates a new list of options used by SceneOptimizer
  61389. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61390. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61391. */
  61392. constructor(
  61393. /**
  61394. * Defines the target frame rate to reach (60 by default)
  61395. */
  61396. targetFrameRate?: number,
  61397. /**
  61398. * Defines the interval between two checkes (2000ms by default)
  61399. */
  61400. trackerDuration?: number);
  61401. /**
  61402. * Add a new optimization
  61403. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61404. * @returns the current SceneOptimizerOptions
  61405. */
  61406. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61407. /**
  61408. * Add a new custom optimization
  61409. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61410. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61411. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61412. * @returns the current SceneOptimizerOptions
  61413. */
  61414. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61415. /**
  61416. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61417. * @param targetFrameRate defines the target frame rate (60 by default)
  61418. * @returns a SceneOptimizerOptions object
  61419. */
  61420. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61421. /**
  61422. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61423. * @param targetFrameRate defines the target frame rate (60 by default)
  61424. * @returns a SceneOptimizerOptions object
  61425. */
  61426. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61427. /**
  61428. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61429. * @param targetFrameRate defines the target frame rate (60 by default)
  61430. * @returns a SceneOptimizerOptions object
  61431. */
  61432. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61433. }
  61434. /**
  61435. * Class used to run optimizations in order to reach a target frame rate
  61436. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61437. */
  61438. export class SceneOptimizer implements IDisposable {
  61439. private _isRunning;
  61440. private _options;
  61441. private _scene;
  61442. private _currentPriorityLevel;
  61443. private _targetFrameRate;
  61444. private _trackerDuration;
  61445. private _currentFrameRate;
  61446. private _sceneDisposeObserver;
  61447. private _improvementMode;
  61448. /**
  61449. * Defines an observable called when the optimizer reaches the target frame rate
  61450. */
  61451. onSuccessObservable: Observable<SceneOptimizer>;
  61452. /**
  61453. * Defines an observable called when the optimizer enables an optimization
  61454. */
  61455. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61456. /**
  61457. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61458. */
  61459. onFailureObservable: Observable<SceneOptimizer>;
  61460. /**
  61461. * Gets a boolean indicating if the optimizer is in improvement mode
  61462. */
  61463. readonly isInImprovementMode: boolean;
  61464. /**
  61465. * Gets the current priority level (0 at start)
  61466. */
  61467. readonly currentPriorityLevel: number;
  61468. /**
  61469. * Gets the current frame rate checked by the SceneOptimizer
  61470. */
  61471. readonly currentFrameRate: number;
  61472. /**
  61473. * Gets or sets the current target frame rate (60 by default)
  61474. */
  61475. /**
  61476. * Gets or sets the current target frame rate (60 by default)
  61477. */
  61478. targetFrameRate: number;
  61479. /**
  61480. * Gets or sets the current interval between two checks (every 2000ms by default)
  61481. */
  61482. /**
  61483. * Gets or sets the current interval between two checks (every 2000ms by default)
  61484. */
  61485. trackerDuration: number;
  61486. /**
  61487. * Gets the list of active optimizations
  61488. */
  61489. readonly optimizations: SceneOptimization[];
  61490. /**
  61491. * Creates a new SceneOptimizer
  61492. * @param scene defines the scene to work on
  61493. * @param options defines the options to use with the SceneOptimizer
  61494. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61495. * @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)
  61496. */
  61497. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61498. /**
  61499. * Stops the current optimizer
  61500. */
  61501. stop(): void;
  61502. /**
  61503. * Reset the optimizer to initial step (current priority level = 0)
  61504. */
  61505. reset(): void;
  61506. /**
  61507. * Start the optimizer. By default it will try to reach a specific framerate
  61508. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61509. */
  61510. start(): void;
  61511. private _checkCurrentState;
  61512. /**
  61513. * Release all resources
  61514. */
  61515. dispose(): void;
  61516. /**
  61517. * Helper function to create a SceneOptimizer with one single line of code
  61518. * @param scene defines the scene to work on
  61519. * @param options defines the options to use with the SceneOptimizer
  61520. * @param onSuccess defines a callback to call on success
  61521. * @param onFailure defines a callback to call on failure
  61522. * @returns the new SceneOptimizer object
  61523. */
  61524. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61525. }
  61526. }
  61527. declare module "babylonjs/Misc/sceneSerializer" {
  61528. import { Scene } from "babylonjs/scene";
  61529. /**
  61530. * Class used to serialize a scene into a string
  61531. */
  61532. export class SceneSerializer {
  61533. /**
  61534. * Clear cache used by a previous serialization
  61535. */
  61536. static ClearCache(): void;
  61537. /**
  61538. * Serialize a scene into a JSON compatible object
  61539. * @param scene defines the scene to serialize
  61540. * @returns a JSON compatible object
  61541. */
  61542. static Serialize(scene: Scene): any;
  61543. /**
  61544. * Serialize a mesh into a JSON compatible object
  61545. * @param toSerialize defines the mesh to serialize
  61546. * @param withParents defines if parents must be serialized as well
  61547. * @param withChildren defines if children must be serialized as well
  61548. * @returns a JSON compatible object
  61549. */
  61550. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61551. }
  61552. }
  61553. declare module "babylonjs/Misc/textureTools" {
  61554. import { Texture } from "babylonjs/Materials/Textures/texture";
  61555. /**
  61556. * Class used to host texture specific utilities
  61557. */
  61558. export class TextureTools {
  61559. /**
  61560. * Uses the GPU to create a copy texture rescaled at a given size
  61561. * @param texture Texture to copy from
  61562. * @param width defines the desired width
  61563. * @param height defines the desired height
  61564. * @param useBilinearMode defines if bilinear mode has to be used
  61565. * @return the generated texture
  61566. */
  61567. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61568. }
  61569. }
  61570. declare module "babylonjs/Misc/videoRecorder" {
  61571. import { Nullable } from "babylonjs/types";
  61572. import { Engine } from "babylonjs/Engines/engine";
  61573. /**
  61574. * This represents the different options avilable for the video capture.
  61575. */
  61576. export interface VideoRecorderOptions {
  61577. /** Defines the mime type of the video */
  61578. mimeType: string;
  61579. /** Defines the video the video should be recorded at */
  61580. fps: number;
  61581. /** Defines the chunk size for the recording data */
  61582. recordChunckSize: number;
  61583. /** The audio tracks to attach to the record */
  61584. audioTracks?: MediaStreamTrack[];
  61585. }
  61586. /**
  61587. * This can helps recording videos from BabylonJS.
  61588. * This is based on the available WebRTC functionalities of the browser.
  61589. *
  61590. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61591. */
  61592. export class VideoRecorder {
  61593. private static readonly _defaultOptions;
  61594. /**
  61595. * Returns wehther or not the VideoRecorder is available in your browser.
  61596. * @param engine Defines the Babylon Engine to check the support for
  61597. * @returns true if supported otherwise false
  61598. */
  61599. static IsSupported(engine: Engine): boolean;
  61600. private readonly _options;
  61601. private _canvas;
  61602. private _mediaRecorder;
  61603. private _recordedChunks;
  61604. private _fileName;
  61605. private _resolve;
  61606. private _reject;
  61607. /**
  61608. * True wether a recording is already in progress.
  61609. */
  61610. readonly isRecording: boolean;
  61611. /**
  61612. * Create a new VideoCapture object which can help converting what you see in Babylon to
  61613. * a video file.
  61614. * @param engine Defines the BabylonJS Engine you wish to record
  61615. * @param options Defines options that can be used to customized the capture
  61616. */
  61617. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61618. /**
  61619. * Stops the current recording before the default capture timeout passed in the startRecording
  61620. * functions.
  61621. */
  61622. stopRecording(): void;
  61623. /**
  61624. * Starts recording the canvas for a max duration specified in parameters.
  61625. * @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.
  61626. * @param maxDuration Defines the maximum recording time in seconds.
  61627. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61628. * @return a promise callback at the end of the recording with the video data in Blob.
  61629. */
  61630. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61631. /**
  61632. * Releases internal resources used during the recording.
  61633. */
  61634. dispose(): void;
  61635. private _handleDataAvailable;
  61636. private _handleError;
  61637. private _handleStop;
  61638. }
  61639. }
  61640. declare module "babylonjs/Misc/screenshotTools" {
  61641. import { Camera } from "babylonjs/Cameras/camera";
  61642. import { Engine } from "babylonjs/Engines/engine";
  61643. /**
  61644. * Class containing a set of static utilities functions for screenshots
  61645. */
  61646. export class ScreenshotTools {
  61647. /**
  61648. * Captures a screenshot of the current rendering
  61649. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61650. * @param engine defines the rendering engine
  61651. * @param camera defines the source camera
  61652. * @param size This parameter can be set to a single number or to an object with the
  61653. * following (optional) properties: precision, width, height. If a single number is passed,
  61654. * it will be used for both width and height. If an object is passed, the screenshot size
  61655. * will be derived from the parameters. The precision property is a multiplier allowing
  61656. * rendering at a higher or lower resolution
  61657. * @param successCallback defines the callback receives a single parameter which contains the
  61658. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61659. * src parameter of an <img> to display it
  61660. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61661. * Check your browser for supported MIME types
  61662. */
  61663. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  61664. /**
  61665. * Generates an image screenshot from the specified camera.
  61666. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61667. * @param engine The engine to use for rendering
  61668. * @param camera The camera to use for rendering
  61669. * @param size This parameter can be set to a single number or to an object with the
  61670. * following (optional) properties: precision, width, height. If a single number is passed,
  61671. * it will be used for both width and height. If an object is passed, the screenshot size
  61672. * will be derived from the parameters. The precision property is a multiplier allowing
  61673. * rendering at a higher or lower resolution
  61674. * @param successCallback The callback receives a single parameter which contains the
  61675. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61676. * src parameter of an <img> to display it
  61677. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61678. * Check your browser for supported MIME types
  61679. * @param samples Texture samples (default: 1)
  61680. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61681. * @param fileName A name for for the downloaded file.
  61682. */
  61683. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61684. }
  61685. }
  61686. declare module "babylonjs/Misc/index" {
  61687. export * from "babylonjs/Misc/andOrNotEvaluator";
  61688. export * from "babylonjs/Misc/assetsManager";
  61689. export * from "babylonjs/Misc/dds";
  61690. export * from "babylonjs/Misc/decorators";
  61691. export * from "babylonjs/Misc/deferred";
  61692. export * from "babylonjs/Misc/environmentTextureTools";
  61693. export * from "babylonjs/Misc/meshExploder";
  61694. export * from "babylonjs/Misc/filesInput";
  61695. export * from "babylonjs/Misc/HighDynamicRange/index";
  61696. export * from "babylonjs/Misc/khronosTextureContainer";
  61697. export * from "babylonjs/Misc/observable";
  61698. export * from "babylonjs/Misc/performanceMonitor";
  61699. export * from "babylonjs/Misc/promise";
  61700. export * from "babylonjs/Misc/sceneOptimizer";
  61701. export * from "babylonjs/Misc/sceneSerializer";
  61702. export * from "babylonjs/Misc/smartArray";
  61703. export * from "babylonjs/Misc/stringDictionary";
  61704. export * from "babylonjs/Misc/tags";
  61705. export * from "babylonjs/Misc/textureTools";
  61706. export * from "babylonjs/Misc/tga";
  61707. export * from "babylonjs/Misc/tools";
  61708. export * from "babylonjs/Misc/videoRecorder";
  61709. export * from "babylonjs/Misc/virtualJoystick";
  61710. export * from "babylonjs/Misc/workerPool";
  61711. export * from "babylonjs/Misc/logger";
  61712. export * from "babylonjs/Misc/typeStore";
  61713. export * from "babylonjs/Misc/filesInputStore";
  61714. export * from "babylonjs/Misc/deepCopier";
  61715. export * from "babylonjs/Misc/pivotTools";
  61716. export * from "babylonjs/Misc/precisionDate";
  61717. export * from "babylonjs/Misc/screenshotTools";
  61718. export * from "babylonjs/Misc/typeStore";
  61719. export * from "babylonjs/Misc/webRequest";
  61720. export * from "babylonjs/Misc/iInspectable";
  61721. export * from "babylonjs/Misc/brdfTextureTools";
  61722. }
  61723. declare module "babylonjs/index" {
  61724. export * from "babylonjs/abstractScene";
  61725. export * from "babylonjs/Actions/index";
  61726. export * from "babylonjs/Animations/index";
  61727. export * from "babylonjs/assetContainer";
  61728. export * from "babylonjs/Audio/index";
  61729. export * from "babylonjs/Behaviors/index";
  61730. export * from "babylonjs/Bones/index";
  61731. export * from "babylonjs/Cameras/index";
  61732. export * from "babylonjs/Collisions/index";
  61733. export * from "babylonjs/Culling/index";
  61734. export * from "babylonjs/Debug/index";
  61735. export * from "babylonjs/Engines/index";
  61736. export * from "babylonjs/Events/index";
  61737. export * from "babylonjs/Gamepads/index";
  61738. export * from "babylonjs/Gizmos/index";
  61739. export * from "babylonjs/Helpers/index";
  61740. export * from "babylonjs/Instrumentation/index";
  61741. export * from "babylonjs/Layers/index";
  61742. export * from "babylonjs/LensFlares/index";
  61743. export * from "babylonjs/Lights/index";
  61744. export * from "babylonjs/Loading/index";
  61745. export * from "babylonjs/Materials/index";
  61746. export * from "babylonjs/Maths/index";
  61747. export * from "babylonjs/Meshes/index";
  61748. export * from "babylonjs/Morph/index";
  61749. export * from "babylonjs/node";
  61750. export * from "babylonjs/Offline/index";
  61751. export * from "babylonjs/Particles/index";
  61752. export * from "babylonjs/Physics/index";
  61753. export * from "babylonjs/PostProcesses/index";
  61754. export * from "babylonjs/Probes/index";
  61755. export * from "babylonjs/Rendering/index";
  61756. export * from "babylonjs/scene";
  61757. export * from "babylonjs/sceneComponent";
  61758. export * from "babylonjs/Sprites/index";
  61759. export * from "babylonjs/States/index";
  61760. export * from "babylonjs/Misc/index";
  61761. export * from "babylonjs/types";
  61762. }
  61763. declare module "babylonjs/Animations/pathCursor" {
  61764. import { Path2, Vector3 } from "babylonjs/Maths/math";
  61765. /**
  61766. * A cursor which tracks a point on a path
  61767. */
  61768. export class PathCursor {
  61769. private path;
  61770. /**
  61771. * Stores path cursor callbacks for when an onchange event is triggered
  61772. */
  61773. private _onchange;
  61774. /**
  61775. * The value of the path cursor
  61776. */
  61777. value: number;
  61778. /**
  61779. * The animation array of the path cursor
  61780. */
  61781. animations: Animation[];
  61782. /**
  61783. * Initializes the path cursor
  61784. * @param path The path to track
  61785. */
  61786. constructor(path: Path2);
  61787. /**
  61788. * Gets the cursor point on the path
  61789. * @returns A point on the path cursor at the cursor location
  61790. */
  61791. getPoint(): Vector3;
  61792. /**
  61793. * Moves the cursor ahead by the step amount
  61794. * @param step The amount to move the cursor forward
  61795. * @returns This path cursor
  61796. */
  61797. moveAhead(step?: number): PathCursor;
  61798. /**
  61799. * Moves the cursor behind by the step amount
  61800. * @param step The amount to move the cursor back
  61801. * @returns This path cursor
  61802. */
  61803. moveBack(step?: number): PathCursor;
  61804. /**
  61805. * Moves the cursor by the step amount
  61806. * If the step amount is greater than one, an exception is thrown
  61807. * @param step The amount to move the cursor
  61808. * @returns This path cursor
  61809. */
  61810. move(step: number): PathCursor;
  61811. /**
  61812. * Ensures that the value is limited between zero and one
  61813. * @returns This path cursor
  61814. */
  61815. private ensureLimits;
  61816. /**
  61817. * Runs onchange callbacks on change (used by the animation engine)
  61818. * @returns This path cursor
  61819. */
  61820. private raiseOnChange;
  61821. /**
  61822. * Executes a function on change
  61823. * @param f A path cursor onchange callback
  61824. * @returns This path cursor
  61825. */
  61826. onchange(f: (cursor: PathCursor) => void): PathCursor;
  61827. }
  61828. }
  61829. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  61830. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  61831. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  61832. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  61833. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  61834. }
  61835. declare module "babylonjs/Engines/Processors/Expressions/index" {
  61836. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  61837. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  61838. }
  61839. declare module "babylonjs/Engines/Processors/index" {
  61840. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  61841. export * from "babylonjs/Engines/Processors/Expressions/index";
  61842. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  61843. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  61844. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  61845. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  61846. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  61847. export * from "babylonjs/Engines/Processors/shaderProcessor";
  61848. }
  61849. declare module "babylonjs/Legacy/legacy" {
  61850. import * as Babylon from "babylonjs/index";
  61851. export * from "babylonjs/index";
  61852. }
  61853. declare module "babylonjs/Shaders/blur.fragment" {
  61854. /** @hidden */
  61855. export var blurPixelShader: {
  61856. name: string;
  61857. shader: string;
  61858. };
  61859. }
  61860. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  61861. /** @hidden */
  61862. export var bones300Declaration: {
  61863. name: string;
  61864. shader: string;
  61865. };
  61866. }
  61867. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  61868. /** @hidden */
  61869. export var instances300Declaration: {
  61870. name: string;
  61871. shader: string;
  61872. };
  61873. }
  61874. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  61875. /** @hidden */
  61876. export var pointCloudVertexDeclaration: {
  61877. name: string;
  61878. shader: string;
  61879. };
  61880. }
  61881. // Mixins
  61882. interface Window {
  61883. mozIndexedDB: IDBFactory;
  61884. webkitIndexedDB: IDBFactory;
  61885. msIndexedDB: IDBFactory;
  61886. webkitURL: typeof URL;
  61887. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  61888. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  61889. WebGLRenderingContext: WebGLRenderingContext;
  61890. MSGesture: MSGesture;
  61891. CANNON: any;
  61892. AudioContext: AudioContext;
  61893. webkitAudioContext: AudioContext;
  61894. PointerEvent: any;
  61895. Math: Math;
  61896. Uint8Array: Uint8ArrayConstructor;
  61897. Float32Array: Float32ArrayConstructor;
  61898. mozURL: typeof URL;
  61899. msURL: typeof URL;
  61900. VRFrameData: any; // WebVR, from specs 1.1
  61901. DracoDecoderModule: any;
  61902. setImmediate(handler: (...args: any[]) => void): number;
  61903. }
  61904. interface HTMLCanvasElement {
  61905. requestPointerLock(): void;
  61906. msRequestPointerLock?(): void;
  61907. mozRequestPointerLock?(): void;
  61908. webkitRequestPointerLock?(): void;
  61909. /** Track wether a record is in progress */
  61910. isRecording: boolean;
  61911. /** Capture Stream method defined by some browsers */
  61912. captureStream(fps?: number): MediaStream;
  61913. }
  61914. interface CanvasRenderingContext2D {
  61915. msImageSmoothingEnabled: boolean;
  61916. }
  61917. interface MouseEvent {
  61918. mozMovementX: number;
  61919. mozMovementY: number;
  61920. webkitMovementX: number;
  61921. webkitMovementY: number;
  61922. msMovementX: number;
  61923. msMovementY: number;
  61924. }
  61925. interface Navigator {
  61926. mozGetVRDevices: (any: any) => any;
  61927. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61928. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61929. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61930. webkitGetGamepads(): Gamepad[];
  61931. msGetGamepads(): Gamepad[];
  61932. webkitGamepads(): Gamepad[];
  61933. }
  61934. interface HTMLVideoElement {
  61935. mozSrcObject: any;
  61936. }
  61937. interface Math {
  61938. fround(x: number): number;
  61939. imul(a: number, b: number): number;
  61940. }
  61941. interface WebGLRenderingContext {
  61942. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  61943. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  61944. vertexAttribDivisor(index: number, divisor: number): void;
  61945. createVertexArray(): any;
  61946. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  61947. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  61948. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  61949. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  61950. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  61951. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  61952. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  61953. // Queries
  61954. createQuery(): WebGLQuery;
  61955. deleteQuery(query: WebGLQuery): void;
  61956. beginQuery(target: number, query: WebGLQuery): void;
  61957. endQuery(target: number): void;
  61958. getQueryParameter(query: WebGLQuery, pname: number): any;
  61959. getQuery(target: number, pname: number): any;
  61960. MAX_SAMPLES: number;
  61961. RGBA8: number;
  61962. READ_FRAMEBUFFER: number;
  61963. DRAW_FRAMEBUFFER: number;
  61964. UNIFORM_BUFFER: number;
  61965. HALF_FLOAT_OES: number;
  61966. RGBA16F: number;
  61967. RGBA32F: number;
  61968. R32F: number;
  61969. RG32F: number;
  61970. RGB32F: number;
  61971. R16F: number;
  61972. RG16F: number;
  61973. RGB16F: number;
  61974. RED: number;
  61975. RG: number;
  61976. R8: number;
  61977. RG8: number;
  61978. UNSIGNED_INT_24_8: number;
  61979. DEPTH24_STENCIL8: number;
  61980. /* Multiple Render Targets */
  61981. drawBuffers(buffers: number[]): void;
  61982. readBuffer(src: number): void;
  61983. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  61984. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  61985. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  61986. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  61987. // Occlusion Query
  61988. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  61989. ANY_SAMPLES_PASSED: number;
  61990. QUERY_RESULT_AVAILABLE: number;
  61991. QUERY_RESULT: number;
  61992. }
  61993. interface WebGLProgram {
  61994. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  61995. }
  61996. interface EXT_disjoint_timer_query {
  61997. QUERY_COUNTER_BITS_EXT: number;
  61998. TIME_ELAPSED_EXT: number;
  61999. TIMESTAMP_EXT: number;
  62000. GPU_DISJOINT_EXT: number;
  62001. QUERY_RESULT_EXT: number;
  62002. QUERY_RESULT_AVAILABLE_EXT: number;
  62003. queryCounterEXT(query: WebGLQuery, target: number): void;
  62004. createQueryEXT(): WebGLQuery;
  62005. beginQueryEXT(target: number, query: WebGLQuery): void;
  62006. endQueryEXT(target: number): void;
  62007. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62008. deleteQueryEXT(query: WebGLQuery): void;
  62009. }
  62010. interface WebGLUniformLocation {
  62011. _currentState: any;
  62012. }
  62013. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62014. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62015. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62016. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62017. interface WebGLRenderingContext {
  62018. readonly RASTERIZER_DISCARD: number;
  62019. readonly DEPTH_COMPONENT24: number;
  62020. readonly TEXTURE_3D: number;
  62021. readonly TEXTURE_2D_ARRAY: number;
  62022. readonly TEXTURE_COMPARE_FUNC: number;
  62023. readonly TEXTURE_COMPARE_MODE: number;
  62024. readonly COMPARE_REF_TO_TEXTURE: number;
  62025. readonly TEXTURE_WRAP_R: number;
  62026. readonly HALF_FLOAT: number;
  62027. readonly RGB8: number;
  62028. readonly RED_INTEGER: number;
  62029. readonly RG_INTEGER: number;
  62030. readonly RGB_INTEGER: number;
  62031. readonly RGBA_INTEGER: number;
  62032. readonly R8_SNORM: number;
  62033. readonly RG8_SNORM: number;
  62034. readonly RGB8_SNORM: number;
  62035. readonly RGBA8_SNORM: number;
  62036. readonly R8I: number;
  62037. readonly RG8I: number;
  62038. readonly RGB8I: number;
  62039. readonly RGBA8I: number;
  62040. readonly R8UI: number;
  62041. readonly RG8UI: number;
  62042. readonly RGB8UI: number;
  62043. readonly RGBA8UI: number;
  62044. readonly R16I: number;
  62045. readonly RG16I: number;
  62046. readonly RGB16I: number;
  62047. readonly RGBA16I: number;
  62048. readonly R16UI: number;
  62049. readonly RG16UI: number;
  62050. readonly RGB16UI: number;
  62051. readonly RGBA16UI: number;
  62052. readonly R32I: number;
  62053. readonly RG32I: number;
  62054. readonly RGB32I: number;
  62055. readonly RGBA32I: number;
  62056. readonly R32UI: number;
  62057. readonly RG32UI: number;
  62058. readonly RGB32UI: number;
  62059. readonly RGBA32UI: number;
  62060. readonly RGB10_A2UI: number;
  62061. readonly R11F_G11F_B10F: number;
  62062. readonly RGB9_E5: number;
  62063. readonly RGB10_A2: number;
  62064. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62065. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62066. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62067. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62068. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62069. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62070. 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;
  62071. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62072. readonly TRANSFORM_FEEDBACK: number;
  62073. readonly INTERLEAVED_ATTRIBS: number;
  62074. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62075. createTransformFeedback(): WebGLTransformFeedback;
  62076. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62077. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62078. beginTransformFeedback(primitiveMode: number): void;
  62079. endTransformFeedback(): void;
  62080. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62081. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62082. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62083. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62084. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62085. }
  62086. interface ImageBitmap {
  62087. readonly width: number;
  62088. readonly height: number;
  62089. close(): void;
  62090. }
  62091. interface WebGLQuery extends WebGLObject {
  62092. }
  62093. declare var WebGLQuery: {
  62094. prototype: WebGLQuery;
  62095. new(): WebGLQuery;
  62096. };
  62097. interface WebGLSampler extends WebGLObject {
  62098. }
  62099. declare var WebGLSampler: {
  62100. prototype: WebGLSampler;
  62101. new(): WebGLSampler;
  62102. };
  62103. interface WebGLSync extends WebGLObject {
  62104. }
  62105. declare var WebGLSync: {
  62106. prototype: WebGLSync;
  62107. new(): WebGLSync;
  62108. };
  62109. interface WebGLTransformFeedback extends WebGLObject {
  62110. }
  62111. declare var WebGLTransformFeedback: {
  62112. prototype: WebGLTransformFeedback;
  62113. new(): WebGLTransformFeedback;
  62114. };
  62115. interface WebGLVertexArrayObject extends WebGLObject {
  62116. }
  62117. declare var WebGLVertexArrayObject: {
  62118. prototype: WebGLVertexArrayObject;
  62119. new(): WebGLVertexArrayObject;
  62120. };
  62121. // Type definitions for WebVR API
  62122. // Project: https://w3c.github.io/webvr/
  62123. // Definitions by: six a <https://github.com/lostfictions>
  62124. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62125. interface VRDisplay extends EventTarget {
  62126. /**
  62127. * Dictionary of capabilities describing the VRDisplay.
  62128. */
  62129. readonly capabilities: VRDisplayCapabilities;
  62130. /**
  62131. * z-depth defining the far plane of the eye view frustum
  62132. * enables mapping of values in the render target depth
  62133. * attachment to scene coordinates. Initially set to 10000.0.
  62134. */
  62135. depthFar: number;
  62136. /**
  62137. * z-depth defining the near plane of the eye view frustum
  62138. * enables mapping of values in the render target depth
  62139. * attachment to scene coordinates. Initially set to 0.01.
  62140. */
  62141. depthNear: number;
  62142. /**
  62143. * An identifier for this distinct VRDisplay. Used as an
  62144. * association point in the Gamepad API.
  62145. */
  62146. readonly displayId: number;
  62147. /**
  62148. * A display name, a user-readable name identifying it.
  62149. */
  62150. readonly displayName: string;
  62151. readonly isConnected: boolean;
  62152. readonly isPresenting: boolean;
  62153. /**
  62154. * If this VRDisplay supports room-scale experiences, the optional
  62155. * stage attribute contains details on the room-scale parameters.
  62156. */
  62157. readonly stageParameters: VRStageParameters | null;
  62158. /**
  62159. * Passing the value returned by `requestAnimationFrame` to
  62160. * `cancelAnimationFrame` will unregister the callback.
  62161. * @param handle Define the hanle of the request to cancel
  62162. */
  62163. cancelAnimationFrame(handle: number): void;
  62164. /**
  62165. * Stops presenting to the VRDisplay.
  62166. * @returns a promise to know when it stopped
  62167. */
  62168. exitPresent(): Promise<void>;
  62169. /**
  62170. * Return the current VREyeParameters for the given eye.
  62171. * @param whichEye Define the eye we want the parameter for
  62172. * @returns the eye parameters
  62173. */
  62174. getEyeParameters(whichEye: string): VREyeParameters;
  62175. /**
  62176. * Populates the passed VRFrameData with the information required to render
  62177. * the current frame.
  62178. * @param frameData Define the data structure to populate
  62179. * @returns true if ok otherwise false
  62180. */
  62181. getFrameData(frameData: VRFrameData): boolean;
  62182. /**
  62183. * Get the layers currently being presented.
  62184. * @returns the list of VR layers
  62185. */
  62186. getLayers(): VRLayer[];
  62187. /**
  62188. * Return a VRPose containing the future predicted pose of the VRDisplay
  62189. * when the current frame will be presented. The value returned will not
  62190. * change until JavaScript has returned control to the browser.
  62191. *
  62192. * The VRPose will contain the position, orientation, velocity,
  62193. * and acceleration of each of these properties.
  62194. * @returns the pose object
  62195. */
  62196. getPose(): VRPose;
  62197. /**
  62198. * Return the current instantaneous pose of the VRDisplay, with no
  62199. * prediction applied.
  62200. * @returns the current instantaneous pose
  62201. */
  62202. getImmediatePose(): VRPose;
  62203. /**
  62204. * The callback passed to `requestAnimationFrame` will be called
  62205. * any time a new frame should be rendered. When the VRDisplay is
  62206. * presenting the callback will be called at the native refresh
  62207. * rate of the HMD. When not presenting this function acts
  62208. * identically to how window.requestAnimationFrame acts. Content should
  62209. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62210. * asynchronously from other displays and at differing refresh rates.
  62211. * @param callback Define the eaction to run next frame
  62212. * @returns the request handle it
  62213. */
  62214. requestAnimationFrame(callback: FrameRequestCallback): number;
  62215. /**
  62216. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62217. * Repeat calls while already presenting will update the VRLayers being displayed.
  62218. * @param layers Define the list of layer to present
  62219. * @returns a promise to know when the request has been fulfilled
  62220. */
  62221. requestPresent(layers: VRLayer[]): Promise<void>;
  62222. /**
  62223. * Reset the pose for this display, treating its current position and
  62224. * orientation as the "origin/zero" values. VRPose.position,
  62225. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62226. * updated when calling resetPose(). This should be called in only
  62227. * sitting-space experiences.
  62228. */
  62229. resetPose(): void;
  62230. /**
  62231. * The VRLayer provided to the VRDisplay will be captured and presented
  62232. * in the HMD. Calling this function has the same effect on the source
  62233. * canvas as any other operation that uses its source image, and canvases
  62234. * created without preserveDrawingBuffer set to true will be cleared.
  62235. * @param pose Define the pose to submit
  62236. */
  62237. submitFrame(pose?: VRPose): void;
  62238. }
  62239. declare var VRDisplay: {
  62240. prototype: VRDisplay;
  62241. new(): VRDisplay;
  62242. };
  62243. interface VRLayer {
  62244. leftBounds?: number[] | Float32Array | null;
  62245. rightBounds?: number[] | Float32Array | null;
  62246. source?: HTMLCanvasElement | null;
  62247. }
  62248. interface VRDisplayCapabilities {
  62249. readonly canPresent: boolean;
  62250. readonly hasExternalDisplay: boolean;
  62251. readonly hasOrientation: boolean;
  62252. readonly hasPosition: boolean;
  62253. readonly maxLayers: number;
  62254. }
  62255. interface VREyeParameters {
  62256. /** @deprecated */
  62257. readonly fieldOfView: VRFieldOfView;
  62258. readonly offset: Float32Array;
  62259. readonly renderHeight: number;
  62260. readonly renderWidth: number;
  62261. }
  62262. interface VRFieldOfView {
  62263. readonly downDegrees: number;
  62264. readonly leftDegrees: number;
  62265. readonly rightDegrees: number;
  62266. readonly upDegrees: number;
  62267. }
  62268. interface VRFrameData {
  62269. readonly leftProjectionMatrix: Float32Array;
  62270. readonly leftViewMatrix: Float32Array;
  62271. readonly pose: VRPose;
  62272. readonly rightProjectionMatrix: Float32Array;
  62273. readonly rightViewMatrix: Float32Array;
  62274. readonly timestamp: number;
  62275. }
  62276. interface VRPose {
  62277. readonly angularAcceleration: Float32Array | null;
  62278. readonly angularVelocity: Float32Array | null;
  62279. readonly linearAcceleration: Float32Array | null;
  62280. readonly linearVelocity: Float32Array | null;
  62281. readonly orientation: Float32Array | null;
  62282. readonly position: Float32Array | null;
  62283. readonly timestamp: number;
  62284. }
  62285. interface VRStageParameters {
  62286. sittingToStandingTransform?: Float32Array;
  62287. sizeX?: number;
  62288. sizeY?: number;
  62289. }
  62290. interface Navigator {
  62291. getVRDisplays(): Promise<VRDisplay[]>;
  62292. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62293. }
  62294. interface Window {
  62295. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62296. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62297. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62298. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62299. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62300. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62301. }
  62302. interface Gamepad {
  62303. readonly displayId: number;
  62304. }
  62305. interface XRDevice {
  62306. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  62307. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  62308. }
  62309. interface XRSession {
  62310. getInputSources(): Array<any>;
  62311. baseLayer: XRWebGLLayer;
  62312. requestFrameOfReference(type: string): Promise<void>;
  62313. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  62314. end(): Promise<void>;
  62315. requestAnimationFrame: Function;
  62316. addEventListener: Function;
  62317. }
  62318. interface XRSessionCreationOptions {
  62319. outputContext?: WebGLRenderingContext | null;
  62320. immersive?: boolean;
  62321. environmentIntegration?: boolean;
  62322. }
  62323. interface XRLayer {
  62324. getViewport: Function;
  62325. framebufferWidth: number;
  62326. framebufferHeight: number;
  62327. }
  62328. interface XRView {
  62329. projectionMatrix: Float32Array;
  62330. }
  62331. interface XRFrame {
  62332. getDevicePose: Function;
  62333. getInputPose: Function;
  62334. views: Array<XRView>;
  62335. baseLayer: XRLayer;
  62336. }
  62337. interface XRFrameOfReference {
  62338. }
  62339. interface XRWebGLLayer extends XRLayer {
  62340. framebuffer: WebGLFramebuffer;
  62341. }
  62342. declare var XRWebGLLayer: {
  62343. prototype: XRWebGLLayer;
  62344. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  62345. };
  62346. declare module "babylonjs" {
  62347. export * from "babylonjs/Legacy/legacy";
  62348. }
  62349. declare module BABYLON {
  62350. /** Alias type for value that can be null */
  62351. export type Nullable<T> = T | null;
  62352. /**
  62353. * Alias type for number that are floats
  62354. * @ignorenaming
  62355. */
  62356. export type float = number;
  62357. /**
  62358. * Alias type for number that are doubles.
  62359. * @ignorenaming
  62360. */
  62361. export type double = number;
  62362. /**
  62363. * Alias type for number that are integer
  62364. * @ignorenaming
  62365. */
  62366. export type int = number;
  62367. /** Alias type for number array or Float32Array */
  62368. export type FloatArray = number[] | Float32Array;
  62369. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  62370. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  62371. /**
  62372. * Alias for types that can be used by a Buffer or VertexBuffer.
  62373. */
  62374. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  62375. /**
  62376. * Alias type for primitive types
  62377. * @ignorenaming
  62378. */
  62379. type Primitive = undefined | null | boolean | string | number | Function;
  62380. /**
  62381. * Type modifier to make all the properties of an object Readonly
  62382. */
  62383. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  62384. /**
  62385. * Type modifier to make all the properties of an object Readonly recursively
  62386. */
  62387. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  62388. /** @hidden */
  62389. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  62390. }
  62391. /** @hidden */
  62392. /** @hidden */
  62393. type DeepImmutableObject<T> = {
  62394. readonly [K in keyof T]: DeepImmutable<T[K]>;
  62395. };
  62396. }
  62397. declare module BABYLON {
  62398. /**
  62399. * Class containing a set of static utilities functions for arrays.
  62400. */
  62401. export class ArrayTools {
  62402. /**
  62403. * Returns an array of the given size filled with element built from the given constructor and the paramters
  62404. * @param size the number of element to construct and put in the array
  62405. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  62406. * @returns a new array filled with new objects
  62407. */
  62408. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  62409. }
  62410. }
  62411. declare module BABYLON {
  62412. /**
  62413. * Scalar computation library
  62414. */
  62415. export class Scalar {
  62416. /**
  62417. * Two pi constants convenient for computation.
  62418. */
  62419. static TwoPi: number;
  62420. /**
  62421. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62422. * @param a number
  62423. * @param b number
  62424. * @param epsilon (default = 1.401298E-45)
  62425. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62426. */
  62427. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  62428. /**
  62429. * Returns a string : the upper case translation of the number i to hexadecimal.
  62430. * @param i number
  62431. * @returns the upper case translation of the number i to hexadecimal.
  62432. */
  62433. static ToHex(i: number): string;
  62434. /**
  62435. * Returns -1 if value is negative and +1 is value is positive.
  62436. * @param value the value
  62437. * @returns the value itself if it's equal to zero.
  62438. */
  62439. static Sign(value: number): number;
  62440. /**
  62441. * Returns the value itself if it's between min and max.
  62442. * Returns min if the value is lower than min.
  62443. * Returns max if the value is greater than max.
  62444. * @param value the value to clmap
  62445. * @param min the min value to clamp to (default: 0)
  62446. * @param max the max value to clamp to (default: 1)
  62447. * @returns the clamped value
  62448. */
  62449. static Clamp(value: number, min?: number, max?: number): number;
  62450. /**
  62451. * the log2 of value.
  62452. * @param value the value to compute log2 of
  62453. * @returns the log2 of value.
  62454. */
  62455. static Log2(value: number): number;
  62456. /**
  62457. * Loops the value, so that it is never larger than length and never smaller than 0.
  62458. *
  62459. * This is similar to the modulo operator but it works with floating point numbers.
  62460. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  62461. * With t = 5 and length = 2.5, the result would be 0.0.
  62462. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  62463. * @param value the value
  62464. * @param length the length
  62465. * @returns the looped value
  62466. */
  62467. static Repeat(value: number, length: number): number;
  62468. /**
  62469. * Normalize the value between 0.0 and 1.0 using min and max values
  62470. * @param value value to normalize
  62471. * @param min max to normalize between
  62472. * @param max min to normalize between
  62473. * @returns the normalized value
  62474. */
  62475. static Normalize(value: number, min: number, max: number): number;
  62476. /**
  62477. * Denormalize the value from 0.0 and 1.0 using min and max values
  62478. * @param normalized value to denormalize
  62479. * @param min max to denormalize between
  62480. * @param max min to denormalize between
  62481. * @returns the denormalized value
  62482. */
  62483. static Denormalize(normalized: number, min: number, max: number): number;
  62484. /**
  62485. * Calculates the shortest difference between two given angles given in degrees.
  62486. * @param current current angle in degrees
  62487. * @param target target angle in degrees
  62488. * @returns the delta
  62489. */
  62490. static DeltaAngle(current: number, target: number): number;
  62491. /**
  62492. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  62493. * @param tx value
  62494. * @param length length
  62495. * @returns The returned value will move back and forth between 0 and length
  62496. */
  62497. static PingPong(tx: number, length: number): number;
  62498. /**
  62499. * Interpolates between min and max with smoothing at the limits.
  62500. *
  62501. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  62502. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  62503. * @param from from
  62504. * @param to to
  62505. * @param tx value
  62506. * @returns the smooth stepped value
  62507. */
  62508. static SmoothStep(from: number, to: number, tx: number): number;
  62509. /**
  62510. * Moves a value current towards target.
  62511. *
  62512. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  62513. * Negative values of maxDelta pushes the value away from target.
  62514. * @param current current value
  62515. * @param target target value
  62516. * @param maxDelta max distance to move
  62517. * @returns resulting value
  62518. */
  62519. static MoveTowards(current: number, target: number, maxDelta: number): number;
  62520. /**
  62521. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62522. *
  62523. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  62524. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  62525. * @param current current value
  62526. * @param target target value
  62527. * @param maxDelta max distance to move
  62528. * @returns resulting angle
  62529. */
  62530. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  62531. /**
  62532. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  62533. * @param start start value
  62534. * @param end target value
  62535. * @param amount amount to lerp between
  62536. * @returns the lerped value
  62537. */
  62538. static Lerp(start: number, end: number, amount: number): number;
  62539. /**
  62540. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62541. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  62542. * @param start start value
  62543. * @param end target value
  62544. * @param amount amount to lerp between
  62545. * @returns the lerped value
  62546. */
  62547. static LerpAngle(start: number, end: number, amount: number): number;
  62548. /**
  62549. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  62550. * @param a start value
  62551. * @param b target value
  62552. * @param value value between a and b
  62553. * @returns the inverseLerp value
  62554. */
  62555. static InverseLerp(a: number, b: number, value: number): number;
  62556. /**
  62557. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  62558. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  62559. * @param value1 spline value
  62560. * @param tangent1 spline value
  62561. * @param value2 spline value
  62562. * @param tangent2 spline value
  62563. * @param amount input value
  62564. * @returns hermite result
  62565. */
  62566. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  62567. /**
  62568. * Returns a random float number between and min and max values
  62569. * @param min min value of random
  62570. * @param max max value of random
  62571. * @returns random value
  62572. */
  62573. static RandomRange(min: number, max: number): number;
  62574. /**
  62575. * This function returns percentage of a number in a given range.
  62576. *
  62577. * RangeToPercent(40,20,60) will return 0.5 (50%)
  62578. * RangeToPercent(34,0,100) will return 0.34 (34%)
  62579. * @param number to convert to percentage
  62580. * @param min min range
  62581. * @param max max range
  62582. * @returns the percentage
  62583. */
  62584. static RangeToPercent(number: number, min: number, max: number): number;
  62585. /**
  62586. * This function returns number that corresponds to the percentage in a given range.
  62587. *
  62588. * PercentToRange(0.34,0,100) will return 34.
  62589. * @param percent to convert to number
  62590. * @param min min range
  62591. * @param max max range
  62592. * @returns the number
  62593. */
  62594. static PercentToRange(percent: number, min: number, max: number): number;
  62595. /**
  62596. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  62597. * @param angle The angle to normalize in radian.
  62598. * @return The converted angle.
  62599. */
  62600. static NormalizeRadians(angle: number): number;
  62601. }
  62602. }
  62603. declare module BABYLON {
  62604. /**
  62605. * Constant used to convert a value to gamma space
  62606. * @ignorenaming
  62607. */
  62608. export const ToGammaSpace: number;
  62609. /**
  62610. * Constant used to convert a value to linear space
  62611. * @ignorenaming
  62612. */
  62613. export const ToLinearSpace = 2.2;
  62614. /**
  62615. * Constant used to define the minimal number value in Babylon.js
  62616. * @ignorenaming
  62617. */
  62618. let Epsilon: number;
  62619. /**
  62620. * Class used to hold a RBG color
  62621. */
  62622. export class Color3 {
  62623. /**
  62624. * Defines the red component (between 0 and 1, default is 0)
  62625. */
  62626. r: number;
  62627. /**
  62628. * Defines the green component (between 0 and 1, default is 0)
  62629. */
  62630. g: number;
  62631. /**
  62632. * Defines the blue component (between 0 and 1, default is 0)
  62633. */
  62634. b: number;
  62635. /**
  62636. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  62637. * @param r defines the red component (between 0 and 1, default is 0)
  62638. * @param g defines the green component (between 0 and 1, default is 0)
  62639. * @param b defines the blue component (between 0 and 1, default is 0)
  62640. */
  62641. constructor(
  62642. /**
  62643. * Defines the red component (between 0 and 1, default is 0)
  62644. */
  62645. r?: number,
  62646. /**
  62647. * Defines the green component (between 0 and 1, default is 0)
  62648. */
  62649. g?: number,
  62650. /**
  62651. * Defines the blue component (between 0 and 1, default is 0)
  62652. */
  62653. b?: number);
  62654. /**
  62655. * Creates a string with the Color3 current values
  62656. * @returns the string representation of the Color3 object
  62657. */
  62658. toString(): string;
  62659. /**
  62660. * Returns the string "Color3"
  62661. * @returns "Color3"
  62662. */
  62663. getClassName(): string;
  62664. /**
  62665. * Compute the Color3 hash code
  62666. * @returns an unique number that can be used to hash Color3 objects
  62667. */
  62668. getHashCode(): number;
  62669. /**
  62670. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  62671. * @param array defines the array where to store the r,g,b components
  62672. * @param index defines an optional index in the target array to define where to start storing values
  62673. * @returns the current Color3 object
  62674. */
  62675. toArray(array: FloatArray, index?: number): Color3;
  62676. /**
  62677. * Returns a new Color4 object from the current Color3 and the given alpha
  62678. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  62679. * @returns a new Color4 object
  62680. */
  62681. toColor4(alpha?: number): Color4;
  62682. /**
  62683. * Returns a new array populated with 3 numeric elements : red, green and blue values
  62684. * @returns the new array
  62685. */
  62686. asArray(): number[];
  62687. /**
  62688. * Returns the luminance value
  62689. * @returns a float value
  62690. */
  62691. toLuminance(): number;
  62692. /**
  62693. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  62694. * @param otherColor defines the second operand
  62695. * @returns the new Color3 object
  62696. */
  62697. multiply(otherColor: DeepImmutable<Color3>): Color3;
  62698. /**
  62699. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  62700. * @param otherColor defines the second operand
  62701. * @param result defines the Color3 object where to store the result
  62702. * @returns the current Color3
  62703. */
  62704. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62705. /**
  62706. * Determines equality between Color3 objects
  62707. * @param otherColor defines the second operand
  62708. * @returns true if the rgb values are equal to the given ones
  62709. */
  62710. equals(otherColor: DeepImmutable<Color3>): boolean;
  62711. /**
  62712. * Determines equality between the current Color3 object and a set of r,b,g values
  62713. * @param r defines the red component to check
  62714. * @param g defines the green component to check
  62715. * @param b defines the blue component to check
  62716. * @returns true if the rgb values are equal to the given ones
  62717. */
  62718. equalsFloats(r: number, g: number, b: number): boolean;
  62719. /**
  62720. * Multiplies in place each rgb value by scale
  62721. * @param scale defines the scaling factor
  62722. * @returns the updated Color3
  62723. */
  62724. scale(scale: number): Color3;
  62725. /**
  62726. * Multiplies the rgb values by scale and stores the result into "result"
  62727. * @param scale defines the scaling factor
  62728. * @param result defines the Color3 object where to store the result
  62729. * @returns the unmodified current Color3
  62730. */
  62731. scaleToRef(scale: number, result: Color3): Color3;
  62732. /**
  62733. * Scale the current Color3 values by a factor and add the result to a given Color3
  62734. * @param scale defines the scale factor
  62735. * @param result defines color to store the result into
  62736. * @returns the unmodified current Color3
  62737. */
  62738. scaleAndAddToRef(scale: number, result: Color3): Color3;
  62739. /**
  62740. * Clamps the rgb values by the min and max values and stores the result into "result"
  62741. * @param min defines minimum clamping value (default is 0)
  62742. * @param max defines maximum clamping value (default is 1)
  62743. * @param result defines color to store the result into
  62744. * @returns the original Color3
  62745. */
  62746. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  62747. /**
  62748. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  62749. * @param otherColor defines the second operand
  62750. * @returns the new Color3
  62751. */
  62752. add(otherColor: DeepImmutable<Color3>): Color3;
  62753. /**
  62754. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  62755. * @param otherColor defines the second operand
  62756. * @param result defines Color3 object to store the result into
  62757. * @returns the unmodified current Color3
  62758. */
  62759. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62760. /**
  62761. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  62762. * @param otherColor defines the second operand
  62763. * @returns the new Color3
  62764. */
  62765. subtract(otherColor: DeepImmutable<Color3>): Color3;
  62766. /**
  62767. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  62768. * @param otherColor defines the second operand
  62769. * @param result defines Color3 object to store the result into
  62770. * @returns the unmodified current Color3
  62771. */
  62772. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62773. /**
  62774. * Copy the current object
  62775. * @returns a new Color3 copied the current one
  62776. */
  62777. clone(): Color3;
  62778. /**
  62779. * Copies the rgb values from the source in the current Color3
  62780. * @param source defines the source Color3 object
  62781. * @returns the updated Color3 object
  62782. */
  62783. copyFrom(source: DeepImmutable<Color3>): Color3;
  62784. /**
  62785. * Updates the Color3 rgb values from the given floats
  62786. * @param r defines the red component to read from
  62787. * @param g defines the green component to read from
  62788. * @param b defines the blue component to read from
  62789. * @returns the current Color3 object
  62790. */
  62791. copyFromFloats(r: number, g: number, b: number): Color3;
  62792. /**
  62793. * Updates the Color3 rgb values from the given floats
  62794. * @param r defines the red component to read from
  62795. * @param g defines the green component to read from
  62796. * @param b defines the blue component to read from
  62797. * @returns the current Color3 object
  62798. */
  62799. set(r: number, g: number, b: number): Color3;
  62800. /**
  62801. * Compute the Color3 hexadecimal code as a string
  62802. * @returns a string containing the hexadecimal representation of the Color3 object
  62803. */
  62804. toHexString(): string;
  62805. /**
  62806. * Computes a new Color3 converted from the current one to linear space
  62807. * @returns a new Color3 object
  62808. */
  62809. toLinearSpace(): Color3;
  62810. /**
  62811. * Converts current color in rgb space to HSV values
  62812. * @returns a new color3 representing the HSV values
  62813. */
  62814. toHSV(): Color3;
  62815. /**
  62816. * Converts current color in rgb space to HSV values
  62817. * @param result defines the Color3 where to store the HSV values
  62818. */
  62819. toHSVToRef(result: Color3): void;
  62820. /**
  62821. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  62822. * @param convertedColor defines the Color3 object where to store the linear space version
  62823. * @returns the unmodified Color3
  62824. */
  62825. toLinearSpaceToRef(convertedColor: Color3): Color3;
  62826. /**
  62827. * Computes a new Color3 converted from the current one to gamma space
  62828. * @returns a new Color3 object
  62829. */
  62830. toGammaSpace(): Color3;
  62831. /**
  62832. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  62833. * @param convertedColor defines the Color3 object where to store the gamma space version
  62834. * @returns the unmodified Color3
  62835. */
  62836. toGammaSpaceToRef(convertedColor: Color3): Color3;
  62837. private static _BlackReadOnly;
  62838. /**
  62839. * Convert Hue, saturation and value to a Color3 (RGB)
  62840. * @param hue defines the hue
  62841. * @param saturation defines the saturation
  62842. * @param value defines the value
  62843. * @param result defines the Color3 where to store the RGB values
  62844. */
  62845. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  62846. /**
  62847. * Creates a new Color3 from the string containing valid hexadecimal values
  62848. * @param hex defines a string containing valid hexadecimal values
  62849. * @returns a new Color3 object
  62850. */
  62851. static FromHexString(hex: string): Color3;
  62852. /**
  62853. * Creates a new Color3 from the starting index of the given array
  62854. * @param array defines the source array
  62855. * @param offset defines an offset in the source array
  62856. * @returns a new Color3 object
  62857. */
  62858. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  62859. /**
  62860. * Creates a new Color3 from integer values (< 256)
  62861. * @param r defines the red component to read from (value between 0 and 255)
  62862. * @param g defines the green component to read from (value between 0 and 255)
  62863. * @param b defines the blue component to read from (value between 0 and 255)
  62864. * @returns a new Color3 object
  62865. */
  62866. static FromInts(r: number, g: number, b: number): Color3;
  62867. /**
  62868. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  62869. * @param start defines the start Color3 value
  62870. * @param end defines the end Color3 value
  62871. * @param amount defines the gradient value between start and end
  62872. * @returns a new Color3 object
  62873. */
  62874. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  62875. /**
  62876. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  62877. * @param left defines the start value
  62878. * @param right defines the end value
  62879. * @param amount defines the gradient factor
  62880. * @param result defines the Color3 object where to store the result
  62881. */
  62882. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  62883. /**
  62884. * Returns a Color3 value containing a red color
  62885. * @returns a new Color3 object
  62886. */
  62887. static Red(): Color3;
  62888. /**
  62889. * Returns a Color3 value containing a green color
  62890. * @returns a new Color3 object
  62891. */
  62892. static Green(): Color3;
  62893. /**
  62894. * Returns a Color3 value containing a blue color
  62895. * @returns a new Color3 object
  62896. */
  62897. static Blue(): Color3;
  62898. /**
  62899. * Returns a Color3 value containing a black color
  62900. * @returns a new Color3 object
  62901. */
  62902. static Black(): Color3;
  62903. /**
  62904. * Gets a Color3 value containing a black color that must not be updated
  62905. */
  62906. static readonly BlackReadOnly: DeepImmutable<Color3>;
  62907. /**
  62908. * Returns a Color3 value containing a white color
  62909. * @returns a new Color3 object
  62910. */
  62911. static White(): Color3;
  62912. /**
  62913. * Returns a Color3 value containing a purple color
  62914. * @returns a new Color3 object
  62915. */
  62916. static Purple(): Color3;
  62917. /**
  62918. * Returns a Color3 value containing a magenta color
  62919. * @returns a new Color3 object
  62920. */
  62921. static Magenta(): Color3;
  62922. /**
  62923. * Returns a Color3 value containing a yellow color
  62924. * @returns a new Color3 object
  62925. */
  62926. static Yellow(): Color3;
  62927. /**
  62928. * Returns a Color3 value containing a gray color
  62929. * @returns a new Color3 object
  62930. */
  62931. static Gray(): Color3;
  62932. /**
  62933. * Returns a Color3 value containing a teal color
  62934. * @returns a new Color3 object
  62935. */
  62936. static Teal(): Color3;
  62937. /**
  62938. * Returns a Color3 value containing a random color
  62939. * @returns a new Color3 object
  62940. */
  62941. static Random(): Color3;
  62942. }
  62943. /**
  62944. * Class used to hold a RBGA color
  62945. */
  62946. export class Color4 {
  62947. /**
  62948. * Defines the red component (between 0 and 1, default is 0)
  62949. */
  62950. r: number;
  62951. /**
  62952. * Defines the green component (between 0 and 1, default is 0)
  62953. */
  62954. g: number;
  62955. /**
  62956. * Defines the blue component (between 0 and 1, default is 0)
  62957. */
  62958. b: number;
  62959. /**
  62960. * Defines the alpha component (between 0 and 1, default is 1)
  62961. */
  62962. a: number;
  62963. /**
  62964. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  62965. * @param r defines the red component (between 0 and 1, default is 0)
  62966. * @param g defines the green component (between 0 and 1, default is 0)
  62967. * @param b defines the blue component (between 0 and 1, default is 0)
  62968. * @param a defines the alpha component (between 0 and 1, default is 1)
  62969. */
  62970. constructor(
  62971. /**
  62972. * Defines the red component (between 0 and 1, default is 0)
  62973. */
  62974. r?: number,
  62975. /**
  62976. * Defines the green component (between 0 and 1, default is 0)
  62977. */
  62978. g?: number,
  62979. /**
  62980. * Defines the blue component (between 0 and 1, default is 0)
  62981. */
  62982. b?: number,
  62983. /**
  62984. * Defines the alpha component (between 0 and 1, default is 1)
  62985. */
  62986. a?: number);
  62987. /**
  62988. * Adds in place the given Color4 values to the current Color4 object
  62989. * @param right defines the second operand
  62990. * @returns the current updated Color4 object
  62991. */
  62992. addInPlace(right: DeepImmutable<Color4>): Color4;
  62993. /**
  62994. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  62995. * @returns the new array
  62996. */
  62997. asArray(): number[];
  62998. /**
  62999. * Stores from the starting index in the given array the Color4 successive values
  63000. * @param array defines the array where to store the r,g,b components
  63001. * @param index defines an optional index in the target array to define where to start storing values
  63002. * @returns the current Color4 object
  63003. */
  63004. toArray(array: number[], index?: number): Color4;
  63005. /**
  63006. * Determines equality between Color4 objects
  63007. * @param otherColor defines the second operand
  63008. * @returns true if the rgba values are equal to the given ones
  63009. */
  63010. equals(otherColor: DeepImmutable<Color4>): boolean;
  63011. /**
  63012. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  63013. * @param right defines the second operand
  63014. * @returns a new Color4 object
  63015. */
  63016. add(right: DeepImmutable<Color4>): Color4;
  63017. /**
  63018. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  63019. * @param right defines the second operand
  63020. * @returns a new Color4 object
  63021. */
  63022. subtract(right: DeepImmutable<Color4>): Color4;
  63023. /**
  63024. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  63025. * @param right defines the second operand
  63026. * @param result defines the Color4 object where to store the result
  63027. * @returns the current Color4 object
  63028. */
  63029. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  63030. /**
  63031. * Creates a new Color4 with the current Color4 values multiplied by scale
  63032. * @param scale defines the scaling factor to apply
  63033. * @returns a new Color4 object
  63034. */
  63035. scale(scale: number): Color4;
  63036. /**
  63037. * Multiplies the current Color4 values by scale and stores the result in "result"
  63038. * @param scale defines the scaling factor to apply
  63039. * @param result defines the Color4 object where to store the result
  63040. * @returns the current unmodified Color4
  63041. */
  63042. scaleToRef(scale: number, result: Color4): Color4;
  63043. /**
  63044. * Scale the current Color4 values by a factor and add the result to a given Color4
  63045. * @param scale defines the scale factor
  63046. * @param result defines the Color4 object where to store the result
  63047. * @returns the unmodified current Color4
  63048. */
  63049. scaleAndAddToRef(scale: number, result: Color4): Color4;
  63050. /**
  63051. * Clamps the rgb values by the min and max values and stores the result into "result"
  63052. * @param min defines minimum clamping value (default is 0)
  63053. * @param max defines maximum clamping value (default is 1)
  63054. * @param result defines color to store the result into.
  63055. * @returns the cuurent Color4
  63056. */
  63057. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  63058. /**
  63059. * Multipy an Color4 value by another and return a new Color4 object
  63060. * @param color defines the Color4 value to multiply by
  63061. * @returns a new Color4 object
  63062. */
  63063. multiply(color: Color4): Color4;
  63064. /**
  63065. * Multipy a Color4 value by another and push the result in a reference value
  63066. * @param color defines the Color4 value to multiply by
  63067. * @param result defines the Color4 to fill the result in
  63068. * @returns the result Color4
  63069. */
  63070. multiplyToRef(color: Color4, result: Color4): Color4;
  63071. /**
  63072. * Creates a string with the Color4 current values
  63073. * @returns the string representation of the Color4 object
  63074. */
  63075. toString(): string;
  63076. /**
  63077. * Returns the string "Color4"
  63078. * @returns "Color4"
  63079. */
  63080. getClassName(): string;
  63081. /**
  63082. * Compute the Color4 hash code
  63083. * @returns an unique number that can be used to hash Color4 objects
  63084. */
  63085. getHashCode(): number;
  63086. /**
  63087. * Creates a new Color4 copied from the current one
  63088. * @returns a new Color4 object
  63089. */
  63090. clone(): Color4;
  63091. /**
  63092. * Copies the given Color4 values into the current one
  63093. * @param source defines the source Color4 object
  63094. * @returns the current updated Color4 object
  63095. */
  63096. copyFrom(source: Color4): Color4;
  63097. /**
  63098. * Copies the given float values into the current one
  63099. * @param r defines the red component to read from
  63100. * @param g defines the green component to read from
  63101. * @param b defines the blue component to read from
  63102. * @param a defines the alpha component to read from
  63103. * @returns the current updated Color4 object
  63104. */
  63105. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  63106. /**
  63107. * Copies the given float values into the current one
  63108. * @param r defines the red component to read from
  63109. * @param g defines the green component to read from
  63110. * @param b defines the blue component to read from
  63111. * @param a defines the alpha component to read from
  63112. * @returns the current updated Color4 object
  63113. */
  63114. set(r: number, g: number, b: number, a: number): Color4;
  63115. /**
  63116. * Compute the Color4 hexadecimal code as a string
  63117. * @returns a string containing the hexadecimal representation of the Color4 object
  63118. */
  63119. toHexString(): string;
  63120. /**
  63121. * Computes a new Color4 converted from the current one to linear space
  63122. * @returns a new Color4 object
  63123. */
  63124. toLinearSpace(): Color4;
  63125. /**
  63126. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  63127. * @param convertedColor defines the Color4 object where to store the linear space version
  63128. * @returns the unmodified Color4
  63129. */
  63130. toLinearSpaceToRef(convertedColor: Color4): Color4;
  63131. /**
  63132. * Computes a new Color4 converted from the current one to gamma space
  63133. * @returns a new Color4 object
  63134. */
  63135. toGammaSpace(): Color4;
  63136. /**
  63137. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  63138. * @param convertedColor defines the Color4 object where to store the gamma space version
  63139. * @returns the unmodified Color4
  63140. */
  63141. toGammaSpaceToRef(convertedColor: Color4): Color4;
  63142. /**
  63143. * Creates a new Color4 from the string containing valid hexadecimal values
  63144. * @param hex defines a string containing valid hexadecimal values
  63145. * @returns a new Color4 object
  63146. */
  63147. static FromHexString(hex: string): Color4;
  63148. /**
  63149. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63150. * @param left defines the start value
  63151. * @param right defines the end value
  63152. * @param amount defines the gradient factor
  63153. * @returns a new Color4 object
  63154. */
  63155. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  63156. /**
  63157. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63158. * @param left defines the start value
  63159. * @param right defines the end value
  63160. * @param amount defines the gradient factor
  63161. * @param result defines the Color4 object where to store data
  63162. */
  63163. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  63164. /**
  63165. * Creates a new Color4 from a Color3 and an alpha value
  63166. * @param color3 defines the source Color3 to read from
  63167. * @param alpha defines the alpha component (1.0 by default)
  63168. * @returns a new Color4 object
  63169. */
  63170. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  63171. /**
  63172. * Creates a new Color4 from the starting index element of the given array
  63173. * @param array defines the source array to read from
  63174. * @param offset defines the offset in the source array
  63175. * @returns a new Color4 object
  63176. */
  63177. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  63178. /**
  63179. * Creates a new Color3 from integer values (< 256)
  63180. * @param r defines the red component to read from (value between 0 and 255)
  63181. * @param g defines the green component to read from (value between 0 and 255)
  63182. * @param b defines the blue component to read from (value between 0 and 255)
  63183. * @param a defines the alpha component to read from (value between 0 and 255)
  63184. * @returns a new Color3 object
  63185. */
  63186. static FromInts(r: number, g: number, b: number, a: number): Color4;
  63187. /**
  63188. * Check the content of a given array and convert it to an array containing RGBA data
  63189. * If the original array was already containing count * 4 values then it is returned directly
  63190. * @param colors defines the array to check
  63191. * @param count defines the number of RGBA data to expect
  63192. * @returns an array containing count * 4 values (RGBA)
  63193. */
  63194. static CheckColors4(colors: number[], count: number): number[];
  63195. }
  63196. /**
  63197. * Class representing a vector containing 2 coordinates
  63198. */
  63199. export class Vector2 {
  63200. /** defines the first coordinate */
  63201. x: number;
  63202. /** defines the second coordinate */
  63203. y: number;
  63204. /**
  63205. * Creates a new Vector2 from the given x and y coordinates
  63206. * @param x defines the first coordinate
  63207. * @param y defines the second coordinate
  63208. */
  63209. constructor(
  63210. /** defines the first coordinate */
  63211. x?: number,
  63212. /** defines the second coordinate */
  63213. y?: number);
  63214. /**
  63215. * Gets a string with the Vector2 coordinates
  63216. * @returns a string with the Vector2 coordinates
  63217. */
  63218. toString(): string;
  63219. /**
  63220. * Gets class name
  63221. * @returns the string "Vector2"
  63222. */
  63223. getClassName(): string;
  63224. /**
  63225. * Gets current vector hash code
  63226. * @returns the Vector2 hash code as a number
  63227. */
  63228. getHashCode(): number;
  63229. /**
  63230. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  63231. * @param array defines the source array
  63232. * @param index defines the offset in source array
  63233. * @returns the current Vector2
  63234. */
  63235. toArray(array: FloatArray, index?: number): Vector2;
  63236. /**
  63237. * Copy the current vector to an array
  63238. * @returns a new array with 2 elements: the Vector2 coordinates.
  63239. */
  63240. asArray(): number[];
  63241. /**
  63242. * Sets the Vector2 coordinates with the given Vector2 coordinates
  63243. * @param source defines the source Vector2
  63244. * @returns the current updated Vector2
  63245. */
  63246. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  63247. /**
  63248. * Sets the Vector2 coordinates with the given floats
  63249. * @param x defines the first coordinate
  63250. * @param y defines the second coordinate
  63251. * @returns the current updated Vector2
  63252. */
  63253. copyFromFloats(x: number, y: number): Vector2;
  63254. /**
  63255. * Sets the Vector2 coordinates with the given floats
  63256. * @param x defines the first coordinate
  63257. * @param y defines the second coordinate
  63258. * @returns the current updated Vector2
  63259. */
  63260. set(x: number, y: number): Vector2;
  63261. /**
  63262. * Add another vector with the current one
  63263. * @param otherVector defines the other vector
  63264. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  63265. */
  63266. add(otherVector: DeepImmutable<Vector2>): Vector2;
  63267. /**
  63268. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  63269. * @param otherVector defines the other vector
  63270. * @param result defines the target vector
  63271. * @returns the unmodified current Vector2
  63272. */
  63273. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63274. /**
  63275. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  63276. * @param otherVector defines the other vector
  63277. * @returns the current updated Vector2
  63278. */
  63279. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63280. /**
  63281. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  63282. * @param otherVector defines the other vector
  63283. * @returns a new Vector2
  63284. */
  63285. addVector3(otherVector: Vector3): Vector2;
  63286. /**
  63287. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  63288. * @param otherVector defines the other vector
  63289. * @returns a new Vector2
  63290. */
  63291. subtract(otherVector: Vector2): Vector2;
  63292. /**
  63293. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  63294. * @param otherVector defines the other vector
  63295. * @param result defines the target vector
  63296. * @returns the unmodified current Vector2
  63297. */
  63298. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63299. /**
  63300. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  63301. * @param otherVector defines the other vector
  63302. * @returns the current updated Vector2
  63303. */
  63304. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63305. /**
  63306. * Multiplies in place the current Vector2 coordinates by the given ones
  63307. * @param otherVector defines the other vector
  63308. * @returns the current updated Vector2
  63309. */
  63310. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63311. /**
  63312. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  63313. * @param otherVector defines the other vector
  63314. * @returns a new Vector2
  63315. */
  63316. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  63317. /**
  63318. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  63319. * @param otherVector defines the other vector
  63320. * @param result defines the target vector
  63321. * @returns the unmodified current Vector2
  63322. */
  63323. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63324. /**
  63325. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  63326. * @param x defines the first coordinate
  63327. * @param y defines the second coordinate
  63328. * @returns a new Vector2
  63329. */
  63330. multiplyByFloats(x: number, y: number): Vector2;
  63331. /**
  63332. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  63333. * @param otherVector defines the other vector
  63334. * @returns a new Vector2
  63335. */
  63336. divide(otherVector: Vector2): Vector2;
  63337. /**
  63338. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  63339. * @param otherVector defines the other vector
  63340. * @param result defines the target vector
  63341. * @returns the unmodified current Vector2
  63342. */
  63343. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63344. /**
  63345. * Divides the current Vector2 coordinates by the given ones
  63346. * @param otherVector defines the other vector
  63347. * @returns the current updated Vector2
  63348. */
  63349. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63350. /**
  63351. * Gets a new Vector2 with current Vector2 negated coordinates
  63352. * @returns a new Vector2
  63353. */
  63354. negate(): Vector2;
  63355. /**
  63356. * Multiply the Vector2 coordinates by scale
  63357. * @param scale defines the scaling factor
  63358. * @returns the current updated Vector2
  63359. */
  63360. scaleInPlace(scale: number): Vector2;
  63361. /**
  63362. * Returns a new Vector2 scaled by "scale" from the current Vector2
  63363. * @param scale defines the scaling factor
  63364. * @returns a new Vector2
  63365. */
  63366. scale(scale: number): Vector2;
  63367. /**
  63368. * Scale the current Vector2 values by a factor to a given Vector2
  63369. * @param scale defines the scale factor
  63370. * @param result defines the Vector2 object where to store the result
  63371. * @returns the unmodified current Vector2
  63372. */
  63373. scaleToRef(scale: number, result: Vector2): Vector2;
  63374. /**
  63375. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  63376. * @param scale defines the scale factor
  63377. * @param result defines the Vector2 object where to store the result
  63378. * @returns the unmodified current Vector2
  63379. */
  63380. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  63381. /**
  63382. * Gets a boolean if two vectors are equals
  63383. * @param otherVector defines the other vector
  63384. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  63385. */
  63386. equals(otherVector: DeepImmutable<Vector2>): boolean;
  63387. /**
  63388. * Gets a boolean if two vectors are equals (using an epsilon value)
  63389. * @param otherVector defines the other vector
  63390. * @param epsilon defines the minimal distance to consider equality
  63391. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  63392. */
  63393. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  63394. /**
  63395. * Gets a new Vector2 from current Vector2 floored values
  63396. * @returns a new Vector2
  63397. */
  63398. floor(): Vector2;
  63399. /**
  63400. * Gets a new Vector2 from current Vector2 floored values
  63401. * @returns a new Vector2
  63402. */
  63403. fract(): Vector2;
  63404. /**
  63405. * Gets the length of the vector
  63406. * @returns the vector length (float)
  63407. */
  63408. length(): number;
  63409. /**
  63410. * Gets the vector squared length
  63411. * @returns the vector squared length (float)
  63412. */
  63413. lengthSquared(): number;
  63414. /**
  63415. * Normalize the vector
  63416. * @returns the current updated Vector2
  63417. */
  63418. normalize(): Vector2;
  63419. /**
  63420. * Gets a new Vector2 copied from the Vector2
  63421. * @returns a new Vector2
  63422. */
  63423. clone(): Vector2;
  63424. /**
  63425. * Gets a new Vector2(0, 0)
  63426. * @returns a new Vector2
  63427. */
  63428. static Zero(): Vector2;
  63429. /**
  63430. * Gets a new Vector2(1, 1)
  63431. * @returns a new Vector2
  63432. */
  63433. static One(): Vector2;
  63434. /**
  63435. * Gets a new Vector2 set from the given index element of the given array
  63436. * @param array defines the data source
  63437. * @param offset defines the offset in the data source
  63438. * @returns a new Vector2
  63439. */
  63440. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  63441. /**
  63442. * Sets "result" from the given index element of the given array
  63443. * @param array defines the data source
  63444. * @param offset defines the offset in the data source
  63445. * @param result defines the target vector
  63446. */
  63447. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  63448. /**
  63449. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  63450. * @param value1 defines 1st point of control
  63451. * @param value2 defines 2nd point of control
  63452. * @param value3 defines 3rd point of control
  63453. * @param value4 defines 4th point of control
  63454. * @param amount defines the interpolation factor
  63455. * @returns a new Vector2
  63456. */
  63457. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  63458. /**
  63459. * 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".
  63460. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  63461. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  63462. * @param value defines the value to clamp
  63463. * @param min defines the lower limit
  63464. * @param max defines the upper limit
  63465. * @returns a new Vector2
  63466. */
  63467. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  63468. /**
  63469. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  63470. * @param value1 defines the 1st control point
  63471. * @param tangent1 defines the outgoing tangent
  63472. * @param value2 defines the 2nd control point
  63473. * @param tangent2 defines the incoming tangent
  63474. * @param amount defines the interpolation factor
  63475. * @returns a new Vector2
  63476. */
  63477. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  63478. /**
  63479. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  63480. * @param start defines the start vector
  63481. * @param end defines the end vector
  63482. * @param amount defines the interpolation factor
  63483. * @returns a new Vector2
  63484. */
  63485. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  63486. /**
  63487. * Gets the dot product of the vector "left" and the vector "right"
  63488. * @param left defines first vector
  63489. * @param right defines second vector
  63490. * @returns the dot product (float)
  63491. */
  63492. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  63493. /**
  63494. * Returns a new Vector2 equal to the normalized given vector
  63495. * @param vector defines the vector to normalize
  63496. * @returns a new Vector2
  63497. */
  63498. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  63499. /**
  63500. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  63501. * @param left defines 1st vector
  63502. * @param right defines 2nd vector
  63503. * @returns a new Vector2
  63504. */
  63505. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63506. /**
  63507. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  63508. * @param left defines 1st vector
  63509. * @param right defines 2nd vector
  63510. * @returns a new Vector2
  63511. */
  63512. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63513. /**
  63514. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  63515. * @param vector defines the vector to transform
  63516. * @param transformation defines the matrix to apply
  63517. * @returns a new Vector2
  63518. */
  63519. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  63520. /**
  63521. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  63522. * @param vector defines the vector to transform
  63523. * @param transformation defines the matrix to apply
  63524. * @param result defines the target vector
  63525. */
  63526. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  63527. /**
  63528. * Determines if a given vector is included in a triangle
  63529. * @param p defines the vector to test
  63530. * @param p0 defines 1st triangle point
  63531. * @param p1 defines 2nd triangle point
  63532. * @param p2 defines 3rd triangle point
  63533. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  63534. */
  63535. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  63536. /**
  63537. * Gets the distance between the vectors "value1" and "value2"
  63538. * @param value1 defines first vector
  63539. * @param value2 defines second vector
  63540. * @returns the distance between vectors
  63541. */
  63542. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63543. /**
  63544. * Returns the squared distance between the vectors "value1" and "value2"
  63545. * @param value1 defines first vector
  63546. * @param value2 defines second vector
  63547. * @returns the squared distance between vectors
  63548. */
  63549. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63550. /**
  63551. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  63552. * @param value1 defines first vector
  63553. * @param value2 defines second vector
  63554. * @returns a new Vector2
  63555. */
  63556. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  63557. /**
  63558. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  63559. * @param p defines the middle point
  63560. * @param segA defines one point of the segment
  63561. * @param segB defines the other point of the segment
  63562. * @returns the shortest distance
  63563. */
  63564. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  63565. }
  63566. /**
  63567. * Classed used to store (x,y,z) vector representation
  63568. * A Vector3 is the main object used in 3D geometry
  63569. * It can represent etiher the coordinates of a point the space, either a direction
  63570. * Reminder: js uses a left handed forward facing system
  63571. */
  63572. export class Vector3 {
  63573. /**
  63574. * Defines the first coordinates (on X axis)
  63575. */
  63576. x: number;
  63577. /**
  63578. * Defines the second coordinates (on Y axis)
  63579. */
  63580. y: number;
  63581. /**
  63582. * Defines the third coordinates (on Z axis)
  63583. */
  63584. z: number;
  63585. private static _UpReadOnly;
  63586. private static _ZeroReadOnly;
  63587. /**
  63588. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  63589. * @param x defines the first coordinates (on X axis)
  63590. * @param y defines the second coordinates (on Y axis)
  63591. * @param z defines the third coordinates (on Z axis)
  63592. */
  63593. constructor(
  63594. /**
  63595. * Defines the first coordinates (on X axis)
  63596. */
  63597. x?: number,
  63598. /**
  63599. * Defines the second coordinates (on Y axis)
  63600. */
  63601. y?: number,
  63602. /**
  63603. * Defines the third coordinates (on Z axis)
  63604. */
  63605. z?: number);
  63606. /**
  63607. * Creates a string representation of the Vector3
  63608. * @returns a string with the Vector3 coordinates.
  63609. */
  63610. toString(): string;
  63611. /**
  63612. * Gets the class name
  63613. * @returns the string "Vector3"
  63614. */
  63615. getClassName(): string;
  63616. /**
  63617. * Creates the Vector3 hash code
  63618. * @returns a number which tends to be unique between Vector3 instances
  63619. */
  63620. getHashCode(): number;
  63621. /**
  63622. * Creates an array containing three elements : the coordinates of the Vector3
  63623. * @returns a new array of numbers
  63624. */
  63625. asArray(): number[];
  63626. /**
  63627. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  63628. * @param array defines the destination array
  63629. * @param index defines the offset in the destination array
  63630. * @returns the current Vector3
  63631. */
  63632. toArray(array: FloatArray, index?: number): Vector3;
  63633. /**
  63634. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  63635. * @returns a new Quaternion object, computed from the Vector3 coordinates
  63636. */
  63637. toQuaternion(): Quaternion;
  63638. /**
  63639. * Adds the given vector to the current Vector3
  63640. * @param otherVector defines the second operand
  63641. * @returns the current updated Vector3
  63642. */
  63643. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63644. /**
  63645. * Adds the given coordinates to the current Vector3
  63646. * @param x defines the x coordinate of the operand
  63647. * @param y defines the y coordinate of the operand
  63648. * @param z defines the z coordinate of the operand
  63649. * @returns the current updated Vector3
  63650. */
  63651. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63652. /**
  63653. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  63654. * @param otherVector defines the second operand
  63655. * @returns the resulting Vector3
  63656. */
  63657. add(otherVector: DeepImmutable<Vector3>): Vector3;
  63658. /**
  63659. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  63660. * @param otherVector defines the second operand
  63661. * @param result defines the Vector3 object where to store the result
  63662. * @returns the current Vector3
  63663. */
  63664. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63665. /**
  63666. * Subtract the given vector from the current Vector3
  63667. * @param otherVector defines the second operand
  63668. * @returns the current updated Vector3
  63669. */
  63670. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63671. /**
  63672. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  63673. * @param otherVector defines the second operand
  63674. * @returns the resulting Vector3
  63675. */
  63676. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  63677. /**
  63678. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  63679. * @param otherVector defines the second operand
  63680. * @param result defines the Vector3 object where to store the result
  63681. * @returns the current Vector3
  63682. */
  63683. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63684. /**
  63685. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  63686. * @param x defines the x coordinate of the operand
  63687. * @param y defines the y coordinate of the operand
  63688. * @param z defines the z coordinate of the operand
  63689. * @returns the resulting Vector3
  63690. */
  63691. subtractFromFloats(x: number, y: number, z: number): Vector3;
  63692. /**
  63693. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  63694. * @param x defines the x coordinate of the operand
  63695. * @param y defines the y coordinate of the operand
  63696. * @param z defines the z coordinate of the operand
  63697. * @param result defines the Vector3 object where to store the result
  63698. * @returns the current Vector3
  63699. */
  63700. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  63701. /**
  63702. * Gets a new Vector3 set with the current Vector3 negated coordinates
  63703. * @returns a new Vector3
  63704. */
  63705. negate(): Vector3;
  63706. /**
  63707. * Multiplies the Vector3 coordinates by the float "scale"
  63708. * @param scale defines the multiplier factor
  63709. * @returns the current updated Vector3
  63710. */
  63711. scaleInPlace(scale: number): Vector3;
  63712. /**
  63713. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  63714. * @param scale defines the multiplier factor
  63715. * @returns a new Vector3
  63716. */
  63717. scale(scale: number): Vector3;
  63718. /**
  63719. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  63720. * @param scale defines the multiplier factor
  63721. * @param result defines the Vector3 object where to store the result
  63722. * @returns the current Vector3
  63723. */
  63724. scaleToRef(scale: number, result: Vector3): Vector3;
  63725. /**
  63726. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  63727. * @param scale defines the scale factor
  63728. * @param result defines the Vector3 object where to store the result
  63729. * @returns the unmodified current Vector3
  63730. */
  63731. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  63732. /**
  63733. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  63734. * @param otherVector defines the second operand
  63735. * @returns true if both vectors are equals
  63736. */
  63737. equals(otherVector: DeepImmutable<Vector3>): boolean;
  63738. /**
  63739. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  63740. * @param otherVector defines the second operand
  63741. * @param epsilon defines the minimal distance to define values as equals
  63742. * @returns true if both vectors are distant less than epsilon
  63743. */
  63744. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  63745. /**
  63746. * Returns true if the current Vector3 coordinates equals the given floats
  63747. * @param x defines the x coordinate of the operand
  63748. * @param y defines the y coordinate of the operand
  63749. * @param z defines the z coordinate of the operand
  63750. * @returns true if both vectors are equals
  63751. */
  63752. equalsToFloats(x: number, y: number, z: number): boolean;
  63753. /**
  63754. * Multiplies the current Vector3 coordinates by the given ones
  63755. * @param otherVector defines the second operand
  63756. * @returns the current updated Vector3
  63757. */
  63758. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63759. /**
  63760. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  63761. * @param otherVector defines the second operand
  63762. * @returns the new Vector3
  63763. */
  63764. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  63765. /**
  63766. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  63767. * @param otherVector defines the second operand
  63768. * @param result defines the Vector3 object where to store the result
  63769. * @returns the current Vector3
  63770. */
  63771. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63772. /**
  63773. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  63774. * @param x defines the x coordinate of the operand
  63775. * @param y defines the y coordinate of the operand
  63776. * @param z defines the z coordinate of the operand
  63777. * @returns the new Vector3
  63778. */
  63779. multiplyByFloats(x: number, y: number, z: number): Vector3;
  63780. /**
  63781. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  63782. * @param otherVector defines the second operand
  63783. * @returns the new Vector3
  63784. */
  63785. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  63786. /**
  63787. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  63788. * @param otherVector defines the second operand
  63789. * @param result defines the Vector3 object where to store the result
  63790. * @returns the current Vector3
  63791. */
  63792. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63793. /**
  63794. * Divides the current Vector3 coordinates by the given ones.
  63795. * @param otherVector defines the second operand
  63796. * @returns the current updated Vector3
  63797. */
  63798. divideInPlace(otherVector: Vector3): Vector3;
  63799. /**
  63800. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  63801. * @param other defines the second operand
  63802. * @returns the current updated Vector3
  63803. */
  63804. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  63805. /**
  63806. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  63807. * @param other defines the second operand
  63808. * @returns the current updated Vector3
  63809. */
  63810. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  63811. /**
  63812. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  63813. * @param x defines the x coordinate of the operand
  63814. * @param y defines the y coordinate of the operand
  63815. * @param z defines the z coordinate of the operand
  63816. * @returns the current updated Vector3
  63817. */
  63818. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63819. /**
  63820. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  63821. * @param x defines the x coordinate of the operand
  63822. * @param y defines the y coordinate of the operand
  63823. * @param z defines the z coordinate of the operand
  63824. * @returns the current updated Vector3
  63825. */
  63826. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63827. /**
  63828. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  63829. * Check if is non uniform within a certain amount of decimal places to account for this
  63830. * @param epsilon the amount the values can differ
  63831. * @returns if the the vector is non uniform to a certain number of decimal places
  63832. */
  63833. isNonUniformWithinEpsilon(epsilon: number): boolean;
  63834. /**
  63835. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  63836. */
  63837. readonly isNonUniform: boolean;
  63838. /**
  63839. * Gets a new Vector3 from current Vector3 floored values
  63840. * @returns a new Vector3
  63841. */
  63842. floor(): Vector3;
  63843. /**
  63844. * Gets a new Vector3 from current Vector3 floored values
  63845. * @returns a new Vector3
  63846. */
  63847. fract(): Vector3;
  63848. /**
  63849. * Gets the length of the Vector3
  63850. * @returns the length of the Vecto3
  63851. */
  63852. length(): number;
  63853. /**
  63854. * Gets the squared length of the Vector3
  63855. * @returns squared length of the Vector3
  63856. */
  63857. lengthSquared(): number;
  63858. /**
  63859. * Normalize the current Vector3.
  63860. * Please note that this is an in place operation.
  63861. * @returns the current updated Vector3
  63862. */
  63863. normalize(): Vector3;
  63864. /**
  63865. * Reorders the x y z properties of the vector in place
  63866. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  63867. * @returns the current updated vector
  63868. */
  63869. reorderInPlace(order: string): this;
  63870. /**
  63871. * Rotates the vector around 0,0,0 by a quaternion
  63872. * @param quaternion the rotation quaternion
  63873. * @param result vector to store the result
  63874. * @returns the resulting vector
  63875. */
  63876. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  63877. /**
  63878. * Rotates a vector around a given point
  63879. * @param quaternion the rotation quaternion
  63880. * @param point the point to rotate around
  63881. * @param result vector to store the result
  63882. * @returns the resulting vector
  63883. */
  63884. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  63885. /**
  63886. * Normalize the current Vector3 with the given input length.
  63887. * Please note that this is an in place operation.
  63888. * @param len the length of the vector
  63889. * @returns the current updated Vector3
  63890. */
  63891. normalizeFromLength(len: number): Vector3;
  63892. /**
  63893. * Normalize the current Vector3 to a new vector
  63894. * @returns the new Vector3
  63895. */
  63896. normalizeToNew(): Vector3;
  63897. /**
  63898. * Normalize the current Vector3 to the reference
  63899. * @param reference define the Vector3 to update
  63900. * @returns the updated Vector3
  63901. */
  63902. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  63903. /**
  63904. * Creates a new Vector3 copied from the current Vector3
  63905. * @returns the new Vector3
  63906. */
  63907. clone(): Vector3;
  63908. /**
  63909. * Copies the given vector coordinates to the current Vector3 ones
  63910. * @param source defines the source Vector3
  63911. * @returns the current updated Vector3
  63912. */
  63913. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  63914. /**
  63915. * Copies the given floats to the current Vector3 coordinates
  63916. * @param x defines the x coordinate of the operand
  63917. * @param y defines the y coordinate of the operand
  63918. * @param z defines the z coordinate of the operand
  63919. * @returns the current updated Vector3
  63920. */
  63921. copyFromFloats(x: number, y: number, z: number): Vector3;
  63922. /**
  63923. * Copies the given floats to the current Vector3 coordinates
  63924. * @param x defines the x coordinate of the operand
  63925. * @param y defines the y coordinate of the operand
  63926. * @param z defines the z coordinate of the operand
  63927. * @returns the current updated Vector3
  63928. */
  63929. set(x: number, y: number, z: number): Vector3;
  63930. /**
  63931. * Copies the given float to the current Vector3 coordinates
  63932. * @param v defines the x, y and z coordinates of the operand
  63933. * @returns the current updated Vector3
  63934. */
  63935. setAll(v: number): Vector3;
  63936. /**
  63937. * Get the clip factor between two vectors
  63938. * @param vector0 defines the first operand
  63939. * @param vector1 defines the second operand
  63940. * @param axis defines the axis to use
  63941. * @param size defines the size along the axis
  63942. * @returns the clip factor
  63943. */
  63944. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  63945. /**
  63946. * Get angle between two vectors
  63947. * @param vector0 angle between vector0 and vector1
  63948. * @param vector1 angle between vector0 and vector1
  63949. * @param normal direction of the normal
  63950. * @return the angle between vector0 and vector1
  63951. */
  63952. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  63953. /**
  63954. * Returns a new Vector3 set from the index "offset" of the given array
  63955. * @param array defines the source array
  63956. * @param offset defines the offset in the source array
  63957. * @returns the new Vector3
  63958. */
  63959. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  63960. /**
  63961. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  63962. * This function is deprecated. Use FromArray instead
  63963. * @param array defines the source array
  63964. * @param offset defines the offset in the source array
  63965. * @returns the new Vector3
  63966. */
  63967. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  63968. /**
  63969. * Sets the given vector "result" with the element values from the index "offset" of the given array
  63970. * @param array defines the source array
  63971. * @param offset defines the offset in the source array
  63972. * @param result defines the Vector3 where to store the result
  63973. */
  63974. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  63975. /**
  63976. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  63977. * This function is deprecated. Use FromArrayToRef instead.
  63978. * @param array defines the source array
  63979. * @param offset defines the offset in the source array
  63980. * @param result defines the Vector3 where to store the result
  63981. */
  63982. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  63983. /**
  63984. * Sets the given vector "result" with the given floats.
  63985. * @param x defines the x coordinate of the source
  63986. * @param y defines the y coordinate of the source
  63987. * @param z defines the z coordinate of the source
  63988. * @param result defines the Vector3 where to store the result
  63989. */
  63990. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  63991. /**
  63992. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  63993. * @returns a new empty Vector3
  63994. */
  63995. static Zero(): Vector3;
  63996. /**
  63997. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  63998. * @returns a new unit Vector3
  63999. */
  64000. static One(): Vector3;
  64001. /**
  64002. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  64003. * @returns a new up Vector3
  64004. */
  64005. static Up(): Vector3;
  64006. /**
  64007. * Gets a up Vector3 that must not be updated
  64008. */
  64009. static readonly UpReadOnly: DeepImmutable<Vector3>;
  64010. /**
  64011. * Gets a zero Vector3 that must not be updated
  64012. */
  64013. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  64014. /**
  64015. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  64016. * @returns a new down Vector3
  64017. */
  64018. static Down(): Vector3;
  64019. /**
  64020. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  64021. * @returns a new forward Vector3
  64022. */
  64023. static Forward(): Vector3;
  64024. /**
  64025. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  64026. * @returns a new forward Vector3
  64027. */
  64028. static Backward(): Vector3;
  64029. /**
  64030. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  64031. * @returns a new right Vector3
  64032. */
  64033. static Right(): Vector3;
  64034. /**
  64035. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  64036. * @returns a new left Vector3
  64037. */
  64038. static Left(): Vector3;
  64039. /**
  64040. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  64041. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64042. * @param vector defines the Vector3 to transform
  64043. * @param transformation defines the transformation matrix
  64044. * @returns the transformed Vector3
  64045. */
  64046. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64047. /**
  64048. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  64049. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64050. * @param vector defines the Vector3 to transform
  64051. * @param transformation defines the transformation matrix
  64052. * @param result defines the Vector3 where to store the result
  64053. */
  64054. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64055. /**
  64056. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  64057. * This method computes tranformed coordinates only, not transformed direction vectors
  64058. * @param x define the x coordinate of the source vector
  64059. * @param y define the y coordinate of the source vector
  64060. * @param z define the z coordinate of the source vector
  64061. * @param transformation defines the transformation matrix
  64062. * @param result defines the Vector3 where to store the result
  64063. */
  64064. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64065. /**
  64066. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  64067. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64068. * @param vector defines the Vector3 to transform
  64069. * @param transformation defines the transformation matrix
  64070. * @returns the new Vector3
  64071. */
  64072. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64073. /**
  64074. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  64075. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64076. * @param vector defines the Vector3 to transform
  64077. * @param transformation defines the transformation matrix
  64078. * @param result defines the Vector3 where to store the result
  64079. */
  64080. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64081. /**
  64082. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  64083. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64084. * @param x define the x coordinate of the source vector
  64085. * @param y define the y coordinate of the source vector
  64086. * @param z define the z coordinate of the source vector
  64087. * @param transformation defines the transformation matrix
  64088. * @param result defines the Vector3 where to store the result
  64089. */
  64090. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64091. /**
  64092. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  64093. * @param value1 defines the first control point
  64094. * @param value2 defines the second control point
  64095. * @param value3 defines the third control point
  64096. * @param value4 defines the fourth control point
  64097. * @param amount defines the amount on the spline to use
  64098. * @returns the new Vector3
  64099. */
  64100. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  64101. /**
  64102. * 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"
  64103. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64104. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64105. * @param value defines the current value
  64106. * @param min defines the lower range value
  64107. * @param max defines the upper range value
  64108. * @returns the new Vector3
  64109. */
  64110. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  64111. /**
  64112. * 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"
  64113. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64114. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64115. * @param value defines the current value
  64116. * @param min defines the lower range value
  64117. * @param max defines the upper range value
  64118. * @param result defines the Vector3 where to store the result
  64119. */
  64120. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  64121. /**
  64122. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  64123. * @param value1 defines the first control point
  64124. * @param tangent1 defines the first tangent vector
  64125. * @param value2 defines the second control point
  64126. * @param tangent2 defines the second tangent vector
  64127. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  64128. * @returns the new Vector3
  64129. */
  64130. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  64131. /**
  64132. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  64133. * @param start defines the start value
  64134. * @param end defines the end value
  64135. * @param amount max defines amount between both (between 0 and 1)
  64136. * @returns the new Vector3
  64137. */
  64138. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  64139. /**
  64140. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  64141. * @param start defines the start value
  64142. * @param end defines the end value
  64143. * @param amount max defines amount between both (between 0 and 1)
  64144. * @param result defines the Vector3 where to store the result
  64145. */
  64146. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  64147. /**
  64148. * Returns the dot product (float) between the vectors "left" and "right"
  64149. * @param left defines the left operand
  64150. * @param right defines the right operand
  64151. * @returns the dot product
  64152. */
  64153. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  64154. /**
  64155. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  64156. * The cross product is then orthogonal to both "left" and "right"
  64157. * @param left defines the left operand
  64158. * @param right defines the right operand
  64159. * @returns the cross product
  64160. */
  64161. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64162. /**
  64163. * Sets the given vector "result" with the cross product of "left" and "right"
  64164. * The cross product is then orthogonal to both "left" and "right"
  64165. * @param left defines the left operand
  64166. * @param right defines the right operand
  64167. * @param result defines the Vector3 where to store the result
  64168. */
  64169. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  64170. /**
  64171. * Returns a new Vector3 as the normalization of the given vector
  64172. * @param vector defines the Vector3 to normalize
  64173. * @returns the new Vector3
  64174. */
  64175. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  64176. /**
  64177. * Sets the given vector "result" with the normalization of the given first vector
  64178. * @param vector defines the Vector3 to normalize
  64179. * @param result defines the Vector3 where to store the result
  64180. */
  64181. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  64182. /**
  64183. * Project a Vector3 onto screen space
  64184. * @param vector defines the Vector3 to project
  64185. * @param world defines the world matrix to use
  64186. * @param transform defines the transform (view x projection) matrix to use
  64187. * @param viewport defines the screen viewport to use
  64188. * @returns the new Vector3
  64189. */
  64190. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  64191. /** @hidden */
  64192. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  64193. /**
  64194. * Unproject from screen space to object space
  64195. * @param source defines the screen space Vector3 to use
  64196. * @param viewportWidth defines the current width of the viewport
  64197. * @param viewportHeight defines the current height of the viewport
  64198. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64199. * @param transform defines the transform (view x projection) matrix to use
  64200. * @returns the new Vector3
  64201. */
  64202. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  64203. /**
  64204. * Unproject from screen space to object space
  64205. * @param source defines the screen space Vector3 to use
  64206. * @param viewportWidth defines the current width of the viewport
  64207. * @param viewportHeight defines the current height of the viewport
  64208. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64209. * @param view defines the view matrix to use
  64210. * @param projection defines the projection matrix to use
  64211. * @returns the new Vector3
  64212. */
  64213. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  64214. /**
  64215. * Unproject from screen space to object space
  64216. * @param source defines the screen space Vector3 to use
  64217. * @param viewportWidth defines the current width of the viewport
  64218. * @param viewportHeight defines the current height of the viewport
  64219. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64220. * @param view defines the view matrix to use
  64221. * @param projection defines the projection matrix to use
  64222. * @param result defines the Vector3 where to store the result
  64223. */
  64224. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64225. /**
  64226. * Unproject from screen space to object space
  64227. * @param sourceX defines the screen space x coordinate to use
  64228. * @param sourceY defines the screen space y coordinate to use
  64229. * @param sourceZ defines the screen space z coordinate to use
  64230. * @param viewportWidth defines the current width of the viewport
  64231. * @param viewportHeight defines the current height of the viewport
  64232. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64233. * @param view defines the view matrix to use
  64234. * @param projection defines the projection matrix to use
  64235. * @param result defines the Vector3 where to store the result
  64236. */
  64237. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64238. /**
  64239. * Gets the minimal coordinate values between two Vector3
  64240. * @param left defines the first operand
  64241. * @param right defines the second operand
  64242. * @returns the new Vector3
  64243. */
  64244. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64245. /**
  64246. * Gets the maximal coordinate values between two Vector3
  64247. * @param left defines the first operand
  64248. * @param right defines the second operand
  64249. * @returns the new Vector3
  64250. */
  64251. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64252. /**
  64253. * Returns the distance between the vectors "value1" and "value2"
  64254. * @param value1 defines the first operand
  64255. * @param value2 defines the second operand
  64256. * @returns the distance
  64257. */
  64258. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64259. /**
  64260. * Returns the squared distance between the vectors "value1" and "value2"
  64261. * @param value1 defines the first operand
  64262. * @param value2 defines the second operand
  64263. * @returns the squared distance
  64264. */
  64265. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64266. /**
  64267. * Returns a new Vector3 located at the center between "value1" and "value2"
  64268. * @param value1 defines the first operand
  64269. * @param value2 defines the second operand
  64270. * @returns the new Vector3
  64271. */
  64272. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  64273. /**
  64274. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  64275. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  64276. * to something in order to rotate it from its local system to the given target system
  64277. * Note: axis1, axis2 and axis3 are normalized during this operation
  64278. * @param axis1 defines the first axis
  64279. * @param axis2 defines the second axis
  64280. * @param axis3 defines the third axis
  64281. * @returns a new Vector3
  64282. */
  64283. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  64284. /**
  64285. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  64286. * @param axis1 defines the first axis
  64287. * @param axis2 defines the second axis
  64288. * @param axis3 defines the third axis
  64289. * @param ref defines the Vector3 where to store the result
  64290. */
  64291. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  64292. }
  64293. /**
  64294. * Vector4 class created for EulerAngle class conversion to Quaternion
  64295. */
  64296. export class Vector4 {
  64297. /** x value of the vector */
  64298. x: number;
  64299. /** y value of the vector */
  64300. y: number;
  64301. /** z value of the vector */
  64302. z: number;
  64303. /** w value of the vector */
  64304. w: number;
  64305. /**
  64306. * Creates a Vector4 object from the given floats.
  64307. * @param x x value of the vector
  64308. * @param y y value of the vector
  64309. * @param z z value of the vector
  64310. * @param w w value of the vector
  64311. */
  64312. constructor(
  64313. /** x value of the vector */
  64314. x: number,
  64315. /** y value of the vector */
  64316. y: number,
  64317. /** z value of the vector */
  64318. z: number,
  64319. /** w value of the vector */
  64320. w: number);
  64321. /**
  64322. * Returns the string with the Vector4 coordinates.
  64323. * @returns a string containing all the vector values
  64324. */
  64325. toString(): string;
  64326. /**
  64327. * Returns the string "Vector4".
  64328. * @returns "Vector4"
  64329. */
  64330. getClassName(): string;
  64331. /**
  64332. * Returns the Vector4 hash code.
  64333. * @returns a unique hash code
  64334. */
  64335. getHashCode(): number;
  64336. /**
  64337. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  64338. * @returns the resulting array
  64339. */
  64340. asArray(): number[];
  64341. /**
  64342. * Populates the given array from the given index with the Vector4 coordinates.
  64343. * @param array array to populate
  64344. * @param index index of the array to start at (default: 0)
  64345. * @returns the Vector4.
  64346. */
  64347. toArray(array: FloatArray, index?: number): Vector4;
  64348. /**
  64349. * Adds the given vector to the current Vector4.
  64350. * @param otherVector the vector to add
  64351. * @returns the updated Vector4.
  64352. */
  64353. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64354. /**
  64355. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  64356. * @param otherVector the vector to add
  64357. * @returns the resulting vector
  64358. */
  64359. add(otherVector: DeepImmutable<Vector4>): Vector4;
  64360. /**
  64361. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  64362. * @param otherVector the vector to add
  64363. * @param result the vector to store the result
  64364. * @returns the current Vector4.
  64365. */
  64366. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64367. /**
  64368. * Subtract in place the given vector from the current Vector4.
  64369. * @param otherVector the vector to subtract
  64370. * @returns the updated Vector4.
  64371. */
  64372. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64373. /**
  64374. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  64375. * @param otherVector the vector to add
  64376. * @returns the new vector with the result
  64377. */
  64378. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  64379. /**
  64380. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  64381. * @param otherVector the vector to subtract
  64382. * @param result the vector to store the result
  64383. * @returns the current Vector4.
  64384. */
  64385. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64386. /**
  64387. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64388. */
  64389. /**
  64390. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64391. * @param x value to subtract
  64392. * @param y value to subtract
  64393. * @param z value to subtract
  64394. * @param w value to subtract
  64395. * @returns new vector containing the result
  64396. */
  64397. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64398. /**
  64399. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64400. * @param x value to subtract
  64401. * @param y value to subtract
  64402. * @param z value to subtract
  64403. * @param w value to subtract
  64404. * @param result the vector to store the result in
  64405. * @returns the current Vector4.
  64406. */
  64407. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  64408. /**
  64409. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  64410. * @returns a new vector with the negated values
  64411. */
  64412. negate(): Vector4;
  64413. /**
  64414. * Multiplies the current Vector4 coordinates by scale (float).
  64415. * @param scale the number to scale with
  64416. * @returns the updated Vector4.
  64417. */
  64418. scaleInPlace(scale: number): Vector4;
  64419. /**
  64420. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  64421. * @param scale the number to scale with
  64422. * @returns a new vector with the result
  64423. */
  64424. scale(scale: number): Vector4;
  64425. /**
  64426. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  64427. * @param scale the number to scale with
  64428. * @param result a vector to store the result in
  64429. * @returns the current Vector4.
  64430. */
  64431. scaleToRef(scale: number, result: Vector4): Vector4;
  64432. /**
  64433. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  64434. * @param scale defines the scale factor
  64435. * @param result defines the Vector4 object where to store the result
  64436. * @returns the unmodified current Vector4
  64437. */
  64438. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  64439. /**
  64440. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  64441. * @param otherVector the vector to compare against
  64442. * @returns true if they are equal
  64443. */
  64444. equals(otherVector: DeepImmutable<Vector4>): boolean;
  64445. /**
  64446. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  64447. * @param otherVector vector to compare against
  64448. * @param epsilon (Default: very small number)
  64449. * @returns true if they are equal
  64450. */
  64451. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  64452. /**
  64453. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  64454. * @param x x value to compare against
  64455. * @param y y value to compare against
  64456. * @param z z value to compare against
  64457. * @param w w value to compare against
  64458. * @returns true if equal
  64459. */
  64460. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  64461. /**
  64462. * Multiplies in place the current Vector4 by the given one.
  64463. * @param otherVector vector to multiple with
  64464. * @returns the updated Vector4.
  64465. */
  64466. multiplyInPlace(otherVector: Vector4): Vector4;
  64467. /**
  64468. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  64469. * @param otherVector vector to multiple with
  64470. * @returns resulting new vector
  64471. */
  64472. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  64473. /**
  64474. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  64475. * @param otherVector vector to multiple with
  64476. * @param result vector to store the result
  64477. * @returns the current Vector4.
  64478. */
  64479. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64480. /**
  64481. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  64482. * @param x x value multiply with
  64483. * @param y y value multiply with
  64484. * @param z z value multiply with
  64485. * @param w w value multiply with
  64486. * @returns resulting new vector
  64487. */
  64488. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  64489. /**
  64490. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  64491. * @param otherVector vector to devide with
  64492. * @returns resulting new vector
  64493. */
  64494. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  64495. /**
  64496. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  64497. * @param otherVector vector to devide with
  64498. * @param result vector to store the result
  64499. * @returns the current Vector4.
  64500. */
  64501. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64502. /**
  64503. * Divides the current Vector3 coordinates by the given ones.
  64504. * @param otherVector vector to devide with
  64505. * @returns the updated Vector3.
  64506. */
  64507. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64508. /**
  64509. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  64510. * @param other defines the second operand
  64511. * @returns the current updated Vector4
  64512. */
  64513. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64514. /**
  64515. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  64516. * @param other defines the second operand
  64517. * @returns the current updated Vector4
  64518. */
  64519. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64520. /**
  64521. * Gets a new Vector4 from current Vector4 floored values
  64522. * @returns a new Vector4
  64523. */
  64524. floor(): Vector4;
  64525. /**
  64526. * Gets a new Vector4 from current Vector3 floored values
  64527. * @returns a new Vector4
  64528. */
  64529. fract(): Vector4;
  64530. /**
  64531. * Returns the Vector4 length (float).
  64532. * @returns the length
  64533. */
  64534. length(): number;
  64535. /**
  64536. * Returns the Vector4 squared length (float).
  64537. * @returns the length squared
  64538. */
  64539. lengthSquared(): number;
  64540. /**
  64541. * Normalizes in place the Vector4.
  64542. * @returns the updated Vector4.
  64543. */
  64544. normalize(): Vector4;
  64545. /**
  64546. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  64547. * @returns this converted to a new vector3
  64548. */
  64549. toVector3(): Vector3;
  64550. /**
  64551. * Returns a new Vector4 copied from the current one.
  64552. * @returns the new cloned vector
  64553. */
  64554. clone(): Vector4;
  64555. /**
  64556. * Updates the current Vector4 with the given one coordinates.
  64557. * @param source the source vector to copy from
  64558. * @returns the updated Vector4.
  64559. */
  64560. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  64561. /**
  64562. * Updates the current Vector4 coordinates with the given floats.
  64563. * @param x float to copy from
  64564. * @param y float to copy from
  64565. * @param z float to copy from
  64566. * @param w float to copy from
  64567. * @returns the updated Vector4.
  64568. */
  64569. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64570. /**
  64571. * Updates the current Vector4 coordinates with the given floats.
  64572. * @param x float to set from
  64573. * @param y float to set from
  64574. * @param z float to set from
  64575. * @param w float to set from
  64576. * @returns the updated Vector4.
  64577. */
  64578. set(x: number, y: number, z: number, w: number): Vector4;
  64579. /**
  64580. * Copies the given float to the current Vector3 coordinates
  64581. * @param v defines the x, y, z and w coordinates of the operand
  64582. * @returns the current updated Vector3
  64583. */
  64584. setAll(v: number): Vector4;
  64585. /**
  64586. * Returns a new Vector4 set from the starting index of the given array.
  64587. * @param array the array to pull values from
  64588. * @param offset the offset into the array to start at
  64589. * @returns the new vector
  64590. */
  64591. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  64592. /**
  64593. * Updates the given vector "result" from the starting index of the given array.
  64594. * @param array the array to pull values from
  64595. * @param offset the offset into the array to start at
  64596. * @param result the vector to store the result in
  64597. */
  64598. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  64599. /**
  64600. * Updates the given vector "result" from the starting index of the given Float32Array.
  64601. * @param array the array to pull values from
  64602. * @param offset the offset into the array to start at
  64603. * @param result the vector to store the result in
  64604. */
  64605. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  64606. /**
  64607. * Updates the given vector "result" coordinates from the given floats.
  64608. * @param x float to set from
  64609. * @param y float to set from
  64610. * @param z float to set from
  64611. * @param w float to set from
  64612. * @param result the vector to the floats in
  64613. */
  64614. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  64615. /**
  64616. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  64617. * @returns the new vector
  64618. */
  64619. static Zero(): Vector4;
  64620. /**
  64621. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  64622. * @returns the new vector
  64623. */
  64624. static One(): Vector4;
  64625. /**
  64626. * Returns a new normalized Vector4 from the given one.
  64627. * @param vector the vector to normalize
  64628. * @returns the vector
  64629. */
  64630. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  64631. /**
  64632. * Updates the given vector "result" from the normalization of the given one.
  64633. * @param vector the vector to normalize
  64634. * @param result the vector to store the result in
  64635. */
  64636. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  64637. /**
  64638. * Returns a vector with the minimum values from the left and right vectors
  64639. * @param left left vector to minimize
  64640. * @param right right vector to minimize
  64641. * @returns a new vector with the minimum of the left and right vector values
  64642. */
  64643. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64644. /**
  64645. * Returns a vector with the maximum values from the left and right vectors
  64646. * @param left left vector to maximize
  64647. * @param right right vector to maximize
  64648. * @returns a new vector with the maximum of the left and right vector values
  64649. */
  64650. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64651. /**
  64652. * Returns the distance (float) between the vectors "value1" and "value2".
  64653. * @param value1 value to calulate the distance between
  64654. * @param value2 value to calulate the distance between
  64655. * @return the distance between the two vectors
  64656. */
  64657. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64658. /**
  64659. * Returns the squared distance (float) between the vectors "value1" and "value2".
  64660. * @param value1 value to calulate the distance between
  64661. * @param value2 value to calulate the distance between
  64662. * @return the distance between the two vectors squared
  64663. */
  64664. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64665. /**
  64666. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  64667. * @param value1 value to calulate the center between
  64668. * @param value2 value to calulate the center between
  64669. * @return the center between the two vectors
  64670. */
  64671. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  64672. /**
  64673. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  64674. * This methods computes transformed normalized direction vectors only.
  64675. * @param vector the vector to transform
  64676. * @param transformation the transformation matrix to apply
  64677. * @returns the new vector
  64678. */
  64679. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  64680. /**
  64681. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  64682. * This methods computes transformed normalized direction vectors only.
  64683. * @param vector the vector to transform
  64684. * @param transformation the transformation matrix to apply
  64685. * @param result the vector to store the result in
  64686. */
  64687. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64688. /**
  64689. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  64690. * This methods computes transformed normalized direction vectors only.
  64691. * @param x value to transform
  64692. * @param y value to transform
  64693. * @param z value to transform
  64694. * @param w value to transform
  64695. * @param transformation the transformation matrix to apply
  64696. * @param result the vector to store the results in
  64697. */
  64698. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64699. /**
  64700. * Creates a new Vector4 from a Vector3
  64701. * @param source defines the source data
  64702. * @param w defines the 4th component (default is 0)
  64703. * @returns a new Vector4
  64704. */
  64705. static FromVector3(source: Vector3, w?: number): Vector4;
  64706. }
  64707. /**
  64708. * Interface for the size containing width and height
  64709. */
  64710. export interface ISize {
  64711. /**
  64712. * Width
  64713. */
  64714. width: number;
  64715. /**
  64716. * Heighht
  64717. */
  64718. height: number;
  64719. }
  64720. /**
  64721. * Size containing widht and height
  64722. */
  64723. export class Size implements ISize {
  64724. /**
  64725. * Width
  64726. */
  64727. width: number;
  64728. /**
  64729. * Height
  64730. */
  64731. height: number;
  64732. /**
  64733. * Creates a Size object from the given width and height (floats).
  64734. * @param width width of the new size
  64735. * @param height height of the new size
  64736. */
  64737. constructor(width: number, height: number);
  64738. /**
  64739. * Returns a string with the Size width and height
  64740. * @returns a string with the Size width and height
  64741. */
  64742. toString(): string;
  64743. /**
  64744. * "Size"
  64745. * @returns the string "Size"
  64746. */
  64747. getClassName(): string;
  64748. /**
  64749. * Returns the Size hash code.
  64750. * @returns a hash code for a unique width and height
  64751. */
  64752. getHashCode(): number;
  64753. /**
  64754. * Updates the current size from the given one.
  64755. * @param src the given size
  64756. */
  64757. copyFrom(src: Size): void;
  64758. /**
  64759. * Updates in place the current Size from the given floats.
  64760. * @param width width of the new size
  64761. * @param height height of the new size
  64762. * @returns the updated Size.
  64763. */
  64764. copyFromFloats(width: number, height: number): Size;
  64765. /**
  64766. * Updates in place the current Size from the given floats.
  64767. * @param width width to set
  64768. * @param height height to set
  64769. * @returns the updated Size.
  64770. */
  64771. set(width: number, height: number): Size;
  64772. /**
  64773. * Multiplies the width and height by numbers
  64774. * @param w factor to multiple the width by
  64775. * @param h factor to multiple the height by
  64776. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  64777. */
  64778. multiplyByFloats(w: number, h: number): Size;
  64779. /**
  64780. * Clones the size
  64781. * @returns a new Size copied from the given one.
  64782. */
  64783. clone(): Size;
  64784. /**
  64785. * True if the current Size and the given one width and height are strictly equal.
  64786. * @param other the other size to compare against
  64787. * @returns True if the current Size and the given one width and height are strictly equal.
  64788. */
  64789. equals(other: Size): boolean;
  64790. /**
  64791. * The surface of the Size : width * height (float).
  64792. */
  64793. readonly surface: number;
  64794. /**
  64795. * Create a new size of zero
  64796. * @returns a new Size set to (0.0, 0.0)
  64797. */
  64798. static Zero(): Size;
  64799. /**
  64800. * Sums the width and height of two sizes
  64801. * @param otherSize size to add to this size
  64802. * @returns a new Size set as the addition result of the current Size and the given one.
  64803. */
  64804. add(otherSize: Size): Size;
  64805. /**
  64806. * Subtracts the width and height of two
  64807. * @param otherSize size to subtract to this size
  64808. * @returns a new Size set as the subtraction result of the given one from the current Size.
  64809. */
  64810. subtract(otherSize: Size): Size;
  64811. /**
  64812. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  64813. * @param start starting size to lerp between
  64814. * @param end end size to lerp between
  64815. * @param amount amount to lerp between the start and end values
  64816. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  64817. */
  64818. static Lerp(start: Size, end: Size, amount: number): Size;
  64819. }
  64820. /**
  64821. * Class used to store quaternion data
  64822. * @see https://en.wikipedia.org/wiki/Quaternion
  64823. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  64824. */
  64825. export class Quaternion {
  64826. /** defines the first component (0 by default) */
  64827. x: number;
  64828. /** defines the second component (0 by default) */
  64829. y: number;
  64830. /** defines the third component (0 by default) */
  64831. z: number;
  64832. /** defines the fourth component (1.0 by default) */
  64833. w: number;
  64834. /**
  64835. * Creates a new Quaternion from the given floats
  64836. * @param x defines the first component (0 by default)
  64837. * @param y defines the second component (0 by default)
  64838. * @param z defines the third component (0 by default)
  64839. * @param w defines the fourth component (1.0 by default)
  64840. */
  64841. constructor(
  64842. /** defines the first component (0 by default) */
  64843. x?: number,
  64844. /** defines the second component (0 by default) */
  64845. y?: number,
  64846. /** defines the third component (0 by default) */
  64847. z?: number,
  64848. /** defines the fourth component (1.0 by default) */
  64849. w?: number);
  64850. /**
  64851. * Gets a string representation for the current quaternion
  64852. * @returns a string with the Quaternion coordinates
  64853. */
  64854. toString(): string;
  64855. /**
  64856. * Gets the class name of the quaternion
  64857. * @returns the string "Quaternion"
  64858. */
  64859. getClassName(): string;
  64860. /**
  64861. * Gets a hash code for this quaternion
  64862. * @returns the quaternion hash code
  64863. */
  64864. getHashCode(): number;
  64865. /**
  64866. * Copy the quaternion to an array
  64867. * @returns a new array populated with 4 elements from the quaternion coordinates
  64868. */
  64869. asArray(): number[];
  64870. /**
  64871. * Check if two quaternions are equals
  64872. * @param otherQuaternion defines the second operand
  64873. * @return true if the current quaternion and the given one coordinates are strictly equals
  64874. */
  64875. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  64876. /**
  64877. * Clone the current quaternion
  64878. * @returns a new quaternion copied from the current one
  64879. */
  64880. clone(): Quaternion;
  64881. /**
  64882. * Copy a quaternion to the current one
  64883. * @param other defines the other quaternion
  64884. * @returns the updated current quaternion
  64885. */
  64886. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  64887. /**
  64888. * Updates the current quaternion with the given float coordinates
  64889. * @param x defines the x coordinate
  64890. * @param y defines the y coordinate
  64891. * @param z defines the z coordinate
  64892. * @param w defines the w coordinate
  64893. * @returns the updated current quaternion
  64894. */
  64895. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  64896. /**
  64897. * Updates the current quaternion from the given float coordinates
  64898. * @param x defines the x coordinate
  64899. * @param y defines the y coordinate
  64900. * @param z defines the z coordinate
  64901. * @param w defines the w coordinate
  64902. * @returns the updated current quaternion
  64903. */
  64904. set(x: number, y: number, z: number, w: number): Quaternion;
  64905. /**
  64906. * Adds two quaternions
  64907. * @param other defines the second operand
  64908. * @returns a new quaternion as the addition result of the given one and the current quaternion
  64909. */
  64910. add(other: DeepImmutable<Quaternion>): Quaternion;
  64911. /**
  64912. * Add a quaternion to the current one
  64913. * @param other defines the quaternion to add
  64914. * @returns the current quaternion
  64915. */
  64916. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  64917. /**
  64918. * Subtract two quaternions
  64919. * @param other defines the second operand
  64920. * @returns a new quaternion as the subtraction result of the given one from the current one
  64921. */
  64922. subtract(other: Quaternion): Quaternion;
  64923. /**
  64924. * Multiplies the current quaternion by a scale factor
  64925. * @param value defines the scale factor
  64926. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  64927. */
  64928. scale(value: number): Quaternion;
  64929. /**
  64930. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  64931. * @param scale defines the scale factor
  64932. * @param result defines the Quaternion object where to store the result
  64933. * @returns the unmodified current quaternion
  64934. */
  64935. scaleToRef(scale: number, result: Quaternion): Quaternion;
  64936. /**
  64937. * Multiplies in place the current quaternion by a scale factor
  64938. * @param value defines the scale factor
  64939. * @returns the current modified quaternion
  64940. */
  64941. scaleInPlace(value: number): Quaternion;
  64942. /**
  64943. * Scale the current quaternion values by a factor and add the result to a given quaternion
  64944. * @param scale defines the scale factor
  64945. * @param result defines the Quaternion object where to store the result
  64946. * @returns the unmodified current quaternion
  64947. */
  64948. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  64949. /**
  64950. * Multiplies two quaternions
  64951. * @param q1 defines the second operand
  64952. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  64953. */
  64954. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  64955. /**
  64956. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  64957. * @param q1 defines the second operand
  64958. * @param result defines the target quaternion
  64959. * @returns the current quaternion
  64960. */
  64961. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  64962. /**
  64963. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  64964. * @param q1 defines the second operand
  64965. * @returns the currentupdated quaternion
  64966. */
  64967. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  64968. /**
  64969. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  64970. * @param ref defines the target quaternion
  64971. * @returns the current quaternion
  64972. */
  64973. conjugateToRef(ref: Quaternion): Quaternion;
  64974. /**
  64975. * Conjugates in place (1-q) the current quaternion
  64976. * @returns the current updated quaternion
  64977. */
  64978. conjugateInPlace(): Quaternion;
  64979. /**
  64980. * Conjugates in place (1-q) the current quaternion
  64981. * @returns a new quaternion
  64982. */
  64983. conjugate(): Quaternion;
  64984. /**
  64985. * Gets length of current quaternion
  64986. * @returns the quaternion length (float)
  64987. */
  64988. length(): number;
  64989. /**
  64990. * Normalize in place the current quaternion
  64991. * @returns the current updated quaternion
  64992. */
  64993. normalize(): Quaternion;
  64994. /**
  64995. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  64996. * @param order is a reserved parameter and is ignore for now
  64997. * @returns a new Vector3 containing the Euler angles
  64998. */
  64999. toEulerAngles(order?: string): Vector3;
  65000. /**
  65001. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  65002. * @param result defines the vector which will be filled with the Euler angles
  65003. * @param order is a reserved parameter and is ignore for now
  65004. * @returns the current unchanged quaternion
  65005. */
  65006. toEulerAnglesToRef(result: Vector3): Quaternion;
  65007. /**
  65008. * Updates the given rotation matrix with the current quaternion values
  65009. * @param result defines the target matrix
  65010. * @returns the current unchanged quaternion
  65011. */
  65012. toRotationMatrix(result: Matrix): Quaternion;
  65013. /**
  65014. * Updates the current quaternion from the given rotation matrix values
  65015. * @param matrix defines the source matrix
  65016. * @returns the current updated quaternion
  65017. */
  65018. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65019. /**
  65020. * Creates a new quaternion from a rotation matrix
  65021. * @param matrix defines the source matrix
  65022. * @returns a new quaternion created from the given rotation matrix values
  65023. */
  65024. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65025. /**
  65026. * Updates the given quaternion with the given rotation matrix values
  65027. * @param matrix defines the source matrix
  65028. * @param result defines the target quaternion
  65029. */
  65030. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  65031. /**
  65032. * Returns the dot product (float) between the quaternions "left" and "right"
  65033. * @param left defines the left operand
  65034. * @param right defines the right operand
  65035. * @returns the dot product
  65036. */
  65037. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  65038. /**
  65039. * Checks if the two quaternions are close to each other
  65040. * @param quat0 defines the first quaternion to check
  65041. * @param quat1 defines the second quaternion to check
  65042. * @returns true if the two quaternions are close to each other
  65043. */
  65044. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  65045. /**
  65046. * Creates an empty quaternion
  65047. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  65048. */
  65049. static Zero(): Quaternion;
  65050. /**
  65051. * Inverse a given quaternion
  65052. * @param q defines the source quaternion
  65053. * @returns a new quaternion as the inverted current quaternion
  65054. */
  65055. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  65056. /**
  65057. * Inverse a given quaternion
  65058. * @param q defines the source quaternion
  65059. * @param result the quaternion the result will be stored in
  65060. * @returns the result quaternion
  65061. */
  65062. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  65063. /**
  65064. * Creates an identity quaternion
  65065. * @returns the identity quaternion
  65066. */
  65067. static Identity(): Quaternion;
  65068. /**
  65069. * Gets a boolean indicating if the given quaternion is identity
  65070. * @param quaternion defines the quaternion to check
  65071. * @returns true if the quaternion is identity
  65072. */
  65073. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  65074. /**
  65075. * Creates a quaternion from a rotation around an axis
  65076. * @param axis defines the axis to use
  65077. * @param angle defines the angle to use
  65078. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  65079. */
  65080. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  65081. /**
  65082. * Creates a rotation around an axis and stores it into the given quaternion
  65083. * @param axis defines the axis to use
  65084. * @param angle defines the angle to use
  65085. * @param result defines the target quaternion
  65086. * @returns the target quaternion
  65087. */
  65088. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  65089. /**
  65090. * Creates a new quaternion from data stored into an array
  65091. * @param array defines the data source
  65092. * @param offset defines the offset in the source array where the data starts
  65093. * @returns a new quaternion
  65094. */
  65095. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  65096. /**
  65097. * Create a quaternion from Euler rotation angles
  65098. * @param x Pitch
  65099. * @param y Yaw
  65100. * @param z Roll
  65101. * @returns the new Quaternion
  65102. */
  65103. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  65104. /**
  65105. * Updates a quaternion from Euler rotation angles
  65106. * @param x Pitch
  65107. * @param y Yaw
  65108. * @param z Roll
  65109. * @param result the quaternion to store the result
  65110. * @returns the updated quaternion
  65111. */
  65112. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  65113. /**
  65114. * Create a quaternion from Euler rotation vector
  65115. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65116. * @returns the new Quaternion
  65117. */
  65118. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  65119. /**
  65120. * Updates a quaternion from Euler rotation vector
  65121. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65122. * @param result the quaternion to store the result
  65123. * @returns the updated quaternion
  65124. */
  65125. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  65126. /**
  65127. * Creates a new quaternion from the given Euler float angles (y, x, z)
  65128. * @param yaw defines the rotation around Y axis
  65129. * @param pitch defines the rotation around X axis
  65130. * @param roll defines the rotation around Z axis
  65131. * @returns the new quaternion
  65132. */
  65133. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  65134. /**
  65135. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  65136. * @param yaw defines the rotation around Y axis
  65137. * @param pitch defines the rotation around X axis
  65138. * @param roll defines the rotation around Z axis
  65139. * @param result defines the target quaternion
  65140. */
  65141. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  65142. /**
  65143. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  65144. * @param alpha defines the rotation around first axis
  65145. * @param beta defines the rotation around second axis
  65146. * @param gamma defines the rotation around third axis
  65147. * @returns the new quaternion
  65148. */
  65149. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  65150. /**
  65151. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  65152. * @param alpha defines the rotation around first axis
  65153. * @param beta defines the rotation around second axis
  65154. * @param gamma defines the rotation around third axis
  65155. * @param result defines the target quaternion
  65156. */
  65157. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  65158. /**
  65159. * 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)
  65160. * @param axis1 defines the first axis
  65161. * @param axis2 defines the second axis
  65162. * @param axis3 defines the third axis
  65163. * @returns the new quaternion
  65164. */
  65165. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  65166. /**
  65167. * 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
  65168. * @param axis1 defines the first axis
  65169. * @param axis2 defines the second axis
  65170. * @param axis3 defines the third axis
  65171. * @param ref defines the target quaternion
  65172. */
  65173. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  65174. /**
  65175. * Interpolates between two quaternions
  65176. * @param left defines first quaternion
  65177. * @param right defines second quaternion
  65178. * @param amount defines the gradient to use
  65179. * @returns the new interpolated quaternion
  65180. */
  65181. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65182. /**
  65183. * Interpolates between two quaternions and stores it into a target quaternion
  65184. * @param left defines first quaternion
  65185. * @param right defines second quaternion
  65186. * @param amount defines the gradient to use
  65187. * @param result defines the target quaternion
  65188. */
  65189. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  65190. /**
  65191. * Interpolate between two quaternions using Hermite interpolation
  65192. * @param value1 defines first quaternion
  65193. * @param tangent1 defines the incoming tangent
  65194. * @param value2 defines second quaternion
  65195. * @param tangent2 defines the outgoing tangent
  65196. * @param amount defines the target quaternion
  65197. * @returns the new interpolated quaternion
  65198. */
  65199. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65200. }
  65201. /**
  65202. * Class used to store matrix data (4x4)
  65203. */
  65204. export class Matrix {
  65205. private static _updateFlagSeed;
  65206. private static _identityReadOnly;
  65207. private _isIdentity;
  65208. private _isIdentityDirty;
  65209. private _isIdentity3x2;
  65210. private _isIdentity3x2Dirty;
  65211. /**
  65212. * Gets the update flag of the matrix which is an unique number for the matrix.
  65213. * It will be incremented every time the matrix data change.
  65214. * You can use it to speed the comparison between two versions of the same matrix.
  65215. */
  65216. updateFlag: number;
  65217. private readonly _m;
  65218. /**
  65219. * Gets the internal data of the matrix
  65220. */
  65221. readonly m: DeepImmutable<Float32Array>;
  65222. /** @hidden */
  65223. _markAsUpdated(): void;
  65224. /** @hidden */
  65225. private _updateIdentityStatus;
  65226. /**
  65227. * Creates an empty matrix (filled with zeros)
  65228. */
  65229. constructor();
  65230. /**
  65231. * Check if the current matrix is identity
  65232. * @returns true is the matrix is the identity matrix
  65233. */
  65234. isIdentity(): boolean;
  65235. /**
  65236. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  65237. * @returns true is the matrix is the identity matrix
  65238. */
  65239. isIdentityAs3x2(): boolean;
  65240. /**
  65241. * Gets the determinant of the matrix
  65242. * @returns the matrix determinant
  65243. */
  65244. determinant(): number;
  65245. /**
  65246. * Returns the matrix as a Float32Array
  65247. * @returns the matrix underlying array
  65248. */
  65249. toArray(): DeepImmutable<Float32Array>;
  65250. /**
  65251. * Returns the matrix as a Float32Array
  65252. * @returns the matrix underlying array.
  65253. */
  65254. asArray(): DeepImmutable<Float32Array>;
  65255. /**
  65256. * Inverts the current matrix in place
  65257. * @returns the current inverted matrix
  65258. */
  65259. invert(): Matrix;
  65260. /**
  65261. * Sets all the matrix elements to zero
  65262. * @returns the current matrix
  65263. */
  65264. reset(): Matrix;
  65265. /**
  65266. * Adds the current matrix with a second one
  65267. * @param other defines the matrix to add
  65268. * @returns a new matrix as the addition of the current matrix and the given one
  65269. */
  65270. add(other: DeepImmutable<Matrix>): Matrix;
  65271. /**
  65272. * Sets the given matrix "result" to the addition of the current matrix and the given one
  65273. * @param other defines the matrix to add
  65274. * @param result defines the target matrix
  65275. * @returns the current matrix
  65276. */
  65277. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65278. /**
  65279. * Adds in place the given matrix to the current matrix
  65280. * @param other defines the second operand
  65281. * @returns the current updated matrix
  65282. */
  65283. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  65284. /**
  65285. * Sets the given matrix to the current inverted Matrix
  65286. * @param other defines the target matrix
  65287. * @returns the unmodified current matrix
  65288. */
  65289. invertToRef(other: Matrix): Matrix;
  65290. /**
  65291. * add a value at the specified position in the current Matrix
  65292. * @param index the index of the value within the matrix. between 0 and 15.
  65293. * @param value the value to be added
  65294. * @returns the current updated matrix
  65295. */
  65296. addAtIndex(index: number, value: number): Matrix;
  65297. /**
  65298. * mutiply the specified position in the current Matrix by a value
  65299. * @param index the index of the value within the matrix. between 0 and 15.
  65300. * @param value the value to be added
  65301. * @returns the current updated matrix
  65302. */
  65303. multiplyAtIndex(index: number, value: number): Matrix;
  65304. /**
  65305. * Inserts the translation vector (using 3 floats) in the current matrix
  65306. * @param x defines the 1st component of the translation
  65307. * @param y defines the 2nd component of the translation
  65308. * @param z defines the 3rd component of the translation
  65309. * @returns the current updated matrix
  65310. */
  65311. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65312. /**
  65313. * Adds the translation vector (using 3 floats) in the current matrix
  65314. * @param x defines the 1st component of the translation
  65315. * @param y defines the 2nd component of the translation
  65316. * @param z defines the 3rd component of the translation
  65317. * @returns the current updated matrix
  65318. */
  65319. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65320. /**
  65321. * Inserts the translation vector in the current matrix
  65322. * @param vector3 defines the translation to insert
  65323. * @returns the current updated matrix
  65324. */
  65325. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  65326. /**
  65327. * Gets the translation value of the current matrix
  65328. * @returns a new Vector3 as the extracted translation from the matrix
  65329. */
  65330. getTranslation(): Vector3;
  65331. /**
  65332. * Fill a Vector3 with the extracted translation from the matrix
  65333. * @param result defines the Vector3 where to store the translation
  65334. * @returns the current matrix
  65335. */
  65336. getTranslationToRef(result: Vector3): Matrix;
  65337. /**
  65338. * Remove rotation and scaling part from the matrix
  65339. * @returns the updated matrix
  65340. */
  65341. removeRotationAndScaling(): Matrix;
  65342. /**
  65343. * Multiply two matrices
  65344. * @param other defines the second operand
  65345. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  65346. */
  65347. multiply(other: DeepImmutable<Matrix>): Matrix;
  65348. /**
  65349. * Copy the current matrix from the given one
  65350. * @param other defines the source matrix
  65351. * @returns the current updated matrix
  65352. */
  65353. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  65354. /**
  65355. * Populates the given array from the starting index with the current matrix values
  65356. * @param array defines the target array
  65357. * @param offset defines the offset in the target array where to start storing values
  65358. * @returns the current matrix
  65359. */
  65360. copyToArray(array: Float32Array, offset?: number): Matrix;
  65361. /**
  65362. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  65363. * @param other defines the second operand
  65364. * @param result defines the matrix where to store the multiplication
  65365. * @returns the current matrix
  65366. */
  65367. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65368. /**
  65369. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  65370. * @param other defines the second operand
  65371. * @param result defines the array where to store the multiplication
  65372. * @param offset defines the offset in the target array where to start storing values
  65373. * @returns the current matrix
  65374. */
  65375. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  65376. /**
  65377. * Check equality between this matrix and a second one
  65378. * @param value defines the second matrix to compare
  65379. * @returns true is the current matrix and the given one values are strictly equal
  65380. */
  65381. equals(value: DeepImmutable<Matrix>): boolean;
  65382. /**
  65383. * Clone the current matrix
  65384. * @returns a new matrix from the current matrix
  65385. */
  65386. clone(): Matrix;
  65387. /**
  65388. * Returns the name of the current matrix class
  65389. * @returns the string "Matrix"
  65390. */
  65391. getClassName(): string;
  65392. /**
  65393. * Gets the hash code of the current matrix
  65394. * @returns the hash code
  65395. */
  65396. getHashCode(): number;
  65397. /**
  65398. * Decomposes the current Matrix into a translation, rotation and scaling components
  65399. * @param scale defines the scale vector3 given as a reference to update
  65400. * @param rotation defines the rotation quaternion given as a reference to update
  65401. * @param translation defines the translation vector3 given as a reference to update
  65402. * @returns true if operation was successful
  65403. */
  65404. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  65405. /**
  65406. * Gets specific row of the matrix
  65407. * @param index defines the number of the row to get
  65408. * @returns the index-th row of the current matrix as a new Vector4
  65409. */
  65410. getRow(index: number): Nullable<Vector4>;
  65411. /**
  65412. * Sets the index-th row of the current matrix to the vector4 values
  65413. * @param index defines the number of the row to set
  65414. * @param row defines the target vector4
  65415. * @returns the updated current matrix
  65416. */
  65417. setRow(index: number, row: Vector4): Matrix;
  65418. /**
  65419. * Compute the transpose of the matrix
  65420. * @returns the new transposed matrix
  65421. */
  65422. transpose(): Matrix;
  65423. /**
  65424. * Compute the transpose of the matrix and store it in a given matrix
  65425. * @param result defines the target matrix
  65426. * @returns the current matrix
  65427. */
  65428. transposeToRef(result: Matrix): Matrix;
  65429. /**
  65430. * Sets the index-th row of the current matrix with the given 4 x float values
  65431. * @param index defines the row index
  65432. * @param x defines the x component to set
  65433. * @param y defines the y component to set
  65434. * @param z defines the z component to set
  65435. * @param w defines the w component to set
  65436. * @returns the updated current matrix
  65437. */
  65438. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  65439. /**
  65440. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  65441. * @param scale defines the scale factor
  65442. * @returns a new matrix
  65443. */
  65444. scale(scale: number): Matrix;
  65445. /**
  65446. * Scale the current matrix values by a factor to a given result matrix
  65447. * @param scale defines the scale factor
  65448. * @param result defines the matrix to store the result
  65449. * @returns the current matrix
  65450. */
  65451. scaleToRef(scale: number, result: Matrix): Matrix;
  65452. /**
  65453. * Scale the current matrix values by a factor and add the result to a given matrix
  65454. * @param scale defines the scale factor
  65455. * @param result defines the Matrix to store the result
  65456. * @returns the current matrix
  65457. */
  65458. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  65459. /**
  65460. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  65461. * @param ref matrix to store the result
  65462. */
  65463. toNormalMatrix(ref: Matrix): void;
  65464. /**
  65465. * Gets only rotation part of the current matrix
  65466. * @returns a new matrix sets to the extracted rotation matrix from the current one
  65467. */
  65468. getRotationMatrix(): Matrix;
  65469. /**
  65470. * Extracts the rotation matrix from the current one and sets it as the given "result"
  65471. * @param result defines the target matrix to store data to
  65472. * @returns the current matrix
  65473. */
  65474. getRotationMatrixToRef(result: Matrix): Matrix;
  65475. /**
  65476. * Toggles model matrix from being right handed to left handed in place and vice versa
  65477. */
  65478. toggleModelMatrixHandInPlace(): void;
  65479. /**
  65480. * Toggles projection matrix from being right handed to left handed in place and vice versa
  65481. */
  65482. toggleProjectionMatrixHandInPlace(): void;
  65483. /**
  65484. * Creates a matrix from an array
  65485. * @param array defines the source array
  65486. * @param offset defines an offset in the source array
  65487. * @returns a new Matrix set from the starting index of the given array
  65488. */
  65489. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  65490. /**
  65491. * Copy the content of an array into a given matrix
  65492. * @param array defines the source array
  65493. * @param offset defines an offset in the source array
  65494. * @param result defines the target matrix
  65495. */
  65496. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  65497. /**
  65498. * Stores an array into a matrix after having multiplied each component by a given factor
  65499. * @param array defines the source array
  65500. * @param offset defines the offset in the source array
  65501. * @param scale defines the scaling factor
  65502. * @param result defines the target matrix
  65503. */
  65504. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  65505. /**
  65506. * Gets an identity matrix that must not be updated
  65507. */
  65508. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  65509. /**
  65510. * Stores a list of values (16) inside a given matrix
  65511. * @param initialM11 defines 1st value of 1st row
  65512. * @param initialM12 defines 2nd value of 1st row
  65513. * @param initialM13 defines 3rd value of 1st row
  65514. * @param initialM14 defines 4th value of 1st row
  65515. * @param initialM21 defines 1st value of 2nd row
  65516. * @param initialM22 defines 2nd value of 2nd row
  65517. * @param initialM23 defines 3rd value of 2nd row
  65518. * @param initialM24 defines 4th value of 2nd row
  65519. * @param initialM31 defines 1st value of 3rd row
  65520. * @param initialM32 defines 2nd value of 3rd row
  65521. * @param initialM33 defines 3rd value of 3rd row
  65522. * @param initialM34 defines 4th value of 3rd row
  65523. * @param initialM41 defines 1st value of 4th row
  65524. * @param initialM42 defines 2nd value of 4th row
  65525. * @param initialM43 defines 3rd value of 4th row
  65526. * @param initialM44 defines 4th value of 4th row
  65527. * @param result defines the target matrix
  65528. */
  65529. 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;
  65530. /**
  65531. * Creates new matrix from a list of values (16)
  65532. * @param initialM11 defines 1st value of 1st row
  65533. * @param initialM12 defines 2nd value of 1st row
  65534. * @param initialM13 defines 3rd value of 1st row
  65535. * @param initialM14 defines 4th value of 1st row
  65536. * @param initialM21 defines 1st value of 2nd row
  65537. * @param initialM22 defines 2nd value of 2nd row
  65538. * @param initialM23 defines 3rd value of 2nd row
  65539. * @param initialM24 defines 4th value of 2nd row
  65540. * @param initialM31 defines 1st value of 3rd row
  65541. * @param initialM32 defines 2nd value of 3rd row
  65542. * @param initialM33 defines 3rd value of 3rd row
  65543. * @param initialM34 defines 4th value of 3rd row
  65544. * @param initialM41 defines 1st value of 4th row
  65545. * @param initialM42 defines 2nd value of 4th row
  65546. * @param initialM43 defines 3rd value of 4th row
  65547. * @param initialM44 defines 4th value of 4th row
  65548. * @returns the new matrix
  65549. */
  65550. 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;
  65551. /**
  65552. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65553. * @param scale defines the scale vector3
  65554. * @param rotation defines the rotation quaternion
  65555. * @param translation defines the translation vector3
  65556. * @returns a new matrix
  65557. */
  65558. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  65559. /**
  65560. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65561. * @param scale defines the scale vector3
  65562. * @param rotation defines the rotation quaternion
  65563. * @param translation defines the translation vector3
  65564. * @param result defines the target matrix
  65565. */
  65566. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  65567. /**
  65568. * Creates a new identity matrix
  65569. * @returns a new identity matrix
  65570. */
  65571. static Identity(): Matrix;
  65572. /**
  65573. * Creates a new identity matrix and stores the result in a given matrix
  65574. * @param result defines the target matrix
  65575. */
  65576. static IdentityToRef(result: Matrix): void;
  65577. /**
  65578. * Creates a new zero matrix
  65579. * @returns a new zero matrix
  65580. */
  65581. static Zero(): Matrix;
  65582. /**
  65583. * Creates a new rotation matrix for "angle" radians around the X axis
  65584. * @param angle defines the angle (in radians) to use
  65585. * @return the new matrix
  65586. */
  65587. static RotationX(angle: number): Matrix;
  65588. /**
  65589. * Creates a new matrix as the invert of a given matrix
  65590. * @param source defines the source matrix
  65591. * @returns the new matrix
  65592. */
  65593. static Invert(source: DeepImmutable<Matrix>): Matrix;
  65594. /**
  65595. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  65596. * @param angle defines the angle (in radians) to use
  65597. * @param result defines the target matrix
  65598. */
  65599. static RotationXToRef(angle: number, result: Matrix): void;
  65600. /**
  65601. * Creates a new rotation matrix for "angle" radians around the Y axis
  65602. * @param angle defines the angle (in radians) to use
  65603. * @return the new matrix
  65604. */
  65605. static RotationY(angle: number): Matrix;
  65606. /**
  65607. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  65608. * @param angle defines the angle (in radians) to use
  65609. * @param result defines the target matrix
  65610. */
  65611. static RotationYToRef(angle: number, result: Matrix): void;
  65612. /**
  65613. * Creates a new rotation matrix for "angle" radians around the Z axis
  65614. * @param angle defines the angle (in radians) to use
  65615. * @return the new matrix
  65616. */
  65617. static RotationZ(angle: number): Matrix;
  65618. /**
  65619. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  65620. * @param angle defines the angle (in radians) to use
  65621. * @param result defines the target matrix
  65622. */
  65623. static RotationZToRef(angle: number, result: Matrix): void;
  65624. /**
  65625. * Creates a new rotation matrix for "angle" radians around the given axis
  65626. * @param axis defines the axis to use
  65627. * @param angle defines the angle (in radians) to use
  65628. * @return the new matrix
  65629. */
  65630. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  65631. /**
  65632. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  65633. * @param axis defines the axis to use
  65634. * @param angle defines the angle (in radians) to use
  65635. * @param result defines the target matrix
  65636. */
  65637. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  65638. /**
  65639. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  65640. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  65641. * @param from defines the vector to align
  65642. * @param to defines the vector to align to
  65643. * @param result defines the target matrix
  65644. */
  65645. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  65646. /**
  65647. * Creates a rotation matrix
  65648. * @param yaw defines the yaw angle in radians (Y axis)
  65649. * @param pitch defines the pitch angle in radians (X axis)
  65650. * @param roll defines the roll angle in radians (X axis)
  65651. * @returns the new rotation matrix
  65652. */
  65653. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  65654. /**
  65655. * Creates a rotation matrix and stores it in a given matrix
  65656. * @param yaw defines the yaw angle in radians (Y axis)
  65657. * @param pitch defines the pitch angle in radians (X axis)
  65658. * @param roll defines the roll angle in radians (X axis)
  65659. * @param result defines the target matrix
  65660. */
  65661. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  65662. /**
  65663. * Creates a scaling matrix
  65664. * @param x defines the scale factor on X axis
  65665. * @param y defines the scale factor on Y axis
  65666. * @param z defines the scale factor on Z axis
  65667. * @returns the new matrix
  65668. */
  65669. static Scaling(x: number, y: number, z: number): Matrix;
  65670. /**
  65671. * Creates a scaling matrix and stores it in a given matrix
  65672. * @param x defines the scale factor on X axis
  65673. * @param y defines the scale factor on Y axis
  65674. * @param z defines the scale factor on Z axis
  65675. * @param result defines the target matrix
  65676. */
  65677. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  65678. /**
  65679. * Creates a translation matrix
  65680. * @param x defines the translation on X axis
  65681. * @param y defines the translation on Y axis
  65682. * @param z defines the translationon Z axis
  65683. * @returns the new matrix
  65684. */
  65685. static Translation(x: number, y: number, z: number): Matrix;
  65686. /**
  65687. * Creates a translation matrix and stores it in a given matrix
  65688. * @param x defines the translation on X axis
  65689. * @param y defines the translation on Y axis
  65690. * @param z defines the translationon Z axis
  65691. * @param result defines the target matrix
  65692. */
  65693. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  65694. /**
  65695. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65696. * @param startValue defines the start value
  65697. * @param endValue defines the end value
  65698. * @param gradient defines the gradient factor
  65699. * @returns the new matrix
  65700. */
  65701. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65702. /**
  65703. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65704. * @param startValue defines the start value
  65705. * @param endValue defines the end value
  65706. * @param gradient defines the gradient factor
  65707. * @param result defines the Matrix object where to store data
  65708. */
  65709. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65710. /**
  65711. * Builds a new matrix whose values are computed by:
  65712. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65713. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65714. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65715. * @param startValue defines the first matrix
  65716. * @param endValue defines the second matrix
  65717. * @param gradient defines the gradient between the two matrices
  65718. * @returns the new matrix
  65719. */
  65720. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65721. /**
  65722. * Update a matrix to values which are computed by:
  65723. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65724. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65725. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65726. * @param startValue defines the first matrix
  65727. * @param endValue defines the second matrix
  65728. * @param gradient defines the gradient between the two matrices
  65729. * @param result defines the target matrix
  65730. */
  65731. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65732. /**
  65733. * 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"
  65734. * This function works in left handed mode
  65735. * @param eye defines the final position of the entity
  65736. * @param target defines where the entity should look at
  65737. * @param up defines the up vector for the entity
  65738. * @returns the new matrix
  65739. */
  65740. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  65741. /**
  65742. * 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".
  65743. * This function works in left handed mode
  65744. * @param eye defines the final position of the entity
  65745. * @param target defines where the entity should look at
  65746. * @param up defines the up vector for the entity
  65747. * @param result defines the target matrix
  65748. */
  65749. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  65750. /**
  65751. * 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"
  65752. * This function works in right handed mode
  65753. * @param eye defines the final position of the entity
  65754. * @param target defines where the entity should look at
  65755. * @param up defines the up vector for the entity
  65756. * @returns the new matrix
  65757. */
  65758. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  65759. /**
  65760. * 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".
  65761. * This function works in right handed mode
  65762. * @param eye defines the final position of the entity
  65763. * @param target defines where the entity should look at
  65764. * @param up defines the up vector for the entity
  65765. * @param result defines the target matrix
  65766. */
  65767. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  65768. /**
  65769. * Create a left-handed orthographic projection matrix
  65770. * @param width defines the viewport width
  65771. * @param height defines the viewport height
  65772. * @param znear defines the near clip plane
  65773. * @param zfar defines the far clip plane
  65774. * @returns a new matrix as a left-handed orthographic projection matrix
  65775. */
  65776. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  65777. /**
  65778. * Store a left-handed orthographic projection to a given matrix
  65779. * @param width defines the viewport width
  65780. * @param height defines the viewport height
  65781. * @param znear defines the near clip plane
  65782. * @param zfar defines the far clip plane
  65783. * @param result defines the target matrix
  65784. */
  65785. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  65786. /**
  65787. * Create a left-handed orthographic projection matrix
  65788. * @param left defines the viewport left coordinate
  65789. * @param right defines the viewport right coordinate
  65790. * @param bottom defines the viewport bottom coordinate
  65791. * @param top defines the viewport top coordinate
  65792. * @param znear defines the near clip plane
  65793. * @param zfar defines the far clip plane
  65794. * @returns a new matrix as a left-handed orthographic projection matrix
  65795. */
  65796. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  65797. /**
  65798. * Stores a left-handed orthographic projection into a given matrix
  65799. * @param left defines the viewport left coordinate
  65800. * @param right defines the viewport right coordinate
  65801. * @param bottom defines the viewport bottom coordinate
  65802. * @param top defines the viewport top coordinate
  65803. * @param znear defines the near clip plane
  65804. * @param zfar defines the far clip plane
  65805. * @param result defines the target matrix
  65806. */
  65807. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  65808. /**
  65809. * Creates a right-handed orthographic projection matrix
  65810. * @param left defines the viewport left coordinate
  65811. * @param right defines the viewport right coordinate
  65812. * @param bottom defines the viewport bottom coordinate
  65813. * @param top defines the viewport top coordinate
  65814. * @param znear defines the near clip plane
  65815. * @param zfar defines the far clip plane
  65816. * @returns a new matrix as a right-handed orthographic projection matrix
  65817. */
  65818. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  65819. /**
  65820. * Stores a right-handed orthographic projection into a given matrix
  65821. * @param left defines the viewport left coordinate
  65822. * @param right defines the viewport right coordinate
  65823. * @param bottom defines the viewport bottom coordinate
  65824. * @param top defines the viewport top coordinate
  65825. * @param znear defines the near clip plane
  65826. * @param zfar defines the far clip plane
  65827. * @param result defines the target matrix
  65828. */
  65829. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  65830. /**
  65831. * Creates a left-handed perspective projection matrix
  65832. * @param width defines the viewport width
  65833. * @param height defines the viewport height
  65834. * @param znear defines the near clip plane
  65835. * @param zfar defines the far clip plane
  65836. * @returns a new matrix as a left-handed perspective projection matrix
  65837. */
  65838. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  65839. /**
  65840. * Creates a left-handed perspective projection matrix
  65841. * @param fov defines the horizontal field of view
  65842. * @param aspect defines the aspect ratio
  65843. * @param znear defines the near clip plane
  65844. * @param zfar defines the far clip plane
  65845. * @returns a new matrix as a left-handed perspective projection matrix
  65846. */
  65847. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  65848. /**
  65849. * Stores a left-handed perspective projection into a given matrix
  65850. * @param fov defines the horizontal field of view
  65851. * @param aspect defines the aspect ratio
  65852. * @param znear defines the near clip plane
  65853. * @param zfar defines the far clip plane
  65854. * @param result defines the target matrix
  65855. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  65856. */
  65857. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  65858. /**
  65859. * Creates a right-handed perspective projection matrix
  65860. * @param fov defines the horizontal field of view
  65861. * @param aspect defines the aspect ratio
  65862. * @param znear defines the near clip plane
  65863. * @param zfar defines the far clip plane
  65864. * @returns a new matrix as a right-handed perspective projection matrix
  65865. */
  65866. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  65867. /**
  65868. * Stores a right-handed perspective projection into a given matrix
  65869. * @param fov defines the horizontal field of view
  65870. * @param aspect defines the aspect ratio
  65871. * @param znear defines the near clip plane
  65872. * @param zfar defines the far clip plane
  65873. * @param result defines the target matrix
  65874. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  65875. */
  65876. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  65877. /**
  65878. * Stores a perspective projection for WebVR info a given matrix
  65879. * @param fov defines the field of view
  65880. * @param znear defines the near clip plane
  65881. * @param zfar defines the far clip plane
  65882. * @param result defines the target matrix
  65883. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  65884. */
  65885. static PerspectiveFovWebVRToRef(fov: {
  65886. upDegrees: number;
  65887. downDegrees: number;
  65888. leftDegrees: number;
  65889. rightDegrees: number;
  65890. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  65891. /**
  65892. * Computes a complete transformation matrix
  65893. * @param viewport defines the viewport to use
  65894. * @param world defines the world matrix
  65895. * @param view defines the view matrix
  65896. * @param projection defines the projection matrix
  65897. * @param zmin defines the near clip plane
  65898. * @param zmax defines the far clip plane
  65899. * @returns the transformation matrix
  65900. */
  65901. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  65902. /**
  65903. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  65904. * @param matrix defines the matrix to use
  65905. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  65906. */
  65907. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  65908. /**
  65909. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  65910. * @param matrix defines the matrix to use
  65911. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  65912. */
  65913. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  65914. /**
  65915. * Compute the transpose of a given matrix
  65916. * @param matrix defines the matrix to transpose
  65917. * @returns the new matrix
  65918. */
  65919. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  65920. /**
  65921. * Compute the transpose of a matrix and store it in a target matrix
  65922. * @param matrix defines the matrix to transpose
  65923. * @param result defines the target matrix
  65924. */
  65925. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  65926. /**
  65927. * Computes a reflection matrix from a plane
  65928. * @param plane defines the reflection plane
  65929. * @returns a new matrix
  65930. */
  65931. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  65932. /**
  65933. * Computes a reflection matrix from a plane
  65934. * @param plane defines the reflection plane
  65935. * @param result defines the target matrix
  65936. */
  65937. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  65938. /**
  65939. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  65940. * @param xaxis defines the value of the 1st axis
  65941. * @param yaxis defines the value of the 2nd axis
  65942. * @param zaxis defines the value of the 3rd axis
  65943. * @param result defines the target matrix
  65944. */
  65945. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  65946. /**
  65947. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  65948. * @param quat defines the quaternion to use
  65949. * @param result defines the target matrix
  65950. */
  65951. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  65952. }
  65953. /**
  65954. * Represens a plane by the equation ax + by + cz + d = 0
  65955. */
  65956. export class Plane {
  65957. /**
  65958. * Normal of the plane (a,b,c)
  65959. */
  65960. normal: Vector3;
  65961. /**
  65962. * d component of the plane
  65963. */
  65964. d: number;
  65965. /**
  65966. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  65967. * @param a a component of the plane
  65968. * @param b b component of the plane
  65969. * @param c c component of the plane
  65970. * @param d d component of the plane
  65971. */
  65972. constructor(a: number, b: number, c: number, d: number);
  65973. /**
  65974. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  65975. */
  65976. asArray(): number[];
  65977. /**
  65978. * @returns a new plane copied from the current Plane.
  65979. */
  65980. clone(): Plane;
  65981. /**
  65982. * @returns the string "Plane".
  65983. */
  65984. getClassName(): string;
  65985. /**
  65986. * @returns the Plane hash code.
  65987. */
  65988. getHashCode(): number;
  65989. /**
  65990. * Normalize the current Plane in place.
  65991. * @returns the updated Plane.
  65992. */
  65993. normalize(): Plane;
  65994. /**
  65995. * Applies a transformation the plane and returns the result
  65996. * @param transformation the transformation matrix to be applied to the plane
  65997. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  65998. */
  65999. transform(transformation: DeepImmutable<Matrix>): Plane;
  66000. /**
  66001. * Calcualtte the dot product between the point and the plane normal
  66002. * @param point point to calculate the dot product with
  66003. * @returns the dot product (float) of the point coordinates and the plane normal.
  66004. */
  66005. dotCoordinate(point: DeepImmutable<Vector3>): number;
  66006. /**
  66007. * Updates the current Plane from the plane defined by the three given points.
  66008. * @param point1 one of the points used to contruct the plane
  66009. * @param point2 one of the points used to contruct the plane
  66010. * @param point3 one of the points used to contruct the plane
  66011. * @returns the updated Plane.
  66012. */
  66013. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66014. /**
  66015. * Checks if the plane is facing a given direction
  66016. * @param direction the direction to check if the plane is facing
  66017. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  66018. * @returns True is the vector "direction" is the same side than the plane normal.
  66019. */
  66020. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  66021. /**
  66022. * Calculates the distance to a point
  66023. * @param point point to calculate distance to
  66024. * @returns the signed distance (float) from the given point to the Plane.
  66025. */
  66026. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  66027. /**
  66028. * Creates a plane from an array
  66029. * @param array the array to create a plane from
  66030. * @returns a new Plane from the given array.
  66031. */
  66032. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  66033. /**
  66034. * Creates a plane from three points
  66035. * @param point1 point used to create the plane
  66036. * @param point2 point used to create the plane
  66037. * @param point3 point used to create the plane
  66038. * @returns a new Plane defined by the three given points.
  66039. */
  66040. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66041. /**
  66042. * Creates a plane from an origin point and a normal
  66043. * @param origin origin of the plane to be constructed
  66044. * @param normal normal of the plane to be constructed
  66045. * @returns a new Plane the normal vector to this plane at the given origin point.
  66046. * Note : the vector "normal" is updated because normalized.
  66047. */
  66048. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  66049. /**
  66050. * Calculates the distance from a plane and a point
  66051. * @param origin origin of the plane to be constructed
  66052. * @param normal normal of the plane to be constructed
  66053. * @param point point to calculate distance to
  66054. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  66055. */
  66056. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  66057. }
  66058. /**
  66059. * Class used to represent a viewport on screen
  66060. */
  66061. export class Viewport {
  66062. /** viewport left coordinate */
  66063. x: number;
  66064. /** viewport top coordinate */
  66065. y: number;
  66066. /**viewport width */
  66067. width: number;
  66068. /** viewport height */
  66069. height: number;
  66070. /**
  66071. * Creates a Viewport object located at (x, y) and sized (width, height)
  66072. * @param x defines viewport left coordinate
  66073. * @param y defines viewport top coordinate
  66074. * @param width defines the viewport width
  66075. * @param height defines the viewport height
  66076. */
  66077. constructor(
  66078. /** viewport left coordinate */
  66079. x: number,
  66080. /** viewport top coordinate */
  66081. y: number,
  66082. /**viewport width */
  66083. width: number,
  66084. /** viewport height */
  66085. height: number);
  66086. /**
  66087. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66088. * @param renderWidth defines the rendering width
  66089. * @param renderHeight defines the rendering height
  66090. * @returns a new Viewport
  66091. */
  66092. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66093. /**
  66094. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66095. * @param renderWidth defines the rendering width
  66096. * @param renderHeight defines the rendering height
  66097. * @param ref defines the target viewport
  66098. * @returns the current viewport
  66099. */
  66100. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66101. /**
  66102. * Returns a new Viewport copied from the current one
  66103. * @returns a new Viewport
  66104. */
  66105. clone(): Viewport;
  66106. }
  66107. /**
  66108. * Reprasents a camera frustum
  66109. */
  66110. export class Frustum {
  66111. /**
  66112. * Gets the planes representing the frustum
  66113. * @param transform matrix to be applied to the returned planes
  66114. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  66115. */
  66116. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  66117. /**
  66118. * Gets the near frustum plane transformed by the transform matrix
  66119. * @param transform transformation matrix to be applied to the resulting frustum plane
  66120. * @param frustumPlane the resuling frustum plane
  66121. */
  66122. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66123. /**
  66124. * Gets the far frustum plane transformed by the transform matrix
  66125. * @param transform transformation matrix to be applied to the resulting frustum plane
  66126. * @param frustumPlane the resuling frustum plane
  66127. */
  66128. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66129. /**
  66130. * Gets the left frustum plane transformed by the transform matrix
  66131. * @param transform transformation matrix to be applied to the resulting frustum plane
  66132. * @param frustumPlane the resuling frustum plane
  66133. */
  66134. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66135. /**
  66136. * Gets the right frustum plane transformed by the transform matrix
  66137. * @param transform transformation matrix to be applied to the resulting frustum plane
  66138. * @param frustumPlane the resuling frustum plane
  66139. */
  66140. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66141. /**
  66142. * Gets the top frustum plane transformed by the transform matrix
  66143. * @param transform transformation matrix to be applied to the resulting frustum plane
  66144. * @param frustumPlane the resuling frustum plane
  66145. */
  66146. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66147. /**
  66148. * Gets the bottom frustum plane transformed by the transform matrix
  66149. * @param transform transformation matrix to be applied to the resulting frustum plane
  66150. * @param frustumPlane the resuling frustum plane
  66151. */
  66152. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66153. /**
  66154. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  66155. * @param transform transformation matrix to be applied to the resulting frustum planes
  66156. * @param frustumPlanes the resuling frustum planes
  66157. */
  66158. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  66159. }
  66160. /** Defines supported spaces */
  66161. export enum Space {
  66162. /** Local (object) space */
  66163. LOCAL = 0,
  66164. /** World space */
  66165. WORLD = 1,
  66166. /** Bone space */
  66167. BONE = 2
  66168. }
  66169. /** Defines the 3 main axes */
  66170. export class Axis {
  66171. /** X axis */
  66172. static X: Vector3;
  66173. /** Y axis */
  66174. static Y: Vector3;
  66175. /** Z axis */
  66176. static Z: Vector3;
  66177. }
  66178. /** Class used to represent a Bezier curve */
  66179. export class BezierCurve {
  66180. /**
  66181. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  66182. * @param t defines the time
  66183. * @param x1 defines the left coordinate on X axis
  66184. * @param y1 defines the left coordinate on Y axis
  66185. * @param x2 defines the right coordinate on X axis
  66186. * @param y2 defines the right coordinate on Y axis
  66187. * @returns the interpolated value
  66188. */
  66189. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  66190. }
  66191. /**
  66192. * Defines potential orientation for back face culling
  66193. */
  66194. export enum Orientation {
  66195. /**
  66196. * Clockwise
  66197. */
  66198. CW = 0,
  66199. /** Counter clockwise */
  66200. CCW = 1
  66201. }
  66202. /**
  66203. * Defines angle representation
  66204. */
  66205. export class Angle {
  66206. private _radians;
  66207. /**
  66208. * Creates an Angle object of "radians" radians (float).
  66209. * @param radians the angle in radians
  66210. */
  66211. constructor(radians: number);
  66212. /**
  66213. * Get value in degrees
  66214. * @returns the Angle value in degrees (float)
  66215. */
  66216. degrees(): number;
  66217. /**
  66218. * Get value in radians
  66219. * @returns the Angle value in radians (float)
  66220. */
  66221. radians(): number;
  66222. /**
  66223. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  66224. * @param a defines first vector
  66225. * @param b defines second vector
  66226. * @returns a new Angle
  66227. */
  66228. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  66229. /**
  66230. * Gets a new Angle object from the given float in radians
  66231. * @param radians defines the angle value in radians
  66232. * @returns a new Angle
  66233. */
  66234. static FromRadians(radians: number): Angle;
  66235. /**
  66236. * Gets a new Angle object from the given float in degrees
  66237. * @param degrees defines the angle value in degrees
  66238. * @returns a new Angle
  66239. */
  66240. static FromDegrees(degrees: number): Angle;
  66241. }
  66242. /**
  66243. * This represents an arc in a 2d space.
  66244. */
  66245. export class Arc2 {
  66246. /** Defines the start point of the arc */
  66247. startPoint: Vector2;
  66248. /** Defines the mid point of the arc */
  66249. midPoint: Vector2;
  66250. /** Defines the end point of the arc */
  66251. endPoint: Vector2;
  66252. /**
  66253. * Defines the center point of the arc.
  66254. */
  66255. centerPoint: Vector2;
  66256. /**
  66257. * Defines the radius of the arc.
  66258. */
  66259. radius: number;
  66260. /**
  66261. * Defines the angle of the arc (from mid point to end point).
  66262. */
  66263. angle: Angle;
  66264. /**
  66265. * Defines the start angle of the arc (from start point to middle point).
  66266. */
  66267. startAngle: Angle;
  66268. /**
  66269. * Defines the orientation of the arc (clock wise/counter clock wise).
  66270. */
  66271. orientation: Orientation;
  66272. /**
  66273. * Creates an Arc object from the three given points : start, middle and end.
  66274. * @param startPoint Defines the start point of the arc
  66275. * @param midPoint Defines the midlle point of the arc
  66276. * @param endPoint Defines the end point of the arc
  66277. */
  66278. constructor(
  66279. /** Defines the start point of the arc */
  66280. startPoint: Vector2,
  66281. /** Defines the mid point of the arc */
  66282. midPoint: Vector2,
  66283. /** Defines the end point of the arc */
  66284. endPoint: Vector2);
  66285. }
  66286. /**
  66287. * Represents a 2D path made up of multiple 2D points
  66288. */
  66289. export class Path2 {
  66290. private _points;
  66291. private _length;
  66292. /**
  66293. * If the path start and end point are the same
  66294. */
  66295. closed: boolean;
  66296. /**
  66297. * Creates a Path2 object from the starting 2D coordinates x and y.
  66298. * @param x the starting points x value
  66299. * @param y the starting points y value
  66300. */
  66301. constructor(x: number, y: number);
  66302. /**
  66303. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  66304. * @param x the added points x value
  66305. * @param y the added points y value
  66306. * @returns the updated Path2.
  66307. */
  66308. addLineTo(x: number, y: number): Path2;
  66309. /**
  66310. * 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.
  66311. * @param midX middle point x value
  66312. * @param midY middle point y value
  66313. * @param endX end point x value
  66314. * @param endY end point y value
  66315. * @param numberOfSegments (default: 36)
  66316. * @returns the updated Path2.
  66317. */
  66318. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  66319. /**
  66320. * Closes the Path2.
  66321. * @returns the Path2.
  66322. */
  66323. close(): Path2;
  66324. /**
  66325. * Gets the sum of the distance between each sequential point in the path
  66326. * @returns the Path2 total length (float).
  66327. */
  66328. length(): number;
  66329. /**
  66330. * Gets the points which construct the path
  66331. * @returns the Path2 internal array of points.
  66332. */
  66333. getPoints(): Vector2[];
  66334. /**
  66335. * Retreives the point at the distance aways from the starting point
  66336. * @param normalizedLengthPosition the length along the path to retreive the point from
  66337. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  66338. */
  66339. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  66340. /**
  66341. * Creates a new path starting from an x and y position
  66342. * @param x starting x value
  66343. * @param y starting y value
  66344. * @returns a new Path2 starting at the coordinates (x, y).
  66345. */
  66346. static StartingAt(x: number, y: number): Path2;
  66347. }
  66348. /**
  66349. * Represents a 3D path made up of multiple 3D points
  66350. */
  66351. export class Path3D {
  66352. /**
  66353. * an array of Vector3, the curve axis of the Path3D
  66354. */
  66355. path: Vector3[];
  66356. private _curve;
  66357. private _distances;
  66358. private _tangents;
  66359. private _normals;
  66360. private _binormals;
  66361. private _raw;
  66362. /**
  66363. * new Path3D(path, normal, raw)
  66364. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  66365. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  66366. * @param path an array of Vector3, the curve axis of the Path3D
  66367. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  66368. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  66369. */
  66370. constructor(
  66371. /**
  66372. * an array of Vector3, the curve axis of the Path3D
  66373. */
  66374. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  66375. /**
  66376. * Returns the Path3D array of successive Vector3 designing its curve.
  66377. * @returns the Path3D array of successive Vector3 designing its curve.
  66378. */
  66379. getCurve(): Vector3[];
  66380. /**
  66381. * Returns an array populated with tangent vectors on each Path3D curve point.
  66382. * @returns an array populated with tangent vectors on each Path3D curve point.
  66383. */
  66384. getTangents(): Vector3[];
  66385. /**
  66386. * Returns an array populated with normal vectors on each Path3D curve point.
  66387. * @returns an array populated with normal vectors on each Path3D curve point.
  66388. */
  66389. getNormals(): Vector3[];
  66390. /**
  66391. * Returns an array populated with binormal vectors on each Path3D curve point.
  66392. * @returns an array populated with binormal vectors on each Path3D curve point.
  66393. */
  66394. getBinormals(): Vector3[];
  66395. /**
  66396. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  66397. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  66398. */
  66399. getDistances(): number[];
  66400. /**
  66401. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  66402. * @param path path which all values are copied into the curves points
  66403. * @param firstNormal which should be projected onto the curve
  66404. * @returns the same object updated.
  66405. */
  66406. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  66407. private _compute;
  66408. private _getFirstNonNullVector;
  66409. private _getLastNonNullVector;
  66410. private _normalVector;
  66411. }
  66412. /**
  66413. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66414. * A Curve3 is designed from a series of successive Vector3.
  66415. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  66416. */
  66417. export class Curve3 {
  66418. private _points;
  66419. private _length;
  66420. /**
  66421. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  66422. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  66423. * @param v1 (Vector3) the control point
  66424. * @param v2 (Vector3) the end point of the Quadratic Bezier
  66425. * @param nbPoints (integer) the wanted number of points in the curve
  66426. * @returns the created Curve3
  66427. */
  66428. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66429. /**
  66430. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  66431. * @param v0 (Vector3) the origin point of the Cubic Bezier
  66432. * @param v1 (Vector3) the first control point
  66433. * @param v2 (Vector3) the second control point
  66434. * @param v3 (Vector3) the end point of the Cubic Bezier
  66435. * @param nbPoints (integer) the wanted number of points in the curve
  66436. * @returns the created Curve3
  66437. */
  66438. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66439. /**
  66440. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  66441. * @param p1 (Vector3) the origin point of the Hermite Spline
  66442. * @param t1 (Vector3) the tangent vector at the origin point
  66443. * @param p2 (Vector3) the end point of the Hermite Spline
  66444. * @param t2 (Vector3) the tangent vector at the end point
  66445. * @param nbPoints (integer) the wanted number of points in the curve
  66446. * @returns the created Curve3
  66447. */
  66448. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66449. /**
  66450. * Returns a Curve3 object along a CatmullRom Spline curve :
  66451. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  66452. * @param nbPoints (integer) the wanted number of points between each curve control points
  66453. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  66454. * @returns the created Curve3
  66455. */
  66456. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  66457. /**
  66458. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66459. * A Curve3 is designed from a series of successive Vector3.
  66460. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  66461. * @param points points which make up the curve
  66462. */
  66463. constructor(points: Vector3[]);
  66464. /**
  66465. * @returns the Curve3 stored array of successive Vector3
  66466. */
  66467. getPoints(): Vector3[];
  66468. /**
  66469. * @returns the computed length (float) of the curve.
  66470. */
  66471. length(): number;
  66472. /**
  66473. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  66474. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  66475. * curveA and curveB keep unchanged.
  66476. * @param curve the curve to continue from this curve
  66477. * @returns the newly constructed curve
  66478. */
  66479. continue(curve: DeepImmutable<Curve3>): Curve3;
  66480. private _computeLength;
  66481. }
  66482. /**
  66483. * Contains position and normal vectors for a vertex
  66484. */
  66485. export class PositionNormalVertex {
  66486. /** the position of the vertex (defaut: 0,0,0) */
  66487. position: Vector3;
  66488. /** the normal of the vertex (defaut: 0,1,0) */
  66489. normal: Vector3;
  66490. /**
  66491. * Creates a PositionNormalVertex
  66492. * @param position the position of the vertex (defaut: 0,0,0)
  66493. * @param normal the normal of the vertex (defaut: 0,1,0)
  66494. */
  66495. constructor(
  66496. /** the position of the vertex (defaut: 0,0,0) */
  66497. position?: Vector3,
  66498. /** the normal of the vertex (defaut: 0,1,0) */
  66499. normal?: Vector3);
  66500. /**
  66501. * Clones the PositionNormalVertex
  66502. * @returns the cloned PositionNormalVertex
  66503. */
  66504. clone(): PositionNormalVertex;
  66505. }
  66506. /**
  66507. * Contains position, normal and uv vectors for a vertex
  66508. */
  66509. export class PositionNormalTextureVertex {
  66510. /** the position of the vertex (defaut: 0,0,0) */
  66511. position: Vector3;
  66512. /** the normal of the vertex (defaut: 0,1,0) */
  66513. normal: Vector3;
  66514. /** the uv of the vertex (default: 0,0) */
  66515. uv: Vector2;
  66516. /**
  66517. * Creates a PositionNormalTextureVertex
  66518. * @param position the position of the vertex (defaut: 0,0,0)
  66519. * @param normal the normal of the vertex (defaut: 0,1,0)
  66520. * @param uv the uv of the vertex (default: 0,0)
  66521. */
  66522. constructor(
  66523. /** the position of the vertex (defaut: 0,0,0) */
  66524. position?: Vector3,
  66525. /** the normal of the vertex (defaut: 0,1,0) */
  66526. normal?: Vector3,
  66527. /** the uv of the vertex (default: 0,0) */
  66528. uv?: Vector2);
  66529. /**
  66530. * Clones the PositionNormalTextureVertex
  66531. * @returns the cloned PositionNormalTextureVertex
  66532. */
  66533. clone(): PositionNormalTextureVertex;
  66534. }
  66535. /**
  66536. * @hidden
  66537. */
  66538. export class Tmp {
  66539. static Color3: Color3[];
  66540. static Color4: Color4[];
  66541. static Vector2: Vector2[];
  66542. static Vector3: Vector3[];
  66543. static Vector4: Vector4[];
  66544. static Quaternion: Quaternion[];
  66545. static Matrix: Matrix[];
  66546. }
  66547. }
  66548. declare module BABYLON {
  66549. /**
  66550. * Class used to enable access to offline support
  66551. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66552. */
  66553. export interface IOfflineProvider {
  66554. /**
  66555. * Gets a boolean indicating if scene must be saved in the database
  66556. */
  66557. enableSceneOffline: boolean;
  66558. /**
  66559. * Gets a boolean indicating if textures must be saved in the database
  66560. */
  66561. enableTexturesOffline: boolean;
  66562. /**
  66563. * Open the offline support and make it available
  66564. * @param successCallback defines the callback to call on success
  66565. * @param errorCallback defines the callback to call on error
  66566. */
  66567. open(successCallback: () => void, errorCallback: () => void): void;
  66568. /**
  66569. * Loads an image from the offline support
  66570. * @param url defines the url to load from
  66571. * @param image defines the target DOM image
  66572. */
  66573. loadImage(url: string, image: HTMLImageElement): void;
  66574. /**
  66575. * Loads a file from offline support
  66576. * @param url defines the URL to load from
  66577. * @param sceneLoaded defines a callback to call on success
  66578. * @param progressCallBack defines a callback to call when progress changed
  66579. * @param errorCallback defines a callback to call on error
  66580. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66581. */
  66582. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66583. }
  66584. }
  66585. declare module BABYLON {
  66586. /**
  66587. * A class serves as a medium between the observable and its observers
  66588. */
  66589. export class EventState {
  66590. /**
  66591. * Create a new EventState
  66592. * @param mask defines the mask associated with this state
  66593. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66594. * @param target defines the original target of the state
  66595. * @param currentTarget defines the current target of the state
  66596. */
  66597. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66598. /**
  66599. * Initialize the current event state
  66600. * @param mask defines the mask associated with this state
  66601. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66602. * @param target defines the original target of the state
  66603. * @param currentTarget defines the current target of the state
  66604. * @returns the current event state
  66605. */
  66606. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66607. /**
  66608. * An Observer can set this property to true to prevent subsequent observers of being notified
  66609. */
  66610. skipNextObservers: boolean;
  66611. /**
  66612. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66613. */
  66614. mask: number;
  66615. /**
  66616. * The object that originally notified the event
  66617. */
  66618. target?: any;
  66619. /**
  66620. * The current object in the bubbling phase
  66621. */
  66622. currentTarget?: any;
  66623. /**
  66624. * This will be populated with the return value of the last function that was executed.
  66625. * If it is the first function in the callback chain it will be the event data.
  66626. */
  66627. lastReturnValue?: any;
  66628. }
  66629. /**
  66630. * Represent an Observer registered to a given Observable object.
  66631. */
  66632. export class Observer<T> {
  66633. /**
  66634. * Defines the callback to call when the observer is notified
  66635. */
  66636. callback: (eventData: T, eventState: EventState) => void;
  66637. /**
  66638. * Defines the mask of the observer (used to filter notifications)
  66639. */
  66640. mask: number;
  66641. /**
  66642. * Defines the current scope used to restore the JS context
  66643. */
  66644. scope: any;
  66645. /** @hidden */
  66646. _willBeUnregistered: boolean;
  66647. /**
  66648. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66649. */
  66650. unregisterOnNextCall: boolean;
  66651. /**
  66652. * Creates a new observer
  66653. * @param callback defines the callback to call when the observer is notified
  66654. * @param mask defines the mask of the observer (used to filter notifications)
  66655. * @param scope defines the current scope used to restore the JS context
  66656. */
  66657. constructor(
  66658. /**
  66659. * Defines the callback to call when the observer is notified
  66660. */
  66661. callback: (eventData: T, eventState: EventState) => void,
  66662. /**
  66663. * Defines the mask of the observer (used to filter notifications)
  66664. */
  66665. mask: number,
  66666. /**
  66667. * Defines the current scope used to restore the JS context
  66668. */
  66669. scope?: any);
  66670. }
  66671. /**
  66672. * Represent a list of observers registered to multiple Observables object.
  66673. */
  66674. export class MultiObserver<T> {
  66675. private _observers;
  66676. private _observables;
  66677. /**
  66678. * Release associated resources
  66679. */
  66680. dispose(): void;
  66681. /**
  66682. * Raise a callback when one of the observable will notify
  66683. * @param observables defines a list of observables to watch
  66684. * @param callback defines the callback to call on notification
  66685. * @param mask defines the mask used to filter notifications
  66686. * @param scope defines the current scope used to restore the JS context
  66687. * @returns the new MultiObserver
  66688. */
  66689. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66690. }
  66691. /**
  66692. * The Observable class is a simple implementation of the Observable pattern.
  66693. *
  66694. * 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.
  66695. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66696. * 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).
  66697. * 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.
  66698. */
  66699. export class Observable<T> {
  66700. private _observers;
  66701. private _eventState;
  66702. private _onObserverAdded;
  66703. /**
  66704. * Creates a new observable
  66705. * @param onObserverAdded defines a callback to call when a new observer is added
  66706. */
  66707. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66708. /**
  66709. * Create a new Observer with the specified callback
  66710. * @param callback the callback that will be executed for that Observer
  66711. * @param mask the mask used to filter observers
  66712. * @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.
  66713. * @param scope optional scope for the callback to be called from
  66714. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66715. * @returns the new observer created for the callback
  66716. */
  66717. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66718. /**
  66719. * Create a new Observer with the specified callback and unregisters after the next notification
  66720. * @param callback the callback that will be executed for that Observer
  66721. * @returns the new observer created for the callback
  66722. */
  66723. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66724. /**
  66725. * Remove an Observer from the Observable object
  66726. * @param observer the instance of the Observer to remove
  66727. * @returns false if it doesn't belong to this Observable
  66728. */
  66729. remove(observer: Nullable<Observer<T>>): boolean;
  66730. /**
  66731. * Remove a callback from the Observable object
  66732. * @param callback the callback to remove
  66733. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66734. * @returns false if it doesn't belong to this Observable
  66735. */
  66736. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66737. private _deferUnregister;
  66738. private _remove;
  66739. /**
  66740. * Moves the observable to the top of the observer list making it get called first when notified
  66741. * @param observer the observer to move
  66742. */
  66743. makeObserverTopPriority(observer: Observer<T>): void;
  66744. /**
  66745. * Moves the observable to the bottom of the observer list making it get called last when notified
  66746. * @param observer the observer to move
  66747. */
  66748. makeObserverBottomPriority(observer: Observer<T>): void;
  66749. /**
  66750. * Notify all Observers by calling their respective callback with the given data
  66751. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66752. * @param eventData defines the data to send to all observers
  66753. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66754. * @param target defines the original target of the state
  66755. * @param currentTarget defines the current target of the state
  66756. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66757. */
  66758. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66759. /**
  66760. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66761. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66762. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66763. * and it is crucial that all callbacks will be executed.
  66764. * The order of the callbacks is kept, callbacks are not executed parallel.
  66765. *
  66766. * @param eventData The data to be sent to each callback
  66767. * @param mask is used to filter observers defaults to -1
  66768. * @param target defines the callback target (see EventState)
  66769. * @param currentTarget defines he current object in the bubbling phase
  66770. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66771. */
  66772. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66773. /**
  66774. * Notify a specific observer
  66775. * @param observer defines the observer to notify
  66776. * @param eventData defines the data to be sent to each callback
  66777. * @param mask is used to filter observers defaults to -1
  66778. */
  66779. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66780. /**
  66781. * Gets a boolean indicating if the observable has at least one observer
  66782. * @returns true is the Observable has at least one Observer registered
  66783. */
  66784. hasObservers(): boolean;
  66785. /**
  66786. * Clear the list of observers
  66787. */
  66788. clear(): void;
  66789. /**
  66790. * Clone the current observable
  66791. * @returns a new observable
  66792. */
  66793. clone(): Observable<T>;
  66794. /**
  66795. * Does this observable handles observer registered with a given mask
  66796. * @param mask defines the mask to be tested
  66797. * @return whether or not one observer registered with the given mask is handeled
  66798. **/
  66799. hasSpecificMask(mask?: number): boolean;
  66800. }
  66801. }
  66802. declare module BABYLON {
  66803. /**
  66804. * Class used to help managing file picking and drag'n'drop
  66805. * File Storage
  66806. */
  66807. export class FilesInputStore {
  66808. /**
  66809. * List of files ready to be loaded
  66810. */
  66811. static FilesToLoad: {
  66812. [key: string]: File;
  66813. };
  66814. }
  66815. }
  66816. declare module BABYLON {
  66817. /** Defines the cross module used constants to avoid circular dependncies */
  66818. export class Constants {
  66819. /** Defines that alpha blending is disabled */
  66820. static readonly ALPHA_DISABLE: number;
  66821. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  66822. static readonly ALPHA_ADD: number;
  66823. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  66824. static readonly ALPHA_COMBINE: number;
  66825. /** Defines that alpha blending to DEST - SRC * DEST */
  66826. static readonly ALPHA_SUBTRACT: number;
  66827. /** Defines that alpha blending to SRC * DEST */
  66828. static readonly ALPHA_MULTIPLY: number;
  66829. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  66830. static readonly ALPHA_MAXIMIZED: number;
  66831. /** Defines that alpha blending to SRC + DEST */
  66832. static readonly ALPHA_ONEONE: number;
  66833. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  66834. static readonly ALPHA_PREMULTIPLIED: number;
  66835. /**
  66836. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  66837. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  66838. */
  66839. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  66840. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  66841. static readonly ALPHA_INTERPOLATE: number;
  66842. /**
  66843. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  66844. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  66845. */
  66846. static readonly ALPHA_SCREENMODE: number;
  66847. /** Defines that the ressource is not delayed*/
  66848. static readonly DELAYLOADSTATE_NONE: number;
  66849. /** Defines that the ressource was successfully delay loaded */
  66850. static readonly DELAYLOADSTATE_LOADED: number;
  66851. /** Defines that the ressource is currently delay loading */
  66852. static readonly DELAYLOADSTATE_LOADING: number;
  66853. /** Defines that the ressource is delayed and has not started loading */
  66854. static readonly DELAYLOADSTATE_NOTLOADED: number;
  66855. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  66856. static readonly NEVER: number;
  66857. /** 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 */
  66858. static readonly ALWAYS: number;
  66859. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  66860. static readonly LESS: number;
  66861. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  66862. static readonly EQUAL: number;
  66863. /** 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 */
  66864. static readonly LEQUAL: number;
  66865. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  66866. static readonly GREATER: number;
  66867. /** 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 */
  66868. static readonly GEQUAL: number;
  66869. /** 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 */
  66870. static readonly NOTEQUAL: number;
  66871. /** Passed to stencilOperation to specify that stencil value must be kept */
  66872. static readonly KEEP: number;
  66873. /** Passed to stencilOperation to specify that stencil value must be replaced */
  66874. static readonly REPLACE: number;
  66875. /** Passed to stencilOperation to specify that stencil value must be incremented */
  66876. static readonly INCR: number;
  66877. /** Passed to stencilOperation to specify that stencil value must be decremented */
  66878. static readonly DECR: number;
  66879. /** Passed to stencilOperation to specify that stencil value must be inverted */
  66880. static readonly INVERT: number;
  66881. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  66882. static readonly INCR_WRAP: number;
  66883. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  66884. static readonly DECR_WRAP: number;
  66885. /** Texture is not repeating outside of 0..1 UVs */
  66886. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  66887. /** Texture is repeating outside of 0..1 UVs */
  66888. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  66889. /** Texture is repeating and mirrored */
  66890. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  66891. /** ALPHA */
  66892. static readonly TEXTUREFORMAT_ALPHA: number;
  66893. /** LUMINANCE */
  66894. static readonly TEXTUREFORMAT_LUMINANCE: number;
  66895. /** LUMINANCE_ALPHA */
  66896. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  66897. /** RGB */
  66898. static readonly TEXTUREFORMAT_RGB: number;
  66899. /** RGBA */
  66900. static readonly TEXTUREFORMAT_RGBA: number;
  66901. /** RED */
  66902. static readonly TEXTUREFORMAT_RED: number;
  66903. /** RED (2nd reference) */
  66904. static readonly TEXTUREFORMAT_R: number;
  66905. /** RG */
  66906. static readonly TEXTUREFORMAT_RG: number;
  66907. /** RED_INTEGER */
  66908. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  66909. /** RED_INTEGER (2nd reference) */
  66910. static readonly TEXTUREFORMAT_R_INTEGER: number;
  66911. /** RG_INTEGER */
  66912. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  66913. /** RGB_INTEGER */
  66914. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  66915. /** RGBA_INTEGER */
  66916. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  66917. /** UNSIGNED_BYTE */
  66918. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  66919. /** UNSIGNED_BYTE (2nd reference) */
  66920. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  66921. /** FLOAT */
  66922. static readonly TEXTURETYPE_FLOAT: number;
  66923. /** HALF_FLOAT */
  66924. static readonly TEXTURETYPE_HALF_FLOAT: number;
  66925. /** BYTE */
  66926. static readonly TEXTURETYPE_BYTE: number;
  66927. /** SHORT */
  66928. static readonly TEXTURETYPE_SHORT: number;
  66929. /** UNSIGNED_SHORT */
  66930. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  66931. /** INT */
  66932. static readonly TEXTURETYPE_INT: number;
  66933. /** UNSIGNED_INT */
  66934. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  66935. /** UNSIGNED_SHORT_4_4_4_4 */
  66936. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  66937. /** UNSIGNED_SHORT_5_5_5_1 */
  66938. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  66939. /** UNSIGNED_SHORT_5_6_5 */
  66940. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  66941. /** UNSIGNED_INT_2_10_10_10_REV */
  66942. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  66943. /** UNSIGNED_INT_24_8 */
  66944. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  66945. /** UNSIGNED_INT_10F_11F_11F_REV */
  66946. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  66947. /** UNSIGNED_INT_5_9_9_9_REV */
  66948. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  66949. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  66950. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  66951. /** nearest is mag = nearest and min = nearest and mip = linear */
  66952. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  66953. /** Bilinear is mag = linear and min = linear and mip = nearest */
  66954. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  66955. /** Trilinear is mag = linear and min = linear and mip = linear */
  66956. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  66957. /** nearest is mag = nearest and min = nearest and mip = linear */
  66958. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  66959. /** Bilinear is mag = linear and min = linear and mip = nearest */
  66960. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  66961. /** Trilinear is mag = linear and min = linear and mip = linear */
  66962. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  66963. /** mag = nearest and min = nearest and mip = nearest */
  66964. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  66965. /** mag = nearest and min = linear and mip = nearest */
  66966. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  66967. /** mag = nearest and min = linear and mip = linear */
  66968. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  66969. /** mag = nearest and min = linear and mip = none */
  66970. static readonly TEXTURE_NEAREST_LINEAR: number;
  66971. /** mag = nearest and min = nearest and mip = none */
  66972. static readonly TEXTURE_NEAREST_NEAREST: number;
  66973. /** mag = linear and min = nearest and mip = nearest */
  66974. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  66975. /** mag = linear and min = nearest and mip = linear */
  66976. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  66977. /** mag = linear and min = linear and mip = none */
  66978. static readonly TEXTURE_LINEAR_LINEAR: number;
  66979. /** mag = linear and min = nearest and mip = none */
  66980. static readonly TEXTURE_LINEAR_NEAREST: number;
  66981. /** Explicit coordinates mode */
  66982. static readonly TEXTURE_EXPLICIT_MODE: number;
  66983. /** Spherical coordinates mode */
  66984. static readonly TEXTURE_SPHERICAL_MODE: number;
  66985. /** Planar coordinates mode */
  66986. static readonly TEXTURE_PLANAR_MODE: number;
  66987. /** Cubic coordinates mode */
  66988. static readonly TEXTURE_CUBIC_MODE: number;
  66989. /** Projection coordinates mode */
  66990. static readonly TEXTURE_PROJECTION_MODE: number;
  66991. /** Skybox coordinates mode */
  66992. static readonly TEXTURE_SKYBOX_MODE: number;
  66993. /** Inverse Cubic coordinates mode */
  66994. static readonly TEXTURE_INVCUBIC_MODE: number;
  66995. /** Equirectangular coordinates mode */
  66996. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  66997. /** Equirectangular Fixed coordinates mode */
  66998. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  66999. /** Equirectangular Fixed Mirrored coordinates mode */
  67000. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67001. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67002. static readonly SCALEMODE_FLOOR: number;
  67003. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67004. static readonly SCALEMODE_NEAREST: number;
  67005. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67006. static readonly SCALEMODE_CEILING: number;
  67007. /**
  67008. * The dirty texture flag value
  67009. */
  67010. static readonly MATERIAL_TextureDirtyFlag: number;
  67011. /**
  67012. * The dirty light flag value
  67013. */
  67014. static readonly MATERIAL_LightDirtyFlag: number;
  67015. /**
  67016. * The dirty fresnel flag value
  67017. */
  67018. static readonly MATERIAL_FresnelDirtyFlag: number;
  67019. /**
  67020. * The dirty attribute flag value
  67021. */
  67022. static readonly MATERIAL_AttributesDirtyFlag: number;
  67023. /**
  67024. * The dirty misc flag value
  67025. */
  67026. static readonly MATERIAL_MiscDirtyFlag: number;
  67027. /**
  67028. * The all dirty flag value
  67029. */
  67030. static readonly MATERIAL_AllDirtyFlag: number;
  67031. /**
  67032. * Returns the triangle fill mode
  67033. */
  67034. static readonly MATERIAL_TriangleFillMode: number;
  67035. /**
  67036. * Returns the wireframe mode
  67037. */
  67038. static readonly MATERIAL_WireFrameFillMode: number;
  67039. /**
  67040. * Returns the point fill mode
  67041. */
  67042. static readonly MATERIAL_PointFillMode: number;
  67043. /**
  67044. * Returns the point list draw mode
  67045. */
  67046. static readonly MATERIAL_PointListDrawMode: number;
  67047. /**
  67048. * Returns the line list draw mode
  67049. */
  67050. static readonly MATERIAL_LineListDrawMode: number;
  67051. /**
  67052. * Returns the line loop draw mode
  67053. */
  67054. static readonly MATERIAL_LineLoopDrawMode: number;
  67055. /**
  67056. * Returns the line strip draw mode
  67057. */
  67058. static readonly MATERIAL_LineStripDrawMode: number;
  67059. /**
  67060. * Returns the triangle strip draw mode
  67061. */
  67062. static readonly MATERIAL_TriangleStripDrawMode: number;
  67063. /**
  67064. * Returns the triangle fan draw mode
  67065. */
  67066. static readonly MATERIAL_TriangleFanDrawMode: number;
  67067. /**
  67068. * Stores the clock-wise side orientation
  67069. */
  67070. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67071. /**
  67072. * Stores the counter clock-wise side orientation
  67073. */
  67074. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67075. /**
  67076. * Nothing
  67077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67078. */
  67079. static readonly ACTION_NothingTrigger: number;
  67080. /**
  67081. * On pick
  67082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67083. */
  67084. static readonly ACTION_OnPickTrigger: number;
  67085. /**
  67086. * On left pick
  67087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67088. */
  67089. static readonly ACTION_OnLeftPickTrigger: number;
  67090. /**
  67091. * On right pick
  67092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67093. */
  67094. static readonly ACTION_OnRightPickTrigger: number;
  67095. /**
  67096. * On center pick
  67097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67098. */
  67099. static readonly ACTION_OnCenterPickTrigger: number;
  67100. /**
  67101. * On pick down
  67102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67103. */
  67104. static readonly ACTION_OnPickDownTrigger: number;
  67105. /**
  67106. * On double pick
  67107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67108. */
  67109. static readonly ACTION_OnDoublePickTrigger: number;
  67110. /**
  67111. * On pick up
  67112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67113. */
  67114. static readonly ACTION_OnPickUpTrigger: number;
  67115. /**
  67116. * On pick out.
  67117. * This trigger will only be raised if you also declared a OnPickDown
  67118. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67119. */
  67120. static readonly ACTION_OnPickOutTrigger: number;
  67121. /**
  67122. * On long press
  67123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67124. */
  67125. static readonly ACTION_OnLongPressTrigger: number;
  67126. /**
  67127. * On pointer over
  67128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67129. */
  67130. static readonly ACTION_OnPointerOverTrigger: number;
  67131. /**
  67132. * On pointer out
  67133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67134. */
  67135. static readonly ACTION_OnPointerOutTrigger: number;
  67136. /**
  67137. * On every frame
  67138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67139. */
  67140. static readonly ACTION_OnEveryFrameTrigger: number;
  67141. /**
  67142. * On intersection enter
  67143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67144. */
  67145. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67146. /**
  67147. * On intersection exit
  67148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67149. */
  67150. static readonly ACTION_OnIntersectionExitTrigger: number;
  67151. /**
  67152. * On key down
  67153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67154. */
  67155. static readonly ACTION_OnKeyDownTrigger: number;
  67156. /**
  67157. * On key up
  67158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67159. */
  67160. static readonly ACTION_OnKeyUpTrigger: number;
  67161. /**
  67162. * Billboard mode will only apply to Y axis
  67163. */
  67164. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67165. /**
  67166. * Billboard mode will apply to all axes
  67167. */
  67168. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67169. /**
  67170. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67171. */
  67172. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67173. /**
  67174. * Gets or sets base Assets URL
  67175. */
  67176. static PARTICLES_BaseAssetsUrl: string;
  67177. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67178. * Test order :
  67179. * Is the bounding sphere outside the frustum ?
  67180. * If not, are the bounding box vertices outside the frustum ?
  67181. * It not, then the cullable object is in the frustum.
  67182. */
  67183. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67184. /** Culling strategy : Bounding Sphere Only.
  67185. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67186. * It's also less accurate than the standard because some not visible objects can still be selected.
  67187. * Test : is the bounding sphere outside the frustum ?
  67188. * If not, then the cullable object is in the frustum.
  67189. */
  67190. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67191. /** Culling strategy : Optimistic Inclusion.
  67192. * This in an inclusion test first, then the standard exclusion test.
  67193. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67194. * 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.
  67195. * Anyway, it's as accurate as the standard strategy.
  67196. * Test :
  67197. * Is the cullable object bounding sphere center in the frustum ?
  67198. * If not, apply the default culling strategy.
  67199. */
  67200. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67201. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67202. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67203. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67204. * 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.
  67205. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67206. * Test :
  67207. * Is the cullable object bounding sphere center in the frustum ?
  67208. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67209. */
  67210. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67211. /**
  67212. * No logging while loading
  67213. */
  67214. static readonly SCENELOADER_NO_LOGGING: number;
  67215. /**
  67216. * Minimal logging while loading
  67217. */
  67218. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67219. /**
  67220. * Summary logging while loading
  67221. */
  67222. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67223. /**
  67224. * Detailled logging while loading
  67225. */
  67226. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67227. }
  67228. }
  67229. declare module BABYLON {
  67230. /**
  67231. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67232. * Babylon.js
  67233. */
  67234. export class DomManagement {
  67235. /**
  67236. * Checks if the window object exists
  67237. * @returns true if the window object exists
  67238. */
  67239. static IsWindowObjectExist(): boolean;
  67240. /**
  67241. * Extracts text content from a DOM element hierarchy
  67242. * @param element defines the root element
  67243. * @returns a string
  67244. */
  67245. static GetDOMTextContent(element: HTMLElement): string;
  67246. }
  67247. }
  67248. declare module BABYLON {
  67249. /**
  67250. * Logger used througouht the application to allow configuration of
  67251. * the log level required for the messages.
  67252. */
  67253. export class Logger {
  67254. /**
  67255. * No log
  67256. */
  67257. static readonly NoneLogLevel: number;
  67258. /**
  67259. * Only message logs
  67260. */
  67261. static readonly MessageLogLevel: number;
  67262. /**
  67263. * Only warning logs
  67264. */
  67265. static readonly WarningLogLevel: number;
  67266. /**
  67267. * Only error logs
  67268. */
  67269. static readonly ErrorLogLevel: number;
  67270. /**
  67271. * All logs
  67272. */
  67273. static readonly AllLogLevel: number;
  67274. private static _LogCache;
  67275. /**
  67276. * Gets a value indicating the number of loading errors
  67277. * @ignorenaming
  67278. */
  67279. static errorsCount: number;
  67280. /**
  67281. * Callback called when a new log is added
  67282. */
  67283. static OnNewCacheEntry: (entry: string) => void;
  67284. private static _AddLogEntry;
  67285. private static _FormatMessage;
  67286. private static _LogDisabled;
  67287. private static _LogEnabled;
  67288. private static _WarnDisabled;
  67289. private static _WarnEnabled;
  67290. private static _ErrorDisabled;
  67291. private static _ErrorEnabled;
  67292. /**
  67293. * Log a message to the console
  67294. */
  67295. static Log: (message: string) => void;
  67296. /**
  67297. * Write a warning message to the console
  67298. */
  67299. static Warn: (message: string) => void;
  67300. /**
  67301. * Write an error message to the console
  67302. */
  67303. static Error: (message: string) => void;
  67304. /**
  67305. * Gets current log cache (list of logs)
  67306. */
  67307. static readonly LogCache: string;
  67308. /**
  67309. * Clears the log cache
  67310. */
  67311. static ClearLogCache(): void;
  67312. /**
  67313. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67314. */
  67315. static LogLevels: number;
  67316. }
  67317. }
  67318. declare module BABYLON {
  67319. /** @hidden */
  67320. export class _TypeStore {
  67321. /** @hidden */
  67322. static RegisteredTypes: {
  67323. [key: string]: Object;
  67324. };
  67325. /** @hidden */
  67326. static GetClass(fqdn: string): any;
  67327. }
  67328. }
  67329. declare module BABYLON {
  67330. /**
  67331. * Class containing a set of static utilities functions for deep copy.
  67332. */
  67333. export class DeepCopier {
  67334. /**
  67335. * Tries to copy an object by duplicating every property
  67336. * @param source defines the source object
  67337. * @param destination defines the target object
  67338. * @param doNotCopyList defines a list of properties to avoid
  67339. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67340. */
  67341. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67342. }
  67343. }
  67344. declare module BABYLON {
  67345. /**
  67346. * Class containing a set of static utilities functions for precision date
  67347. */
  67348. export class PrecisionDate {
  67349. /**
  67350. * Gets either window.performance.now() if supported or Date.now() else
  67351. */
  67352. static readonly Now: number;
  67353. }
  67354. }
  67355. declare module BABYLON {
  67356. /** @hidden */
  67357. export class _DevTools {
  67358. static WarnImport(name: string): string;
  67359. }
  67360. }
  67361. declare module BABYLON {
  67362. /**
  67363. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67364. */
  67365. export class WebRequest {
  67366. private _xhr;
  67367. /**
  67368. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67369. * i.e. when loading files, where the server/service expects an Authorization header
  67370. */
  67371. static CustomRequestHeaders: {
  67372. [key: string]: string;
  67373. };
  67374. /**
  67375. * Add callback functions in this array to update all the requests before they get sent to the network
  67376. */
  67377. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  67378. private _injectCustomRequestHeaders;
  67379. /**
  67380. * Gets or sets a function to be called when loading progress changes
  67381. */
  67382. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67383. /**
  67384. * Returns client's state
  67385. */
  67386. readonly readyState: number;
  67387. /**
  67388. * Returns client's status
  67389. */
  67390. readonly status: number;
  67391. /**
  67392. * Returns client's status as a text
  67393. */
  67394. readonly statusText: string;
  67395. /**
  67396. * Returns client's response
  67397. */
  67398. readonly response: any;
  67399. /**
  67400. * Returns client's response url
  67401. */
  67402. readonly responseURL: string;
  67403. /**
  67404. * Returns client's response as text
  67405. */
  67406. readonly responseText: string;
  67407. /**
  67408. * Gets or sets the expected response type
  67409. */
  67410. responseType: XMLHttpRequestResponseType;
  67411. /** @hidden */
  67412. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67413. /** @hidden */
  67414. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67415. /**
  67416. * Cancels any network activity
  67417. */
  67418. abort(): void;
  67419. /**
  67420. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67421. * @param body defines an optional request body
  67422. */
  67423. send(body?: Document | BodyInit | null): void;
  67424. /**
  67425. * Sets the request method, request URL
  67426. * @param method defines the method to use (GET, POST, etc..)
  67427. * @param url defines the url to connect with
  67428. */
  67429. open(method: string, url: string): void;
  67430. }
  67431. }
  67432. declare module BABYLON {
  67433. /**
  67434. * Class used to evalaute queries containing `and` and `or` operators
  67435. */
  67436. export class AndOrNotEvaluator {
  67437. /**
  67438. * Evaluate a query
  67439. * @param query defines the query to evaluate
  67440. * @param evaluateCallback defines the callback used to filter result
  67441. * @returns true if the query matches
  67442. */
  67443. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  67444. private static _HandleParenthesisContent;
  67445. private static _SimplifyNegation;
  67446. }
  67447. }
  67448. declare module BABYLON {
  67449. /**
  67450. * Class used to store custom tags
  67451. */
  67452. export class Tags {
  67453. /**
  67454. * Adds support for tags on the given object
  67455. * @param obj defines the object to use
  67456. */
  67457. static EnableFor(obj: any): void;
  67458. /**
  67459. * Removes tags support
  67460. * @param obj defines the object to use
  67461. */
  67462. static DisableFor(obj: any): void;
  67463. /**
  67464. * Gets a boolean indicating if the given object has tags
  67465. * @param obj defines the object to use
  67466. * @returns a boolean
  67467. */
  67468. static HasTags(obj: any): boolean;
  67469. /**
  67470. * Gets the tags available on a given object
  67471. * @param obj defines the object to use
  67472. * @param asString defines if the tags must be returned as a string instead of an array of strings
  67473. * @returns the tags
  67474. */
  67475. static GetTags(obj: any, asString?: boolean): any;
  67476. /**
  67477. * Adds tags to an object
  67478. * @param obj defines the object to use
  67479. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  67480. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  67481. */
  67482. static AddTagsTo(obj: any, tagsString: string): void;
  67483. /**
  67484. * @hidden
  67485. */
  67486. static _AddTagTo(obj: any, tag: string): void;
  67487. /**
  67488. * Removes specific tags from a specific object
  67489. * @param obj defines the object to use
  67490. * @param tagsString defines the tags to remove
  67491. */
  67492. static RemoveTagsFrom(obj: any, tagsString: string): void;
  67493. /**
  67494. * @hidden
  67495. */
  67496. static _RemoveTagFrom(obj: any, tag: string): void;
  67497. /**
  67498. * Defines if tags hosted on an object match a given query
  67499. * @param obj defines the object to use
  67500. * @param tagsQuery defines the tag query
  67501. * @returns a boolean
  67502. */
  67503. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  67504. }
  67505. }
  67506. declare module BABYLON {
  67507. /**
  67508. * Manages the defines for the Material
  67509. */
  67510. export class MaterialDefines {
  67511. /** @hidden */
  67512. protected _keys: string[];
  67513. private _isDirty;
  67514. /** @hidden */
  67515. _renderId: number;
  67516. /** @hidden */
  67517. _areLightsDirty: boolean;
  67518. /** @hidden */
  67519. _areAttributesDirty: boolean;
  67520. /** @hidden */
  67521. _areTexturesDirty: boolean;
  67522. /** @hidden */
  67523. _areFresnelDirty: boolean;
  67524. /** @hidden */
  67525. _areMiscDirty: boolean;
  67526. /** @hidden */
  67527. _areImageProcessingDirty: boolean;
  67528. /** @hidden */
  67529. _normals: boolean;
  67530. /** @hidden */
  67531. _uvs: boolean;
  67532. /** @hidden */
  67533. _needNormals: boolean;
  67534. /** @hidden */
  67535. _needUVs: boolean;
  67536. [id: string]: any;
  67537. /**
  67538. * Specifies if the material needs to be re-calculated
  67539. */
  67540. readonly isDirty: boolean;
  67541. /**
  67542. * Marks the material to indicate that it has been re-calculated
  67543. */
  67544. markAsProcessed(): void;
  67545. /**
  67546. * Marks the material to indicate that it needs to be re-calculated
  67547. */
  67548. markAsUnprocessed(): void;
  67549. /**
  67550. * Marks the material to indicate all of its defines need to be re-calculated
  67551. */
  67552. markAllAsDirty(): void;
  67553. /**
  67554. * Marks the material to indicate that image processing needs to be re-calculated
  67555. */
  67556. markAsImageProcessingDirty(): void;
  67557. /**
  67558. * Marks the material to indicate the lights need to be re-calculated
  67559. */
  67560. markAsLightDirty(): void;
  67561. /**
  67562. * Marks the attribute state as changed
  67563. */
  67564. markAsAttributesDirty(): void;
  67565. /**
  67566. * Marks the texture state as changed
  67567. */
  67568. markAsTexturesDirty(): void;
  67569. /**
  67570. * Marks the fresnel state as changed
  67571. */
  67572. markAsFresnelDirty(): void;
  67573. /**
  67574. * Marks the misc state as changed
  67575. */
  67576. markAsMiscDirty(): void;
  67577. /**
  67578. * Rebuilds the material defines
  67579. */
  67580. rebuild(): void;
  67581. /**
  67582. * Specifies if two material defines are equal
  67583. * @param other - A material define instance to compare to
  67584. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  67585. */
  67586. isEqual(other: MaterialDefines): boolean;
  67587. /**
  67588. * Clones this instance's defines to another instance
  67589. * @param other - material defines to clone values to
  67590. */
  67591. cloneTo(other: MaterialDefines): void;
  67592. /**
  67593. * Resets the material define values
  67594. */
  67595. reset(): void;
  67596. /**
  67597. * Converts the material define values to a string
  67598. * @returns - String of material define information
  67599. */
  67600. toString(): string;
  67601. }
  67602. }
  67603. declare module BABYLON {
  67604. /**
  67605. * Class used to store and describe the pipeline context associated with an effect
  67606. */
  67607. export interface IPipelineContext {
  67608. /**
  67609. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67610. */
  67611. isAsync: boolean;
  67612. /**
  67613. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67614. */
  67615. isReady: boolean;
  67616. /** @hidden */
  67617. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67618. }
  67619. }
  67620. declare module BABYLON {
  67621. /**
  67622. * Class used to store gfx data (like WebGLBuffer)
  67623. */
  67624. export class DataBuffer {
  67625. /**
  67626. * Gets or sets the number of objects referencing this buffer
  67627. */
  67628. references: number;
  67629. /** Gets or sets the size of the underlying buffer */
  67630. capacity: number;
  67631. /**
  67632. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67633. */
  67634. is32Bits: boolean;
  67635. /**
  67636. * Gets the underlying buffer
  67637. */
  67638. readonly underlyingResource: any;
  67639. }
  67640. }
  67641. declare module BABYLON {
  67642. /** @hidden */
  67643. export interface IShaderProcessor {
  67644. attributeProcessor?: (attribute: string) => string;
  67645. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  67646. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67647. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67648. }
  67649. }
  67650. declare module BABYLON {
  67651. /** @hidden */
  67652. export interface ProcessingOptions {
  67653. defines: string[];
  67654. indexParameters: any;
  67655. isFragment: boolean;
  67656. shouldUseHighPrecisionShader: boolean;
  67657. supportsUniformBuffers: boolean;
  67658. shadersRepository: string;
  67659. includesShadersStore: {
  67660. [key: string]: string;
  67661. };
  67662. processor?: IShaderProcessor;
  67663. version: string;
  67664. }
  67665. }
  67666. declare module BABYLON {
  67667. /** @hidden */
  67668. export class ShaderCodeNode {
  67669. line: string;
  67670. children: ShaderCodeNode[];
  67671. additionalDefineKey?: string;
  67672. additionalDefineValue?: string;
  67673. isValid(preprocessors: {
  67674. [key: string]: string;
  67675. }): boolean;
  67676. process(preprocessors: {
  67677. [key: string]: string;
  67678. }, options: ProcessingOptions): string;
  67679. private _lineStartsWith;
  67680. }
  67681. }
  67682. declare module BABYLON {
  67683. /** @hidden */
  67684. export class ShaderCodeCursor {
  67685. private _lines;
  67686. lineIndex: number;
  67687. readonly currentLine: string;
  67688. readonly canRead: boolean;
  67689. lines: string[];
  67690. }
  67691. }
  67692. declare module BABYLON {
  67693. /** @hidden */
  67694. export class ShaderCodeConditionNode extends ShaderCodeNode {
  67695. process(preprocessors: {
  67696. [key: string]: string;
  67697. }, options: ProcessingOptions): string;
  67698. }
  67699. }
  67700. declare module BABYLON {
  67701. /** @hidden */
  67702. export class ShaderDefineExpression {
  67703. isTrue(preprocessors: {
  67704. [key: string]: string;
  67705. }): boolean;
  67706. }
  67707. }
  67708. declare module BABYLON {
  67709. /** @hidden */
  67710. export class ShaderCodeTestNode extends ShaderCodeNode {
  67711. testExpression: ShaderDefineExpression;
  67712. isValid(preprocessors: {
  67713. [key: string]: string;
  67714. }): boolean;
  67715. }
  67716. }
  67717. declare module BABYLON {
  67718. /** @hidden */
  67719. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  67720. define: string;
  67721. not: boolean;
  67722. constructor(define: string, not?: boolean);
  67723. isTrue(preprocessors: {
  67724. [key: string]: string;
  67725. }): boolean;
  67726. }
  67727. }
  67728. declare module BABYLON {
  67729. /** @hidden */
  67730. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  67731. leftOperand: ShaderDefineExpression;
  67732. rightOperand: ShaderDefineExpression;
  67733. isTrue(preprocessors: {
  67734. [key: string]: string;
  67735. }): boolean;
  67736. }
  67737. }
  67738. declare module BABYLON {
  67739. /** @hidden */
  67740. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  67741. leftOperand: ShaderDefineExpression;
  67742. rightOperand: ShaderDefineExpression;
  67743. isTrue(preprocessors: {
  67744. [key: string]: string;
  67745. }): boolean;
  67746. }
  67747. }
  67748. declare module BABYLON {
  67749. /** @hidden */
  67750. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  67751. define: string;
  67752. operand: string;
  67753. testValue: string;
  67754. constructor(define: string, operand: string, testValue: string);
  67755. isTrue(preprocessors: {
  67756. [key: string]: string;
  67757. }): boolean;
  67758. }
  67759. }
  67760. declare module BABYLON {
  67761. /** @hidden */
  67762. export class ShaderProcessor {
  67763. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  67764. private static _ProcessPrecision;
  67765. private static _ExtractOperation;
  67766. private static _BuildSubExpression;
  67767. private static _BuildExpression;
  67768. private static _MoveCursorWithinIf;
  67769. private static _MoveCursor;
  67770. private static _EvaluatePreProcessors;
  67771. private static _PreparePreProcessors;
  67772. private static _ProcessShaderConversion;
  67773. private static _ProcessIncludes;
  67774. }
  67775. }
  67776. declare module BABYLON {
  67777. /**
  67778. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  67779. */
  67780. export class PerformanceMonitor {
  67781. private _enabled;
  67782. private _rollingFrameTime;
  67783. private _lastFrameTimeMs;
  67784. /**
  67785. * constructor
  67786. * @param frameSampleSize The number of samples required to saturate the sliding window
  67787. */
  67788. constructor(frameSampleSize?: number);
  67789. /**
  67790. * Samples current frame
  67791. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  67792. */
  67793. sampleFrame(timeMs?: number): void;
  67794. /**
  67795. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  67796. */
  67797. readonly averageFrameTime: number;
  67798. /**
  67799. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  67800. */
  67801. readonly averageFrameTimeVariance: number;
  67802. /**
  67803. * Returns the frame time of the most recent frame
  67804. */
  67805. readonly instantaneousFrameTime: number;
  67806. /**
  67807. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  67808. */
  67809. readonly averageFPS: number;
  67810. /**
  67811. * Returns the average framerate in frames per second using the most recent frame time
  67812. */
  67813. readonly instantaneousFPS: number;
  67814. /**
  67815. * Returns true if enough samples have been taken to completely fill the sliding window
  67816. */
  67817. readonly isSaturated: boolean;
  67818. /**
  67819. * Enables contributions to the sliding window sample set
  67820. */
  67821. enable(): void;
  67822. /**
  67823. * Disables contributions to the sliding window sample set
  67824. * Samples will not be interpolated over the disabled period
  67825. */
  67826. disable(): void;
  67827. /**
  67828. * Returns true if sampling is enabled
  67829. */
  67830. readonly isEnabled: boolean;
  67831. /**
  67832. * Resets performance monitor
  67833. */
  67834. reset(): void;
  67835. }
  67836. /**
  67837. * RollingAverage
  67838. *
  67839. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  67840. */
  67841. export class RollingAverage {
  67842. /**
  67843. * Current average
  67844. */
  67845. average: number;
  67846. /**
  67847. * Current variance
  67848. */
  67849. variance: number;
  67850. protected _samples: Array<number>;
  67851. protected _sampleCount: number;
  67852. protected _pos: number;
  67853. protected _m2: number;
  67854. /**
  67855. * constructor
  67856. * @param length The number of samples required to saturate the sliding window
  67857. */
  67858. constructor(length: number);
  67859. /**
  67860. * Adds a sample to the sample set
  67861. * @param v The sample value
  67862. */
  67863. add(v: number): void;
  67864. /**
  67865. * Returns previously added values or null if outside of history or outside the sliding window domain
  67866. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  67867. * @return Value previously recorded with add() or null if outside of range
  67868. */
  67869. history(i: number): number;
  67870. /**
  67871. * Returns true if enough samples have been taken to completely fill the sliding window
  67872. * @return true if sample-set saturated
  67873. */
  67874. isSaturated(): boolean;
  67875. /**
  67876. * Resets the rolling average (equivalent to 0 samples taken so far)
  67877. */
  67878. reset(): void;
  67879. /**
  67880. * Wraps a value around the sample range boundaries
  67881. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  67882. * @return Wrapped position in sample range
  67883. */
  67884. protected _wrapPosition(i: number): number;
  67885. }
  67886. }
  67887. declare module BABYLON {
  67888. /**
  67889. * This class implement a typical dictionary using a string as key and the generic type T as value.
  67890. * The underlying implementation relies on an associative array to ensure the best performances.
  67891. * The value can be anything including 'null' but except 'undefined'
  67892. */
  67893. export class StringDictionary<T> {
  67894. /**
  67895. * This will clear this dictionary and copy the content from the 'source' one.
  67896. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  67897. * @param source the dictionary to take the content from and copy to this dictionary
  67898. */
  67899. copyFrom(source: StringDictionary<T>): void;
  67900. /**
  67901. * Get a value based from its key
  67902. * @param key the given key to get the matching value from
  67903. * @return the value if found, otherwise undefined is returned
  67904. */
  67905. get(key: string): T | undefined;
  67906. /**
  67907. * Get a value from its key or add it if it doesn't exist.
  67908. * This method will ensure you that a given key/data will be present in the dictionary.
  67909. * @param key the given key to get the matching value from
  67910. * @param factory the factory that will create the value if the key is not present in the dictionary.
  67911. * The factory will only be invoked if there's no data for the given key.
  67912. * @return the value corresponding to the key.
  67913. */
  67914. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  67915. /**
  67916. * Get a value from its key if present in the dictionary otherwise add it
  67917. * @param key the key to get the value from
  67918. * @param val if there's no such key/value pair in the dictionary add it with this value
  67919. * @return the value corresponding to the key
  67920. */
  67921. getOrAdd(key: string, val: T): T;
  67922. /**
  67923. * Check if there's a given key in the dictionary
  67924. * @param key the key to check for
  67925. * @return true if the key is present, false otherwise
  67926. */
  67927. contains(key: string): boolean;
  67928. /**
  67929. * Add a new key and its corresponding value
  67930. * @param key the key to add
  67931. * @param value the value corresponding to the key
  67932. * @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
  67933. */
  67934. add(key: string, value: T): boolean;
  67935. /**
  67936. * Update a specific value associated to a key
  67937. * @param key defines the key to use
  67938. * @param value defines the value to store
  67939. * @returns true if the value was updated (or false if the key was not found)
  67940. */
  67941. set(key: string, value: T): boolean;
  67942. /**
  67943. * Get the element of the given key and remove it from the dictionary
  67944. * @param key defines the key to search
  67945. * @returns the value associated with the key or null if not found
  67946. */
  67947. getAndRemove(key: string): Nullable<T>;
  67948. /**
  67949. * Remove a key/value from the dictionary.
  67950. * @param key the key to remove
  67951. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  67952. */
  67953. remove(key: string): boolean;
  67954. /**
  67955. * Clear the whole content of the dictionary
  67956. */
  67957. clear(): void;
  67958. /**
  67959. * Gets the current count
  67960. */
  67961. readonly count: number;
  67962. /**
  67963. * Execute a callback on each key/val of the dictionary.
  67964. * Note that you can remove any element in this dictionary in the callback implementation
  67965. * @param callback the callback to execute on a given key/value pair
  67966. */
  67967. forEach(callback: (key: string, val: T) => void): void;
  67968. /**
  67969. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  67970. * If the callback returns null or undefined the method will iterate to the next key/value pair
  67971. * Note that you can remove any element in this dictionary in the callback implementation
  67972. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  67973. * @returns the first item
  67974. */
  67975. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  67976. private _count;
  67977. private _data;
  67978. }
  67979. }
  67980. declare module BABYLON {
  67981. /**
  67982. * Helper class that provides a small promise polyfill
  67983. */
  67984. export class PromisePolyfill {
  67985. /**
  67986. * Static function used to check if the polyfill is required
  67987. * If this is the case then the function will inject the polyfill to window.Promise
  67988. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  67989. */
  67990. static Apply(force?: boolean): void;
  67991. }
  67992. }
  67993. declare module BABYLON {
  67994. /**
  67995. * Class used to store data that will be store in GPU memory
  67996. */
  67997. export class Buffer {
  67998. private _engine;
  67999. private _buffer;
  68000. /** @hidden */
  68001. _data: Nullable<DataArray>;
  68002. private _updatable;
  68003. private _instanced;
  68004. /**
  68005. * Gets the byte stride.
  68006. */
  68007. readonly byteStride: number;
  68008. /**
  68009. * Constructor
  68010. * @param engine the engine
  68011. * @param data the data to use for this buffer
  68012. * @param updatable whether the data is updatable
  68013. * @param stride the stride (optional)
  68014. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68015. * @param instanced whether the buffer is instanced (optional)
  68016. * @param useBytes set to true if the stride in in bytes (optional)
  68017. */
  68018. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  68019. /**
  68020. * Create a new VertexBuffer based on the current buffer
  68021. * @param kind defines the vertex buffer kind (position, normal, etc.)
  68022. * @param offset defines offset in the buffer (0 by default)
  68023. * @param size defines the size in floats of attributes (position is 3 for instance)
  68024. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  68025. * @param instanced defines if the vertex buffer contains indexed data
  68026. * @param useBytes defines if the offset and stride are in bytes
  68027. * @returns the new vertex buffer
  68028. */
  68029. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  68030. /**
  68031. * Gets a boolean indicating if the Buffer is updatable?
  68032. * @returns true if the buffer is updatable
  68033. */
  68034. isUpdatable(): boolean;
  68035. /**
  68036. * Gets current buffer's data
  68037. * @returns a DataArray or null
  68038. */
  68039. getData(): Nullable<DataArray>;
  68040. /**
  68041. * Gets underlying native buffer
  68042. * @returns underlying native buffer
  68043. */
  68044. getBuffer(): Nullable<DataBuffer>;
  68045. /**
  68046. * Gets the stride in float32 units (i.e. byte stride / 4).
  68047. * May not be an integer if the byte stride is not divisible by 4.
  68048. * DEPRECATED. Use byteStride instead.
  68049. * @returns the stride in float32 units
  68050. */
  68051. getStrideSize(): number;
  68052. /**
  68053. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68054. * @param data defines the data to store
  68055. */
  68056. create(data?: Nullable<DataArray>): void;
  68057. /** @hidden */
  68058. _rebuild(): void;
  68059. /**
  68060. * Update current buffer data
  68061. * @param data defines the data to store
  68062. */
  68063. update(data: DataArray): void;
  68064. /**
  68065. * Updates the data directly.
  68066. * @param data the new data
  68067. * @param offset the new offset
  68068. * @param vertexCount the vertex count (optional)
  68069. * @param useBytes set to true if the offset is in bytes
  68070. */
  68071. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  68072. /**
  68073. * Release all resources
  68074. */
  68075. dispose(): void;
  68076. }
  68077. /**
  68078. * Specialized buffer used to store vertex data
  68079. */
  68080. export class VertexBuffer {
  68081. /** @hidden */
  68082. _buffer: Buffer;
  68083. private _kind;
  68084. private _size;
  68085. private _ownsBuffer;
  68086. private _instanced;
  68087. private _instanceDivisor;
  68088. /**
  68089. * The byte type.
  68090. */
  68091. static readonly BYTE: number;
  68092. /**
  68093. * The unsigned byte type.
  68094. */
  68095. static readonly UNSIGNED_BYTE: number;
  68096. /**
  68097. * The short type.
  68098. */
  68099. static readonly SHORT: number;
  68100. /**
  68101. * The unsigned short type.
  68102. */
  68103. static readonly UNSIGNED_SHORT: number;
  68104. /**
  68105. * The integer type.
  68106. */
  68107. static readonly INT: number;
  68108. /**
  68109. * The unsigned integer type.
  68110. */
  68111. static readonly UNSIGNED_INT: number;
  68112. /**
  68113. * The float type.
  68114. */
  68115. static readonly FLOAT: number;
  68116. /**
  68117. * Gets or sets the instance divisor when in instanced mode
  68118. */
  68119. instanceDivisor: number;
  68120. /**
  68121. * Gets the byte stride.
  68122. */
  68123. readonly byteStride: number;
  68124. /**
  68125. * Gets the byte offset.
  68126. */
  68127. readonly byteOffset: number;
  68128. /**
  68129. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  68130. */
  68131. readonly normalized: boolean;
  68132. /**
  68133. * Gets the data type of each component in the array.
  68134. */
  68135. readonly type: number;
  68136. /**
  68137. * Constructor
  68138. * @param engine the engine
  68139. * @param data the data to use for this vertex buffer
  68140. * @param kind the vertex buffer kind
  68141. * @param updatable whether the data is updatable
  68142. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68143. * @param stride the stride (optional)
  68144. * @param instanced whether the buffer is instanced (optional)
  68145. * @param offset the offset of the data (optional)
  68146. * @param size the number of components (optional)
  68147. * @param type the type of the component (optional)
  68148. * @param normalized whether the data contains normalized data (optional)
  68149. * @param useBytes set to true if stride and offset are in bytes (optional)
  68150. */
  68151. 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);
  68152. /** @hidden */
  68153. _rebuild(): void;
  68154. /**
  68155. * Returns the kind of the VertexBuffer (string)
  68156. * @returns a string
  68157. */
  68158. getKind(): string;
  68159. /**
  68160. * Gets a boolean indicating if the VertexBuffer is updatable?
  68161. * @returns true if the buffer is updatable
  68162. */
  68163. isUpdatable(): boolean;
  68164. /**
  68165. * Gets current buffer's data
  68166. * @returns a DataArray or null
  68167. */
  68168. getData(): Nullable<DataArray>;
  68169. /**
  68170. * Gets underlying native buffer
  68171. * @returns underlying native buffer
  68172. */
  68173. getBuffer(): Nullable<DataBuffer>;
  68174. /**
  68175. * Gets the stride in float32 units (i.e. byte stride / 4).
  68176. * May not be an integer if the byte stride is not divisible by 4.
  68177. * DEPRECATED. Use byteStride instead.
  68178. * @returns the stride in float32 units
  68179. */
  68180. getStrideSize(): number;
  68181. /**
  68182. * Returns the offset as a multiple of the type byte length.
  68183. * DEPRECATED. Use byteOffset instead.
  68184. * @returns the offset in bytes
  68185. */
  68186. getOffset(): number;
  68187. /**
  68188. * Returns the number of components per vertex attribute (integer)
  68189. * @returns the size in float
  68190. */
  68191. getSize(): number;
  68192. /**
  68193. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  68194. * @returns true if this buffer is instanced
  68195. */
  68196. getIsInstanced(): boolean;
  68197. /**
  68198. * Returns the instancing divisor, zero for non-instanced (integer).
  68199. * @returns a number
  68200. */
  68201. getInstanceDivisor(): number;
  68202. /**
  68203. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68204. * @param data defines the data to store
  68205. */
  68206. create(data?: DataArray): void;
  68207. /**
  68208. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  68209. * This function will create a new buffer if the current one is not updatable
  68210. * @param data defines the data to store
  68211. */
  68212. update(data: DataArray): void;
  68213. /**
  68214. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  68215. * Returns the directly updated WebGLBuffer.
  68216. * @param data the new data
  68217. * @param offset the new offset
  68218. * @param useBytes set to true if the offset is in bytes
  68219. */
  68220. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  68221. /**
  68222. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  68223. */
  68224. dispose(): void;
  68225. /**
  68226. * Enumerates each value of this vertex buffer as numbers.
  68227. * @param count the number of values to enumerate
  68228. * @param callback the callback function called for each value
  68229. */
  68230. forEach(count: number, callback: (value: number, index: number) => void): void;
  68231. /**
  68232. * Positions
  68233. */
  68234. static readonly PositionKind: string;
  68235. /**
  68236. * Normals
  68237. */
  68238. static readonly NormalKind: string;
  68239. /**
  68240. * Tangents
  68241. */
  68242. static readonly TangentKind: string;
  68243. /**
  68244. * Texture coordinates
  68245. */
  68246. static readonly UVKind: string;
  68247. /**
  68248. * Texture coordinates 2
  68249. */
  68250. static readonly UV2Kind: string;
  68251. /**
  68252. * Texture coordinates 3
  68253. */
  68254. static readonly UV3Kind: string;
  68255. /**
  68256. * Texture coordinates 4
  68257. */
  68258. static readonly UV4Kind: string;
  68259. /**
  68260. * Texture coordinates 5
  68261. */
  68262. static readonly UV5Kind: string;
  68263. /**
  68264. * Texture coordinates 6
  68265. */
  68266. static readonly UV6Kind: string;
  68267. /**
  68268. * Colors
  68269. */
  68270. static readonly ColorKind: string;
  68271. /**
  68272. * Matrix indices (for bones)
  68273. */
  68274. static readonly MatricesIndicesKind: string;
  68275. /**
  68276. * Matrix weights (for bones)
  68277. */
  68278. static readonly MatricesWeightsKind: string;
  68279. /**
  68280. * Additional matrix indices (for bones)
  68281. */
  68282. static readonly MatricesIndicesExtraKind: string;
  68283. /**
  68284. * Additional matrix weights (for bones)
  68285. */
  68286. static readonly MatricesWeightsExtraKind: string;
  68287. /**
  68288. * Deduces the stride given a kind.
  68289. * @param kind The kind string to deduce
  68290. * @returns The deduced stride
  68291. */
  68292. static DeduceStride(kind: string): number;
  68293. /**
  68294. * Gets the byte length of the given type.
  68295. * @param type the type
  68296. * @returns the number of bytes
  68297. */
  68298. static GetTypeByteLength(type: number): number;
  68299. /**
  68300. * Enumerates each value of the given parameters as numbers.
  68301. * @param data the data to enumerate
  68302. * @param byteOffset the byte offset of the data
  68303. * @param byteStride the byte stride of the data
  68304. * @param componentCount the number of components per element
  68305. * @param componentType the type of the component
  68306. * @param count the total number of components
  68307. * @param normalized whether the data is normalized
  68308. * @param callback the callback function called for each value
  68309. */
  68310. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  68311. private static _GetFloatValue;
  68312. }
  68313. }
  68314. declare module BABYLON {
  68315. /**
  68316. * Class representing spherical harmonics coefficients to the 3rd degree
  68317. */
  68318. export class SphericalHarmonics {
  68319. /**
  68320. * Defines whether or not the harmonics have been prescaled for rendering.
  68321. */
  68322. preScaled: boolean;
  68323. /**
  68324. * The l0,0 coefficients of the spherical harmonics
  68325. */
  68326. l00: Vector3;
  68327. /**
  68328. * The l1,-1 coefficients of the spherical harmonics
  68329. */
  68330. l1_1: Vector3;
  68331. /**
  68332. * The l1,0 coefficients of the spherical harmonics
  68333. */
  68334. l10: Vector3;
  68335. /**
  68336. * The l1,1 coefficients of the spherical harmonics
  68337. */
  68338. l11: Vector3;
  68339. /**
  68340. * The l2,-2 coefficients of the spherical harmonics
  68341. */
  68342. l2_2: Vector3;
  68343. /**
  68344. * The l2,-1 coefficients of the spherical harmonics
  68345. */
  68346. l2_1: Vector3;
  68347. /**
  68348. * The l2,0 coefficients of the spherical harmonics
  68349. */
  68350. l20: Vector3;
  68351. /**
  68352. * The l2,1 coefficients of the spherical harmonics
  68353. */
  68354. l21: Vector3;
  68355. /**
  68356. * The l2,2 coefficients of the spherical harmonics
  68357. */
  68358. l22: Vector3;
  68359. /**
  68360. * Adds a light to the spherical harmonics
  68361. * @param direction the direction of the light
  68362. * @param color the color of the light
  68363. * @param deltaSolidAngle the delta solid angle of the light
  68364. */
  68365. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  68366. /**
  68367. * Scales the spherical harmonics by the given amount
  68368. * @param scale the amount to scale
  68369. */
  68370. scaleInPlace(scale: number): void;
  68371. /**
  68372. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  68373. *
  68374. * ```
  68375. * E_lm = A_l * L_lm
  68376. * ```
  68377. *
  68378. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  68379. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  68380. * the scaling factors are given in equation 9.
  68381. */
  68382. convertIncidentRadianceToIrradiance(): void;
  68383. /**
  68384. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  68385. *
  68386. * ```
  68387. * L = (1/pi) * E * rho
  68388. * ```
  68389. *
  68390. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  68391. */
  68392. convertIrradianceToLambertianRadiance(): void;
  68393. /**
  68394. * Integrates the reconstruction coefficients directly in to the SH preventing further
  68395. * required operations at run time.
  68396. *
  68397. * This is simply done by scaling back the SH with Ylm constants parameter.
  68398. * The trigonometric part being applied by the shader at run time.
  68399. */
  68400. preScaleForRendering(): void;
  68401. /**
  68402. * Constructs a spherical harmonics from an array.
  68403. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  68404. * @returns the spherical harmonics
  68405. */
  68406. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  68407. /**
  68408. * Gets the spherical harmonics from polynomial
  68409. * @param polynomial the spherical polynomial
  68410. * @returns the spherical harmonics
  68411. */
  68412. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  68413. }
  68414. /**
  68415. * Class representing spherical polynomial coefficients to the 3rd degree
  68416. */
  68417. export class SphericalPolynomial {
  68418. private _harmonics;
  68419. /**
  68420. * The spherical harmonics used to create the polynomials.
  68421. */
  68422. readonly preScaledHarmonics: SphericalHarmonics;
  68423. /**
  68424. * The x coefficients of the spherical polynomial
  68425. */
  68426. x: Vector3;
  68427. /**
  68428. * The y coefficients of the spherical polynomial
  68429. */
  68430. y: Vector3;
  68431. /**
  68432. * The z coefficients of the spherical polynomial
  68433. */
  68434. z: Vector3;
  68435. /**
  68436. * The xx coefficients of the spherical polynomial
  68437. */
  68438. xx: Vector3;
  68439. /**
  68440. * The yy coefficients of the spherical polynomial
  68441. */
  68442. yy: Vector3;
  68443. /**
  68444. * The zz coefficients of the spherical polynomial
  68445. */
  68446. zz: Vector3;
  68447. /**
  68448. * The xy coefficients of the spherical polynomial
  68449. */
  68450. xy: Vector3;
  68451. /**
  68452. * The yz coefficients of the spherical polynomial
  68453. */
  68454. yz: Vector3;
  68455. /**
  68456. * The zx coefficients of the spherical polynomial
  68457. */
  68458. zx: Vector3;
  68459. /**
  68460. * Adds an ambient color to the spherical polynomial
  68461. * @param color the color to add
  68462. */
  68463. addAmbient(color: Color3): void;
  68464. /**
  68465. * Scales the spherical polynomial by the given amount
  68466. * @param scale the amount to scale
  68467. */
  68468. scaleInPlace(scale: number): void;
  68469. /**
  68470. * Gets the spherical polynomial from harmonics
  68471. * @param harmonics the spherical harmonics
  68472. * @returns the spherical polynomial
  68473. */
  68474. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  68475. /**
  68476. * Constructs a spherical polynomial from an array.
  68477. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  68478. * @returns the spherical polynomial
  68479. */
  68480. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  68481. }
  68482. }
  68483. declare module BABYLON {
  68484. /**
  68485. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  68486. */
  68487. export interface CubeMapInfo {
  68488. /**
  68489. * The pixel array for the front face.
  68490. * This is stored in format, left to right, up to down format.
  68491. */
  68492. front: Nullable<ArrayBufferView>;
  68493. /**
  68494. * The pixel array for the back face.
  68495. * This is stored in format, left to right, up to down format.
  68496. */
  68497. back: Nullable<ArrayBufferView>;
  68498. /**
  68499. * The pixel array for the left face.
  68500. * This is stored in format, left to right, up to down format.
  68501. */
  68502. left: Nullable<ArrayBufferView>;
  68503. /**
  68504. * The pixel array for the right face.
  68505. * This is stored in format, left to right, up to down format.
  68506. */
  68507. right: Nullable<ArrayBufferView>;
  68508. /**
  68509. * The pixel array for the up face.
  68510. * This is stored in format, left to right, up to down format.
  68511. */
  68512. up: Nullable<ArrayBufferView>;
  68513. /**
  68514. * The pixel array for the down face.
  68515. * This is stored in format, left to right, up to down format.
  68516. */
  68517. down: Nullable<ArrayBufferView>;
  68518. /**
  68519. * The size of the cubemap stored.
  68520. *
  68521. * Each faces will be size * size pixels.
  68522. */
  68523. size: number;
  68524. /**
  68525. * The format of the texture.
  68526. *
  68527. * RGBA, RGB.
  68528. */
  68529. format: number;
  68530. /**
  68531. * The type of the texture data.
  68532. *
  68533. * UNSIGNED_INT, FLOAT.
  68534. */
  68535. type: number;
  68536. /**
  68537. * Specifies whether the texture is in gamma space.
  68538. */
  68539. gammaSpace: boolean;
  68540. }
  68541. /**
  68542. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  68543. */
  68544. export class PanoramaToCubeMapTools {
  68545. private static FACE_FRONT;
  68546. private static FACE_BACK;
  68547. private static FACE_RIGHT;
  68548. private static FACE_LEFT;
  68549. private static FACE_DOWN;
  68550. private static FACE_UP;
  68551. /**
  68552. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  68553. *
  68554. * @param float32Array The source data.
  68555. * @param inputWidth The width of the input panorama.
  68556. * @param inputHeight The height of the input panorama.
  68557. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  68558. * @return The cubemap data
  68559. */
  68560. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  68561. private static CreateCubemapTexture;
  68562. private static CalcProjectionSpherical;
  68563. }
  68564. }
  68565. declare module BABYLON {
  68566. /**
  68567. * Helper class dealing with the extraction of spherical polynomial dataArray
  68568. * from a cube map.
  68569. */
  68570. export class CubeMapToSphericalPolynomialTools {
  68571. private static FileFaces;
  68572. /**
  68573. * Converts a texture to the according Spherical Polynomial data.
  68574. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68575. *
  68576. * @param texture The texture to extract the information from.
  68577. * @return The Spherical Polynomial data.
  68578. */
  68579. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  68580. /**
  68581. * Converts a cubemap to the according Spherical Polynomial data.
  68582. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68583. *
  68584. * @param cubeInfo The Cube map to extract the information from.
  68585. * @return The Spherical Polynomial data.
  68586. */
  68587. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  68588. }
  68589. }
  68590. declare module BABYLON {
  68591. /**
  68592. * The engine store class is responsible to hold all the instances of Engine and Scene created
  68593. * during the life time of the application.
  68594. */
  68595. export class EngineStore {
  68596. /** Gets the list of created engines */
  68597. static Instances: Engine[];
  68598. /** @hidden */
  68599. static _LastCreatedScene: Nullable<Scene>;
  68600. /**
  68601. * Gets the latest created engine
  68602. */
  68603. static readonly LastCreatedEngine: Nullable<Engine>;
  68604. /**
  68605. * Gets the latest created scene
  68606. */
  68607. static readonly LastCreatedScene: Nullable<Scene>;
  68608. }
  68609. }
  68610. declare module BABYLON {
  68611. /**
  68612. * Define options used to create a render target texture
  68613. */
  68614. export class RenderTargetCreationOptions {
  68615. /**
  68616. * Specifies is mipmaps must be generated
  68617. */
  68618. generateMipMaps?: boolean;
  68619. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68620. generateDepthBuffer?: boolean;
  68621. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68622. generateStencilBuffer?: boolean;
  68623. /** Defines texture type (int by default) */
  68624. type?: number;
  68625. /** Defines sampling mode (trilinear by default) */
  68626. samplingMode?: number;
  68627. /** Defines format (RGBA by default) */
  68628. format?: number;
  68629. }
  68630. }
  68631. declare module BABYLON {
  68632. /**
  68633. * @hidden
  68634. **/
  68635. export class _AlphaState {
  68636. private _isAlphaBlendDirty;
  68637. private _isBlendFunctionParametersDirty;
  68638. private _isBlendEquationParametersDirty;
  68639. private _isBlendConstantsDirty;
  68640. private _alphaBlend;
  68641. private _blendFunctionParameters;
  68642. private _blendEquationParameters;
  68643. private _blendConstants;
  68644. /**
  68645. * Initializes the state.
  68646. */
  68647. constructor();
  68648. readonly isDirty: boolean;
  68649. alphaBlend: boolean;
  68650. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  68651. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  68652. setAlphaEquationParameters(rgb: number, alpha: number): void;
  68653. reset(): void;
  68654. apply(gl: WebGLRenderingContext): void;
  68655. }
  68656. }
  68657. declare module BABYLON {
  68658. /**
  68659. * @hidden
  68660. **/
  68661. export class _DepthCullingState {
  68662. private _isDepthTestDirty;
  68663. private _isDepthMaskDirty;
  68664. private _isDepthFuncDirty;
  68665. private _isCullFaceDirty;
  68666. private _isCullDirty;
  68667. private _isZOffsetDirty;
  68668. private _isFrontFaceDirty;
  68669. private _depthTest;
  68670. private _depthMask;
  68671. private _depthFunc;
  68672. private _cull;
  68673. private _cullFace;
  68674. private _zOffset;
  68675. private _frontFace;
  68676. /**
  68677. * Initializes the state.
  68678. */
  68679. constructor();
  68680. readonly isDirty: boolean;
  68681. zOffset: number;
  68682. cullFace: Nullable<number>;
  68683. cull: Nullable<boolean>;
  68684. depthFunc: Nullable<number>;
  68685. depthMask: boolean;
  68686. depthTest: boolean;
  68687. frontFace: Nullable<number>;
  68688. reset(): void;
  68689. apply(gl: WebGLRenderingContext): void;
  68690. }
  68691. }
  68692. declare module BABYLON {
  68693. /**
  68694. * @hidden
  68695. **/
  68696. export class _StencilState {
  68697. /** 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 */
  68698. static readonly ALWAYS: number;
  68699. /** Passed to stencilOperation to specify that stencil value must be kept */
  68700. static readonly KEEP: number;
  68701. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68702. static readonly REPLACE: number;
  68703. private _isStencilTestDirty;
  68704. private _isStencilMaskDirty;
  68705. private _isStencilFuncDirty;
  68706. private _isStencilOpDirty;
  68707. private _stencilTest;
  68708. private _stencilMask;
  68709. private _stencilFunc;
  68710. private _stencilFuncRef;
  68711. private _stencilFuncMask;
  68712. private _stencilOpStencilFail;
  68713. private _stencilOpDepthFail;
  68714. private _stencilOpStencilDepthPass;
  68715. readonly isDirty: boolean;
  68716. stencilFunc: number;
  68717. stencilFuncRef: number;
  68718. stencilFuncMask: number;
  68719. stencilOpStencilFail: number;
  68720. stencilOpDepthFail: number;
  68721. stencilOpStencilDepthPass: number;
  68722. stencilMask: number;
  68723. stencilTest: boolean;
  68724. constructor();
  68725. reset(): void;
  68726. apply(gl: WebGLRenderingContext): void;
  68727. }
  68728. }
  68729. declare module BABYLON {
  68730. /**
  68731. * @hidden
  68732. **/
  68733. export class _TimeToken {
  68734. _startTimeQuery: Nullable<WebGLQuery>;
  68735. _endTimeQuery: Nullable<WebGLQuery>;
  68736. _timeElapsedQuery: Nullable<WebGLQuery>;
  68737. _timeElapsedQueryEnded: boolean;
  68738. }
  68739. }
  68740. declare module BABYLON {
  68741. /**
  68742. * Class used to store data associated with WebGL texture data for the engine
  68743. * This class should not be used directly
  68744. */
  68745. export class InternalTexture {
  68746. /** @hidden */
  68747. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  68748. /**
  68749. * The source of the texture data is unknown
  68750. */
  68751. static DATASOURCE_UNKNOWN: number;
  68752. /**
  68753. * Texture data comes from an URL
  68754. */
  68755. static DATASOURCE_URL: number;
  68756. /**
  68757. * Texture data is only used for temporary storage
  68758. */
  68759. static DATASOURCE_TEMP: number;
  68760. /**
  68761. * Texture data comes from raw data (ArrayBuffer)
  68762. */
  68763. static DATASOURCE_RAW: number;
  68764. /**
  68765. * Texture content is dynamic (video or dynamic texture)
  68766. */
  68767. static DATASOURCE_DYNAMIC: number;
  68768. /**
  68769. * Texture content is generated by rendering to it
  68770. */
  68771. static DATASOURCE_RENDERTARGET: number;
  68772. /**
  68773. * Texture content is part of a multi render target process
  68774. */
  68775. static DATASOURCE_MULTIRENDERTARGET: number;
  68776. /**
  68777. * Texture data comes from a cube data file
  68778. */
  68779. static DATASOURCE_CUBE: number;
  68780. /**
  68781. * Texture data comes from a raw cube data
  68782. */
  68783. static DATASOURCE_CUBERAW: number;
  68784. /**
  68785. * Texture data come from a prefiltered cube data file
  68786. */
  68787. static DATASOURCE_CUBEPREFILTERED: number;
  68788. /**
  68789. * Texture content is raw 3D data
  68790. */
  68791. static DATASOURCE_RAW3D: number;
  68792. /**
  68793. * Texture content is a depth texture
  68794. */
  68795. static DATASOURCE_DEPTHTEXTURE: number;
  68796. /**
  68797. * Texture data comes from a raw cube data encoded with RGBD
  68798. */
  68799. static DATASOURCE_CUBERAW_RGBD: number;
  68800. /**
  68801. * Defines if the texture is ready
  68802. */
  68803. isReady: boolean;
  68804. /**
  68805. * Defines if the texture is a cube texture
  68806. */
  68807. isCube: boolean;
  68808. /**
  68809. * Defines if the texture contains 3D data
  68810. */
  68811. is3D: boolean;
  68812. /**
  68813. * Defines if the texture contains multiview data
  68814. */
  68815. isMultiview: boolean;
  68816. /**
  68817. * Gets the URL used to load this texture
  68818. */
  68819. url: string;
  68820. /**
  68821. * Gets the sampling mode of the texture
  68822. */
  68823. samplingMode: number;
  68824. /**
  68825. * Gets a boolean indicating if the texture needs mipmaps generation
  68826. */
  68827. generateMipMaps: boolean;
  68828. /**
  68829. * Gets the number of samples used by the texture (WebGL2+ only)
  68830. */
  68831. samples: number;
  68832. /**
  68833. * Gets the type of the texture (int, float...)
  68834. */
  68835. type: number;
  68836. /**
  68837. * Gets the format of the texture (RGB, RGBA...)
  68838. */
  68839. format: number;
  68840. /**
  68841. * Observable called when the texture is loaded
  68842. */
  68843. onLoadedObservable: Observable<InternalTexture>;
  68844. /**
  68845. * Gets the width of the texture
  68846. */
  68847. width: number;
  68848. /**
  68849. * Gets the height of the texture
  68850. */
  68851. height: number;
  68852. /**
  68853. * Gets the depth of the texture
  68854. */
  68855. depth: number;
  68856. /**
  68857. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  68858. */
  68859. baseWidth: number;
  68860. /**
  68861. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  68862. */
  68863. baseHeight: number;
  68864. /**
  68865. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  68866. */
  68867. baseDepth: number;
  68868. /**
  68869. * Gets a boolean indicating if the texture is inverted on Y axis
  68870. */
  68871. invertY: boolean;
  68872. /** @hidden */
  68873. _invertVScale: boolean;
  68874. /** @hidden */
  68875. _associatedChannel: number;
  68876. /** @hidden */
  68877. _dataSource: number;
  68878. /** @hidden */
  68879. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  68880. /** @hidden */
  68881. _bufferView: Nullable<ArrayBufferView>;
  68882. /** @hidden */
  68883. _bufferViewArray: Nullable<ArrayBufferView[]>;
  68884. /** @hidden */
  68885. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  68886. /** @hidden */
  68887. _size: number;
  68888. /** @hidden */
  68889. _extension: string;
  68890. /** @hidden */
  68891. _files: Nullable<string[]>;
  68892. /** @hidden */
  68893. _workingCanvas: Nullable<HTMLCanvasElement>;
  68894. /** @hidden */
  68895. _workingContext: Nullable<CanvasRenderingContext2D>;
  68896. /** @hidden */
  68897. _framebuffer: Nullable<WebGLFramebuffer>;
  68898. /** @hidden */
  68899. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  68900. /** @hidden */
  68901. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  68902. /** @hidden */
  68903. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  68904. /** @hidden */
  68905. _attachments: Nullable<number[]>;
  68906. /** @hidden */
  68907. _cachedCoordinatesMode: Nullable<number>;
  68908. /** @hidden */
  68909. _cachedWrapU: Nullable<number>;
  68910. /** @hidden */
  68911. _cachedWrapV: Nullable<number>;
  68912. /** @hidden */
  68913. _cachedWrapR: Nullable<number>;
  68914. /** @hidden */
  68915. _cachedAnisotropicFilteringLevel: Nullable<number>;
  68916. /** @hidden */
  68917. _isDisabled: boolean;
  68918. /** @hidden */
  68919. _compression: Nullable<string>;
  68920. /** @hidden */
  68921. _generateStencilBuffer: boolean;
  68922. /** @hidden */
  68923. _generateDepthBuffer: boolean;
  68924. /** @hidden */
  68925. _comparisonFunction: number;
  68926. /** @hidden */
  68927. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  68928. /** @hidden */
  68929. _lodGenerationScale: number;
  68930. /** @hidden */
  68931. _lodGenerationOffset: number;
  68932. /** @hidden */
  68933. _colorTextureArray: Nullable<WebGLTexture>;
  68934. /** @hidden */
  68935. _depthStencilTextureArray: Nullable<WebGLTexture>;
  68936. /** @hidden */
  68937. _lodTextureHigh: Nullable<BaseTexture>;
  68938. /** @hidden */
  68939. _lodTextureMid: Nullable<BaseTexture>;
  68940. /** @hidden */
  68941. _lodTextureLow: Nullable<BaseTexture>;
  68942. /** @hidden */
  68943. _isRGBD: boolean;
  68944. /** @hidden */
  68945. _linearSpecularLOD: boolean;
  68946. /** @hidden */
  68947. _irradianceTexture: Nullable<BaseTexture>;
  68948. /** @hidden */
  68949. _webGLTexture: Nullable<WebGLTexture>;
  68950. /** @hidden */
  68951. _references: number;
  68952. private _engine;
  68953. /**
  68954. * Gets the Engine the texture belongs to.
  68955. * @returns The babylon engine
  68956. */
  68957. getEngine(): Engine;
  68958. /**
  68959. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  68960. */
  68961. readonly dataSource: number;
  68962. /**
  68963. * Creates a new InternalTexture
  68964. * @param engine defines the engine to use
  68965. * @param dataSource defines the type of data that will be used
  68966. * @param delayAllocation if the texture allocation should be delayed (default: false)
  68967. */
  68968. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  68969. /**
  68970. * Increments the number of references (ie. the number of Texture that point to it)
  68971. */
  68972. incrementReferences(): void;
  68973. /**
  68974. * Change the size of the texture (not the size of the content)
  68975. * @param width defines the new width
  68976. * @param height defines the new height
  68977. * @param depth defines the new depth (1 by default)
  68978. */
  68979. updateSize(width: int, height: int, depth?: int): void;
  68980. /** @hidden */
  68981. _rebuild(): void;
  68982. /** @hidden */
  68983. _swapAndDie(target: InternalTexture): void;
  68984. /**
  68985. * Dispose the current allocated resources
  68986. */
  68987. dispose(): void;
  68988. }
  68989. }
  68990. declare module BABYLON {
  68991. /**
  68992. * This represents the main contract an easing function should follow.
  68993. * Easing functions are used throughout the animation system.
  68994. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68995. */
  68996. export interface IEasingFunction {
  68997. /**
  68998. * Given an input gradient between 0 and 1, this returns the corrseponding value
  68999. * of the easing function.
  69000. * The link below provides some of the most common examples of easing functions.
  69001. * @see https://easings.net/
  69002. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69003. * @returns the corresponding value on the curve defined by the easing function
  69004. */
  69005. ease(gradient: number): number;
  69006. }
  69007. /**
  69008. * Base class used for every default easing function.
  69009. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69010. */
  69011. export class EasingFunction implements IEasingFunction {
  69012. /**
  69013. * Interpolation follows the mathematical formula associated with the easing function.
  69014. */
  69015. static readonly EASINGMODE_EASEIN: number;
  69016. /**
  69017. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69018. */
  69019. static readonly EASINGMODE_EASEOUT: number;
  69020. /**
  69021. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69022. */
  69023. static readonly EASINGMODE_EASEINOUT: number;
  69024. private _easingMode;
  69025. /**
  69026. * Sets the easing mode of the current function.
  69027. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69028. */
  69029. setEasingMode(easingMode: number): void;
  69030. /**
  69031. * Gets the current easing mode.
  69032. * @returns the easing mode
  69033. */
  69034. getEasingMode(): number;
  69035. /**
  69036. * @hidden
  69037. */
  69038. easeInCore(gradient: number): number;
  69039. /**
  69040. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69041. * of the easing function.
  69042. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69043. * @returns the corresponding value on the curve defined by the easing function
  69044. */
  69045. ease(gradient: number): number;
  69046. }
  69047. /**
  69048. * Easing function with a circle shape (see link below).
  69049. * @see https://easings.net/#easeInCirc
  69050. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69051. */
  69052. export class CircleEase extends EasingFunction implements IEasingFunction {
  69053. /** @hidden */
  69054. easeInCore(gradient: number): number;
  69055. }
  69056. /**
  69057. * Easing function with a ease back shape (see link below).
  69058. * @see https://easings.net/#easeInBack
  69059. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69060. */
  69061. export class BackEase extends EasingFunction implements IEasingFunction {
  69062. /** Defines the amplitude of the function */
  69063. amplitude: number;
  69064. /**
  69065. * Instantiates a back ease easing
  69066. * @see https://easings.net/#easeInBack
  69067. * @param amplitude Defines the amplitude of the function
  69068. */
  69069. constructor(
  69070. /** Defines the amplitude of the function */
  69071. amplitude?: number);
  69072. /** @hidden */
  69073. easeInCore(gradient: number): number;
  69074. }
  69075. /**
  69076. * Easing function with a bouncing shape (see link below).
  69077. * @see https://easings.net/#easeInBounce
  69078. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69079. */
  69080. export class BounceEase extends EasingFunction implements IEasingFunction {
  69081. /** Defines the number of bounces */
  69082. bounces: number;
  69083. /** Defines the amplitude of the bounce */
  69084. bounciness: number;
  69085. /**
  69086. * Instantiates a bounce easing
  69087. * @see https://easings.net/#easeInBounce
  69088. * @param bounces Defines the number of bounces
  69089. * @param bounciness Defines the amplitude of the bounce
  69090. */
  69091. constructor(
  69092. /** Defines the number of bounces */
  69093. bounces?: number,
  69094. /** Defines the amplitude of the bounce */
  69095. bounciness?: number);
  69096. /** @hidden */
  69097. easeInCore(gradient: number): number;
  69098. }
  69099. /**
  69100. * Easing function with a power of 3 shape (see link below).
  69101. * @see https://easings.net/#easeInCubic
  69102. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69103. */
  69104. export class CubicEase extends EasingFunction implements IEasingFunction {
  69105. /** @hidden */
  69106. easeInCore(gradient: number): number;
  69107. }
  69108. /**
  69109. * Easing function with an elastic shape (see link below).
  69110. * @see https://easings.net/#easeInElastic
  69111. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69112. */
  69113. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69114. /** Defines the number of oscillations*/
  69115. oscillations: number;
  69116. /** Defines the amplitude of the oscillations*/
  69117. springiness: number;
  69118. /**
  69119. * Instantiates an elastic easing function
  69120. * @see https://easings.net/#easeInElastic
  69121. * @param oscillations Defines the number of oscillations
  69122. * @param springiness Defines the amplitude of the oscillations
  69123. */
  69124. constructor(
  69125. /** Defines the number of oscillations*/
  69126. oscillations?: number,
  69127. /** Defines the amplitude of the oscillations*/
  69128. springiness?: number);
  69129. /** @hidden */
  69130. easeInCore(gradient: number): number;
  69131. }
  69132. /**
  69133. * Easing function with an exponential shape (see link below).
  69134. * @see https://easings.net/#easeInExpo
  69135. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69136. */
  69137. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69138. /** Defines the exponent of the function */
  69139. exponent: number;
  69140. /**
  69141. * Instantiates an exponential easing function
  69142. * @see https://easings.net/#easeInExpo
  69143. * @param exponent Defines the exponent of the function
  69144. */
  69145. constructor(
  69146. /** Defines the exponent of the function */
  69147. exponent?: number);
  69148. /** @hidden */
  69149. easeInCore(gradient: number): number;
  69150. }
  69151. /**
  69152. * Easing function with a power shape (see link below).
  69153. * @see https://easings.net/#easeInQuad
  69154. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69155. */
  69156. export class PowerEase extends EasingFunction implements IEasingFunction {
  69157. /** Defines the power of the function */
  69158. power: number;
  69159. /**
  69160. * Instantiates an power base easing function
  69161. * @see https://easings.net/#easeInQuad
  69162. * @param power Defines the power of the function
  69163. */
  69164. constructor(
  69165. /** Defines the power of the function */
  69166. power?: number);
  69167. /** @hidden */
  69168. easeInCore(gradient: number): number;
  69169. }
  69170. /**
  69171. * Easing function with a power of 2 shape (see link below).
  69172. * @see https://easings.net/#easeInQuad
  69173. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69174. */
  69175. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69176. /** @hidden */
  69177. easeInCore(gradient: number): number;
  69178. }
  69179. /**
  69180. * Easing function with a power of 4 shape (see link below).
  69181. * @see https://easings.net/#easeInQuart
  69182. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69183. */
  69184. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69185. /** @hidden */
  69186. easeInCore(gradient: number): number;
  69187. }
  69188. /**
  69189. * Easing function with a power of 5 shape (see link below).
  69190. * @see https://easings.net/#easeInQuint
  69191. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69192. */
  69193. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69194. /** @hidden */
  69195. easeInCore(gradient: number): number;
  69196. }
  69197. /**
  69198. * Easing function with a sin shape (see link below).
  69199. * @see https://easings.net/#easeInSine
  69200. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69201. */
  69202. export class SineEase extends EasingFunction implements IEasingFunction {
  69203. /** @hidden */
  69204. easeInCore(gradient: number): number;
  69205. }
  69206. /**
  69207. * Easing function with a bezier shape (see link below).
  69208. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69209. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69210. */
  69211. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69212. /** Defines the x component of the start tangent in the bezier curve */
  69213. x1: number;
  69214. /** Defines the y component of the start tangent in the bezier curve */
  69215. y1: number;
  69216. /** Defines the x component of the end tangent in the bezier curve */
  69217. x2: number;
  69218. /** Defines the y component of the end tangent in the bezier curve */
  69219. y2: number;
  69220. /**
  69221. * Instantiates a bezier function
  69222. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69223. * @param x1 Defines the x component of the start tangent in the bezier curve
  69224. * @param y1 Defines the y component of the start tangent in the bezier curve
  69225. * @param x2 Defines the x component of the end tangent in the bezier curve
  69226. * @param y2 Defines the y component of the end tangent in the bezier curve
  69227. */
  69228. constructor(
  69229. /** Defines the x component of the start tangent in the bezier curve */
  69230. x1?: number,
  69231. /** Defines the y component of the start tangent in the bezier curve */
  69232. y1?: number,
  69233. /** Defines the x component of the end tangent in the bezier curve */
  69234. x2?: number,
  69235. /** Defines the y component of the end tangent in the bezier curve */
  69236. y2?: number);
  69237. /** @hidden */
  69238. easeInCore(gradient: number): number;
  69239. }
  69240. }
  69241. declare module BABYLON {
  69242. /**
  69243. * Defines an interface which represents an animation key frame
  69244. */
  69245. export interface IAnimationKey {
  69246. /**
  69247. * Frame of the key frame
  69248. */
  69249. frame: number;
  69250. /**
  69251. * Value at the specifies key frame
  69252. */
  69253. value: any;
  69254. /**
  69255. * The input tangent for the cubic hermite spline
  69256. */
  69257. inTangent?: any;
  69258. /**
  69259. * The output tangent for the cubic hermite spline
  69260. */
  69261. outTangent?: any;
  69262. /**
  69263. * The animation interpolation type
  69264. */
  69265. interpolation?: AnimationKeyInterpolation;
  69266. }
  69267. /**
  69268. * Enum for the animation key frame interpolation type
  69269. */
  69270. export enum AnimationKeyInterpolation {
  69271. /**
  69272. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69273. */
  69274. STEP = 1
  69275. }
  69276. }
  69277. declare module BABYLON {
  69278. /**
  69279. * Represents the range of an animation
  69280. */
  69281. export class AnimationRange {
  69282. /**The name of the animation range**/
  69283. name: string;
  69284. /**The starting frame of the animation */
  69285. from: number;
  69286. /**The ending frame of the animation*/
  69287. to: number;
  69288. /**
  69289. * Initializes the range of an animation
  69290. * @param name The name of the animation range
  69291. * @param from The starting frame of the animation
  69292. * @param to The ending frame of the animation
  69293. */
  69294. constructor(
  69295. /**The name of the animation range**/
  69296. name: string,
  69297. /**The starting frame of the animation */
  69298. from: number,
  69299. /**The ending frame of the animation*/
  69300. to: number);
  69301. /**
  69302. * Makes a copy of the animation range
  69303. * @returns A copy of the animation range
  69304. */
  69305. clone(): AnimationRange;
  69306. }
  69307. }
  69308. declare module BABYLON {
  69309. /**
  69310. * Composed of a frame, and an action function
  69311. */
  69312. export class AnimationEvent {
  69313. /** The frame for which the event is triggered **/
  69314. frame: number;
  69315. /** The event to perform when triggered **/
  69316. action: (currentFrame: number) => void;
  69317. /** Specifies if the event should be triggered only once**/
  69318. onlyOnce?: boolean | undefined;
  69319. /**
  69320. * Specifies if the animation event is done
  69321. */
  69322. isDone: boolean;
  69323. /**
  69324. * Initializes the animation event
  69325. * @param frame The frame for which the event is triggered
  69326. * @param action The event to perform when triggered
  69327. * @param onlyOnce Specifies if the event should be triggered only once
  69328. */
  69329. constructor(
  69330. /** The frame for which the event is triggered **/
  69331. frame: number,
  69332. /** The event to perform when triggered **/
  69333. action: (currentFrame: number) => void,
  69334. /** Specifies if the event should be triggered only once**/
  69335. onlyOnce?: boolean | undefined);
  69336. /** @hidden */
  69337. _clone(): AnimationEvent;
  69338. }
  69339. }
  69340. declare module BABYLON {
  69341. /**
  69342. * Interface used to define a behavior
  69343. */
  69344. export interface Behavior<T> {
  69345. /** gets or sets behavior's name */
  69346. name: string;
  69347. /**
  69348. * Function called when the behavior needs to be initialized (after attaching it to a target)
  69349. */
  69350. init(): void;
  69351. /**
  69352. * Called when the behavior is attached to a target
  69353. * @param target defines the target where the behavior is attached to
  69354. */
  69355. attach(target: T): void;
  69356. /**
  69357. * Called when the behavior is detached from its target
  69358. */
  69359. detach(): void;
  69360. }
  69361. /**
  69362. * Interface implemented by classes supporting behaviors
  69363. */
  69364. export interface IBehaviorAware<T> {
  69365. /**
  69366. * Attach a behavior
  69367. * @param behavior defines the behavior to attach
  69368. * @returns the current host
  69369. */
  69370. addBehavior(behavior: Behavior<T>): T;
  69371. /**
  69372. * Remove a behavior from the current object
  69373. * @param behavior defines the behavior to detach
  69374. * @returns the current host
  69375. */
  69376. removeBehavior(behavior: Behavior<T>): T;
  69377. /**
  69378. * Gets a behavior using its name to search
  69379. * @param name defines the name to search
  69380. * @returns the behavior or null if not found
  69381. */
  69382. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  69383. }
  69384. }
  69385. declare module BABYLON {
  69386. /**
  69387. * @hidden
  69388. */
  69389. export class IntersectionInfo {
  69390. bu: Nullable<number>;
  69391. bv: Nullable<number>;
  69392. distance: number;
  69393. faceId: number;
  69394. subMeshId: number;
  69395. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  69396. }
  69397. }
  69398. declare module BABYLON {
  69399. /**
  69400. * Class used to store bounding sphere information
  69401. */
  69402. export class BoundingSphere {
  69403. /**
  69404. * Gets the center of the bounding sphere in local space
  69405. */
  69406. readonly center: Vector3;
  69407. /**
  69408. * Radius of the bounding sphere in local space
  69409. */
  69410. radius: number;
  69411. /**
  69412. * Gets the center of the bounding sphere in world space
  69413. */
  69414. readonly centerWorld: Vector3;
  69415. /**
  69416. * Radius of the bounding sphere in world space
  69417. */
  69418. radiusWorld: number;
  69419. /**
  69420. * Gets the minimum vector in local space
  69421. */
  69422. readonly minimum: Vector3;
  69423. /**
  69424. * Gets the maximum vector in local space
  69425. */
  69426. readonly maximum: Vector3;
  69427. private _worldMatrix;
  69428. private static readonly TmpVector3;
  69429. /**
  69430. * Creates a new bounding sphere
  69431. * @param min defines the minimum vector (in local space)
  69432. * @param max defines the maximum vector (in local space)
  69433. * @param worldMatrix defines the new world matrix
  69434. */
  69435. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69436. /**
  69437. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  69438. * @param min defines the new minimum vector (in local space)
  69439. * @param max defines the new maximum vector (in local space)
  69440. * @param worldMatrix defines the new world matrix
  69441. */
  69442. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69443. /**
  69444. * Scale the current bounding sphere by applying a scale factor
  69445. * @param factor defines the scale factor to apply
  69446. * @returns the current bounding box
  69447. */
  69448. scale(factor: number): BoundingSphere;
  69449. /**
  69450. * Gets the world matrix of the bounding box
  69451. * @returns a matrix
  69452. */
  69453. getWorldMatrix(): DeepImmutable<Matrix>;
  69454. /** @hidden */
  69455. _update(worldMatrix: DeepImmutable<Matrix>): void;
  69456. /**
  69457. * Tests if the bounding sphere is intersecting the frustum planes
  69458. * @param frustumPlanes defines the frustum planes to test
  69459. * @returns true if there is an intersection
  69460. */
  69461. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69462. /**
  69463. * Tests if the bounding sphere center is in between the frustum planes.
  69464. * Used for optimistic fast inclusion.
  69465. * @param frustumPlanes defines the frustum planes to test
  69466. * @returns true if the sphere center is in between the frustum planes
  69467. */
  69468. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69469. /**
  69470. * Tests if a point is inside the bounding sphere
  69471. * @param point defines the point to test
  69472. * @returns true if the point is inside the bounding sphere
  69473. */
  69474. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69475. /**
  69476. * Checks if two sphere intersct
  69477. * @param sphere0 sphere 0
  69478. * @param sphere1 sphere 1
  69479. * @returns true if the speres intersect
  69480. */
  69481. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  69482. }
  69483. }
  69484. declare module BABYLON {
  69485. /**
  69486. * Class used to store bounding box information
  69487. */
  69488. export class BoundingBox implements ICullable {
  69489. /**
  69490. * Gets the 8 vectors representing the bounding box in local space
  69491. */
  69492. readonly vectors: Vector3[];
  69493. /**
  69494. * Gets the center of the bounding box in local space
  69495. */
  69496. readonly center: Vector3;
  69497. /**
  69498. * Gets the center of the bounding box in world space
  69499. */
  69500. readonly centerWorld: Vector3;
  69501. /**
  69502. * Gets the extend size in local space
  69503. */
  69504. readonly extendSize: Vector3;
  69505. /**
  69506. * Gets the extend size in world space
  69507. */
  69508. readonly extendSizeWorld: Vector3;
  69509. /**
  69510. * Gets the OBB (object bounding box) directions
  69511. */
  69512. readonly directions: Vector3[];
  69513. /**
  69514. * Gets the 8 vectors representing the bounding box in world space
  69515. */
  69516. readonly vectorsWorld: Vector3[];
  69517. /**
  69518. * Gets the minimum vector in world space
  69519. */
  69520. readonly minimumWorld: Vector3;
  69521. /**
  69522. * Gets the maximum vector in world space
  69523. */
  69524. readonly maximumWorld: Vector3;
  69525. /**
  69526. * Gets the minimum vector in local space
  69527. */
  69528. readonly minimum: Vector3;
  69529. /**
  69530. * Gets the maximum vector in local space
  69531. */
  69532. readonly maximum: Vector3;
  69533. private _worldMatrix;
  69534. private static readonly TmpVector3;
  69535. /**
  69536. * @hidden
  69537. */
  69538. _tag: number;
  69539. /**
  69540. * Creates a new bounding box
  69541. * @param min defines the minimum vector (in local space)
  69542. * @param max defines the maximum vector (in local space)
  69543. * @param worldMatrix defines the new world matrix
  69544. */
  69545. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69546. /**
  69547. * Recreates the entire bounding box from scratch as if we call the constructor in place
  69548. * @param min defines the new minimum vector (in local space)
  69549. * @param max defines the new maximum vector (in local space)
  69550. * @param worldMatrix defines the new world matrix
  69551. */
  69552. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69553. /**
  69554. * Scale the current bounding box by applying a scale factor
  69555. * @param factor defines the scale factor to apply
  69556. * @returns the current bounding box
  69557. */
  69558. scale(factor: number): BoundingBox;
  69559. /**
  69560. * Gets the world matrix of the bounding box
  69561. * @returns a matrix
  69562. */
  69563. getWorldMatrix(): DeepImmutable<Matrix>;
  69564. /** @hidden */
  69565. _update(world: DeepImmutable<Matrix>): void;
  69566. /**
  69567. * Tests if the bounding box is intersecting the frustum planes
  69568. * @param frustumPlanes defines the frustum planes to test
  69569. * @returns true if there is an intersection
  69570. */
  69571. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69572. /**
  69573. * Tests if the bounding box is entirely inside the frustum planes
  69574. * @param frustumPlanes defines the frustum planes to test
  69575. * @returns true if there is an inclusion
  69576. */
  69577. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69578. /**
  69579. * Tests if a point is inside the bounding box
  69580. * @param point defines the point to test
  69581. * @returns true if the point is inside the bounding box
  69582. */
  69583. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69584. /**
  69585. * Tests if the bounding box intersects with a bounding sphere
  69586. * @param sphere defines the sphere to test
  69587. * @returns true if there is an intersection
  69588. */
  69589. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  69590. /**
  69591. * Tests if the bounding box intersects with a box defined by a min and max vectors
  69592. * @param min defines the min vector to use
  69593. * @param max defines the max vector to use
  69594. * @returns true if there is an intersection
  69595. */
  69596. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  69597. /**
  69598. * Tests if two bounding boxes are intersections
  69599. * @param box0 defines the first box to test
  69600. * @param box1 defines the second box to test
  69601. * @returns true if there is an intersection
  69602. */
  69603. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  69604. /**
  69605. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  69606. * @param minPoint defines the minimum vector of the bounding box
  69607. * @param maxPoint defines the maximum vector of the bounding box
  69608. * @param sphereCenter defines the sphere center
  69609. * @param sphereRadius defines the sphere radius
  69610. * @returns true if there is an intersection
  69611. */
  69612. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  69613. /**
  69614. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  69615. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69616. * @param frustumPlanes defines the frustum planes to test
  69617. * @return true if there is an inclusion
  69618. */
  69619. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69620. /**
  69621. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  69622. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69623. * @param frustumPlanes defines the frustum planes to test
  69624. * @return true if there is an intersection
  69625. */
  69626. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69627. }
  69628. }
  69629. declare module BABYLON {
  69630. /** @hidden */
  69631. export class Collider {
  69632. /** Define if a collision was found */
  69633. collisionFound: boolean;
  69634. /**
  69635. * Define last intersection point in local space
  69636. */
  69637. intersectionPoint: Vector3;
  69638. /**
  69639. * Define last collided mesh
  69640. */
  69641. collidedMesh: Nullable<AbstractMesh>;
  69642. private _collisionPoint;
  69643. private _planeIntersectionPoint;
  69644. private _tempVector;
  69645. private _tempVector2;
  69646. private _tempVector3;
  69647. private _tempVector4;
  69648. private _edge;
  69649. private _baseToVertex;
  69650. private _destinationPoint;
  69651. private _slidePlaneNormal;
  69652. private _displacementVector;
  69653. /** @hidden */
  69654. _radius: Vector3;
  69655. /** @hidden */
  69656. _retry: number;
  69657. private _velocity;
  69658. private _basePoint;
  69659. private _epsilon;
  69660. /** @hidden */
  69661. _velocityWorldLength: number;
  69662. /** @hidden */
  69663. _basePointWorld: Vector3;
  69664. private _velocityWorld;
  69665. private _normalizedVelocity;
  69666. /** @hidden */
  69667. _initialVelocity: Vector3;
  69668. /** @hidden */
  69669. _initialPosition: Vector3;
  69670. private _nearestDistance;
  69671. private _collisionMask;
  69672. collisionMask: number;
  69673. /**
  69674. * Gets the plane normal used to compute the sliding response (in local space)
  69675. */
  69676. readonly slidePlaneNormal: Vector3;
  69677. /** @hidden */
  69678. _initialize(source: Vector3, dir: Vector3, e: number): void;
  69679. /** @hidden */
  69680. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  69681. /** @hidden */
  69682. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  69683. /** @hidden */
  69684. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  69685. /** @hidden */
  69686. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  69687. /** @hidden */
  69688. _getResponse(pos: Vector3, vel: Vector3): void;
  69689. }
  69690. }
  69691. declare module BABYLON {
  69692. /**
  69693. * Interface for cullable objects
  69694. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  69695. */
  69696. export interface ICullable {
  69697. /**
  69698. * Checks if the object or part of the object is in the frustum
  69699. * @param frustumPlanes Camera near/planes
  69700. * @returns true if the object is in frustum otherwise false
  69701. */
  69702. isInFrustum(frustumPlanes: Plane[]): boolean;
  69703. /**
  69704. * Checks if a cullable object (mesh...) is in the camera frustum
  69705. * Unlike isInFrustum this cheks the full bounding box
  69706. * @param frustumPlanes Camera near/planes
  69707. * @returns true if the object is in frustum otherwise false
  69708. */
  69709. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  69710. }
  69711. /**
  69712. * Info for a bounding data of a mesh
  69713. */
  69714. export class BoundingInfo implements ICullable {
  69715. /**
  69716. * Bounding box for the mesh
  69717. */
  69718. readonly boundingBox: BoundingBox;
  69719. /**
  69720. * Bounding sphere for the mesh
  69721. */
  69722. readonly boundingSphere: BoundingSphere;
  69723. private _isLocked;
  69724. private static readonly TmpVector3;
  69725. /**
  69726. * Constructs bounding info
  69727. * @param minimum min vector of the bounding box/sphere
  69728. * @param maximum max vector of the bounding box/sphere
  69729. * @param worldMatrix defines the new world matrix
  69730. */
  69731. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69732. /**
  69733. * Recreates the entire bounding info from scratch as if we call the constructor in place
  69734. * @param min defines the new minimum vector (in local space)
  69735. * @param max defines the new maximum vector (in local space)
  69736. * @param worldMatrix defines the new world matrix
  69737. */
  69738. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69739. /**
  69740. * min vector of the bounding box/sphere
  69741. */
  69742. readonly minimum: Vector3;
  69743. /**
  69744. * max vector of the bounding box/sphere
  69745. */
  69746. readonly maximum: Vector3;
  69747. /**
  69748. * If the info is locked and won't be updated to avoid perf overhead
  69749. */
  69750. isLocked: boolean;
  69751. /**
  69752. * Updates the bounding sphere and box
  69753. * @param world world matrix to be used to update
  69754. */
  69755. update(world: DeepImmutable<Matrix>): void;
  69756. /**
  69757. * Recreate the bounding info to be centered around a specific point given a specific extend.
  69758. * @param center New center of the bounding info
  69759. * @param extend New extend of the bounding info
  69760. * @returns the current bounding info
  69761. */
  69762. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  69763. /**
  69764. * Scale the current bounding info by applying a scale factor
  69765. * @param factor defines the scale factor to apply
  69766. * @returns the current bounding info
  69767. */
  69768. scale(factor: number): BoundingInfo;
  69769. /**
  69770. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  69771. * @param frustumPlanes defines the frustum to test
  69772. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  69773. * @returns true if the bounding info is in the frustum planes
  69774. */
  69775. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  69776. /**
  69777. * Gets the world distance between the min and max points of the bounding box
  69778. */
  69779. readonly diagonalLength: number;
  69780. /**
  69781. * Checks if a cullable object (mesh...) is in the camera frustum
  69782. * Unlike isInFrustum this cheks the full bounding box
  69783. * @param frustumPlanes Camera near/planes
  69784. * @returns true if the object is in frustum otherwise false
  69785. */
  69786. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69787. /** @hidden */
  69788. _checkCollision(collider: Collider): boolean;
  69789. /**
  69790. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  69791. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  69792. * @param point the point to check intersection with
  69793. * @returns if the point intersects
  69794. */
  69795. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69796. /**
  69797. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  69798. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  69799. * @param boundingInfo the bounding info to check intersection with
  69800. * @param precise if the intersection should be done using OBB
  69801. * @returns if the bounding info intersects
  69802. */
  69803. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  69804. }
  69805. }
  69806. declare module BABYLON {
  69807. /**
  69808. * Defines an array and its length.
  69809. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  69810. */
  69811. export interface ISmartArrayLike<T> {
  69812. /**
  69813. * The data of the array.
  69814. */
  69815. data: Array<T>;
  69816. /**
  69817. * The active length of the array.
  69818. */
  69819. length: number;
  69820. }
  69821. /**
  69822. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  69823. */
  69824. export class SmartArray<T> implements ISmartArrayLike<T> {
  69825. /**
  69826. * The full set of data from the array.
  69827. */
  69828. data: Array<T>;
  69829. /**
  69830. * The active length of the array.
  69831. */
  69832. length: number;
  69833. protected _id: number;
  69834. /**
  69835. * Instantiates a Smart Array.
  69836. * @param capacity defines the default capacity of the array.
  69837. */
  69838. constructor(capacity: number);
  69839. /**
  69840. * Pushes a value at the end of the active data.
  69841. * @param value defines the object to push in the array.
  69842. */
  69843. push(value: T): void;
  69844. /**
  69845. * Iterates over the active data and apply the lambda to them.
  69846. * @param func defines the action to apply on each value.
  69847. */
  69848. forEach(func: (content: T) => void): void;
  69849. /**
  69850. * Sorts the full sets of data.
  69851. * @param compareFn defines the comparison function to apply.
  69852. */
  69853. sort(compareFn: (a: T, b: T) => number): void;
  69854. /**
  69855. * Resets the active data to an empty array.
  69856. */
  69857. reset(): void;
  69858. /**
  69859. * Releases all the data from the array as well as the array.
  69860. */
  69861. dispose(): void;
  69862. /**
  69863. * Concats the active data with a given array.
  69864. * @param array defines the data to concatenate with.
  69865. */
  69866. concat(array: any): void;
  69867. /**
  69868. * Returns the position of a value in the active data.
  69869. * @param value defines the value to find the index for
  69870. * @returns the index if found in the active data otherwise -1
  69871. */
  69872. indexOf(value: T): number;
  69873. /**
  69874. * Returns whether an element is part of the active data.
  69875. * @param value defines the value to look for
  69876. * @returns true if found in the active data otherwise false
  69877. */
  69878. contains(value: T): boolean;
  69879. private static _GlobalId;
  69880. }
  69881. /**
  69882. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  69883. * The data in this array can only be present once
  69884. */
  69885. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  69886. private _duplicateId;
  69887. /**
  69888. * Pushes a value at the end of the active data.
  69889. * THIS DOES NOT PREVENT DUPPLICATE DATA
  69890. * @param value defines the object to push in the array.
  69891. */
  69892. push(value: T): void;
  69893. /**
  69894. * Pushes a value at the end of the active data.
  69895. * If the data is already present, it won t be added again
  69896. * @param value defines the object to push in the array.
  69897. * @returns true if added false if it was already present
  69898. */
  69899. pushNoDuplicate(value: T): boolean;
  69900. /**
  69901. * Resets the active data to an empty array.
  69902. */
  69903. reset(): void;
  69904. /**
  69905. * Concats the active data with a given array.
  69906. * This ensures no dupplicate will be present in the result.
  69907. * @param array defines the data to concatenate with.
  69908. */
  69909. concatWithNoDuplicate(array: any): void;
  69910. }
  69911. }
  69912. declare module BABYLON {
  69913. /**
  69914. * A multi-material is used to apply different materials to different parts of the same object without the need of
  69915. * separate meshes. This can be use to improve performances.
  69916. * @see http://doc.babylonjs.com/how_to/multi_materials
  69917. */
  69918. export class MultiMaterial extends Material {
  69919. private _subMaterials;
  69920. /**
  69921. * Gets or Sets the list of Materials used within the multi material.
  69922. * They need to be ordered according to the submeshes order in the associated mesh
  69923. */
  69924. subMaterials: Nullable<Material>[];
  69925. /**
  69926. * Function used to align with Node.getChildren()
  69927. * @returns the list of Materials used within the multi material
  69928. */
  69929. getChildren(): Nullable<Material>[];
  69930. /**
  69931. * Instantiates a new Multi Material
  69932. * A multi-material is used to apply different materials to different parts of the same object without the need of
  69933. * separate meshes. This can be use to improve performances.
  69934. * @see http://doc.babylonjs.com/how_to/multi_materials
  69935. * @param name Define the name in the scene
  69936. * @param scene Define the scene the material belongs to
  69937. */
  69938. constructor(name: string, scene: Scene);
  69939. private _hookArray;
  69940. /**
  69941. * Get one of the submaterial by its index in the submaterials array
  69942. * @param index The index to look the sub material at
  69943. * @returns The Material if the index has been defined
  69944. */
  69945. getSubMaterial(index: number): Nullable<Material>;
  69946. /**
  69947. * Get the list of active textures for the whole sub materials list.
  69948. * @returns All the textures that will be used during the rendering
  69949. */
  69950. getActiveTextures(): BaseTexture[];
  69951. /**
  69952. * Gets the current class name of the material e.g. "MultiMaterial"
  69953. * Mainly use in serialization.
  69954. * @returns the class name
  69955. */
  69956. getClassName(): string;
  69957. /**
  69958. * Checks if the material is ready to render the requested sub mesh
  69959. * @param mesh Define the mesh the submesh belongs to
  69960. * @param subMesh Define the sub mesh to look readyness for
  69961. * @param useInstances Define whether or not the material is used with instances
  69962. * @returns true if ready, otherwise false
  69963. */
  69964. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  69965. /**
  69966. * Clones the current material and its related sub materials
  69967. * @param name Define the name of the newly cloned material
  69968. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  69969. * @returns the cloned material
  69970. */
  69971. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  69972. /**
  69973. * Serializes the materials into a JSON representation.
  69974. * @returns the JSON representation
  69975. */
  69976. serialize(): any;
  69977. /**
  69978. * Dispose the material and release its associated resources
  69979. * @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)
  69980. * @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)
  69981. * @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)
  69982. */
  69983. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  69984. /**
  69985. * Creates a MultiMaterial from parsed MultiMaterial data.
  69986. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  69987. * @param scene defines the hosting scene
  69988. * @returns a new MultiMaterial
  69989. */
  69990. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  69991. }
  69992. }
  69993. declare module BABYLON {
  69994. /**
  69995. * Class used to represent data loading progression
  69996. */
  69997. export class SceneLoaderFlags {
  69998. private static _ForceFullSceneLoadingForIncremental;
  69999. private static _ShowLoadingScreen;
  70000. private static _CleanBoneMatrixWeights;
  70001. private static _loggingLevel;
  70002. /**
  70003. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  70004. */
  70005. static ForceFullSceneLoadingForIncremental: boolean;
  70006. /**
  70007. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  70008. */
  70009. static ShowLoadingScreen: boolean;
  70010. /**
  70011. * Defines the current logging level (while loading the scene)
  70012. * @ignorenaming
  70013. */
  70014. static loggingLevel: number;
  70015. /**
  70016. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  70017. */
  70018. static CleanBoneMatrixWeights: boolean;
  70019. }
  70020. }
  70021. declare module BABYLON {
  70022. /**
  70023. * 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.
  70024. * @see https://doc.babylonjs.com/how_to/transformnode
  70025. */
  70026. export class TransformNode extends Node {
  70027. /**
  70028. * Object will not rotate to face the camera
  70029. */
  70030. static BILLBOARDMODE_NONE: number;
  70031. /**
  70032. * Object will rotate to face the camera but only on the x axis
  70033. */
  70034. static BILLBOARDMODE_X: number;
  70035. /**
  70036. * Object will rotate to face the camera but only on the y axis
  70037. */
  70038. static BILLBOARDMODE_Y: number;
  70039. /**
  70040. * Object will rotate to face the camera but only on the z axis
  70041. */
  70042. static BILLBOARDMODE_Z: number;
  70043. /**
  70044. * Object will rotate to face the camera
  70045. */
  70046. static BILLBOARDMODE_ALL: number;
  70047. private _forward;
  70048. private _forwardInverted;
  70049. private _up;
  70050. private _right;
  70051. private _rightInverted;
  70052. private _position;
  70053. private _rotation;
  70054. private _rotationQuaternion;
  70055. protected _scaling: Vector3;
  70056. protected _isDirty: boolean;
  70057. private _transformToBoneReferal;
  70058. private _billboardMode;
  70059. /**
  70060. * Gets or sets the billboard mode. Default is 0.
  70061. *
  70062. * | Value | Type | Description |
  70063. * | --- | --- | --- |
  70064. * | 0 | BILLBOARDMODE_NONE | |
  70065. * | 1 | BILLBOARDMODE_X | |
  70066. * | 2 | BILLBOARDMODE_Y | |
  70067. * | 4 | BILLBOARDMODE_Z | |
  70068. * | 7 | BILLBOARDMODE_ALL | |
  70069. *
  70070. */
  70071. billboardMode: number;
  70072. private _preserveParentRotationForBillboard;
  70073. /**
  70074. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  70075. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  70076. */
  70077. preserveParentRotationForBillboard: boolean;
  70078. /**
  70079. * 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
  70080. */
  70081. scalingDeterminant: number;
  70082. private _infiniteDistance;
  70083. /**
  70084. * Gets or sets the distance of the object to max, often used by skybox
  70085. */
  70086. infiniteDistance: boolean;
  70087. /**
  70088. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  70089. * By default the system will update normals to compensate
  70090. */
  70091. ignoreNonUniformScaling: boolean;
  70092. /**
  70093. * 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
  70094. */
  70095. reIntegrateRotationIntoRotationQuaternion: boolean;
  70096. /** @hidden */
  70097. _poseMatrix: Nullable<Matrix>;
  70098. /** @hidden */
  70099. _localMatrix: Matrix;
  70100. private _usePivotMatrix;
  70101. private _absolutePosition;
  70102. private _pivotMatrix;
  70103. private _pivotMatrixInverse;
  70104. protected _postMultiplyPivotMatrix: boolean;
  70105. protected _isWorldMatrixFrozen: boolean;
  70106. /** @hidden */
  70107. _indexInSceneTransformNodesArray: number;
  70108. /**
  70109. * An event triggered after the world matrix is updated
  70110. */
  70111. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  70112. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  70113. /**
  70114. * Gets a string identifying the name of the class
  70115. * @returns "TransformNode" string
  70116. */
  70117. getClassName(): string;
  70118. /**
  70119. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  70120. */
  70121. position: Vector3;
  70122. /**
  70123. * 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)).
  70124. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  70125. */
  70126. rotation: Vector3;
  70127. /**
  70128. * 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)).
  70129. */
  70130. scaling: Vector3;
  70131. /**
  70132. * 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).
  70133. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  70134. */
  70135. rotationQuaternion: Nullable<Quaternion>;
  70136. /**
  70137. * The forward direction of that transform in world space.
  70138. */
  70139. readonly forward: Vector3;
  70140. /**
  70141. * The up direction of that transform in world space.
  70142. */
  70143. readonly up: Vector3;
  70144. /**
  70145. * The right direction of that transform in world space.
  70146. */
  70147. readonly right: Vector3;
  70148. /**
  70149. * Copies the parameter passed Matrix into the mesh Pose matrix.
  70150. * @param matrix the matrix to copy the pose from
  70151. * @returns this TransformNode.
  70152. */
  70153. updatePoseMatrix(matrix: Matrix): TransformNode;
  70154. /**
  70155. * Returns the mesh Pose matrix.
  70156. * @returns the pose matrix
  70157. */
  70158. getPoseMatrix(): Matrix;
  70159. /** @hidden */
  70160. _isSynchronized(): boolean;
  70161. /** @hidden */
  70162. _initCache(): void;
  70163. /**
  70164. * Flag the transform node as dirty (Forcing it to update everything)
  70165. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  70166. * @returns this transform node
  70167. */
  70168. markAsDirty(property: string): TransformNode;
  70169. /**
  70170. * Returns the current mesh absolute position.
  70171. * Returns a Vector3.
  70172. */
  70173. readonly absolutePosition: Vector3;
  70174. /**
  70175. * Sets a new matrix to apply before all other transformation
  70176. * @param matrix defines the transform matrix
  70177. * @returns the current TransformNode
  70178. */
  70179. setPreTransformMatrix(matrix: Matrix): TransformNode;
  70180. /**
  70181. * Sets a new pivot matrix to the current node
  70182. * @param matrix defines the new pivot matrix to use
  70183. * @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
  70184. * @returns the current TransformNode
  70185. */
  70186. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  70187. /**
  70188. * Returns the mesh pivot matrix.
  70189. * Default : Identity.
  70190. * @returns the matrix
  70191. */
  70192. getPivotMatrix(): Matrix;
  70193. /**
  70194. * Prevents the World matrix to be computed any longer.
  70195. * @returns the TransformNode.
  70196. */
  70197. freezeWorldMatrix(): TransformNode;
  70198. /**
  70199. * Allows back the World matrix computation.
  70200. * @returns the TransformNode.
  70201. */
  70202. unfreezeWorldMatrix(): this;
  70203. /**
  70204. * True if the World matrix has been frozen.
  70205. */
  70206. readonly isWorldMatrixFrozen: boolean;
  70207. /**
  70208. * Retuns the mesh absolute position in the World.
  70209. * @returns a Vector3.
  70210. */
  70211. getAbsolutePosition(): Vector3;
  70212. /**
  70213. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  70214. * @param absolutePosition the absolute position to set
  70215. * @returns the TransformNode.
  70216. */
  70217. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  70218. /**
  70219. * Sets the mesh position in its local space.
  70220. * @param vector3 the position to set in localspace
  70221. * @returns the TransformNode.
  70222. */
  70223. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  70224. /**
  70225. * Returns the mesh position in the local space from the current World matrix values.
  70226. * @returns a new Vector3.
  70227. */
  70228. getPositionExpressedInLocalSpace(): Vector3;
  70229. /**
  70230. * Translates the mesh along the passed Vector3 in its local space.
  70231. * @param vector3 the distance to translate in localspace
  70232. * @returns the TransformNode.
  70233. */
  70234. locallyTranslate(vector3: Vector3): TransformNode;
  70235. private static _lookAtVectorCache;
  70236. /**
  70237. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  70238. * @param targetPoint the position (must be in same space as current mesh) to look at
  70239. * @param yawCor optional yaw (y-axis) correction in radians
  70240. * @param pitchCor optional pitch (x-axis) correction in radians
  70241. * @param rollCor optional roll (z-axis) correction in radians
  70242. * @param space the choosen space of the target
  70243. * @returns the TransformNode.
  70244. */
  70245. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  70246. /**
  70247. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  70248. * This Vector3 is expressed in the World space.
  70249. * @param localAxis axis to rotate
  70250. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  70251. */
  70252. getDirection(localAxis: Vector3): Vector3;
  70253. /**
  70254. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  70255. * localAxis is expressed in the mesh local space.
  70256. * result is computed in the Wordl space from the mesh World matrix.
  70257. * @param localAxis axis to rotate
  70258. * @param result the resulting transformnode
  70259. * @returns this TransformNode.
  70260. */
  70261. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  70262. /**
  70263. * Sets this transform node rotation to the given local axis.
  70264. * @param localAxis the axis in local space
  70265. * @param yawCor optional yaw (y-axis) correction in radians
  70266. * @param pitchCor optional pitch (x-axis) correction in radians
  70267. * @param rollCor optional roll (z-axis) correction in radians
  70268. * @returns this TransformNode
  70269. */
  70270. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  70271. /**
  70272. * Sets a new pivot point to the current node
  70273. * @param point defines the new pivot point to use
  70274. * @param space defines if the point is in world or local space (local by default)
  70275. * @returns the current TransformNode
  70276. */
  70277. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  70278. /**
  70279. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  70280. * @returns the pivot point
  70281. */
  70282. getPivotPoint(): Vector3;
  70283. /**
  70284. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  70285. * @param result the vector3 to store the result
  70286. * @returns this TransformNode.
  70287. */
  70288. getPivotPointToRef(result: Vector3): TransformNode;
  70289. /**
  70290. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  70291. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  70292. */
  70293. getAbsolutePivotPoint(): Vector3;
  70294. /**
  70295. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  70296. * @param result vector3 to store the result
  70297. * @returns this TransformNode.
  70298. */
  70299. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  70300. /**
  70301. * Defines the passed node as the parent of the current node.
  70302. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  70303. * @see https://doc.babylonjs.com/how_to/parenting
  70304. * @param node the node ot set as the parent
  70305. * @returns this TransformNode.
  70306. */
  70307. setParent(node: Nullable<Node>): TransformNode;
  70308. private _nonUniformScaling;
  70309. /**
  70310. * True if the scaling property of this object is non uniform eg. (1,2,1)
  70311. */
  70312. readonly nonUniformScaling: boolean;
  70313. /** @hidden */
  70314. _updateNonUniformScalingState(value: boolean): boolean;
  70315. /**
  70316. * Attach the current TransformNode to another TransformNode associated with a bone
  70317. * @param bone Bone affecting the TransformNode
  70318. * @param affectedTransformNode TransformNode associated with the bone
  70319. * @returns this object
  70320. */
  70321. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  70322. /**
  70323. * Detach the transform node if its associated with a bone
  70324. * @returns this object
  70325. */
  70326. detachFromBone(): TransformNode;
  70327. private static _rotationAxisCache;
  70328. /**
  70329. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  70330. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  70331. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  70332. * The passed axis is also normalized.
  70333. * @param axis the axis to rotate around
  70334. * @param amount the amount to rotate in radians
  70335. * @param space Space to rotate in (Default: local)
  70336. * @returns the TransformNode.
  70337. */
  70338. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  70339. /**
  70340. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  70341. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  70342. * The passed axis is also normalized. .
  70343. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  70344. * @param point the point to rotate around
  70345. * @param axis the axis to rotate around
  70346. * @param amount the amount to rotate in radians
  70347. * @returns the TransformNode
  70348. */
  70349. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  70350. /**
  70351. * Translates the mesh along the axis vector for the passed distance in the given space.
  70352. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  70353. * @param axis the axis to translate in
  70354. * @param distance the distance to translate
  70355. * @param space Space to rotate in (Default: local)
  70356. * @returns the TransformNode.
  70357. */
  70358. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  70359. /**
  70360. * Adds a rotation step to the mesh current rotation.
  70361. * x, y, z are Euler angles expressed in radians.
  70362. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  70363. * This means this rotation is made in the mesh local space only.
  70364. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  70365. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  70366. * ```javascript
  70367. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  70368. * ```
  70369. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  70370. * 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.
  70371. * @param x Rotation to add
  70372. * @param y Rotation to add
  70373. * @param z Rotation to add
  70374. * @returns the TransformNode.
  70375. */
  70376. addRotation(x: number, y: number, z: number): TransformNode;
  70377. /**
  70378. * @hidden
  70379. */
  70380. protected _getEffectiveParent(): Nullable<Node>;
  70381. /**
  70382. * Computes the world matrix of the node
  70383. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  70384. * @returns the world matrix
  70385. */
  70386. computeWorldMatrix(force?: boolean): Matrix;
  70387. protected _afterComputeWorldMatrix(): void;
  70388. /**
  70389. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  70390. * @param func callback function to add
  70391. *
  70392. * @returns the TransformNode.
  70393. */
  70394. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  70395. /**
  70396. * Removes a registered callback function.
  70397. * @param func callback function to remove
  70398. * @returns the TransformNode.
  70399. */
  70400. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  70401. /**
  70402. * Gets the position of the current mesh in camera space
  70403. * @param camera defines the camera to use
  70404. * @returns a position
  70405. */
  70406. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  70407. /**
  70408. * Returns the distance from the mesh to the active camera
  70409. * @param camera defines the camera to use
  70410. * @returns the distance
  70411. */
  70412. getDistanceToCamera(camera?: Nullable<Camera>): number;
  70413. /**
  70414. * Clone the current transform node
  70415. * @param name Name of the new clone
  70416. * @param newParent New parent for the clone
  70417. * @param doNotCloneChildren Do not clone children hierarchy
  70418. * @returns the new transform node
  70419. */
  70420. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  70421. /**
  70422. * Serializes the objects information.
  70423. * @param currentSerializationObject defines the object to serialize in
  70424. * @returns the serialized object
  70425. */
  70426. serialize(currentSerializationObject?: any): any;
  70427. /**
  70428. * Returns a new TransformNode object parsed from the source provided.
  70429. * @param parsedTransformNode is the source.
  70430. * @param scene the scne the object belongs to
  70431. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  70432. * @returns a new TransformNode object parsed from the source provided.
  70433. */
  70434. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  70435. /**
  70436. * Get all child-transformNodes of this node
  70437. * @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
  70438. * @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
  70439. * @returns an array of TransformNode
  70440. */
  70441. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  70442. /**
  70443. * Releases resources associated with this transform node.
  70444. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  70445. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  70446. */
  70447. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  70448. }
  70449. }
  70450. declare module BABYLON {
  70451. /**
  70452. * Class used to override all child animations of a given target
  70453. */
  70454. export class AnimationPropertiesOverride {
  70455. /**
  70456. * Gets or sets a value indicating if animation blending must be used
  70457. */
  70458. enableBlending: boolean;
  70459. /**
  70460. * Gets or sets the blending speed to use when enableBlending is true
  70461. */
  70462. blendingSpeed: number;
  70463. /**
  70464. * Gets or sets the default loop mode to use
  70465. */
  70466. loopMode: number;
  70467. }
  70468. }
  70469. declare module BABYLON {
  70470. /**
  70471. * Class used to store bone information
  70472. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  70473. */
  70474. export class Bone extends Node {
  70475. /**
  70476. * defines the bone name
  70477. */
  70478. name: string;
  70479. private static _tmpVecs;
  70480. private static _tmpQuat;
  70481. private static _tmpMats;
  70482. /**
  70483. * Gets the list of child bones
  70484. */
  70485. children: Bone[];
  70486. /** Gets the animations associated with this bone */
  70487. animations: Animation[];
  70488. /**
  70489. * Gets or sets bone length
  70490. */
  70491. length: number;
  70492. /**
  70493. * @hidden Internal only
  70494. * Set this value to map this bone to a different index in the transform matrices
  70495. * Set this value to -1 to exclude the bone from the transform matrices
  70496. */
  70497. _index: Nullable<number>;
  70498. private _skeleton;
  70499. private _localMatrix;
  70500. private _restPose;
  70501. private _baseMatrix;
  70502. private _absoluteTransform;
  70503. private _invertedAbsoluteTransform;
  70504. private _parent;
  70505. private _scalingDeterminant;
  70506. private _worldTransform;
  70507. private _localScaling;
  70508. private _localRotation;
  70509. private _localPosition;
  70510. private _needToDecompose;
  70511. private _needToCompose;
  70512. /** @hidden */
  70513. _linkedTransformNode: Nullable<TransformNode>;
  70514. /** @hidden */
  70515. _waitingTransformNodeId: Nullable<string>;
  70516. /** @hidden */
  70517. /** @hidden */
  70518. _matrix: Matrix;
  70519. /**
  70520. * Create a new bone
  70521. * @param name defines the bone name
  70522. * @param skeleton defines the parent skeleton
  70523. * @param parentBone defines the parent (can be null if the bone is the root)
  70524. * @param localMatrix defines the local matrix
  70525. * @param restPose defines the rest pose matrix
  70526. * @param baseMatrix defines the base matrix
  70527. * @param index defines index of the bone in the hiearchy
  70528. */
  70529. constructor(
  70530. /**
  70531. * defines the bone name
  70532. */
  70533. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  70534. /**
  70535. * Gets the current object class name.
  70536. * @return the class name
  70537. */
  70538. getClassName(): string;
  70539. /**
  70540. * Gets the parent skeleton
  70541. * @returns a skeleton
  70542. */
  70543. getSkeleton(): Skeleton;
  70544. /**
  70545. * Gets parent bone
  70546. * @returns a bone or null if the bone is the root of the bone hierarchy
  70547. */
  70548. getParent(): Nullable<Bone>;
  70549. /**
  70550. * Returns an array containing the root bones
  70551. * @returns an array containing the root bones
  70552. */
  70553. getChildren(): Array<Bone>;
  70554. /**
  70555. * Sets the parent bone
  70556. * @param parent defines the parent (can be null if the bone is the root)
  70557. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  70558. */
  70559. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  70560. /**
  70561. * Gets the local matrix
  70562. * @returns a matrix
  70563. */
  70564. getLocalMatrix(): Matrix;
  70565. /**
  70566. * Gets the base matrix (initial matrix which remains unchanged)
  70567. * @returns a matrix
  70568. */
  70569. getBaseMatrix(): Matrix;
  70570. /**
  70571. * Gets the rest pose matrix
  70572. * @returns a matrix
  70573. */
  70574. getRestPose(): Matrix;
  70575. /**
  70576. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  70577. */
  70578. getWorldMatrix(): Matrix;
  70579. /**
  70580. * Sets the local matrix to rest pose matrix
  70581. */
  70582. returnToRest(): void;
  70583. /**
  70584. * Gets the inverse of the absolute transform matrix.
  70585. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  70586. * @returns a matrix
  70587. */
  70588. getInvertedAbsoluteTransform(): Matrix;
  70589. /**
  70590. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  70591. * @returns a matrix
  70592. */
  70593. getAbsoluteTransform(): Matrix;
  70594. /**
  70595. * Links with the given transform node.
  70596. * The local matrix of this bone is copied from the transform node every frame.
  70597. * @param transformNode defines the transform node to link to
  70598. */
  70599. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  70600. /** Gets or sets current position (in local space) */
  70601. position: Vector3;
  70602. /** Gets or sets current rotation (in local space) */
  70603. rotation: Vector3;
  70604. /** Gets or sets current rotation quaternion (in local space) */
  70605. rotationQuaternion: Quaternion;
  70606. /** Gets or sets current scaling (in local space) */
  70607. scaling: Vector3;
  70608. /**
  70609. * Gets the animation properties override
  70610. */
  70611. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  70612. private _decompose;
  70613. private _compose;
  70614. /**
  70615. * Update the base and local matrices
  70616. * @param matrix defines the new base or local matrix
  70617. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  70618. * @param updateLocalMatrix defines if the local matrix should be updated
  70619. */
  70620. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  70621. /** @hidden */
  70622. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  70623. /**
  70624. * Flag the bone as dirty (Forcing it to update everything)
  70625. */
  70626. markAsDirty(): void;
  70627. /** @hidden */
  70628. _markAsDirtyAndCompose(): void;
  70629. private _markAsDirtyAndDecompose;
  70630. /**
  70631. * Translate the bone in local or world space
  70632. * @param vec The amount to translate the bone
  70633. * @param space The space that the translation is in
  70634. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70635. */
  70636. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  70637. /**
  70638. * Set the postion of the bone in local or world space
  70639. * @param position The position to set the bone
  70640. * @param space The space that the position is in
  70641. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70642. */
  70643. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  70644. /**
  70645. * Set the absolute position of the bone (world space)
  70646. * @param position The position to set the bone
  70647. * @param mesh The mesh that this bone is attached to
  70648. */
  70649. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  70650. /**
  70651. * Scale the bone on the x, y and z axes (in local space)
  70652. * @param x The amount to scale the bone on the x axis
  70653. * @param y The amount to scale the bone on the y axis
  70654. * @param z The amount to scale the bone on the z axis
  70655. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  70656. */
  70657. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  70658. /**
  70659. * Set the bone scaling in local space
  70660. * @param scale defines the scaling vector
  70661. */
  70662. setScale(scale: Vector3): void;
  70663. /**
  70664. * Gets the current scaling in local space
  70665. * @returns the current scaling vector
  70666. */
  70667. getScale(): Vector3;
  70668. /**
  70669. * Gets the current scaling in local space and stores it in a target vector
  70670. * @param result defines the target vector
  70671. */
  70672. getScaleToRef(result: Vector3): void;
  70673. /**
  70674. * Set the yaw, pitch, and roll of the bone in local or world space
  70675. * @param yaw The rotation of the bone on the y axis
  70676. * @param pitch The rotation of the bone on the x axis
  70677. * @param roll The rotation of the bone on the z axis
  70678. * @param space The space that the axes of rotation are in
  70679. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70680. */
  70681. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  70682. /**
  70683. * Add a rotation to the bone on an axis in local or world space
  70684. * @param axis The axis to rotate the bone on
  70685. * @param amount The amount to rotate the bone
  70686. * @param space The space that the axis is in
  70687. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70688. */
  70689. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  70690. /**
  70691. * Set the rotation of the bone to a particular axis angle in local or world space
  70692. * @param axis The axis to rotate the bone on
  70693. * @param angle The angle that the bone should be rotated to
  70694. * @param space The space that the axis is in
  70695. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70696. */
  70697. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  70698. /**
  70699. * Set the euler rotation of the bone in local of world space
  70700. * @param rotation The euler rotation that the bone should be set to
  70701. * @param space The space that the rotation is in
  70702. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70703. */
  70704. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  70705. /**
  70706. * Set the quaternion rotation of the bone in local of world space
  70707. * @param quat The quaternion rotation that the bone should be set to
  70708. * @param space The space that the rotation is in
  70709. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70710. */
  70711. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  70712. /**
  70713. * Set the rotation matrix of the bone in local of world space
  70714. * @param rotMat The rotation matrix that the bone should be set to
  70715. * @param space The space that the rotation is in
  70716. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70717. */
  70718. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  70719. private _rotateWithMatrix;
  70720. private _getNegativeRotationToRef;
  70721. /**
  70722. * Get the position of the bone in local or world space
  70723. * @param space The space that the returned position is in
  70724. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70725. * @returns The position of the bone
  70726. */
  70727. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  70728. /**
  70729. * Copy the position of the bone to a vector3 in local or world space
  70730. * @param space The space that the returned position is in
  70731. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70732. * @param result The vector3 to copy the position to
  70733. */
  70734. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  70735. /**
  70736. * Get the absolute position of the bone (world space)
  70737. * @param mesh The mesh that this bone is attached to
  70738. * @returns The absolute position of the bone
  70739. */
  70740. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  70741. /**
  70742. * Copy the absolute position of the bone (world space) to the result param
  70743. * @param mesh The mesh that this bone is attached to
  70744. * @param result The vector3 to copy the absolute position to
  70745. */
  70746. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  70747. /**
  70748. * Compute the absolute transforms of this bone and its children
  70749. */
  70750. computeAbsoluteTransforms(): void;
  70751. /**
  70752. * Get the world direction from an axis that is in the local space of the bone
  70753. * @param localAxis The local direction that is used to compute the world direction
  70754. * @param mesh The mesh that this bone is attached to
  70755. * @returns The world direction
  70756. */
  70757. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  70758. /**
  70759. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  70760. * @param localAxis The local direction that is used to compute the world direction
  70761. * @param mesh The mesh that this bone is attached to
  70762. * @param result The vector3 that the world direction will be copied to
  70763. */
  70764. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70765. /**
  70766. * Get the euler rotation of the bone in local or world space
  70767. * @param space The space that the rotation should be in
  70768. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70769. * @returns The euler rotation
  70770. */
  70771. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  70772. /**
  70773. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  70774. * @param space The space that the rotation should be in
  70775. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70776. * @param result The vector3 that the rotation should be copied to
  70777. */
  70778. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70779. /**
  70780. * Get the quaternion rotation of the bone in either local or world space
  70781. * @param space The space that the rotation should be in
  70782. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70783. * @returns The quaternion rotation
  70784. */
  70785. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  70786. /**
  70787. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  70788. * @param space The space that the rotation should be in
  70789. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70790. * @param result The quaternion that the rotation should be copied to
  70791. */
  70792. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  70793. /**
  70794. * Get the rotation matrix of the bone in local or world space
  70795. * @param space The space that the rotation should be in
  70796. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70797. * @returns The rotation matrix
  70798. */
  70799. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  70800. /**
  70801. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  70802. * @param space The space that the rotation should be in
  70803. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70804. * @param result The quaternion that the rotation should be copied to
  70805. */
  70806. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  70807. /**
  70808. * Get the world position of a point that is in the local space of the bone
  70809. * @param position The local position
  70810. * @param mesh The mesh that this bone is attached to
  70811. * @returns The world position
  70812. */
  70813. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  70814. /**
  70815. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  70816. * @param position The local position
  70817. * @param mesh The mesh that this bone is attached to
  70818. * @param result The vector3 that the world position should be copied to
  70819. */
  70820. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70821. /**
  70822. * Get the local position of a point that is in world space
  70823. * @param position The world position
  70824. * @param mesh The mesh that this bone is attached to
  70825. * @returns The local position
  70826. */
  70827. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  70828. /**
  70829. * Get the local position of a point that is in world space and copy it to the result param
  70830. * @param position The world position
  70831. * @param mesh The mesh that this bone is attached to
  70832. * @param result The vector3 that the local position should be copied to
  70833. */
  70834. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70835. }
  70836. }
  70837. declare module BABYLON {
  70838. /**
  70839. * Enum that determines the text-wrapping mode to use.
  70840. */
  70841. export enum InspectableType {
  70842. /**
  70843. * Checkbox for booleans
  70844. */
  70845. Checkbox = 0,
  70846. /**
  70847. * Sliders for numbers
  70848. */
  70849. Slider = 1,
  70850. /**
  70851. * Vector3
  70852. */
  70853. Vector3 = 2,
  70854. /**
  70855. * Quaternions
  70856. */
  70857. Quaternion = 3,
  70858. /**
  70859. * Color3
  70860. */
  70861. Color3 = 4
  70862. }
  70863. /**
  70864. * Interface used to define custom inspectable properties.
  70865. * This interface is used by the inspector to display custom property grids
  70866. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70867. */
  70868. export interface IInspectable {
  70869. /**
  70870. * Gets the label to display
  70871. */
  70872. label: string;
  70873. /**
  70874. * Gets the name of the property to edit
  70875. */
  70876. propertyName: string;
  70877. /**
  70878. * Gets the type of the editor to use
  70879. */
  70880. type: InspectableType;
  70881. /**
  70882. * Gets the minimum value of the property when using in "slider" mode
  70883. */
  70884. min?: number;
  70885. /**
  70886. * Gets the maximum value of the property when using in "slider" mode
  70887. */
  70888. max?: number;
  70889. /**
  70890. * Gets the setp to use when using in "slider" mode
  70891. */
  70892. step?: number;
  70893. }
  70894. }
  70895. declare module BABYLON {
  70896. /**
  70897. * This represents the required contract to create a new type of texture loader.
  70898. */
  70899. export interface IInternalTextureLoader {
  70900. /**
  70901. * Defines wether the loader supports cascade loading the different faces.
  70902. */
  70903. supportCascades: boolean;
  70904. /**
  70905. * This returns if the loader support the current file information.
  70906. * @param extension defines the file extension of the file being loaded
  70907. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70908. * @param fallback defines the fallback internal texture if any
  70909. * @param isBase64 defines whether the texture is encoded as a base64
  70910. * @param isBuffer defines whether the texture data are stored as a buffer
  70911. * @returns true if the loader can load the specified file
  70912. */
  70913. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70914. /**
  70915. * Transform the url before loading if required.
  70916. * @param rootUrl the url of the texture
  70917. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70918. * @returns the transformed texture
  70919. */
  70920. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70921. /**
  70922. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70923. * @param rootUrl the url of the texture
  70924. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70925. * @returns the fallback texture
  70926. */
  70927. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70928. /**
  70929. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70930. * @param data contains the texture data
  70931. * @param texture defines the BabylonJS internal texture
  70932. * @param createPolynomials will be true if polynomials have been requested
  70933. * @param onLoad defines the callback to trigger once the texture is ready
  70934. * @param onError defines the callback to trigger in case of error
  70935. */
  70936. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70937. /**
  70938. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70939. * @param data contains the texture data
  70940. * @param texture defines the BabylonJS internal texture
  70941. * @param callback defines the method to call once ready to upload
  70942. */
  70943. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70944. }
  70945. }
  70946. declare module BABYLON {
  70947. interface Engine {
  70948. /**
  70949. * Creates a depth stencil cube texture.
  70950. * This is only available in WebGL 2.
  70951. * @param size The size of face edge in the cube texture.
  70952. * @param options The options defining the cube texture.
  70953. * @returns The cube texture
  70954. */
  70955. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70956. /**
  70957. * Creates a cube texture
  70958. * @param rootUrl defines the url where the files to load is located
  70959. * @param scene defines the current scene
  70960. * @param files defines the list of files to load (1 per face)
  70961. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70962. * @param onLoad defines an optional callback raised when the texture is loaded
  70963. * @param onError defines an optional callback raised if there is an issue to load the texture
  70964. * @param format defines the format of the data
  70965. * @param forcedExtension defines the extension to use to pick the right loader
  70966. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70967. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70968. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70969. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70970. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70971. * @returns the cube texture as an InternalTexture
  70972. */
  70973. 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;
  70974. /**
  70975. * Creates a cube texture
  70976. * @param rootUrl defines the url where the files to load is located
  70977. * @param scene defines the current scene
  70978. * @param files defines the list of files to load (1 per face)
  70979. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70980. * @param onLoad defines an optional callback raised when the texture is loaded
  70981. * @param onError defines an optional callback raised if there is an issue to load the texture
  70982. * @param format defines the format of the data
  70983. * @param forcedExtension defines the extension to use to pick the right loader
  70984. * @returns the cube texture as an InternalTexture
  70985. */
  70986. 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;
  70987. /**
  70988. * Creates a cube texture
  70989. * @param rootUrl defines the url where the files to load is located
  70990. * @param scene defines the current scene
  70991. * @param files defines the list of files to load (1 per face)
  70992. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70993. * @param onLoad defines an optional callback raised when the texture is loaded
  70994. * @param onError defines an optional callback raised if there is an issue to load the texture
  70995. * @param format defines the format of the data
  70996. * @param forcedExtension defines the extension to use to pick the right loader
  70997. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70998. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70999. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71000. * @returns the cube texture as an InternalTexture
  71001. */
  71002. 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;
  71003. /** @hidden */
  71004. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71005. /** @hidden */
  71006. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71007. /** @hidden */
  71008. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71009. /** @hidden */
  71010. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71011. }
  71012. }
  71013. declare module BABYLON {
  71014. /**
  71015. * Class for creating a cube texture
  71016. */
  71017. export class CubeTexture extends BaseTexture {
  71018. private _delayedOnLoad;
  71019. /**
  71020. * The url of the texture
  71021. */
  71022. url: string;
  71023. /**
  71024. * Gets or sets the center of the bounding box associated with the cube texture.
  71025. * It must define where the camera used to render the texture was set
  71026. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71027. */
  71028. boundingBoxPosition: Vector3;
  71029. private _boundingBoxSize;
  71030. /**
  71031. * Gets or sets the size of the bounding box associated with the cube texture
  71032. * When defined, the cubemap will switch to local mode
  71033. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  71034. * @example https://www.babylonjs-playground.com/#RNASML
  71035. */
  71036. /**
  71037. * Returns the bounding box size
  71038. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71039. */
  71040. boundingBoxSize: Vector3;
  71041. protected _rotationY: number;
  71042. /**
  71043. * Sets texture matrix rotation angle around Y axis in radians.
  71044. */
  71045. /**
  71046. * Gets texture matrix rotation angle around Y axis radians.
  71047. */
  71048. rotationY: number;
  71049. /**
  71050. * Are mip maps generated for this texture or not.
  71051. */
  71052. readonly noMipmap: boolean;
  71053. private _noMipmap;
  71054. private _files;
  71055. private _extensions;
  71056. private _textureMatrix;
  71057. private _format;
  71058. private _createPolynomials;
  71059. /** @hidden */
  71060. _prefiltered: boolean;
  71061. /**
  71062. * Creates a cube texture from an array of image urls
  71063. * @param files defines an array of image urls
  71064. * @param scene defines the hosting scene
  71065. * @param noMipmap specifies if mip maps are not used
  71066. * @returns a cube texture
  71067. */
  71068. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  71069. /**
  71070. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  71071. * @param url defines the url of the prefiltered texture
  71072. * @param scene defines the scene the texture is attached to
  71073. * @param forcedExtension defines the extension of the file if different from the url
  71074. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71075. * @return the prefiltered texture
  71076. */
  71077. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  71078. /**
  71079. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  71080. * as prefiltered data.
  71081. * @param rootUrl defines the url of the texture or the root name of the six images
  71082. * @param scene defines the scene the texture is attached to
  71083. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  71084. * @param noMipmap defines if mipmaps should be created or not
  71085. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  71086. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  71087. * @param onError defines a callback triggered in case of error during load
  71088. * @param format defines the internal format to use for the texture once loaded
  71089. * @param prefiltered defines whether or not the texture is created from prefiltered data
  71090. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  71091. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71092. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71093. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71094. * @return the cube texture
  71095. */
  71096. 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);
  71097. /**
  71098. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  71099. */
  71100. readonly isPrefiltered: boolean;
  71101. /**
  71102. * Get the current class name of the texture useful for serialization or dynamic coding.
  71103. * @returns "CubeTexture"
  71104. */
  71105. getClassName(): string;
  71106. /**
  71107. * Update the url (and optional buffer) of this texture if url was null during construction.
  71108. * @param url the url of the texture
  71109. * @param forcedExtension defines the extension to use
  71110. * @param onLoad callback called when the texture is loaded (defaults to null)
  71111. */
  71112. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  71113. /**
  71114. * Delays loading of the cube texture
  71115. * @param forcedExtension defines the extension to use
  71116. */
  71117. delayLoad(forcedExtension?: string): void;
  71118. /**
  71119. * Returns the reflection texture matrix
  71120. * @returns the reflection texture matrix
  71121. */
  71122. getReflectionTextureMatrix(): Matrix;
  71123. /**
  71124. * Sets the reflection texture matrix
  71125. * @param value Reflection texture matrix
  71126. */
  71127. setReflectionTextureMatrix(value: Matrix): void;
  71128. /**
  71129. * Parses text to create a cube texture
  71130. * @param parsedTexture define the serialized text to read from
  71131. * @param scene defines the hosting scene
  71132. * @param rootUrl defines the root url of the cube texture
  71133. * @returns a cube texture
  71134. */
  71135. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  71136. /**
  71137. * Makes a clone, or deep copy, of the cube texture
  71138. * @returns a new cube texture
  71139. */
  71140. clone(): CubeTexture;
  71141. }
  71142. }
  71143. declare module BABYLON {
  71144. /** @hidden */
  71145. export var postprocessVertexShader: {
  71146. name: string;
  71147. shader: string;
  71148. };
  71149. }
  71150. declare module BABYLON {
  71151. /**
  71152. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  71153. * This is the base of the follow, arc rotate cameras and Free camera
  71154. * @see http://doc.babylonjs.com/features/cameras
  71155. */
  71156. export class TargetCamera extends Camera {
  71157. private static _RigCamTransformMatrix;
  71158. private static _TargetTransformMatrix;
  71159. private static _TargetFocalPoint;
  71160. /**
  71161. * Define the current direction the camera is moving to
  71162. */
  71163. cameraDirection: Vector3;
  71164. /**
  71165. * Define the current rotation the camera is rotating to
  71166. */
  71167. cameraRotation: Vector2;
  71168. /**
  71169. * When set, the up vector of the camera will be updated by the rotation of the camera
  71170. */
  71171. updateUpVectorFromRotation: boolean;
  71172. private _tmpQuaternion;
  71173. /**
  71174. * Define the current rotation of the camera
  71175. */
  71176. rotation: Vector3;
  71177. /**
  71178. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  71179. */
  71180. rotationQuaternion: Quaternion;
  71181. /**
  71182. * Define the current speed of the camera
  71183. */
  71184. speed: number;
  71185. /**
  71186. * Add cconstraint to the camera to prevent it to move freely in all directions and
  71187. * around all axis.
  71188. */
  71189. noRotationConstraint: boolean;
  71190. /**
  71191. * Define the current target of the camera as an object or a position.
  71192. */
  71193. lockedTarget: any;
  71194. /** @hidden */
  71195. _currentTarget: Vector3;
  71196. /** @hidden */
  71197. _initialFocalDistance: number;
  71198. /** @hidden */
  71199. _viewMatrix: Matrix;
  71200. /** @hidden */
  71201. _camMatrix: Matrix;
  71202. /** @hidden */
  71203. _cameraTransformMatrix: Matrix;
  71204. /** @hidden */
  71205. _cameraRotationMatrix: Matrix;
  71206. /** @hidden */
  71207. _referencePoint: Vector3;
  71208. /** @hidden */
  71209. _transformedReferencePoint: Vector3;
  71210. protected _globalCurrentTarget: Vector3;
  71211. protected _globalCurrentUpVector: Vector3;
  71212. /** @hidden */
  71213. _reset: () => void;
  71214. private _defaultUp;
  71215. /**
  71216. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  71217. * This is the base of the follow, arc rotate cameras and Free camera
  71218. * @see http://doc.babylonjs.com/features/cameras
  71219. * @param name Defines the name of the camera in the scene
  71220. * @param position Defines the start position of the camera in the scene
  71221. * @param scene Defines the scene the camera belongs to
  71222. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  71223. */
  71224. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  71225. /**
  71226. * Gets the position in front of the camera at a given distance.
  71227. * @param distance The distance from the camera we want the position to be
  71228. * @returns the position
  71229. */
  71230. getFrontPosition(distance: number): Vector3;
  71231. /** @hidden */
  71232. _getLockedTargetPosition(): Nullable<Vector3>;
  71233. private _storedPosition;
  71234. private _storedRotation;
  71235. private _storedRotationQuaternion;
  71236. /**
  71237. * Store current camera state of the camera (fov, position, rotation, etc..)
  71238. * @returns the camera
  71239. */
  71240. storeState(): Camera;
  71241. /**
  71242. * Restored camera state. You must call storeState() first
  71243. * @returns whether it was successful or not
  71244. * @hidden
  71245. */
  71246. _restoreStateValues(): boolean;
  71247. /** @hidden */
  71248. _initCache(): void;
  71249. /** @hidden */
  71250. _updateCache(ignoreParentClass?: boolean): void;
  71251. /** @hidden */
  71252. _isSynchronizedViewMatrix(): boolean;
  71253. /** @hidden */
  71254. _computeLocalCameraSpeed(): number;
  71255. /**
  71256. * Defines the target the camera should look at.
  71257. * This will automatically adapt alpha beta and radius to fit within the new target.
  71258. * @param target Defines the new target as a Vector or a mesh
  71259. */
  71260. setTarget(target: Vector3): void;
  71261. /**
  71262. * Return the current target position of the camera. This value is expressed in local space.
  71263. * @returns the target position
  71264. */
  71265. getTarget(): Vector3;
  71266. /** @hidden */
  71267. _decideIfNeedsToMove(): boolean;
  71268. /** @hidden */
  71269. _updatePosition(): void;
  71270. /** @hidden */
  71271. _checkInputs(): void;
  71272. protected _updateCameraRotationMatrix(): void;
  71273. /**
  71274. * 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)
  71275. * @returns the current camera
  71276. */
  71277. private _rotateUpVectorWithCameraRotationMatrix;
  71278. private _cachedRotationZ;
  71279. private _cachedQuaternionRotationZ;
  71280. /** @hidden */
  71281. _getViewMatrix(): Matrix;
  71282. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  71283. /**
  71284. * @hidden
  71285. */
  71286. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  71287. /**
  71288. * @hidden
  71289. */
  71290. _updateRigCameras(): void;
  71291. private _getRigCamPositionAndTarget;
  71292. /**
  71293. * Gets the current object class name.
  71294. * @return the class name
  71295. */
  71296. getClassName(): string;
  71297. }
  71298. }
  71299. declare module BABYLON {
  71300. /**
  71301. * @ignore
  71302. * This is a list of all the different input types that are available in the application.
  71303. * Fo instance: ArcRotateCameraGamepadInput...
  71304. */
  71305. export var CameraInputTypes: {};
  71306. /**
  71307. * This is the contract to implement in order to create a new input class.
  71308. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  71309. */
  71310. export interface ICameraInput<TCamera extends Camera> {
  71311. /**
  71312. * Defines the camera the input is attached to.
  71313. */
  71314. camera: Nullable<TCamera>;
  71315. /**
  71316. * Gets the class name of the current intput.
  71317. * @returns the class name
  71318. */
  71319. getClassName(): string;
  71320. /**
  71321. * Get the friendly name associated with the input class.
  71322. * @returns the input friendly name
  71323. */
  71324. getSimpleName(): string;
  71325. /**
  71326. * Attach the input controls to a specific dom element to get the input from.
  71327. * @param element Defines the element the controls should be listened from
  71328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71329. */
  71330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71331. /**
  71332. * Detach the current controls from the specified dom element.
  71333. * @param element Defines the element to stop listening the inputs from
  71334. */
  71335. detachControl(element: Nullable<HTMLElement>): void;
  71336. /**
  71337. * Update the current camera state depending on the inputs that have been used this frame.
  71338. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71339. */
  71340. checkInputs?: () => void;
  71341. }
  71342. /**
  71343. * Represents a map of input types to input instance or input index to input instance.
  71344. */
  71345. export interface CameraInputsMap<TCamera extends Camera> {
  71346. /**
  71347. * Accessor to the input by input type.
  71348. */
  71349. [name: string]: ICameraInput<TCamera>;
  71350. /**
  71351. * Accessor to the input by input index.
  71352. */
  71353. [idx: number]: ICameraInput<TCamera>;
  71354. }
  71355. /**
  71356. * This represents the input manager used within a camera.
  71357. * It helps dealing with all the different kind of input attached to a camera.
  71358. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71359. */
  71360. export class CameraInputsManager<TCamera extends Camera> {
  71361. /**
  71362. * Defines the list of inputs attahed to the camera.
  71363. */
  71364. attached: CameraInputsMap<TCamera>;
  71365. /**
  71366. * Defines the dom element the camera is collecting inputs from.
  71367. * This is null if the controls have not been attached.
  71368. */
  71369. attachedElement: Nullable<HTMLElement>;
  71370. /**
  71371. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71372. */
  71373. noPreventDefault: boolean;
  71374. /**
  71375. * Defined the camera the input manager belongs to.
  71376. */
  71377. camera: TCamera;
  71378. /**
  71379. * Update the current camera state depending on the inputs that have been used this frame.
  71380. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71381. */
  71382. checkInputs: () => void;
  71383. /**
  71384. * Instantiate a new Camera Input Manager.
  71385. * @param camera Defines the camera the input manager blongs to
  71386. */
  71387. constructor(camera: TCamera);
  71388. /**
  71389. * Add an input method to a camera
  71390. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71391. * @param input camera input method
  71392. */
  71393. add(input: ICameraInput<TCamera>): void;
  71394. /**
  71395. * Remove a specific input method from a camera
  71396. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  71397. * @param inputToRemove camera input method
  71398. */
  71399. remove(inputToRemove: ICameraInput<TCamera>): void;
  71400. /**
  71401. * Remove a specific input type from a camera
  71402. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  71403. * @param inputType the type of the input to remove
  71404. */
  71405. removeByType(inputType: string): void;
  71406. private _addCheckInputs;
  71407. /**
  71408. * Attach the input controls to the currently attached dom element to listen the events from.
  71409. * @param input Defines the input to attach
  71410. */
  71411. attachInput(input: ICameraInput<TCamera>): void;
  71412. /**
  71413. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  71414. * @param element Defines the dom element to collect the events from
  71415. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71416. */
  71417. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  71418. /**
  71419. * Detach the current manager inputs controls from a specific dom element.
  71420. * @param element Defines the dom element to collect the events from
  71421. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  71422. */
  71423. detachElement(element: HTMLElement, disconnect?: boolean): void;
  71424. /**
  71425. * Rebuild the dynamic inputCheck function from the current list of
  71426. * defined inputs in the manager.
  71427. */
  71428. rebuildInputCheck(): void;
  71429. /**
  71430. * Remove all attached input methods from a camera
  71431. */
  71432. clear(): void;
  71433. /**
  71434. * Serialize the current input manager attached to a camera.
  71435. * This ensures than once parsed,
  71436. * the input associated to the camera will be identical to the current ones
  71437. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  71438. */
  71439. serialize(serializedCamera: any): void;
  71440. /**
  71441. * Parses an input manager serialized JSON to restore the previous list of inputs
  71442. * and states associated to a camera.
  71443. * @param parsedCamera Defines the JSON to parse
  71444. */
  71445. parse(parsedCamera: any): void;
  71446. }
  71447. }
  71448. declare module BABYLON {
  71449. /**
  71450. * Gather the list of keyboard event types as constants.
  71451. */
  71452. export class KeyboardEventTypes {
  71453. /**
  71454. * The keydown event is fired when a key becomes active (pressed).
  71455. */
  71456. static readonly KEYDOWN: number;
  71457. /**
  71458. * The keyup event is fired when a key has been released.
  71459. */
  71460. static readonly KEYUP: number;
  71461. }
  71462. /**
  71463. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71464. */
  71465. export class KeyboardInfo {
  71466. /**
  71467. * Defines the type of event (KeyboardEventTypes)
  71468. */
  71469. type: number;
  71470. /**
  71471. * Defines the related dom event
  71472. */
  71473. event: KeyboardEvent;
  71474. /**
  71475. * Instantiates a new keyboard info.
  71476. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71477. * @param type Defines the type of event (KeyboardEventTypes)
  71478. * @param event Defines the related dom event
  71479. */
  71480. constructor(
  71481. /**
  71482. * Defines the type of event (KeyboardEventTypes)
  71483. */
  71484. type: number,
  71485. /**
  71486. * Defines the related dom event
  71487. */
  71488. event: KeyboardEvent);
  71489. }
  71490. /**
  71491. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71492. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  71493. */
  71494. export class KeyboardInfoPre extends KeyboardInfo {
  71495. /**
  71496. * Defines the type of event (KeyboardEventTypes)
  71497. */
  71498. type: number;
  71499. /**
  71500. * Defines the related dom event
  71501. */
  71502. event: KeyboardEvent;
  71503. /**
  71504. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  71505. */
  71506. skipOnPointerObservable: boolean;
  71507. /**
  71508. * Instantiates a new keyboard pre info.
  71509. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71510. * @param type Defines the type of event (KeyboardEventTypes)
  71511. * @param event Defines the related dom event
  71512. */
  71513. constructor(
  71514. /**
  71515. * Defines the type of event (KeyboardEventTypes)
  71516. */
  71517. type: number,
  71518. /**
  71519. * Defines the related dom event
  71520. */
  71521. event: KeyboardEvent);
  71522. }
  71523. }
  71524. declare module BABYLON {
  71525. /**
  71526. * Manage the keyboard inputs to control the movement of a free camera.
  71527. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71528. */
  71529. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  71530. /**
  71531. * Defines the camera the input is attached to.
  71532. */
  71533. camera: FreeCamera;
  71534. /**
  71535. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71536. */
  71537. keysUp: number[];
  71538. /**
  71539. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71540. */
  71541. keysDown: number[];
  71542. /**
  71543. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71544. */
  71545. keysLeft: number[];
  71546. /**
  71547. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71548. */
  71549. keysRight: number[];
  71550. private _keys;
  71551. private _onCanvasBlurObserver;
  71552. private _onKeyboardObserver;
  71553. private _engine;
  71554. private _scene;
  71555. /**
  71556. * Attach the input controls to a specific dom element to get the input from.
  71557. * @param element Defines the element the controls should be listened from
  71558. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71559. */
  71560. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71561. /**
  71562. * Detach the current controls from the specified dom element.
  71563. * @param element Defines the element to stop listening the inputs from
  71564. */
  71565. detachControl(element: Nullable<HTMLElement>): void;
  71566. /**
  71567. * Update the current camera state depending on the inputs that have been used this frame.
  71568. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71569. */
  71570. checkInputs(): void;
  71571. /**
  71572. * Gets the class name of the current intput.
  71573. * @returns the class name
  71574. */
  71575. getClassName(): string;
  71576. /** @hidden */
  71577. _onLostFocus(): void;
  71578. /**
  71579. * Get the friendly name associated with the input class.
  71580. * @returns the input friendly name
  71581. */
  71582. getSimpleName(): string;
  71583. }
  71584. }
  71585. declare module BABYLON {
  71586. /**
  71587. * Interface describing all the common properties and methods a shadow light needs to implement.
  71588. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  71589. * as well as binding the different shadow properties to the effects.
  71590. */
  71591. export interface IShadowLight extends Light {
  71592. /**
  71593. * The light id in the scene (used in scene.findLighById for instance)
  71594. */
  71595. id: string;
  71596. /**
  71597. * The position the shdow will be casted from.
  71598. */
  71599. position: Vector3;
  71600. /**
  71601. * In 2d mode (needCube being false), the direction used to cast the shadow.
  71602. */
  71603. direction: Vector3;
  71604. /**
  71605. * The transformed position. Position of the light in world space taking parenting in account.
  71606. */
  71607. transformedPosition: Vector3;
  71608. /**
  71609. * The transformed direction. Direction of the light in world space taking parenting in account.
  71610. */
  71611. transformedDirection: Vector3;
  71612. /**
  71613. * The friendly name of the light in the scene.
  71614. */
  71615. name: string;
  71616. /**
  71617. * Defines the shadow projection clipping minimum z value.
  71618. */
  71619. shadowMinZ: number;
  71620. /**
  71621. * Defines the shadow projection clipping maximum z value.
  71622. */
  71623. shadowMaxZ: number;
  71624. /**
  71625. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  71626. * @returns true if the information has been computed, false if it does not need to (no parenting)
  71627. */
  71628. computeTransformedInformation(): boolean;
  71629. /**
  71630. * Gets the scene the light belongs to.
  71631. * @returns The scene
  71632. */
  71633. getScene(): Scene;
  71634. /**
  71635. * Callback defining a custom Projection Matrix Builder.
  71636. * This can be used to override the default projection matrix computation.
  71637. */
  71638. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  71639. /**
  71640. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  71641. * @param matrix The materix to updated with the projection information
  71642. * @param viewMatrix The transform matrix of the light
  71643. * @param renderList The list of mesh to render in the map
  71644. * @returns The current light
  71645. */
  71646. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  71647. /**
  71648. * Gets the current depth scale used in ESM.
  71649. * @returns The scale
  71650. */
  71651. getDepthScale(): number;
  71652. /**
  71653. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  71654. * @returns true if a cube texture needs to be use
  71655. */
  71656. needCube(): boolean;
  71657. /**
  71658. * Detects if the projection matrix requires to be recomputed this frame.
  71659. * @returns true if it requires to be recomputed otherwise, false.
  71660. */
  71661. needProjectionMatrixCompute(): boolean;
  71662. /**
  71663. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  71664. */
  71665. forceProjectionMatrixCompute(): void;
  71666. /**
  71667. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  71668. * @param faceIndex The index of the face we are computed the direction to generate shadow
  71669. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  71670. */
  71671. getShadowDirection(faceIndex?: number): Vector3;
  71672. /**
  71673. * Gets the minZ used for shadow according to both the scene and the light.
  71674. * @param activeCamera The camera we are returning the min for
  71675. * @returns the depth min z
  71676. */
  71677. getDepthMinZ(activeCamera: Camera): number;
  71678. /**
  71679. * Gets the maxZ used for shadow according to both the scene and the light.
  71680. * @param activeCamera The camera we are returning the max for
  71681. * @returns the depth max z
  71682. */
  71683. getDepthMaxZ(activeCamera: Camera): number;
  71684. }
  71685. /**
  71686. * Base implementation IShadowLight
  71687. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  71688. */
  71689. export abstract class ShadowLight extends Light implements IShadowLight {
  71690. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  71691. protected _position: Vector3;
  71692. protected _setPosition(value: Vector3): void;
  71693. /**
  71694. * Sets the position the shadow will be casted from. Also use as the light position for both
  71695. * point and spot lights.
  71696. */
  71697. /**
  71698. * Sets the position the shadow will be casted from. Also use as the light position for both
  71699. * point and spot lights.
  71700. */
  71701. position: Vector3;
  71702. protected _direction: Vector3;
  71703. protected _setDirection(value: Vector3): void;
  71704. /**
  71705. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  71706. * Also use as the light direction on spot and directional lights.
  71707. */
  71708. /**
  71709. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  71710. * Also use as the light direction on spot and directional lights.
  71711. */
  71712. direction: Vector3;
  71713. private _shadowMinZ;
  71714. /**
  71715. * Gets the shadow projection clipping minimum z value.
  71716. */
  71717. /**
  71718. * Sets the shadow projection clipping minimum z value.
  71719. */
  71720. shadowMinZ: number;
  71721. private _shadowMaxZ;
  71722. /**
  71723. * Sets the shadow projection clipping maximum z value.
  71724. */
  71725. /**
  71726. * Gets the shadow projection clipping maximum z value.
  71727. */
  71728. shadowMaxZ: number;
  71729. /**
  71730. * Callback defining a custom Projection Matrix Builder.
  71731. * This can be used to override the default projection matrix computation.
  71732. */
  71733. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  71734. /**
  71735. * The transformed position. Position of the light in world space taking parenting in account.
  71736. */
  71737. transformedPosition: Vector3;
  71738. /**
  71739. * The transformed direction. Direction of the light in world space taking parenting in account.
  71740. */
  71741. transformedDirection: Vector3;
  71742. private _needProjectionMatrixCompute;
  71743. /**
  71744. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  71745. * @returns true if the information has been computed, false if it does not need to (no parenting)
  71746. */
  71747. computeTransformedInformation(): boolean;
  71748. /**
  71749. * Return the depth scale used for the shadow map.
  71750. * @returns the depth scale.
  71751. */
  71752. getDepthScale(): number;
  71753. /**
  71754. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  71755. * @param faceIndex The index of the face we are computed the direction to generate shadow
  71756. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  71757. */
  71758. getShadowDirection(faceIndex?: number): Vector3;
  71759. /**
  71760. * Returns the ShadowLight absolute position in the World.
  71761. * @returns the position vector in world space
  71762. */
  71763. getAbsolutePosition(): Vector3;
  71764. /**
  71765. * Sets the ShadowLight direction toward the passed target.
  71766. * @param target The point to target in local space
  71767. * @returns the updated ShadowLight direction
  71768. */
  71769. setDirectionToTarget(target: Vector3): Vector3;
  71770. /**
  71771. * Returns the light rotation in euler definition.
  71772. * @returns the x y z rotation in local space.
  71773. */
  71774. getRotation(): Vector3;
  71775. /**
  71776. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  71777. * @returns true if a cube texture needs to be use
  71778. */
  71779. needCube(): boolean;
  71780. /**
  71781. * Detects if the projection matrix requires to be recomputed this frame.
  71782. * @returns true if it requires to be recomputed otherwise, false.
  71783. */
  71784. needProjectionMatrixCompute(): boolean;
  71785. /**
  71786. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  71787. */
  71788. forceProjectionMatrixCompute(): void;
  71789. /** @hidden */
  71790. _initCache(): void;
  71791. /** @hidden */
  71792. _isSynchronized(): boolean;
  71793. /**
  71794. * Computes the world matrix of the node
  71795. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71796. * @returns the world matrix
  71797. */
  71798. computeWorldMatrix(force?: boolean): Matrix;
  71799. /**
  71800. * Gets the minZ used for shadow according to both the scene and the light.
  71801. * @param activeCamera The camera we are returning the min for
  71802. * @returns the depth min z
  71803. */
  71804. getDepthMinZ(activeCamera: Camera): number;
  71805. /**
  71806. * Gets the maxZ used for shadow according to both the scene and the light.
  71807. * @param activeCamera The camera we are returning the max for
  71808. * @returns the depth max z
  71809. */
  71810. getDepthMaxZ(activeCamera: Camera): number;
  71811. /**
  71812. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  71813. * @param matrix The materix to updated with the projection information
  71814. * @param viewMatrix The transform matrix of the light
  71815. * @param renderList The list of mesh to render in the map
  71816. * @returns The current light
  71817. */
  71818. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  71819. }
  71820. }
  71821. declare module BABYLON {
  71822. /**
  71823. * "Static Class" containing the most commonly used helper while dealing with material for
  71824. * rendering purpose.
  71825. *
  71826. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  71827. *
  71828. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  71829. */
  71830. export class MaterialHelper {
  71831. /**
  71832. * Bind the current view position to an effect.
  71833. * @param effect The effect to be bound
  71834. * @param scene The scene the eyes position is used from
  71835. */
  71836. static BindEyePosition(effect: Effect, scene: Scene): void;
  71837. /**
  71838. * Helps preparing the defines values about the UVs in used in the effect.
  71839. * UVs are shared as much as we can accross channels in the shaders.
  71840. * @param texture The texture we are preparing the UVs for
  71841. * @param defines The defines to update
  71842. * @param key The channel key "diffuse", "specular"... used in the shader
  71843. */
  71844. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  71845. /**
  71846. * Binds a texture matrix value to its corrsponding uniform
  71847. * @param texture The texture to bind the matrix for
  71848. * @param uniformBuffer The uniform buffer receivin the data
  71849. * @param key The channel key "diffuse", "specular"... used in the shader
  71850. */
  71851. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  71852. /**
  71853. * Gets the current status of the fog (should it be enabled?)
  71854. * @param mesh defines the mesh to evaluate for fog support
  71855. * @param scene defines the hosting scene
  71856. * @returns true if fog must be enabled
  71857. */
  71858. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  71859. /**
  71860. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  71861. * @param mesh defines the current mesh
  71862. * @param scene defines the current scene
  71863. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  71864. * @param pointsCloud defines if point cloud rendering has to be turned on
  71865. * @param fogEnabled defines if fog has to be turned on
  71866. * @param alphaTest defines if alpha testing has to be turned on
  71867. * @param defines defines the current list of defines
  71868. */
  71869. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  71870. /**
  71871. * Helper used to prepare the list of defines associated with frame values for shader compilation
  71872. * @param scene defines the current scene
  71873. * @param engine defines the current engine
  71874. * @param defines specifies the list of active defines
  71875. * @param useInstances defines if instances have to be turned on
  71876. * @param useClipPlane defines if clip plane have to be turned on
  71877. */
  71878. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  71879. /**
  71880. * Prepares the defines for bones
  71881. * @param mesh The mesh containing the geometry data we will draw
  71882. * @param defines The defines to update
  71883. */
  71884. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  71885. /**
  71886. * Prepares the defines for morph targets
  71887. * @param mesh The mesh containing the geometry data we will draw
  71888. * @param defines The defines to update
  71889. */
  71890. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  71891. /**
  71892. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  71893. * @param mesh The mesh containing the geometry data we will draw
  71894. * @param defines The defines to update
  71895. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  71896. * @param useBones Precise whether bones should be used or not (override mesh info)
  71897. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  71898. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  71899. * @returns false if defines are considered not dirty and have not been checked
  71900. */
  71901. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  71902. /**
  71903. * Prepares the defines related to multiview
  71904. * @param scene The scene we are intending to draw
  71905. * @param defines The defines to update
  71906. */
  71907. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  71908. /**
  71909. * Prepares the defines related to the light information passed in parameter
  71910. * @param scene The scene we are intending to draw
  71911. * @param mesh The mesh the effect is compiling for
  71912. * @param defines The defines to update
  71913. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  71914. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  71915. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  71916. * @returns true if normals will be required for the rest of the effect
  71917. */
  71918. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  71919. /**
  71920. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  71921. * that won t be acctive due to defines being turned off.
  71922. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  71923. * @param samplersList The samplers list
  71924. * @param defines The defines helping in the list generation
  71925. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  71926. */
  71927. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  71928. /**
  71929. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  71930. * @param defines The defines to update while falling back
  71931. * @param fallbacks The authorized effect fallbacks
  71932. * @param maxSimultaneousLights The maximum number of lights allowed
  71933. * @param rank the current rank of the Effect
  71934. * @returns The newly affected rank
  71935. */
  71936. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  71937. /**
  71938. * Prepares the list of attributes required for morph targets according to the effect defines.
  71939. * @param attribs The current list of supported attribs
  71940. * @param mesh The mesh to prepare the morph targets attributes for
  71941. * @param defines The current Defines of the effect
  71942. */
  71943. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  71944. /**
  71945. * Prepares the list of attributes required for bones according to the effect defines.
  71946. * @param attribs The current list of supported attribs
  71947. * @param mesh The mesh to prepare the bones attributes for
  71948. * @param defines The current Defines of the effect
  71949. * @param fallbacks The current efffect fallback strategy
  71950. */
  71951. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  71952. /**
  71953. * Check and prepare the list of attributes required for instances according to the effect defines.
  71954. * @param attribs The current list of supported attribs
  71955. * @param defines The current MaterialDefines of the effect
  71956. */
  71957. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  71958. /**
  71959. * Add the list of attributes required for instances to the attribs array.
  71960. * @param attribs The current list of supported attribs
  71961. */
  71962. static PushAttributesForInstances(attribs: string[]): void;
  71963. /**
  71964. * Binds the light shadow information to the effect for the given mesh.
  71965. * @param light The light containing the generator
  71966. * @param scene The scene the lights belongs to
  71967. * @param mesh The mesh we are binding the information to render
  71968. * @param lightIndex The light index in the effect used to render the mesh
  71969. * @param effect The effect we are binding the data to
  71970. */
  71971. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  71972. /**
  71973. * Binds the light information to the effect.
  71974. * @param light The light containing the generator
  71975. * @param effect The effect we are binding the data to
  71976. * @param lightIndex The light index in the effect used to render
  71977. */
  71978. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  71979. /**
  71980. * Binds the lights information from the scene to the effect for the given mesh.
  71981. * @param scene The scene the lights belongs to
  71982. * @param mesh The mesh we are binding the information to render
  71983. * @param effect The effect we are binding the data to
  71984. * @param defines The generated defines for the effect
  71985. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  71986. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  71987. */
  71988. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  71989. private static _tempFogColor;
  71990. /**
  71991. * Binds the fog information from the scene to the effect for the given mesh.
  71992. * @param scene The scene the lights belongs to
  71993. * @param mesh The mesh we are binding the information to render
  71994. * @param effect The effect we are binding the data to
  71995. * @param linearSpace Defines if the fog effect is applied in linear space
  71996. */
  71997. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  71998. /**
  71999. * Binds the bones information from the mesh to the effect.
  72000. * @param mesh The mesh we are binding the information to render
  72001. * @param effect The effect we are binding the data to
  72002. */
  72003. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  72004. /**
  72005. * Binds the morph targets information from the mesh to the effect.
  72006. * @param abstractMesh The mesh we are binding the information to render
  72007. * @param effect The effect we are binding the data to
  72008. */
  72009. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  72010. /**
  72011. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  72012. * @param defines The generated defines used in the effect
  72013. * @param effect The effect we are binding the data to
  72014. * @param scene The scene we are willing to render with logarithmic scale for
  72015. */
  72016. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  72017. /**
  72018. * Binds the clip plane information from the scene to the effect.
  72019. * @param scene The scene the clip plane information are extracted from
  72020. * @param effect The effect we are binding the data to
  72021. */
  72022. static BindClipPlane(effect: Effect, scene: Scene): void;
  72023. }
  72024. }
  72025. declare module BABYLON {
  72026. /** @hidden */
  72027. export var kernelBlurVaryingDeclaration: {
  72028. name: string;
  72029. shader: string;
  72030. };
  72031. }
  72032. declare module BABYLON {
  72033. /** @hidden */
  72034. export var kernelBlurFragment: {
  72035. name: string;
  72036. shader: string;
  72037. };
  72038. }
  72039. declare module BABYLON {
  72040. /** @hidden */
  72041. export var kernelBlurFragment2: {
  72042. name: string;
  72043. shader: string;
  72044. };
  72045. }
  72046. declare module BABYLON {
  72047. /** @hidden */
  72048. export var kernelBlurPixelShader: {
  72049. name: string;
  72050. shader: string;
  72051. };
  72052. }
  72053. declare module BABYLON {
  72054. /** @hidden */
  72055. export var kernelBlurVertex: {
  72056. name: string;
  72057. shader: string;
  72058. };
  72059. }
  72060. declare module BABYLON {
  72061. /** @hidden */
  72062. export var kernelBlurVertexShader: {
  72063. name: string;
  72064. shader: string;
  72065. };
  72066. }
  72067. declare module BABYLON {
  72068. /**
  72069. * The Blur Post Process which blurs an image based on a kernel and direction.
  72070. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  72071. */
  72072. export class BlurPostProcess extends PostProcess {
  72073. /** The direction in which to blur the image. */
  72074. direction: Vector2;
  72075. private blockCompilation;
  72076. protected _kernel: number;
  72077. protected _idealKernel: number;
  72078. protected _packedFloat: boolean;
  72079. private _staticDefines;
  72080. /**
  72081. * Sets the length in pixels of the blur sample region
  72082. */
  72083. /**
  72084. * Gets the length in pixels of the blur sample region
  72085. */
  72086. kernel: number;
  72087. /**
  72088. * Sets wether or not the blur needs to unpack/repack floats
  72089. */
  72090. /**
  72091. * Gets wether or not the blur is unpacking/repacking floats
  72092. */
  72093. packedFloat: boolean;
  72094. /**
  72095. * Creates a new instance BlurPostProcess
  72096. * @param name The name of the effect.
  72097. * @param direction The direction in which to blur the image.
  72098. * @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.
  72099. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  72100. * @param camera The camera to apply the render pass to.
  72101. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72102. * @param engine The engine which the post process will be applied. (default: current engine)
  72103. * @param reusable If the post process can be reused on the same frame. (default: false)
  72104. * @param textureType Type of textures used when performing the post process. (default: 0)
  72105. * @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)
  72106. */
  72107. constructor(name: string,
  72108. /** The direction in which to blur the image. */
  72109. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  72110. /**
  72111. * Updates the effect with the current post process compile time values and recompiles the shader.
  72112. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72113. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72114. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72115. * @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
  72116. * @param onCompiled Called when the shader has been compiled.
  72117. * @param onError Called if there is an error when compiling a shader.
  72118. */
  72119. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72120. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72121. /**
  72122. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  72123. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  72124. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  72125. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  72126. * The gaps between physical kernels are compensated for in the weighting of the samples
  72127. * @param idealKernel Ideal blur kernel.
  72128. * @return Nearest best kernel.
  72129. */
  72130. protected _nearestBestKernel(idealKernel: number): number;
  72131. /**
  72132. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  72133. * @param x The point on the Gaussian distribution to sample.
  72134. * @return the value of the Gaussian function at x.
  72135. */
  72136. protected _gaussianWeight(x: number): number;
  72137. /**
  72138. * Generates a string that can be used as a floating point number in GLSL.
  72139. * @param x Value to print.
  72140. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  72141. * @return GLSL float string.
  72142. */
  72143. protected _glslFloat(x: number, decimalFigures?: number): string;
  72144. }
  72145. }
  72146. declare module BABYLON {
  72147. /** @hidden */
  72148. export var shadowMapPixelShader: {
  72149. name: string;
  72150. shader: string;
  72151. };
  72152. }
  72153. declare module BABYLON {
  72154. /** @hidden */
  72155. export var bonesDeclaration: {
  72156. name: string;
  72157. shader: string;
  72158. };
  72159. }
  72160. declare module BABYLON {
  72161. /** @hidden */
  72162. export var morphTargetsVertexGlobalDeclaration: {
  72163. name: string;
  72164. shader: string;
  72165. };
  72166. }
  72167. declare module BABYLON {
  72168. /** @hidden */
  72169. export var morphTargetsVertexDeclaration: {
  72170. name: string;
  72171. shader: string;
  72172. };
  72173. }
  72174. declare module BABYLON {
  72175. /** @hidden */
  72176. export var instancesDeclaration: {
  72177. name: string;
  72178. shader: string;
  72179. };
  72180. }
  72181. declare module BABYLON {
  72182. /** @hidden */
  72183. export var helperFunctions: {
  72184. name: string;
  72185. shader: string;
  72186. };
  72187. }
  72188. declare module BABYLON {
  72189. /** @hidden */
  72190. export var morphTargetsVertex: {
  72191. name: string;
  72192. shader: string;
  72193. };
  72194. }
  72195. declare module BABYLON {
  72196. /** @hidden */
  72197. export var instancesVertex: {
  72198. name: string;
  72199. shader: string;
  72200. };
  72201. }
  72202. declare module BABYLON {
  72203. /** @hidden */
  72204. export var bonesVertex: {
  72205. name: string;
  72206. shader: string;
  72207. };
  72208. }
  72209. declare module BABYLON {
  72210. /** @hidden */
  72211. export var shadowMapVertexShader: {
  72212. name: string;
  72213. shader: string;
  72214. };
  72215. }
  72216. declare module BABYLON {
  72217. /** @hidden */
  72218. export var depthBoxBlurPixelShader: {
  72219. name: string;
  72220. shader: string;
  72221. };
  72222. }
  72223. declare module BABYLON {
  72224. /**
  72225. * Defines the options associated with the creation of a custom shader for a shadow generator.
  72226. */
  72227. export interface ICustomShaderOptions {
  72228. /**
  72229. * Gets or sets the custom shader name to use
  72230. */
  72231. shaderName: string;
  72232. /**
  72233. * The list of attribute names used in the shader
  72234. */
  72235. attributes?: string[];
  72236. /**
  72237. * The list of unifrom names used in the shader
  72238. */
  72239. uniforms?: string[];
  72240. /**
  72241. * The list of sampler names used in the shader
  72242. */
  72243. samplers?: string[];
  72244. /**
  72245. * The list of defines used in the shader
  72246. */
  72247. defines?: string[];
  72248. }
  72249. /**
  72250. * Interface to implement to create a shadow generator compatible with BJS.
  72251. */
  72252. export interface IShadowGenerator {
  72253. /**
  72254. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  72255. * @returns The render target texture if present otherwise, null
  72256. */
  72257. getShadowMap(): Nullable<RenderTargetTexture>;
  72258. /**
  72259. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  72260. * @returns The render target texture if the shadow map is present otherwise, null
  72261. */
  72262. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  72263. /**
  72264. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  72265. * @param subMesh The submesh we want to render in the shadow map
  72266. * @param useInstances Defines wether will draw in the map using instances
  72267. * @returns true if ready otherwise, false
  72268. */
  72269. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72270. /**
  72271. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  72272. * @param defines Defines of the material we want to update
  72273. * @param lightIndex Index of the light in the enabled light list of the material
  72274. */
  72275. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  72276. /**
  72277. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  72278. * defined in the generator but impacting the effect).
  72279. * It implies the unifroms available on the materials are the standard BJS ones.
  72280. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  72281. * @param effect The effect we are binfing the information for
  72282. */
  72283. bindShadowLight(lightIndex: string, effect: Effect): void;
  72284. /**
  72285. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  72286. * (eq to shadow prjection matrix * light transform matrix)
  72287. * @returns The transform matrix used to create the shadow map
  72288. */
  72289. getTransformMatrix(): Matrix;
  72290. /**
  72291. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  72292. * Cube and 2D textures for instance.
  72293. */
  72294. recreateShadowMap(): void;
  72295. /**
  72296. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72297. * @param onCompiled Callback triggered at the and of the effects compilation
  72298. * @param options Sets of optional options forcing the compilation with different modes
  72299. */
  72300. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  72301. useInstances: boolean;
  72302. }>): void;
  72303. /**
  72304. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72305. * @param options Sets of optional options forcing the compilation with different modes
  72306. * @returns A promise that resolves when the compilation completes
  72307. */
  72308. forceCompilationAsync(options?: Partial<{
  72309. useInstances: boolean;
  72310. }>): Promise<void>;
  72311. /**
  72312. * Serializes the shadow generator setup to a json object.
  72313. * @returns The serialized JSON object
  72314. */
  72315. serialize(): any;
  72316. /**
  72317. * Disposes the Shadow map and related Textures and effects.
  72318. */
  72319. dispose(): void;
  72320. }
  72321. /**
  72322. * Default implementation IShadowGenerator.
  72323. * This is the main object responsible of generating shadows in the framework.
  72324. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  72325. */
  72326. export class ShadowGenerator implements IShadowGenerator {
  72327. /**
  72328. * Shadow generator mode None: no filtering applied.
  72329. */
  72330. static readonly FILTER_NONE: number;
  72331. /**
  72332. * Shadow generator mode ESM: Exponential Shadow Mapping.
  72333. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72334. */
  72335. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  72336. /**
  72337. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  72338. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  72339. */
  72340. static readonly FILTER_POISSONSAMPLING: number;
  72341. /**
  72342. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  72343. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72344. */
  72345. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  72346. /**
  72347. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  72348. * edge artifacts on steep falloff.
  72349. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72350. */
  72351. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  72352. /**
  72353. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  72354. * edge artifacts on steep falloff.
  72355. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72356. */
  72357. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  72358. /**
  72359. * Shadow generator mode PCF: Percentage Closer Filtering
  72360. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  72361. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  72362. */
  72363. static readonly FILTER_PCF: number;
  72364. /**
  72365. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  72366. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  72367. * Contact Hardening
  72368. */
  72369. static readonly FILTER_PCSS: number;
  72370. /**
  72371. * Reserved for PCF and PCSS
  72372. * Highest Quality.
  72373. *
  72374. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  72375. *
  72376. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  72377. */
  72378. static readonly QUALITY_HIGH: number;
  72379. /**
  72380. * Reserved for PCF and PCSS
  72381. * Good tradeoff for quality/perf cross devices
  72382. *
  72383. * Execute PCF on a 3*3 kernel.
  72384. *
  72385. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  72386. */
  72387. static readonly QUALITY_MEDIUM: number;
  72388. /**
  72389. * Reserved for PCF and PCSS
  72390. * The lowest quality but the fastest.
  72391. *
  72392. * Execute PCF on a 1*1 kernel.
  72393. *
  72394. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  72395. */
  72396. static readonly QUALITY_LOW: number;
  72397. /** Gets or sets the custom shader name to use */
  72398. customShaderOptions: ICustomShaderOptions;
  72399. /**
  72400. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  72401. */
  72402. onBeforeShadowMapRenderObservable: Observable<Effect>;
  72403. /**
  72404. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  72405. */
  72406. onAfterShadowMapRenderObservable: Observable<Effect>;
  72407. /**
  72408. * Observable triggered before a mesh is rendered in the shadow map.
  72409. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  72410. */
  72411. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  72412. /**
  72413. * Observable triggered after a mesh is rendered in the shadow map.
  72414. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  72415. */
  72416. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  72417. private _bias;
  72418. /**
  72419. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  72420. */
  72421. /**
  72422. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  72423. */
  72424. bias: number;
  72425. private _normalBias;
  72426. /**
  72427. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  72428. */
  72429. /**
  72430. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  72431. */
  72432. normalBias: number;
  72433. private _blurBoxOffset;
  72434. /**
  72435. * Gets the blur box offset: offset applied during the blur pass.
  72436. * Only useful if useKernelBlur = false
  72437. */
  72438. /**
  72439. * Sets the blur box offset: offset applied during the blur pass.
  72440. * Only useful if useKernelBlur = false
  72441. */
  72442. blurBoxOffset: number;
  72443. private _blurScale;
  72444. /**
  72445. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  72446. * 2 means half of the size.
  72447. */
  72448. /**
  72449. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  72450. * 2 means half of the size.
  72451. */
  72452. blurScale: number;
  72453. private _blurKernel;
  72454. /**
  72455. * Gets the blur kernel: kernel size of the blur pass.
  72456. * Only useful if useKernelBlur = true
  72457. */
  72458. /**
  72459. * Sets the blur kernel: kernel size of the blur pass.
  72460. * Only useful if useKernelBlur = true
  72461. */
  72462. blurKernel: number;
  72463. private _useKernelBlur;
  72464. /**
  72465. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  72466. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  72467. */
  72468. /**
  72469. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  72470. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  72471. */
  72472. useKernelBlur: boolean;
  72473. private _depthScale;
  72474. /**
  72475. * Gets the depth scale used in ESM mode.
  72476. */
  72477. /**
  72478. * Sets the depth scale used in ESM mode.
  72479. * This can override the scale stored on the light.
  72480. */
  72481. depthScale: number;
  72482. private _filter;
  72483. /**
  72484. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  72485. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  72486. */
  72487. /**
  72488. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  72489. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  72490. */
  72491. filter: number;
  72492. /**
  72493. * Gets if the current filter is set to Poisson Sampling.
  72494. */
  72495. /**
  72496. * Sets the current filter to Poisson Sampling.
  72497. */
  72498. usePoissonSampling: boolean;
  72499. /**
  72500. * Gets if the current filter is set to ESM.
  72501. */
  72502. /**
  72503. * Sets the current filter is to ESM.
  72504. */
  72505. useExponentialShadowMap: boolean;
  72506. /**
  72507. * Gets if the current filter is set to filtered ESM.
  72508. */
  72509. /**
  72510. * Gets if the current filter is set to filtered ESM.
  72511. */
  72512. useBlurExponentialShadowMap: boolean;
  72513. /**
  72514. * Gets if the current filter is set to "close ESM" (using the inverse of the
  72515. * exponential to prevent steep falloff artifacts).
  72516. */
  72517. /**
  72518. * Sets the current filter to "close ESM" (using the inverse of the
  72519. * exponential to prevent steep falloff artifacts).
  72520. */
  72521. useCloseExponentialShadowMap: boolean;
  72522. /**
  72523. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  72524. * exponential to prevent steep falloff artifacts).
  72525. */
  72526. /**
  72527. * Sets the current filter to filtered "close ESM" (using the inverse of the
  72528. * exponential to prevent steep falloff artifacts).
  72529. */
  72530. useBlurCloseExponentialShadowMap: boolean;
  72531. /**
  72532. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  72533. */
  72534. /**
  72535. * Sets the current filter to "PCF" (percentage closer filtering).
  72536. */
  72537. usePercentageCloserFiltering: boolean;
  72538. private _filteringQuality;
  72539. /**
  72540. * Gets the PCF or PCSS Quality.
  72541. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  72542. */
  72543. /**
  72544. * Sets the PCF or PCSS Quality.
  72545. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  72546. */
  72547. filteringQuality: number;
  72548. /**
  72549. * Gets if the current filter is set to "PCSS" (contact hardening).
  72550. */
  72551. /**
  72552. * Sets the current filter to "PCSS" (contact hardening).
  72553. */
  72554. useContactHardeningShadow: boolean;
  72555. private _contactHardeningLightSizeUVRatio;
  72556. /**
  72557. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  72558. * Using a ratio helps keeping shape stability independently of the map size.
  72559. *
  72560. * It does not account for the light projection as it was having too much
  72561. * instability during the light setup or during light position changes.
  72562. *
  72563. * Only valid if useContactHardeningShadow is true.
  72564. */
  72565. /**
  72566. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  72567. * Using a ratio helps keeping shape stability independently of the map size.
  72568. *
  72569. * It does not account for the light projection as it was having too much
  72570. * instability during the light setup or during light position changes.
  72571. *
  72572. * Only valid if useContactHardeningShadow is true.
  72573. */
  72574. contactHardeningLightSizeUVRatio: number;
  72575. private _darkness;
  72576. /** Gets or sets the actual darkness of a shadow */
  72577. darkness: number;
  72578. /**
  72579. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  72580. * 0 means strongest and 1 would means no shadow.
  72581. * @returns the darkness.
  72582. */
  72583. getDarkness(): number;
  72584. /**
  72585. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  72586. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  72587. * @returns the shadow generator allowing fluent coding.
  72588. */
  72589. setDarkness(darkness: number): ShadowGenerator;
  72590. private _transparencyShadow;
  72591. /** Gets or sets the ability to have transparent shadow */
  72592. transparencyShadow: boolean;
  72593. /**
  72594. * Sets the ability to have transparent shadow (boolean).
  72595. * @param transparent True if transparent else False
  72596. * @returns the shadow generator allowing fluent coding
  72597. */
  72598. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  72599. private _shadowMap;
  72600. private _shadowMap2;
  72601. /**
  72602. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  72603. * @returns The render target texture if present otherwise, null
  72604. */
  72605. getShadowMap(): Nullable<RenderTargetTexture>;
  72606. /**
  72607. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  72608. * @returns The render target texture if the shadow map is present otherwise, null
  72609. */
  72610. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  72611. /**
  72612. * Gets the class name of that object
  72613. * @returns "ShadowGenerator"
  72614. */
  72615. getClassName(): string;
  72616. /**
  72617. * Helper function to add a mesh and its descendants to the list of shadow casters.
  72618. * @param mesh Mesh to add
  72619. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  72620. * @returns the Shadow Generator itself
  72621. */
  72622. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  72623. /**
  72624. * Helper function to remove a mesh and its descendants from the list of shadow casters
  72625. * @param mesh Mesh to remove
  72626. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  72627. * @returns the Shadow Generator itself
  72628. */
  72629. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  72630. /**
  72631. * Controls the extent to which the shadows fade out at the edge of the frustum
  72632. * Used only by directionals and spots
  72633. */
  72634. frustumEdgeFalloff: number;
  72635. private _light;
  72636. /**
  72637. * Returns the associated light object.
  72638. * @returns the light generating the shadow
  72639. */
  72640. getLight(): IShadowLight;
  72641. /**
  72642. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  72643. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  72644. * It might on the other hand introduce peter panning.
  72645. */
  72646. forceBackFacesOnly: boolean;
  72647. private _scene;
  72648. private _lightDirection;
  72649. private _effect;
  72650. private _viewMatrix;
  72651. private _projectionMatrix;
  72652. private _transformMatrix;
  72653. private _cachedPosition;
  72654. private _cachedDirection;
  72655. private _cachedDefines;
  72656. private _currentRenderID;
  72657. private _boxBlurPostprocess;
  72658. private _kernelBlurXPostprocess;
  72659. private _kernelBlurYPostprocess;
  72660. private _blurPostProcesses;
  72661. private _mapSize;
  72662. private _currentFaceIndex;
  72663. private _currentFaceIndexCache;
  72664. private _textureType;
  72665. private _defaultTextureMatrix;
  72666. /** @hidden */
  72667. static _SceneComponentInitialization: (scene: Scene) => void;
  72668. /**
  72669. * Creates a ShadowGenerator object.
  72670. * A ShadowGenerator is the required tool to use the shadows.
  72671. * Each light casting shadows needs to use its own ShadowGenerator.
  72672. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  72673. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  72674. * @param light The light object generating the shadows.
  72675. * @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.
  72676. */
  72677. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  72678. private _initializeGenerator;
  72679. private _initializeShadowMap;
  72680. private _initializeBlurRTTAndPostProcesses;
  72681. private _renderForShadowMap;
  72682. private _renderSubMeshForShadowMap;
  72683. private _applyFilterValues;
  72684. /**
  72685. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72686. * @param onCompiled Callback triggered at the and of the effects compilation
  72687. * @param options Sets of optional options forcing the compilation with different modes
  72688. */
  72689. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  72690. useInstances: boolean;
  72691. }>): void;
  72692. /**
  72693. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72694. * @param options Sets of optional options forcing the compilation with different modes
  72695. * @returns A promise that resolves when the compilation completes
  72696. */
  72697. forceCompilationAsync(options?: Partial<{
  72698. useInstances: boolean;
  72699. }>): Promise<void>;
  72700. /**
  72701. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  72702. * @param subMesh The submesh we want to render in the shadow map
  72703. * @param useInstances Defines wether will draw in the map using instances
  72704. * @returns true if ready otherwise, false
  72705. */
  72706. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72707. /**
  72708. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  72709. * @param defines Defines of the material we want to update
  72710. * @param lightIndex Index of the light in the enabled light list of the material
  72711. */
  72712. prepareDefines(defines: any, lightIndex: number): void;
  72713. /**
  72714. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  72715. * defined in the generator but impacting the effect).
  72716. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  72717. * @param effect The effect we are binfing the information for
  72718. */
  72719. bindShadowLight(lightIndex: string, effect: Effect): void;
  72720. /**
  72721. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  72722. * (eq to shadow prjection matrix * light transform matrix)
  72723. * @returns The transform matrix used to create the shadow map
  72724. */
  72725. getTransformMatrix(): Matrix;
  72726. /**
  72727. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  72728. * Cube and 2D textures for instance.
  72729. */
  72730. recreateShadowMap(): void;
  72731. private _disposeBlurPostProcesses;
  72732. private _disposeRTTandPostProcesses;
  72733. /**
  72734. * Disposes the ShadowGenerator.
  72735. * Returns nothing.
  72736. */
  72737. dispose(): void;
  72738. /**
  72739. * Serializes the shadow generator setup to a json object.
  72740. * @returns The serialized JSON object
  72741. */
  72742. serialize(): any;
  72743. /**
  72744. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  72745. * @param parsedShadowGenerator The JSON object to parse
  72746. * @param scene The scene to create the shadow map for
  72747. * @returns The parsed shadow generator
  72748. */
  72749. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  72750. }
  72751. }
  72752. declare module BABYLON {
  72753. /**
  72754. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  72755. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  72756. * 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.
  72757. */
  72758. export abstract class Light extends Node {
  72759. /**
  72760. * Falloff Default: light is falling off following the material specification:
  72761. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  72762. */
  72763. static readonly FALLOFF_DEFAULT: number;
  72764. /**
  72765. * Falloff Physical: light is falling off following the inverse squared distance law.
  72766. */
  72767. static readonly FALLOFF_PHYSICAL: number;
  72768. /**
  72769. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  72770. * to enhance interoperability with other engines.
  72771. */
  72772. static readonly FALLOFF_GLTF: number;
  72773. /**
  72774. * Falloff Standard: light is falling off like in the standard material
  72775. * to enhance interoperability with other materials.
  72776. */
  72777. static readonly FALLOFF_STANDARD: number;
  72778. /**
  72779. * If every light affecting the material is in this lightmapMode,
  72780. * material.lightmapTexture adds or multiplies
  72781. * (depends on material.useLightmapAsShadowmap)
  72782. * after every other light calculations.
  72783. */
  72784. static readonly LIGHTMAP_DEFAULT: number;
  72785. /**
  72786. * material.lightmapTexture as only diffuse lighting from this light
  72787. * adds only specular lighting from this light
  72788. * adds dynamic shadows
  72789. */
  72790. static readonly LIGHTMAP_SPECULAR: number;
  72791. /**
  72792. * material.lightmapTexture as only lighting
  72793. * no light calculation from this light
  72794. * only adds dynamic shadows from this light
  72795. */
  72796. static readonly LIGHTMAP_SHADOWSONLY: number;
  72797. /**
  72798. * Each light type uses the default quantity according to its type:
  72799. * point/spot lights use luminous intensity
  72800. * directional lights use illuminance
  72801. */
  72802. static readonly INTENSITYMODE_AUTOMATIC: number;
  72803. /**
  72804. * lumen (lm)
  72805. */
  72806. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  72807. /**
  72808. * candela (lm/sr)
  72809. */
  72810. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  72811. /**
  72812. * lux (lm/m^2)
  72813. */
  72814. static readonly INTENSITYMODE_ILLUMINANCE: number;
  72815. /**
  72816. * nit (cd/m^2)
  72817. */
  72818. static readonly INTENSITYMODE_LUMINANCE: number;
  72819. /**
  72820. * Light type const id of the point light.
  72821. */
  72822. static readonly LIGHTTYPEID_POINTLIGHT: number;
  72823. /**
  72824. * Light type const id of the directional light.
  72825. */
  72826. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  72827. /**
  72828. * Light type const id of the spot light.
  72829. */
  72830. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  72831. /**
  72832. * Light type const id of the hemispheric light.
  72833. */
  72834. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  72835. /**
  72836. * Diffuse gives the basic color to an object.
  72837. */
  72838. diffuse: Color3;
  72839. /**
  72840. * Specular produces a highlight color on an object.
  72841. * Note: This is note affecting PBR materials.
  72842. */
  72843. specular: Color3;
  72844. /**
  72845. * Defines the falloff type for this light. This lets overrriding how punctual light are
  72846. * falling off base on range or angle.
  72847. * This can be set to any values in Light.FALLOFF_x.
  72848. *
  72849. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  72850. * other types of materials.
  72851. */
  72852. falloffType: number;
  72853. /**
  72854. * Strength of the light.
  72855. * Note: By default it is define in the framework own unit.
  72856. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  72857. */
  72858. intensity: number;
  72859. private _range;
  72860. protected _inverseSquaredRange: number;
  72861. /**
  72862. * Defines how far from the source the light is impacting in scene units.
  72863. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  72864. */
  72865. /**
  72866. * Defines how far from the source the light is impacting in scene units.
  72867. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  72868. */
  72869. range: number;
  72870. /**
  72871. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  72872. * of light.
  72873. */
  72874. private _photometricScale;
  72875. private _intensityMode;
  72876. /**
  72877. * Gets the photometric scale used to interpret the intensity.
  72878. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  72879. */
  72880. /**
  72881. * Sets the photometric scale used to interpret the intensity.
  72882. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  72883. */
  72884. intensityMode: number;
  72885. private _radius;
  72886. /**
  72887. * Gets the light radius used by PBR Materials to simulate soft area lights.
  72888. */
  72889. /**
  72890. * sets the light radius used by PBR Materials to simulate soft area lights.
  72891. */
  72892. radius: number;
  72893. private _renderPriority;
  72894. /**
  72895. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  72896. * exceeding the number allowed of the materials.
  72897. */
  72898. renderPriority: number;
  72899. private _shadowEnabled;
  72900. /**
  72901. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  72902. * the current shadow generator.
  72903. */
  72904. /**
  72905. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  72906. * the current shadow generator.
  72907. */
  72908. shadowEnabled: boolean;
  72909. private _includedOnlyMeshes;
  72910. /**
  72911. * Gets the only meshes impacted by this light.
  72912. */
  72913. /**
  72914. * Sets the only meshes impacted by this light.
  72915. */
  72916. includedOnlyMeshes: AbstractMesh[];
  72917. private _excludedMeshes;
  72918. /**
  72919. * Gets the meshes not impacted by this light.
  72920. */
  72921. /**
  72922. * Sets the meshes not impacted by this light.
  72923. */
  72924. excludedMeshes: AbstractMesh[];
  72925. private _excludeWithLayerMask;
  72926. /**
  72927. * Gets the layer id use to find what meshes are not impacted by the light.
  72928. * Inactive if 0
  72929. */
  72930. /**
  72931. * Sets the layer id use to find what meshes are not impacted by the light.
  72932. * Inactive if 0
  72933. */
  72934. excludeWithLayerMask: number;
  72935. private _includeOnlyWithLayerMask;
  72936. /**
  72937. * Gets the layer id use to find what meshes are impacted by the light.
  72938. * Inactive if 0
  72939. */
  72940. /**
  72941. * Sets the layer id use to find what meshes are impacted by the light.
  72942. * Inactive if 0
  72943. */
  72944. includeOnlyWithLayerMask: number;
  72945. private _lightmapMode;
  72946. /**
  72947. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  72948. */
  72949. /**
  72950. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  72951. */
  72952. lightmapMode: number;
  72953. /**
  72954. * Shadow generator associted to the light.
  72955. * @hidden Internal use only.
  72956. */
  72957. _shadowGenerator: Nullable<IShadowGenerator>;
  72958. /**
  72959. * @hidden Internal use only.
  72960. */
  72961. _excludedMeshesIds: string[];
  72962. /**
  72963. * @hidden Internal use only.
  72964. */
  72965. _includedOnlyMeshesIds: string[];
  72966. /**
  72967. * The current light unifom buffer.
  72968. * @hidden Internal use only.
  72969. */
  72970. _uniformBuffer: UniformBuffer;
  72971. /**
  72972. * Creates a Light object in the scene.
  72973. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72974. * @param name The firendly name of the light
  72975. * @param scene The scene the light belongs too
  72976. */
  72977. constructor(name: string, scene: Scene);
  72978. protected abstract _buildUniformLayout(): void;
  72979. /**
  72980. * Sets the passed Effect "effect" with the Light information.
  72981. * @param effect The effect to update
  72982. * @param lightIndex The index of the light in the effect to update
  72983. * @returns The light
  72984. */
  72985. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  72986. /**
  72987. * Returns the string "Light".
  72988. * @returns the class name
  72989. */
  72990. getClassName(): string;
  72991. /** @hidden */
  72992. readonly _isLight: boolean;
  72993. /**
  72994. * Converts the light information to a readable string for debug purpose.
  72995. * @param fullDetails Supports for multiple levels of logging within scene loading
  72996. * @returns the human readable light info
  72997. */
  72998. toString(fullDetails?: boolean): string;
  72999. /** @hidden */
  73000. protected _syncParentEnabledState(): void;
  73001. /**
  73002. * Set the enabled state of this node.
  73003. * @param value - the new enabled state
  73004. */
  73005. setEnabled(value: boolean): void;
  73006. /**
  73007. * Returns the Light associated shadow generator if any.
  73008. * @return the associated shadow generator.
  73009. */
  73010. getShadowGenerator(): Nullable<IShadowGenerator>;
  73011. /**
  73012. * Returns a Vector3, the absolute light position in the World.
  73013. * @returns the world space position of the light
  73014. */
  73015. getAbsolutePosition(): Vector3;
  73016. /**
  73017. * Specifies if the light will affect the passed mesh.
  73018. * @param mesh The mesh to test against the light
  73019. * @return true the mesh is affected otherwise, false.
  73020. */
  73021. canAffectMesh(mesh: AbstractMesh): boolean;
  73022. /**
  73023. * Sort function to order lights for rendering.
  73024. * @param a First Light object to compare to second.
  73025. * @param b Second Light object to compare first.
  73026. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  73027. */
  73028. static CompareLightsPriority(a: Light, b: Light): number;
  73029. /**
  73030. * Releases resources associated with this node.
  73031. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  73032. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  73033. */
  73034. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73035. /**
  73036. * Returns the light type ID (integer).
  73037. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73038. */
  73039. getTypeID(): number;
  73040. /**
  73041. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  73042. * @returns the scaled intensity in intensity mode unit
  73043. */
  73044. getScaledIntensity(): number;
  73045. /**
  73046. * Returns a new Light object, named "name", from the current one.
  73047. * @param name The name of the cloned light
  73048. * @returns the new created light
  73049. */
  73050. clone(name: string): Nullable<Light>;
  73051. /**
  73052. * Serializes the current light into a Serialization object.
  73053. * @returns the serialized object.
  73054. */
  73055. serialize(): any;
  73056. /**
  73057. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  73058. * This new light is named "name" and added to the passed scene.
  73059. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  73060. * @param name The friendly name of the light
  73061. * @param scene The scene the new light will belong to
  73062. * @returns the constructor function
  73063. */
  73064. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  73065. /**
  73066. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  73067. * @param parsedLight The JSON representation of the light
  73068. * @param scene The scene to create the parsed light in
  73069. * @returns the created light after parsing
  73070. */
  73071. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  73072. private _hookArrayForExcluded;
  73073. private _hookArrayForIncludedOnly;
  73074. private _resyncMeshes;
  73075. /**
  73076. * Forces the meshes to update their light related information in their rendering used effects
  73077. * @hidden Internal Use Only
  73078. */
  73079. _markMeshesAsLightDirty(): void;
  73080. /**
  73081. * Recomputes the cached photometric scale if needed.
  73082. */
  73083. private _computePhotometricScale;
  73084. /**
  73085. * Returns the Photometric Scale according to the light type and intensity mode.
  73086. */
  73087. private _getPhotometricScale;
  73088. /**
  73089. * Reorder the light in the scene according to their defined priority.
  73090. * @hidden Internal Use Only
  73091. */
  73092. _reorderLightsInScene(): void;
  73093. /**
  73094. * Prepares the list of defines specific to the light type.
  73095. * @param defines the list of defines
  73096. * @param lightIndex defines the index of the light for the effect
  73097. */
  73098. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73099. }
  73100. }
  73101. declare module BABYLON {
  73102. /**
  73103. * Interface used to define Action
  73104. */
  73105. export interface IAction {
  73106. /**
  73107. * Trigger for the action
  73108. */
  73109. trigger: number;
  73110. /** Options of the trigger */
  73111. triggerOptions: any;
  73112. /**
  73113. * Gets the trigger parameters
  73114. * @returns the trigger parameters
  73115. */
  73116. getTriggerParameter(): any;
  73117. /**
  73118. * Internal only - executes current action event
  73119. * @hidden
  73120. */
  73121. _executeCurrent(evt?: ActionEvent): void;
  73122. /**
  73123. * Serialize placeholder for child classes
  73124. * @param parent of child
  73125. * @returns the serialized object
  73126. */
  73127. serialize(parent: any): any;
  73128. /**
  73129. * Internal only
  73130. * @hidden
  73131. */
  73132. _prepare(): void;
  73133. /**
  73134. * Internal only - manager for action
  73135. * @hidden
  73136. */
  73137. _actionManager: AbstractActionManager;
  73138. /**
  73139. * Adds action to chain of actions, may be a DoNothingAction
  73140. * @param action defines the next action to execute
  73141. * @returns The action passed in
  73142. * @see https://www.babylonjs-playground.com/#1T30HR#0
  73143. */
  73144. then(action: IAction): IAction;
  73145. }
  73146. /**
  73147. * The action to be carried out following a trigger
  73148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  73149. */
  73150. export class Action implements IAction {
  73151. /** the trigger, with or without parameters, for the action */
  73152. triggerOptions: any;
  73153. /**
  73154. * Trigger for the action
  73155. */
  73156. trigger: number;
  73157. /**
  73158. * Internal only - manager for action
  73159. * @hidden
  73160. */
  73161. _actionManager: ActionManager;
  73162. private _nextActiveAction;
  73163. private _child;
  73164. private _condition?;
  73165. private _triggerParameter;
  73166. /**
  73167. * An event triggered prior to action being executed.
  73168. */
  73169. onBeforeExecuteObservable: Observable<Action>;
  73170. /**
  73171. * Creates a new Action
  73172. * @param triggerOptions the trigger, with or without parameters, for the action
  73173. * @param condition an optional determinant of action
  73174. */
  73175. constructor(
  73176. /** the trigger, with or without parameters, for the action */
  73177. triggerOptions: any, condition?: Condition);
  73178. /**
  73179. * Internal only
  73180. * @hidden
  73181. */
  73182. _prepare(): void;
  73183. /**
  73184. * Gets the trigger parameters
  73185. * @returns the trigger parameters
  73186. */
  73187. getTriggerParameter(): any;
  73188. /**
  73189. * Internal only - executes current action event
  73190. * @hidden
  73191. */
  73192. _executeCurrent(evt?: ActionEvent): void;
  73193. /**
  73194. * Execute placeholder for child classes
  73195. * @param evt optional action event
  73196. */
  73197. execute(evt?: ActionEvent): void;
  73198. /**
  73199. * Skips to next active action
  73200. */
  73201. skipToNextActiveAction(): void;
  73202. /**
  73203. * Adds action to chain of actions, may be a DoNothingAction
  73204. * @param action defines the next action to execute
  73205. * @returns The action passed in
  73206. * @see https://www.babylonjs-playground.com/#1T30HR#0
  73207. */
  73208. then(action: Action): Action;
  73209. /**
  73210. * Internal only
  73211. * @hidden
  73212. */
  73213. _getProperty(propertyPath: string): string;
  73214. /**
  73215. * Internal only
  73216. * @hidden
  73217. */
  73218. _getEffectiveTarget(target: any, propertyPath: string): any;
  73219. /**
  73220. * Serialize placeholder for child classes
  73221. * @param parent of child
  73222. * @returns the serialized object
  73223. */
  73224. serialize(parent: any): any;
  73225. /**
  73226. * Internal only called by serialize
  73227. * @hidden
  73228. */
  73229. protected _serialize(serializedAction: any, parent?: any): any;
  73230. /**
  73231. * Internal only
  73232. * @hidden
  73233. */
  73234. static _SerializeValueAsString: (value: any) => string;
  73235. /**
  73236. * Internal only
  73237. * @hidden
  73238. */
  73239. static _GetTargetProperty: (target: Scene | Node) => {
  73240. name: string;
  73241. targetType: string;
  73242. value: string;
  73243. };
  73244. }
  73245. }
  73246. declare module BABYLON {
  73247. /**
  73248. * A Condition applied to an Action
  73249. */
  73250. export class Condition {
  73251. /**
  73252. * Internal only - manager for action
  73253. * @hidden
  73254. */
  73255. _actionManager: ActionManager;
  73256. /**
  73257. * Internal only
  73258. * @hidden
  73259. */
  73260. _evaluationId: number;
  73261. /**
  73262. * Internal only
  73263. * @hidden
  73264. */
  73265. _currentResult: boolean;
  73266. /**
  73267. * Creates a new Condition
  73268. * @param actionManager the manager of the action the condition is applied to
  73269. */
  73270. constructor(actionManager: ActionManager);
  73271. /**
  73272. * Check if the current condition is valid
  73273. * @returns a boolean
  73274. */
  73275. isValid(): boolean;
  73276. /**
  73277. * Internal only
  73278. * @hidden
  73279. */
  73280. _getProperty(propertyPath: string): string;
  73281. /**
  73282. * Internal only
  73283. * @hidden
  73284. */
  73285. _getEffectiveTarget(target: any, propertyPath: string): any;
  73286. /**
  73287. * Serialize placeholder for child classes
  73288. * @returns the serialized object
  73289. */
  73290. serialize(): any;
  73291. /**
  73292. * Internal only
  73293. * @hidden
  73294. */
  73295. protected _serialize(serializedCondition: any): any;
  73296. }
  73297. /**
  73298. * Defines specific conditional operators as extensions of Condition
  73299. */
  73300. export class ValueCondition extends Condition {
  73301. /** path to specify the property of the target the conditional operator uses */
  73302. propertyPath: string;
  73303. /** the value compared by the conditional operator against the current value of the property */
  73304. value: any;
  73305. /** the conditional operator, default ValueCondition.IsEqual */
  73306. operator: number;
  73307. /**
  73308. * Internal only
  73309. * @hidden
  73310. */
  73311. private static _IsEqual;
  73312. /**
  73313. * Internal only
  73314. * @hidden
  73315. */
  73316. private static _IsDifferent;
  73317. /**
  73318. * Internal only
  73319. * @hidden
  73320. */
  73321. private static _IsGreater;
  73322. /**
  73323. * Internal only
  73324. * @hidden
  73325. */
  73326. private static _IsLesser;
  73327. /**
  73328. * returns the number for IsEqual
  73329. */
  73330. static readonly IsEqual: number;
  73331. /**
  73332. * Returns the number for IsDifferent
  73333. */
  73334. static readonly IsDifferent: number;
  73335. /**
  73336. * Returns the number for IsGreater
  73337. */
  73338. static readonly IsGreater: number;
  73339. /**
  73340. * Returns the number for IsLesser
  73341. */
  73342. static readonly IsLesser: number;
  73343. /**
  73344. * Internal only The action manager for the condition
  73345. * @hidden
  73346. */
  73347. _actionManager: ActionManager;
  73348. /**
  73349. * Internal only
  73350. * @hidden
  73351. */
  73352. private _target;
  73353. /**
  73354. * Internal only
  73355. * @hidden
  73356. */
  73357. private _effectiveTarget;
  73358. /**
  73359. * Internal only
  73360. * @hidden
  73361. */
  73362. private _property;
  73363. /**
  73364. * Creates a new ValueCondition
  73365. * @param actionManager manager for the action the condition applies to
  73366. * @param target for the action
  73367. * @param propertyPath path to specify the property of the target the conditional operator uses
  73368. * @param value the value compared by the conditional operator against the current value of the property
  73369. * @param operator the conditional operator, default ValueCondition.IsEqual
  73370. */
  73371. constructor(actionManager: ActionManager, target: any,
  73372. /** path to specify the property of the target the conditional operator uses */
  73373. propertyPath: string,
  73374. /** the value compared by the conditional operator against the current value of the property */
  73375. value: any,
  73376. /** the conditional operator, default ValueCondition.IsEqual */
  73377. operator?: number);
  73378. /**
  73379. * Compares the given value with the property value for the specified conditional operator
  73380. * @returns the result of the comparison
  73381. */
  73382. isValid(): boolean;
  73383. /**
  73384. * Serialize the ValueCondition into a JSON compatible object
  73385. * @returns serialization object
  73386. */
  73387. serialize(): any;
  73388. /**
  73389. * Gets the name of the conditional operator for the ValueCondition
  73390. * @param operator the conditional operator
  73391. * @returns the name
  73392. */
  73393. static GetOperatorName(operator: number): string;
  73394. }
  73395. /**
  73396. * Defines a predicate condition as an extension of Condition
  73397. */
  73398. export class PredicateCondition extends Condition {
  73399. /** defines the predicate function used to validate the condition */
  73400. predicate: () => boolean;
  73401. /**
  73402. * Internal only - manager for action
  73403. * @hidden
  73404. */
  73405. _actionManager: ActionManager;
  73406. /**
  73407. * Creates a new PredicateCondition
  73408. * @param actionManager manager for the action the condition applies to
  73409. * @param predicate defines the predicate function used to validate the condition
  73410. */
  73411. constructor(actionManager: ActionManager,
  73412. /** defines the predicate function used to validate the condition */
  73413. predicate: () => boolean);
  73414. /**
  73415. * @returns the validity of the predicate condition
  73416. */
  73417. isValid(): boolean;
  73418. }
  73419. /**
  73420. * Defines a state condition as an extension of Condition
  73421. */
  73422. export class StateCondition extends Condition {
  73423. /** Value to compare with target state */
  73424. value: string;
  73425. /**
  73426. * Internal only - manager for action
  73427. * @hidden
  73428. */
  73429. _actionManager: ActionManager;
  73430. /**
  73431. * Internal only
  73432. * @hidden
  73433. */
  73434. private _target;
  73435. /**
  73436. * Creates a new StateCondition
  73437. * @param actionManager manager for the action the condition applies to
  73438. * @param target of the condition
  73439. * @param value to compare with target state
  73440. */
  73441. constructor(actionManager: ActionManager, target: any,
  73442. /** Value to compare with target state */
  73443. value: string);
  73444. /**
  73445. * Gets a boolean indicating if the current condition is met
  73446. * @returns the validity of the state
  73447. */
  73448. isValid(): boolean;
  73449. /**
  73450. * Serialize the StateCondition into a JSON compatible object
  73451. * @returns serialization object
  73452. */
  73453. serialize(): any;
  73454. }
  73455. }
  73456. declare module BABYLON {
  73457. /**
  73458. * This defines an action responsible to toggle a boolean once triggered.
  73459. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73460. */
  73461. export class SwitchBooleanAction extends Action {
  73462. /**
  73463. * The path to the boolean property in the target object
  73464. */
  73465. propertyPath: string;
  73466. private _target;
  73467. private _effectiveTarget;
  73468. private _property;
  73469. /**
  73470. * Instantiate the action
  73471. * @param triggerOptions defines the trigger options
  73472. * @param target defines the object containing the boolean
  73473. * @param propertyPath defines the path to the boolean property in the target object
  73474. * @param condition defines the trigger related conditions
  73475. */
  73476. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  73477. /** @hidden */
  73478. _prepare(): void;
  73479. /**
  73480. * Execute the action toggle the boolean value.
  73481. */
  73482. execute(): void;
  73483. /**
  73484. * Serializes the actions and its related information.
  73485. * @param parent defines the object to serialize in
  73486. * @returns the serialized object
  73487. */
  73488. serialize(parent: any): any;
  73489. }
  73490. /**
  73491. * This defines an action responsible to set a the state field of the target
  73492. * to a desired value once triggered.
  73493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73494. */
  73495. export class SetStateAction extends Action {
  73496. /**
  73497. * The value to store in the state field.
  73498. */
  73499. value: string;
  73500. private _target;
  73501. /**
  73502. * Instantiate the action
  73503. * @param triggerOptions defines the trigger options
  73504. * @param target defines the object containing the state property
  73505. * @param value defines the value to store in the state field
  73506. * @param condition defines the trigger related conditions
  73507. */
  73508. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  73509. /**
  73510. * Execute the action and store the value on the target state property.
  73511. */
  73512. execute(): void;
  73513. /**
  73514. * Serializes the actions and its related information.
  73515. * @param parent defines the object to serialize in
  73516. * @returns the serialized object
  73517. */
  73518. serialize(parent: any): any;
  73519. }
  73520. /**
  73521. * This defines an action responsible to set a property of the target
  73522. * to a desired value once triggered.
  73523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73524. */
  73525. export class SetValueAction extends Action {
  73526. /**
  73527. * The path of the property to set in the target.
  73528. */
  73529. propertyPath: string;
  73530. /**
  73531. * The value to set in the property
  73532. */
  73533. value: any;
  73534. private _target;
  73535. private _effectiveTarget;
  73536. private _property;
  73537. /**
  73538. * Instantiate the action
  73539. * @param triggerOptions defines the trigger options
  73540. * @param target defines the object containing the property
  73541. * @param propertyPath defines the path of the property to set in the target
  73542. * @param value defines the value to set in the property
  73543. * @param condition defines the trigger related conditions
  73544. */
  73545. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  73546. /** @hidden */
  73547. _prepare(): void;
  73548. /**
  73549. * Execute the action and set the targetted property to the desired value.
  73550. */
  73551. execute(): void;
  73552. /**
  73553. * Serializes the actions and its related information.
  73554. * @param parent defines the object to serialize in
  73555. * @returns the serialized object
  73556. */
  73557. serialize(parent: any): any;
  73558. }
  73559. /**
  73560. * This defines an action responsible to increment the target value
  73561. * to a desired value once triggered.
  73562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73563. */
  73564. export class IncrementValueAction extends Action {
  73565. /**
  73566. * The path of the property to increment in the target.
  73567. */
  73568. propertyPath: string;
  73569. /**
  73570. * The value we should increment the property by.
  73571. */
  73572. value: any;
  73573. private _target;
  73574. private _effectiveTarget;
  73575. private _property;
  73576. /**
  73577. * Instantiate the action
  73578. * @param triggerOptions defines the trigger options
  73579. * @param target defines the object containing the property
  73580. * @param propertyPath defines the path of the property to increment in the target
  73581. * @param value defines the value value we should increment the property by
  73582. * @param condition defines the trigger related conditions
  73583. */
  73584. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  73585. /** @hidden */
  73586. _prepare(): void;
  73587. /**
  73588. * Execute the action and increment the target of the value amount.
  73589. */
  73590. execute(): void;
  73591. /**
  73592. * Serializes the actions and its related information.
  73593. * @param parent defines the object to serialize in
  73594. * @returns the serialized object
  73595. */
  73596. serialize(parent: any): any;
  73597. }
  73598. /**
  73599. * This defines an action responsible to start an animation once triggered.
  73600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73601. */
  73602. export class PlayAnimationAction extends Action {
  73603. /**
  73604. * Where the animation should start (animation frame)
  73605. */
  73606. from: number;
  73607. /**
  73608. * Where the animation should stop (animation frame)
  73609. */
  73610. to: number;
  73611. /**
  73612. * Define if the animation should loop or stop after the first play.
  73613. */
  73614. loop?: boolean;
  73615. private _target;
  73616. /**
  73617. * Instantiate the action
  73618. * @param triggerOptions defines the trigger options
  73619. * @param target defines the target animation or animation name
  73620. * @param from defines from where the animation should start (animation frame)
  73621. * @param end defines where the animation should stop (animation frame)
  73622. * @param loop defines if the animation should loop or stop after the first play
  73623. * @param condition defines the trigger related conditions
  73624. */
  73625. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  73626. /** @hidden */
  73627. _prepare(): void;
  73628. /**
  73629. * Execute the action and play the animation.
  73630. */
  73631. execute(): void;
  73632. /**
  73633. * Serializes the actions and its related information.
  73634. * @param parent defines the object to serialize in
  73635. * @returns the serialized object
  73636. */
  73637. serialize(parent: any): any;
  73638. }
  73639. /**
  73640. * This defines an action responsible to stop an animation once triggered.
  73641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73642. */
  73643. export class StopAnimationAction extends Action {
  73644. private _target;
  73645. /**
  73646. * Instantiate the action
  73647. * @param triggerOptions defines the trigger options
  73648. * @param target defines the target animation or animation name
  73649. * @param condition defines the trigger related conditions
  73650. */
  73651. constructor(triggerOptions: any, target: any, condition?: Condition);
  73652. /** @hidden */
  73653. _prepare(): void;
  73654. /**
  73655. * Execute the action and stop the animation.
  73656. */
  73657. execute(): void;
  73658. /**
  73659. * Serializes the actions and its related information.
  73660. * @param parent defines the object to serialize in
  73661. * @returns the serialized object
  73662. */
  73663. serialize(parent: any): any;
  73664. }
  73665. /**
  73666. * This defines an action responsible that does nothing once triggered.
  73667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73668. */
  73669. export class DoNothingAction extends Action {
  73670. /**
  73671. * Instantiate the action
  73672. * @param triggerOptions defines the trigger options
  73673. * @param condition defines the trigger related conditions
  73674. */
  73675. constructor(triggerOptions?: any, condition?: Condition);
  73676. /**
  73677. * Execute the action and do nothing.
  73678. */
  73679. execute(): void;
  73680. /**
  73681. * Serializes the actions and its related information.
  73682. * @param parent defines the object to serialize in
  73683. * @returns the serialized object
  73684. */
  73685. serialize(parent: any): any;
  73686. }
  73687. /**
  73688. * This defines an action responsible to trigger several actions once triggered.
  73689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73690. */
  73691. export class CombineAction extends Action {
  73692. /**
  73693. * The list of aggregated animations to run.
  73694. */
  73695. children: Action[];
  73696. /**
  73697. * Instantiate the action
  73698. * @param triggerOptions defines the trigger options
  73699. * @param children defines the list of aggregated animations to run
  73700. * @param condition defines the trigger related conditions
  73701. */
  73702. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  73703. /** @hidden */
  73704. _prepare(): void;
  73705. /**
  73706. * Execute the action and executes all the aggregated actions.
  73707. */
  73708. execute(evt: ActionEvent): void;
  73709. /**
  73710. * Serializes the actions and its related information.
  73711. * @param parent defines the object to serialize in
  73712. * @returns the serialized object
  73713. */
  73714. serialize(parent: any): any;
  73715. }
  73716. /**
  73717. * This defines an action responsible to run code (external event) once triggered.
  73718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73719. */
  73720. export class ExecuteCodeAction extends Action {
  73721. /**
  73722. * The callback function to run.
  73723. */
  73724. func: (evt: ActionEvent) => void;
  73725. /**
  73726. * Instantiate the action
  73727. * @param triggerOptions defines the trigger options
  73728. * @param func defines the callback function to run
  73729. * @param condition defines the trigger related conditions
  73730. */
  73731. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  73732. /**
  73733. * Execute the action and run the attached code.
  73734. */
  73735. execute(evt: ActionEvent): void;
  73736. }
  73737. /**
  73738. * This defines an action responsible to set the parent property of the target once triggered.
  73739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73740. */
  73741. export class SetParentAction extends Action {
  73742. private _parent;
  73743. private _target;
  73744. /**
  73745. * Instantiate the action
  73746. * @param triggerOptions defines the trigger options
  73747. * @param target defines the target containing the parent property
  73748. * @param parent defines from where the animation should start (animation frame)
  73749. * @param condition defines the trigger related conditions
  73750. */
  73751. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  73752. /** @hidden */
  73753. _prepare(): void;
  73754. /**
  73755. * Execute the action and set the parent property.
  73756. */
  73757. execute(): void;
  73758. /**
  73759. * Serializes the actions and its related information.
  73760. * @param parent defines the object to serialize in
  73761. * @returns the serialized object
  73762. */
  73763. serialize(parent: any): any;
  73764. }
  73765. }
  73766. declare module BABYLON {
  73767. /**
  73768. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  73769. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  73770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73771. */
  73772. export class ActionManager extends AbstractActionManager {
  73773. /**
  73774. * Nothing
  73775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73776. */
  73777. static readonly NothingTrigger: number;
  73778. /**
  73779. * On pick
  73780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73781. */
  73782. static readonly OnPickTrigger: number;
  73783. /**
  73784. * On left pick
  73785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73786. */
  73787. static readonly OnLeftPickTrigger: number;
  73788. /**
  73789. * On right pick
  73790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73791. */
  73792. static readonly OnRightPickTrigger: number;
  73793. /**
  73794. * On center pick
  73795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73796. */
  73797. static readonly OnCenterPickTrigger: number;
  73798. /**
  73799. * On pick down
  73800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73801. */
  73802. static readonly OnPickDownTrigger: number;
  73803. /**
  73804. * On double pick
  73805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73806. */
  73807. static readonly OnDoublePickTrigger: number;
  73808. /**
  73809. * On pick up
  73810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73811. */
  73812. static readonly OnPickUpTrigger: number;
  73813. /**
  73814. * On pick out.
  73815. * This trigger will only be raised if you also declared a OnPickDown
  73816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73817. */
  73818. static readonly OnPickOutTrigger: number;
  73819. /**
  73820. * On long press
  73821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73822. */
  73823. static readonly OnLongPressTrigger: number;
  73824. /**
  73825. * On pointer over
  73826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73827. */
  73828. static readonly OnPointerOverTrigger: number;
  73829. /**
  73830. * On pointer out
  73831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73832. */
  73833. static readonly OnPointerOutTrigger: number;
  73834. /**
  73835. * On every frame
  73836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73837. */
  73838. static readonly OnEveryFrameTrigger: number;
  73839. /**
  73840. * On intersection enter
  73841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73842. */
  73843. static readonly OnIntersectionEnterTrigger: number;
  73844. /**
  73845. * On intersection exit
  73846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73847. */
  73848. static readonly OnIntersectionExitTrigger: number;
  73849. /**
  73850. * On key down
  73851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73852. */
  73853. static readonly OnKeyDownTrigger: number;
  73854. /**
  73855. * On key up
  73856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73857. */
  73858. static readonly OnKeyUpTrigger: number;
  73859. private _scene;
  73860. /**
  73861. * Creates a new action manager
  73862. * @param scene defines the hosting scene
  73863. */
  73864. constructor(scene: Scene);
  73865. /**
  73866. * Releases all associated resources
  73867. */
  73868. dispose(): void;
  73869. /**
  73870. * Gets hosting scene
  73871. * @returns the hosting scene
  73872. */
  73873. getScene(): Scene;
  73874. /**
  73875. * Does this action manager handles actions of any of the given triggers
  73876. * @param triggers defines the triggers to be tested
  73877. * @return a boolean indicating whether one (or more) of the triggers is handled
  73878. */
  73879. hasSpecificTriggers(triggers: number[]): boolean;
  73880. /**
  73881. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  73882. * speed.
  73883. * @param triggerA defines the trigger to be tested
  73884. * @param triggerB defines the trigger to be tested
  73885. * @return a boolean indicating whether one (or more) of the triggers is handled
  73886. */
  73887. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  73888. /**
  73889. * Does this action manager handles actions of a given trigger
  73890. * @param trigger defines the trigger to be tested
  73891. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  73892. * @return whether the trigger is handled
  73893. */
  73894. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  73895. /**
  73896. * Does this action manager has pointer triggers
  73897. */
  73898. readonly hasPointerTriggers: boolean;
  73899. /**
  73900. * Does this action manager has pick triggers
  73901. */
  73902. readonly hasPickTriggers: boolean;
  73903. /**
  73904. * Registers an action to this action manager
  73905. * @param action defines the action to be registered
  73906. * @return the action amended (prepared) after registration
  73907. */
  73908. registerAction(action: IAction): Nullable<IAction>;
  73909. /**
  73910. * Unregisters an action to this action manager
  73911. * @param action defines the action to be unregistered
  73912. * @return a boolean indicating whether the action has been unregistered
  73913. */
  73914. unregisterAction(action: IAction): Boolean;
  73915. /**
  73916. * Process a specific trigger
  73917. * @param trigger defines the trigger to process
  73918. * @param evt defines the event details to be processed
  73919. */
  73920. processTrigger(trigger: number, evt?: IActionEvent): void;
  73921. /** @hidden */
  73922. _getEffectiveTarget(target: any, propertyPath: string): any;
  73923. /** @hidden */
  73924. _getProperty(propertyPath: string): string;
  73925. /**
  73926. * Serialize this manager to a JSON object
  73927. * @param name defines the property name to store this manager
  73928. * @returns a JSON representation of this manager
  73929. */
  73930. serialize(name: string): any;
  73931. /**
  73932. * Creates a new ActionManager from a JSON data
  73933. * @param parsedActions defines the JSON data to read from
  73934. * @param object defines the hosting mesh
  73935. * @param scene defines the hosting scene
  73936. */
  73937. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  73938. /**
  73939. * Get a trigger name by index
  73940. * @param trigger defines the trigger index
  73941. * @returns a trigger name
  73942. */
  73943. static GetTriggerName(trigger: number): string;
  73944. }
  73945. }
  73946. declare module BABYLON {
  73947. /**
  73948. * Class representing a ray with position and direction
  73949. */
  73950. export class Ray {
  73951. /** origin point */
  73952. origin: Vector3;
  73953. /** direction */
  73954. direction: Vector3;
  73955. /** length of the ray */
  73956. length: number;
  73957. private static readonly TmpVector3;
  73958. private _tmpRay;
  73959. /**
  73960. * Creates a new ray
  73961. * @param origin origin point
  73962. * @param direction direction
  73963. * @param length length of the ray
  73964. */
  73965. constructor(
  73966. /** origin point */
  73967. origin: Vector3,
  73968. /** direction */
  73969. direction: Vector3,
  73970. /** length of the ray */
  73971. length?: number);
  73972. /**
  73973. * Checks if the ray intersects a box
  73974. * @param minimum bound of the box
  73975. * @param maximum bound of the box
  73976. * @param intersectionTreshold extra extend to be added to the box in all direction
  73977. * @returns if the box was hit
  73978. */
  73979. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  73980. /**
  73981. * Checks if the ray intersects a box
  73982. * @param box the bounding box to check
  73983. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  73984. * @returns if the box was hit
  73985. */
  73986. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  73987. /**
  73988. * If the ray hits a sphere
  73989. * @param sphere the bounding sphere to check
  73990. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  73991. * @returns true if it hits the sphere
  73992. */
  73993. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  73994. /**
  73995. * If the ray hits a triange
  73996. * @param vertex0 triangle vertex
  73997. * @param vertex1 triangle vertex
  73998. * @param vertex2 triangle vertex
  73999. * @returns intersection information if hit
  74000. */
  74001. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  74002. /**
  74003. * Checks if ray intersects a plane
  74004. * @param plane the plane to check
  74005. * @returns the distance away it was hit
  74006. */
  74007. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  74008. /**
  74009. * Checks if ray intersects a mesh
  74010. * @param mesh the mesh to check
  74011. * @param fastCheck if only the bounding box should checked
  74012. * @returns picking info of the intersecton
  74013. */
  74014. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  74015. /**
  74016. * Checks if ray intersects a mesh
  74017. * @param meshes the meshes to check
  74018. * @param fastCheck if only the bounding box should checked
  74019. * @param results array to store result in
  74020. * @returns Array of picking infos
  74021. */
  74022. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  74023. private _comparePickingInfo;
  74024. private static smallnum;
  74025. private static rayl;
  74026. /**
  74027. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  74028. * @param sega the first point of the segment to test the intersection against
  74029. * @param segb the second point of the segment to test the intersection against
  74030. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  74031. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  74032. */
  74033. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  74034. /**
  74035. * Update the ray from viewport position
  74036. * @param x position
  74037. * @param y y position
  74038. * @param viewportWidth viewport width
  74039. * @param viewportHeight viewport height
  74040. * @param world world matrix
  74041. * @param view view matrix
  74042. * @param projection projection matrix
  74043. * @returns this ray updated
  74044. */
  74045. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74046. /**
  74047. * Creates a ray with origin and direction of 0,0,0
  74048. * @returns the new ray
  74049. */
  74050. static Zero(): Ray;
  74051. /**
  74052. * Creates a new ray from screen space and viewport
  74053. * @param x position
  74054. * @param y y position
  74055. * @param viewportWidth viewport width
  74056. * @param viewportHeight viewport height
  74057. * @param world world matrix
  74058. * @param view view matrix
  74059. * @param projection projection matrix
  74060. * @returns new ray
  74061. */
  74062. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74063. /**
  74064. * 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
  74065. * transformed to the given world matrix.
  74066. * @param origin The origin point
  74067. * @param end The end point
  74068. * @param world a matrix to transform the ray to. Default is the identity matrix.
  74069. * @returns the new ray
  74070. */
  74071. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  74072. /**
  74073. * Transforms a ray by a matrix
  74074. * @param ray ray to transform
  74075. * @param matrix matrix to apply
  74076. * @returns the resulting new ray
  74077. */
  74078. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  74079. /**
  74080. * Transforms a ray by a matrix
  74081. * @param ray ray to transform
  74082. * @param matrix matrix to apply
  74083. * @param result ray to store result in
  74084. */
  74085. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  74086. /**
  74087. * Unproject a ray from screen space to object space
  74088. * @param sourceX defines the screen space x coordinate to use
  74089. * @param sourceY defines the screen space y coordinate to use
  74090. * @param viewportWidth defines the current width of the viewport
  74091. * @param viewportHeight defines the current height of the viewport
  74092. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74093. * @param view defines the view matrix to use
  74094. * @param projection defines the projection matrix to use
  74095. */
  74096. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  74097. }
  74098. /**
  74099. * Type used to define predicate used to select faces when a mesh intersection is detected
  74100. */
  74101. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  74102. interface Scene {
  74103. /** @hidden */
  74104. _tempPickingRay: Nullable<Ray>;
  74105. /** @hidden */
  74106. _cachedRayForTransform: Ray;
  74107. /** @hidden */
  74108. _pickWithRayInverseMatrix: Matrix;
  74109. /** @hidden */
  74110. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  74111. /** @hidden */
  74112. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  74113. }
  74114. }
  74115. declare module BABYLON {
  74116. /**
  74117. * Groups all the scene component constants in one place to ease maintenance.
  74118. * @hidden
  74119. */
  74120. export class SceneComponentConstants {
  74121. static readonly NAME_EFFECTLAYER: string;
  74122. static readonly NAME_LAYER: string;
  74123. static readonly NAME_LENSFLARESYSTEM: string;
  74124. static readonly NAME_BOUNDINGBOXRENDERER: string;
  74125. static readonly NAME_PARTICLESYSTEM: string;
  74126. static readonly NAME_GAMEPAD: string;
  74127. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  74128. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  74129. static readonly NAME_DEPTHRENDERER: string;
  74130. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  74131. static readonly NAME_SPRITE: string;
  74132. static readonly NAME_OUTLINERENDERER: string;
  74133. static readonly NAME_PROCEDURALTEXTURE: string;
  74134. static readonly NAME_SHADOWGENERATOR: string;
  74135. static readonly NAME_OCTREE: string;
  74136. static readonly NAME_PHYSICSENGINE: string;
  74137. static readonly NAME_AUDIO: string;
  74138. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  74139. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74140. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  74141. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74142. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  74143. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  74144. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  74145. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  74146. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  74147. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  74148. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  74149. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  74150. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  74151. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  74152. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  74153. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  74154. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  74155. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  74156. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  74157. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  74158. static readonly STEP_AFTERRENDER_AUDIO: number;
  74159. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  74160. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  74161. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  74162. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  74163. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  74164. static readonly STEP_POINTERMOVE_SPRITE: number;
  74165. static readonly STEP_POINTERDOWN_SPRITE: number;
  74166. static readonly STEP_POINTERUP_SPRITE: number;
  74167. }
  74168. /**
  74169. * This represents a scene component.
  74170. *
  74171. * This is used to decouple the dependency the scene is having on the different workloads like
  74172. * layers, post processes...
  74173. */
  74174. export interface ISceneComponent {
  74175. /**
  74176. * The name of the component. Each component must have a unique name.
  74177. */
  74178. name: string;
  74179. /**
  74180. * The scene the component belongs to.
  74181. */
  74182. scene: Scene;
  74183. /**
  74184. * Register the component to one instance of a scene.
  74185. */
  74186. register(): void;
  74187. /**
  74188. * Rebuilds the elements related to this component in case of
  74189. * context lost for instance.
  74190. */
  74191. rebuild(): void;
  74192. /**
  74193. * Disposes the component and the associated ressources.
  74194. */
  74195. dispose(): void;
  74196. }
  74197. /**
  74198. * This represents a SERIALIZABLE scene component.
  74199. *
  74200. * This extends Scene Component to add Serialization methods on top.
  74201. */
  74202. export interface ISceneSerializableComponent extends ISceneComponent {
  74203. /**
  74204. * Adds all the elements from the container to the scene
  74205. * @param container the container holding the elements
  74206. */
  74207. addFromContainer(container: AbstractScene): void;
  74208. /**
  74209. * Removes all the elements in the container from the scene
  74210. * @param container contains the elements to remove
  74211. * @param dispose if the removed element should be disposed (default: false)
  74212. */
  74213. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  74214. /**
  74215. * Serializes the component data to the specified json object
  74216. * @param serializationObject The object to serialize to
  74217. */
  74218. serialize(serializationObject: any): void;
  74219. }
  74220. /**
  74221. * Strong typing of a Mesh related stage step action
  74222. */
  74223. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  74224. /**
  74225. * Strong typing of a Evaluate Sub Mesh related stage step action
  74226. */
  74227. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  74228. /**
  74229. * Strong typing of a Active Mesh related stage step action
  74230. */
  74231. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  74232. /**
  74233. * Strong typing of a Camera related stage step action
  74234. */
  74235. export type CameraStageAction = (camera: Camera) => void;
  74236. /**
  74237. * Strong typing of a Camera Frame buffer related stage step action
  74238. */
  74239. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  74240. /**
  74241. * Strong typing of a Render Target related stage step action
  74242. */
  74243. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  74244. /**
  74245. * Strong typing of a RenderingGroup related stage step action
  74246. */
  74247. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  74248. /**
  74249. * Strong typing of a Mesh Render related stage step action
  74250. */
  74251. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  74252. /**
  74253. * Strong typing of a simple stage step action
  74254. */
  74255. export type SimpleStageAction = () => void;
  74256. /**
  74257. * Strong typing of a render target action.
  74258. */
  74259. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  74260. /**
  74261. * Strong typing of a pointer move action.
  74262. */
  74263. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  74264. /**
  74265. * Strong typing of a pointer up/down action.
  74266. */
  74267. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  74268. /**
  74269. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  74270. * @hidden
  74271. */
  74272. export class Stage<T extends Function> extends Array<{
  74273. index: number;
  74274. component: ISceneComponent;
  74275. action: T;
  74276. }> {
  74277. /**
  74278. * Hide ctor from the rest of the world.
  74279. * @param items The items to add.
  74280. */
  74281. private constructor();
  74282. /**
  74283. * Creates a new Stage.
  74284. * @returns A new instance of a Stage
  74285. */
  74286. static Create<T extends Function>(): Stage<T>;
  74287. /**
  74288. * Registers a step in an ordered way in the targeted stage.
  74289. * @param index Defines the position to register the step in
  74290. * @param component Defines the component attached to the step
  74291. * @param action Defines the action to launch during the step
  74292. */
  74293. registerStep(index: number, component: ISceneComponent, action: T): void;
  74294. /**
  74295. * Clears all the steps from the stage.
  74296. */
  74297. clear(): void;
  74298. }
  74299. }
  74300. declare module BABYLON {
  74301. interface Scene {
  74302. /** @hidden */
  74303. _pointerOverSprite: Nullable<Sprite>;
  74304. /** @hidden */
  74305. _pickedDownSprite: Nullable<Sprite>;
  74306. /** @hidden */
  74307. _tempSpritePickingRay: Nullable<Ray>;
  74308. /**
  74309. * All of the sprite managers added to this scene
  74310. * @see http://doc.babylonjs.com/babylon101/sprites
  74311. */
  74312. spriteManagers: Array<ISpriteManager>;
  74313. /**
  74314. * An event triggered when sprites rendering is about to start
  74315. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  74316. */
  74317. onBeforeSpritesRenderingObservable: Observable<Scene>;
  74318. /**
  74319. * An event triggered when sprites rendering is done
  74320. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  74321. */
  74322. onAfterSpritesRenderingObservable: Observable<Scene>;
  74323. /** @hidden */
  74324. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74325. /** Launch a ray to try to pick a sprite in the scene
  74326. * @param x position on screen
  74327. * @param y position on screen
  74328. * @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
  74329. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  74330. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  74331. * @returns a PickingInfo
  74332. */
  74333. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74334. /** Use the given ray to pick a sprite in the scene
  74335. * @param ray The ray (in world space) to use to pick meshes
  74336. * @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
  74337. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  74338. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  74339. * @returns a PickingInfo
  74340. */
  74341. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74342. /**
  74343. * Force the sprite under the pointer
  74344. * @param sprite defines the sprite to use
  74345. */
  74346. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  74347. /**
  74348. * Gets the sprite under the pointer
  74349. * @returns a Sprite or null if no sprite is under the pointer
  74350. */
  74351. getPointerOverSprite(): Nullable<Sprite>;
  74352. }
  74353. /**
  74354. * Defines the sprite scene component responsible to manage sprites
  74355. * in a given scene.
  74356. */
  74357. export class SpriteSceneComponent implements ISceneComponent {
  74358. /**
  74359. * The component name helpfull to identify the component in the list of scene components.
  74360. */
  74361. readonly name: string;
  74362. /**
  74363. * The scene the component belongs to.
  74364. */
  74365. scene: Scene;
  74366. /** @hidden */
  74367. private _spritePredicate;
  74368. /**
  74369. * Creates a new instance of the component for the given scene
  74370. * @param scene Defines the scene to register the component in
  74371. */
  74372. constructor(scene: Scene);
  74373. /**
  74374. * Registers the component in a given scene
  74375. */
  74376. register(): void;
  74377. /**
  74378. * Rebuilds the elements related to this component in case of
  74379. * context lost for instance.
  74380. */
  74381. rebuild(): void;
  74382. /**
  74383. * Disposes the component and the associated ressources.
  74384. */
  74385. dispose(): void;
  74386. private _pickSpriteButKeepRay;
  74387. private _pointerMove;
  74388. private _pointerDown;
  74389. private _pointerUp;
  74390. }
  74391. }
  74392. declare module BABYLON {
  74393. /** @hidden */
  74394. export var fogFragmentDeclaration: {
  74395. name: string;
  74396. shader: string;
  74397. };
  74398. }
  74399. declare module BABYLON {
  74400. /** @hidden */
  74401. export var fogFragment: {
  74402. name: string;
  74403. shader: string;
  74404. };
  74405. }
  74406. declare module BABYLON {
  74407. /** @hidden */
  74408. export var spritesPixelShader: {
  74409. name: string;
  74410. shader: string;
  74411. };
  74412. }
  74413. declare module BABYLON {
  74414. /** @hidden */
  74415. export var fogVertexDeclaration: {
  74416. name: string;
  74417. shader: string;
  74418. };
  74419. }
  74420. declare module BABYLON {
  74421. /** @hidden */
  74422. export var spritesVertexShader: {
  74423. name: string;
  74424. shader: string;
  74425. };
  74426. }
  74427. declare module BABYLON {
  74428. /**
  74429. * Defines the minimum interface to fullfil in order to be a sprite manager.
  74430. */
  74431. export interface ISpriteManager extends IDisposable {
  74432. /**
  74433. * Restricts the camera to viewing objects with the same layerMask.
  74434. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  74435. */
  74436. layerMask: number;
  74437. /**
  74438. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  74439. */
  74440. isPickable: boolean;
  74441. /**
  74442. * Specifies the rendering group id for this mesh (0 by default)
  74443. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  74444. */
  74445. renderingGroupId: number;
  74446. /**
  74447. * Defines the list of sprites managed by the manager.
  74448. */
  74449. sprites: Array<Sprite>;
  74450. /**
  74451. * Tests the intersection of a sprite with a specific ray.
  74452. * @param ray The ray we are sending to test the collision
  74453. * @param camera The camera space we are sending rays in
  74454. * @param predicate A predicate allowing excluding sprites from the list of object to test
  74455. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  74456. * @returns picking info or null.
  74457. */
  74458. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  74459. /**
  74460. * Renders the list of sprites on screen.
  74461. */
  74462. render(): void;
  74463. }
  74464. /**
  74465. * Class used to manage multiple sprites on the same spritesheet
  74466. * @see http://doc.babylonjs.com/babylon101/sprites
  74467. */
  74468. export class SpriteManager implements ISpriteManager {
  74469. /** defines the manager's name */
  74470. name: string;
  74471. /** Gets the list of sprites */
  74472. sprites: Sprite[];
  74473. /** Gets or sets the rendering group id (0 by default) */
  74474. renderingGroupId: number;
  74475. /** Gets or sets camera layer mask */
  74476. layerMask: number;
  74477. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  74478. fogEnabled: boolean;
  74479. /** Gets or sets a boolean indicating if the sprites are pickable */
  74480. isPickable: boolean;
  74481. /** Defines the default width of a cell in the spritesheet */
  74482. cellWidth: number;
  74483. /** Defines the default height of a cell in the spritesheet */
  74484. cellHeight: number;
  74485. /**
  74486. * An event triggered when the manager is disposed.
  74487. */
  74488. onDisposeObservable: Observable<SpriteManager>;
  74489. private _onDisposeObserver;
  74490. /**
  74491. * Callback called when the manager is disposed
  74492. */
  74493. onDispose: () => void;
  74494. private _capacity;
  74495. private _spriteTexture;
  74496. private _epsilon;
  74497. private _scene;
  74498. private _vertexData;
  74499. private _buffer;
  74500. private _vertexBuffers;
  74501. private _indexBuffer;
  74502. private _effectBase;
  74503. private _effectFog;
  74504. /**
  74505. * Gets or sets the spritesheet texture
  74506. */
  74507. texture: Texture;
  74508. /**
  74509. * Creates a new sprite manager
  74510. * @param name defines the manager's name
  74511. * @param imgUrl defines the sprite sheet url
  74512. * @param capacity defines the maximum allowed number of sprites
  74513. * @param cellSize defines the size of a sprite cell
  74514. * @param scene defines the hosting scene
  74515. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74516. * @param samplingMode defines the smapling mode to use with spritesheet
  74517. */
  74518. constructor(
  74519. /** defines the manager's name */
  74520. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  74521. private _appendSpriteVertex;
  74522. /**
  74523. * Intersects the sprites with a ray
  74524. * @param ray defines the ray to intersect with
  74525. * @param camera defines the current active camera
  74526. * @param predicate defines a predicate used to select candidate sprites
  74527. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  74528. * @returns null if no hit or a PickingInfo
  74529. */
  74530. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  74531. /**
  74532. * Render all child sprites
  74533. */
  74534. render(): void;
  74535. /**
  74536. * Release associated resources
  74537. */
  74538. dispose(): void;
  74539. }
  74540. }
  74541. declare module BABYLON {
  74542. /**
  74543. * Class used to represent a sprite
  74544. * @see http://doc.babylonjs.com/babylon101/sprites
  74545. */
  74546. export class Sprite {
  74547. /** defines the name */
  74548. name: string;
  74549. /** Gets or sets the current world position */
  74550. position: Vector3;
  74551. /** Gets or sets the main color */
  74552. color: Color4;
  74553. /** Gets or sets the width */
  74554. width: number;
  74555. /** Gets or sets the height */
  74556. height: number;
  74557. /** Gets or sets rotation angle */
  74558. angle: number;
  74559. /** Gets or sets the cell index in the sprite sheet */
  74560. cellIndex: number;
  74561. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  74562. invertU: number;
  74563. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  74564. invertV: number;
  74565. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  74566. disposeWhenFinishedAnimating: boolean;
  74567. /** Gets the list of attached animations */
  74568. animations: Animation[];
  74569. /** Gets or sets a boolean indicating if the sprite can be picked */
  74570. isPickable: boolean;
  74571. /**
  74572. * Gets or sets the associated action manager
  74573. */
  74574. actionManager: Nullable<ActionManager>;
  74575. private _animationStarted;
  74576. private _loopAnimation;
  74577. private _fromIndex;
  74578. private _toIndex;
  74579. private _delay;
  74580. private _direction;
  74581. private _manager;
  74582. private _time;
  74583. private _onAnimationEnd;
  74584. /**
  74585. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  74586. */
  74587. isVisible: boolean;
  74588. /**
  74589. * Gets or sets the sprite size
  74590. */
  74591. size: number;
  74592. /**
  74593. * Creates a new Sprite
  74594. * @param name defines the name
  74595. * @param manager defines the manager
  74596. */
  74597. constructor(
  74598. /** defines the name */
  74599. name: string, manager: ISpriteManager);
  74600. /**
  74601. * Starts an animation
  74602. * @param from defines the initial key
  74603. * @param to defines the end key
  74604. * @param loop defines if the animation must loop
  74605. * @param delay defines the start delay (in ms)
  74606. * @param onAnimationEnd defines a callback to call when animation ends
  74607. */
  74608. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  74609. /** Stops current animation (if any) */
  74610. stopAnimation(): void;
  74611. /** @hidden */
  74612. _animate(deltaTime: number): void;
  74613. /** Release associated resources */
  74614. dispose(): void;
  74615. }
  74616. }
  74617. declare module BABYLON {
  74618. /**
  74619. * Information about the result of picking within a scene
  74620. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  74621. */
  74622. export class PickingInfo {
  74623. /** @hidden */
  74624. _pickingUnavailable: boolean;
  74625. /**
  74626. * If the pick collided with an object
  74627. */
  74628. hit: boolean;
  74629. /**
  74630. * Distance away where the pick collided
  74631. */
  74632. distance: number;
  74633. /**
  74634. * The location of pick collision
  74635. */
  74636. pickedPoint: Nullable<Vector3>;
  74637. /**
  74638. * The mesh corresponding the the pick collision
  74639. */
  74640. pickedMesh: Nullable<AbstractMesh>;
  74641. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  74642. bu: number;
  74643. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  74644. bv: number;
  74645. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  74646. faceId: number;
  74647. /** Id of the the submesh that was picked */
  74648. subMeshId: number;
  74649. /** If a sprite was picked, this will be the sprite the pick collided with */
  74650. pickedSprite: Nullable<Sprite>;
  74651. /**
  74652. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  74653. */
  74654. originMesh: Nullable<AbstractMesh>;
  74655. /**
  74656. * The ray that was used to perform the picking.
  74657. */
  74658. ray: Nullable<Ray>;
  74659. /**
  74660. * Gets the normal correspodning to the face the pick collided with
  74661. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  74662. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  74663. * @returns The normal correspodning to the face the pick collided with
  74664. */
  74665. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  74666. /**
  74667. * Gets the texture coordinates of where the pick occured
  74668. * @returns the vector containing the coordnates of the texture
  74669. */
  74670. getTextureCoordinates(): Nullable<Vector2>;
  74671. }
  74672. }
  74673. declare module BABYLON {
  74674. /**
  74675. * Gather the list of pointer event types as constants.
  74676. */
  74677. export class PointerEventTypes {
  74678. /**
  74679. * 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.
  74680. */
  74681. static readonly POINTERDOWN: number;
  74682. /**
  74683. * The pointerup event is fired when a pointer is no longer active.
  74684. */
  74685. static readonly POINTERUP: number;
  74686. /**
  74687. * The pointermove event is fired when a pointer changes coordinates.
  74688. */
  74689. static readonly POINTERMOVE: number;
  74690. /**
  74691. * The pointerwheel event is fired when a mouse wheel has been rotated.
  74692. */
  74693. static readonly POINTERWHEEL: number;
  74694. /**
  74695. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  74696. */
  74697. static readonly POINTERPICK: number;
  74698. /**
  74699. * The pointertap event is fired when a the object has been touched and released without drag.
  74700. */
  74701. static readonly POINTERTAP: number;
  74702. /**
  74703. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  74704. */
  74705. static readonly POINTERDOUBLETAP: number;
  74706. }
  74707. /**
  74708. * Base class of pointer info types.
  74709. */
  74710. export class PointerInfoBase {
  74711. /**
  74712. * Defines the type of event (PointerEventTypes)
  74713. */
  74714. type: number;
  74715. /**
  74716. * Defines the related dom event
  74717. */
  74718. event: PointerEvent | MouseWheelEvent;
  74719. /**
  74720. * Instantiates the base class of pointers info.
  74721. * @param type Defines the type of event (PointerEventTypes)
  74722. * @param event Defines the related dom event
  74723. */
  74724. constructor(
  74725. /**
  74726. * Defines the type of event (PointerEventTypes)
  74727. */
  74728. type: number,
  74729. /**
  74730. * Defines the related dom event
  74731. */
  74732. event: PointerEvent | MouseWheelEvent);
  74733. }
  74734. /**
  74735. * This class is used to store pointer related info for the onPrePointerObservable event.
  74736. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  74737. */
  74738. export class PointerInfoPre extends PointerInfoBase {
  74739. /**
  74740. * Ray from a pointer if availible (eg. 6dof controller)
  74741. */
  74742. ray: Nullable<Ray>;
  74743. /**
  74744. * Defines the local position of the pointer on the canvas.
  74745. */
  74746. localPosition: Vector2;
  74747. /**
  74748. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  74749. */
  74750. skipOnPointerObservable: boolean;
  74751. /**
  74752. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  74753. * @param type Defines the type of event (PointerEventTypes)
  74754. * @param event Defines the related dom event
  74755. * @param localX Defines the local x coordinates of the pointer when the event occured
  74756. * @param localY Defines the local y coordinates of the pointer when the event occured
  74757. */
  74758. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  74759. }
  74760. /**
  74761. * This type contains all the data related to a pointer event in Babylon.js.
  74762. * 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.
  74763. */
  74764. export class PointerInfo extends PointerInfoBase {
  74765. /**
  74766. * Defines the picking info associated to the info (if any)\
  74767. */
  74768. pickInfo: Nullable<PickingInfo>;
  74769. /**
  74770. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  74771. * @param type Defines the type of event (PointerEventTypes)
  74772. * @param event Defines the related dom event
  74773. * @param pickInfo Defines the picking info associated to the info (if any)\
  74774. */
  74775. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  74776. /**
  74777. * Defines the picking info associated to the info (if any)\
  74778. */
  74779. pickInfo: Nullable<PickingInfo>);
  74780. }
  74781. /**
  74782. * Data relating to a touch event on the screen.
  74783. */
  74784. export interface PointerTouch {
  74785. /**
  74786. * X coordinate of touch.
  74787. */
  74788. x: number;
  74789. /**
  74790. * Y coordinate of touch.
  74791. */
  74792. y: number;
  74793. /**
  74794. * Id of touch. Unique for each finger.
  74795. */
  74796. pointerId: number;
  74797. /**
  74798. * Event type passed from DOM.
  74799. */
  74800. type: any;
  74801. }
  74802. }
  74803. declare module BABYLON {
  74804. /**
  74805. * Manage the mouse inputs to control the movement of a free camera.
  74806. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74807. */
  74808. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  74809. /**
  74810. * Define if touch is enabled in the mouse input
  74811. */
  74812. touchEnabled: boolean;
  74813. /**
  74814. * Defines the camera the input is attached to.
  74815. */
  74816. camera: FreeCamera;
  74817. /**
  74818. * Defines the buttons associated with the input to handle camera move.
  74819. */
  74820. buttons: number[];
  74821. /**
  74822. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  74823. */
  74824. angularSensibility: number;
  74825. private _pointerInput;
  74826. private _onMouseMove;
  74827. private _observer;
  74828. private previousPosition;
  74829. /**
  74830. * Observable for when a pointer move event occurs containing the move offset
  74831. */
  74832. onPointerMovedObservable: Observable<{
  74833. offsetX: number;
  74834. offsetY: number;
  74835. }>;
  74836. /**
  74837. * @hidden
  74838. * If the camera should be rotated automatically based on pointer movement
  74839. */
  74840. _allowCameraRotation: boolean;
  74841. /**
  74842. * Manage the mouse inputs to control the movement of a free camera.
  74843. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74844. * @param touchEnabled Defines if touch is enabled or not
  74845. */
  74846. constructor(
  74847. /**
  74848. * Define if touch is enabled in the mouse input
  74849. */
  74850. touchEnabled?: boolean);
  74851. /**
  74852. * Attach the input controls to a specific dom element to get the input from.
  74853. * @param element Defines the element the controls should be listened from
  74854. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74855. */
  74856. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74857. /**
  74858. * Called on JS contextmenu event.
  74859. * Override this method to provide functionality.
  74860. */
  74861. protected onContextMenu(evt: PointerEvent): void;
  74862. /**
  74863. * Detach the current controls from the specified dom element.
  74864. * @param element Defines the element to stop listening the inputs from
  74865. */
  74866. detachControl(element: Nullable<HTMLElement>): void;
  74867. /**
  74868. * Gets the class name of the current intput.
  74869. * @returns the class name
  74870. */
  74871. getClassName(): string;
  74872. /**
  74873. * Get the friendly name associated with the input class.
  74874. * @returns the input friendly name
  74875. */
  74876. getSimpleName(): string;
  74877. }
  74878. }
  74879. declare module BABYLON {
  74880. /**
  74881. * Manage the touch inputs to control the movement of a free camera.
  74882. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74883. */
  74884. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  74885. /**
  74886. * Defines the camera the input is attached to.
  74887. */
  74888. camera: FreeCamera;
  74889. /**
  74890. * Defines the touch sensibility for rotation.
  74891. * The higher the faster.
  74892. */
  74893. touchAngularSensibility: number;
  74894. /**
  74895. * Defines the touch sensibility for move.
  74896. * The higher the faster.
  74897. */
  74898. touchMoveSensibility: number;
  74899. private _offsetX;
  74900. private _offsetY;
  74901. private _pointerPressed;
  74902. private _pointerInput;
  74903. private _observer;
  74904. private _onLostFocus;
  74905. /**
  74906. * Attach the input controls to a specific dom element to get the input from.
  74907. * @param element Defines the element the controls should be listened from
  74908. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74909. */
  74910. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74911. /**
  74912. * Detach the current controls from the specified dom element.
  74913. * @param element Defines the element to stop listening the inputs from
  74914. */
  74915. detachControl(element: Nullable<HTMLElement>): void;
  74916. /**
  74917. * Update the current camera state depending on the inputs that have been used this frame.
  74918. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74919. */
  74920. checkInputs(): void;
  74921. /**
  74922. * Gets the class name of the current intput.
  74923. * @returns the class name
  74924. */
  74925. getClassName(): string;
  74926. /**
  74927. * Get the friendly name associated with the input class.
  74928. * @returns the input friendly name
  74929. */
  74930. getSimpleName(): string;
  74931. }
  74932. }
  74933. declare module BABYLON {
  74934. /**
  74935. * Default Inputs manager for the FreeCamera.
  74936. * It groups all the default supported inputs for ease of use.
  74937. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74938. */
  74939. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  74940. /**
  74941. * @hidden
  74942. */
  74943. _mouseInput: Nullable<FreeCameraMouseInput>;
  74944. /**
  74945. * Instantiates a new FreeCameraInputsManager.
  74946. * @param camera Defines the camera the inputs belong to
  74947. */
  74948. constructor(camera: FreeCamera);
  74949. /**
  74950. * Add keyboard input support to the input manager.
  74951. * @returns the current input manager
  74952. */
  74953. addKeyboard(): FreeCameraInputsManager;
  74954. /**
  74955. * Add mouse input support to the input manager.
  74956. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  74957. * @returns the current input manager
  74958. */
  74959. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  74960. /**
  74961. * Removes the mouse input support from the manager
  74962. * @returns the current input manager
  74963. */
  74964. removeMouse(): FreeCameraInputsManager;
  74965. /**
  74966. * Add touch input support to the input manager.
  74967. * @returns the current input manager
  74968. */
  74969. addTouch(): FreeCameraInputsManager;
  74970. /**
  74971. * Remove all attached input methods from a camera
  74972. */
  74973. clear(): void;
  74974. }
  74975. }
  74976. declare module BABYLON {
  74977. /**
  74978. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  74979. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  74980. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  74981. */
  74982. export class FreeCamera extends TargetCamera {
  74983. /**
  74984. * Define the collision ellipsoid of the camera.
  74985. * This is helpful to simulate a camera body like the player body around the camera
  74986. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  74987. */
  74988. ellipsoid: Vector3;
  74989. /**
  74990. * Define an offset for the position of the ellipsoid around the camera.
  74991. * This can be helpful to determine the center of the body near the gravity center of the body
  74992. * instead of its head.
  74993. */
  74994. ellipsoidOffset: Vector3;
  74995. /**
  74996. * Enable or disable collisions of the camera with the rest of the scene objects.
  74997. */
  74998. checkCollisions: boolean;
  74999. /**
  75000. * Enable or disable gravity on the camera.
  75001. */
  75002. applyGravity: boolean;
  75003. /**
  75004. * Define the input manager associated to the camera.
  75005. */
  75006. inputs: FreeCameraInputsManager;
  75007. /**
  75008. * Gets the input sensibility for a mouse input. (default is 2000.0)
  75009. * Higher values reduce sensitivity.
  75010. */
  75011. /**
  75012. * Sets the input sensibility for a mouse input. (default is 2000.0)
  75013. * Higher values reduce sensitivity.
  75014. */
  75015. angularSensibility: number;
  75016. /**
  75017. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75018. */
  75019. keysUp: number[];
  75020. /**
  75021. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75022. */
  75023. keysDown: number[];
  75024. /**
  75025. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75026. */
  75027. keysLeft: number[];
  75028. /**
  75029. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75030. */
  75031. keysRight: number[];
  75032. /**
  75033. * Event raised when the camera collide with a mesh in the scene.
  75034. */
  75035. onCollide: (collidedMesh: AbstractMesh) => void;
  75036. private _collider;
  75037. private _needMoveForGravity;
  75038. private _oldPosition;
  75039. private _diffPosition;
  75040. private _newPosition;
  75041. /** @hidden */
  75042. _localDirection: Vector3;
  75043. /** @hidden */
  75044. _transformedDirection: Vector3;
  75045. /**
  75046. * Instantiates a Free Camera.
  75047. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  75048. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  75049. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  75050. * @param name Define the name of the camera in the scene
  75051. * @param position Define the start position of the camera in the scene
  75052. * @param scene Define the scene the camera belongs to
  75053. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75054. */
  75055. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75056. /**
  75057. * Attached controls to the current camera.
  75058. * @param element Defines the element the controls should be listened from
  75059. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75060. */
  75061. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75062. /**
  75063. * Detach the current controls from the camera.
  75064. * The camera will stop reacting to inputs.
  75065. * @param element Defines the element to stop listening the inputs from
  75066. */
  75067. detachControl(element: HTMLElement): void;
  75068. private _collisionMask;
  75069. /**
  75070. * Define a collision mask to limit the list of object the camera can collide with
  75071. */
  75072. collisionMask: number;
  75073. /** @hidden */
  75074. _collideWithWorld(displacement: Vector3): void;
  75075. private _onCollisionPositionChange;
  75076. /** @hidden */
  75077. _checkInputs(): void;
  75078. /** @hidden */
  75079. _decideIfNeedsToMove(): boolean;
  75080. /** @hidden */
  75081. _updatePosition(): void;
  75082. /**
  75083. * Destroy the camera and release the current resources hold by it.
  75084. */
  75085. dispose(): void;
  75086. /**
  75087. * Gets the current object class name.
  75088. * @return the class name
  75089. */
  75090. getClassName(): string;
  75091. }
  75092. }
  75093. declare module BABYLON {
  75094. /**
  75095. * Represents a gamepad control stick position
  75096. */
  75097. export class StickValues {
  75098. /**
  75099. * The x component of the control stick
  75100. */
  75101. x: number;
  75102. /**
  75103. * The y component of the control stick
  75104. */
  75105. y: number;
  75106. /**
  75107. * Initializes the gamepad x and y control stick values
  75108. * @param x The x component of the gamepad control stick value
  75109. * @param y The y component of the gamepad control stick value
  75110. */
  75111. constructor(
  75112. /**
  75113. * The x component of the control stick
  75114. */
  75115. x: number,
  75116. /**
  75117. * The y component of the control stick
  75118. */
  75119. y: number);
  75120. }
  75121. /**
  75122. * An interface which manages callbacks for gamepad button changes
  75123. */
  75124. export interface GamepadButtonChanges {
  75125. /**
  75126. * Called when a gamepad has been changed
  75127. */
  75128. changed: boolean;
  75129. /**
  75130. * Called when a gamepad press event has been triggered
  75131. */
  75132. pressChanged: boolean;
  75133. /**
  75134. * Called when a touch event has been triggered
  75135. */
  75136. touchChanged: boolean;
  75137. /**
  75138. * Called when a value has changed
  75139. */
  75140. valueChanged: boolean;
  75141. }
  75142. /**
  75143. * Represents a gamepad
  75144. */
  75145. export class Gamepad {
  75146. /**
  75147. * The id of the gamepad
  75148. */
  75149. id: string;
  75150. /**
  75151. * The index of the gamepad
  75152. */
  75153. index: number;
  75154. /**
  75155. * The browser gamepad
  75156. */
  75157. browserGamepad: any;
  75158. /**
  75159. * Specifies what type of gamepad this represents
  75160. */
  75161. type: number;
  75162. private _leftStick;
  75163. private _rightStick;
  75164. /** @hidden */
  75165. _isConnected: boolean;
  75166. private _leftStickAxisX;
  75167. private _leftStickAxisY;
  75168. private _rightStickAxisX;
  75169. private _rightStickAxisY;
  75170. /**
  75171. * Triggered when the left control stick has been changed
  75172. */
  75173. private _onleftstickchanged;
  75174. /**
  75175. * Triggered when the right control stick has been changed
  75176. */
  75177. private _onrightstickchanged;
  75178. /**
  75179. * Represents a gamepad controller
  75180. */
  75181. static GAMEPAD: number;
  75182. /**
  75183. * Represents a generic controller
  75184. */
  75185. static GENERIC: number;
  75186. /**
  75187. * Represents an XBox controller
  75188. */
  75189. static XBOX: number;
  75190. /**
  75191. * Represents a pose-enabled controller
  75192. */
  75193. static POSE_ENABLED: number;
  75194. /**
  75195. * Specifies whether the left control stick should be Y-inverted
  75196. */
  75197. protected _invertLeftStickY: boolean;
  75198. /**
  75199. * Specifies if the gamepad has been connected
  75200. */
  75201. readonly isConnected: boolean;
  75202. /**
  75203. * Initializes the gamepad
  75204. * @param id The id of the gamepad
  75205. * @param index The index of the gamepad
  75206. * @param browserGamepad The browser gamepad
  75207. * @param leftStickX The x component of the left joystick
  75208. * @param leftStickY The y component of the left joystick
  75209. * @param rightStickX The x component of the right joystick
  75210. * @param rightStickY The y component of the right joystick
  75211. */
  75212. constructor(
  75213. /**
  75214. * The id of the gamepad
  75215. */
  75216. id: string,
  75217. /**
  75218. * The index of the gamepad
  75219. */
  75220. index: number,
  75221. /**
  75222. * The browser gamepad
  75223. */
  75224. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  75225. /**
  75226. * Callback triggered when the left joystick has changed
  75227. * @param callback
  75228. */
  75229. onleftstickchanged(callback: (values: StickValues) => void): void;
  75230. /**
  75231. * Callback triggered when the right joystick has changed
  75232. * @param callback
  75233. */
  75234. onrightstickchanged(callback: (values: StickValues) => void): void;
  75235. /**
  75236. * Gets the left joystick
  75237. */
  75238. /**
  75239. * Sets the left joystick values
  75240. */
  75241. leftStick: StickValues;
  75242. /**
  75243. * Gets the right joystick
  75244. */
  75245. /**
  75246. * Sets the right joystick value
  75247. */
  75248. rightStick: StickValues;
  75249. /**
  75250. * Updates the gamepad joystick positions
  75251. */
  75252. update(): void;
  75253. /**
  75254. * Disposes the gamepad
  75255. */
  75256. dispose(): void;
  75257. }
  75258. /**
  75259. * Represents a generic gamepad
  75260. */
  75261. export class GenericPad extends Gamepad {
  75262. private _buttons;
  75263. private _onbuttondown;
  75264. private _onbuttonup;
  75265. /**
  75266. * Observable triggered when a button has been pressed
  75267. */
  75268. onButtonDownObservable: Observable<number>;
  75269. /**
  75270. * Observable triggered when a button has been released
  75271. */
  75272. onButtonUpObservable: Observable<number>;
  75273. /**
  75274. * Callback triggered when a button has been pressed
  75275. * @param callback Called when a button has been pressed
  75276. */
  75277. onbuttondown(callback: (buttonPressed: number) => void): void;
  75278. /**
  75279. * Callback triggered when a button has been released
  75280. * @param callback Called when a button has been released
  75281. */
  75282. onbuttonup(callback: (buttonReleased: number) => void): void;
  75283. /**
  75284. * Initializes the generic gamepad
  75285. * @param id The id of the generic gamepad
  75286. * @param index The index of the generic gamepad
  75287. * @param browserGamepad The browser gamepad
  75288. */
  75289. constructor(id: string, index: number, browserGamepad: any);
  75290. private _setButtonValue;
  75291. /**
  75292. * Updates the generic gamepad
  75293. */
  75294. update(): void;
  75295. /**
  75296. * Disposes the generic gamepad
  75297. */
  75298. dispose(): void;
  75299. }
  75300. }
  75301. declare module BABYLON {
  75302. /**
  75303. * Defines the types of pose enabled controllers that are supported
  75304. */
  75305. export enum PoseEnabledControllerType {
  75306. /**
  75307. * HTC Vive
  75308. */
  75309. VIVE = 0,
  75310. /**
  75311. * Oculus Rift
  75312. */
  75313. OCULUS = 1,
  75314. /**
  75315. * Windows mixed reality
  75316. */
  75317. WINDOWS = 2,
  75318. /**
  75319. * Samsung gear VR
  75320. */
  75321. GEAR_VR = 3,
  75322. /**
  75323. * Google Daydream
  75324. */
  75325. DAYDREAM = 4,
  75326. /**
  75327. * Generic
  75328. */
  75329. GENERIC = 5
  75330. }
  75331. /**
  75332. * Defines the MutableGamepadButton interface for the state of a gamepad button
  75333. */
  75334. export interface MutableGamepadButton {
  75335. /**
  75336. * Value of the button/trigger
  75337. */
  75338. value: number;
  75339. /**
  75340. * If the button/trigger is currently touched
  75341. */
  75342. touched: boolean;
  75343. /**
  75344. * If the button/trigger is currently pressed
  75345. */
  75346. pressed: boolean;
  75347. }
  75348. /**
  75349. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  75350. * @hidden
  75351. */
  75352. export interface ExtendedGamepadButton extends GamepadButton {
  75353. /**
  75354. * If the button/trigger is currently pressed
  75355. */
  75356. readonly pressed: boolean;
  75357. /**
  75358. * If the button/trigger is currently touched
  75359. */
  75360. readonly touched: boolean;
  75361. /**
  75362. * Value of the button/trigger
  75363. */
  75364. readonly value: number;
  75365. }
  75366. /** @hidden */
  75367. export interface _GamePadFactory {
  75368. /**
  75369. * Returns wether or not the current gamepad can be created for this type of controller.
  75370. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  75371. * @returns true if it can be created, otherwise false
  75372. */
  75373. canCreate(gamepadInfo: any): boolean;
  75374. /**
  75375. * Creates a new instance of the Gamepad.
  75376. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  75377. * @returns the new gamepad instance
  75378. */
  75379. create(gamepadInfo: any): Gamepad;
  75380. }
  75381. /**
  75382. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  75383. */
  75384. export class PoseEnabledControllerHelper {
  75385. /** @hidden */
  75386. static _ControllerFactories: _GamePadFactory[];
  75387. /** @hidden */
  75388. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  75389. /**
  75390. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  75391. * @param vrGamepad the gamepad to initialized
  75392. * @returns a vr controller of the type the gamepad identified as
  75393. */
  75394. static InitiateController(vrGamepad: any): Gamepad;
  75395. }
  75396. /**
  75397. * Defines the PoseEnabledController object that contains state of a vr capable controller
  75398. */
  75399. export class PoseEnabledController extends Gamepad implements PoseControlled {
  75400. private _deviceRoomPosition;
  75401. private _deviceRoomRotationQuaternion;
  75402. /**
  75403. * The device position in babylon space
  75404. */
  75405. devicePosition: Vector3;
  75406. /**
  75407. * The device rotation in babylon space
  75408. */
  75409. deviceRotationQuaternion: Quaternion;
  75410. /**
  75411. * The scale factor of the device in babylon space
  75412. */
  75413. deviceScaleFactor: number;
  75414. /**
  75415. * (Likely devicePosition should be used instead) The device position in its room space
  75416. */
  75417. position: Vector3;
  75418. /**
  75419. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  75420. */
  75421. rotationQuaternion: Quaternion;
  75422. /**
  75423. * The type of controller (Eg. Windows mixed reality)
  75424. */
  75425. controllerType: PoseEnabledControllerType;
  75426. protected _calculatedPosition: Vector3;
  75427. private _calculatedRotation;
  75428. /**
  75429. * The raw pose from the device
  75430. */
  75431. rawPose: DevicePose;
  75432. private _trackPosition;
  75433. private _maxRotationDistFromHeadset;
  75434. private _draggedRoomRotation;
  75435. /**
  75436. * @hidden
  75437. */
  75438. _disableTrackPosition(fixedPosition: Vector3): void;
  75439. /**
  75440. * Internal, the mesh attached to the controller
  75441. * @hidden
  75442. */
  75443. _mesh: Nullable<AbstractMesh>;
  75444. private _poseControlledCamera;
  75445. private _leftHandSystemQuaternion;
  75446. /**
  75447. * Internal, matrix used to convert room space to babylon space
  75448. * @hidden
  75449. */
  75450. _deviceToWorld: Matrix;
  75451. /**
  75452. * Node to be used when casting a ray from the controller
  75453. * @hidden
  75454. */
  75455. _pointingPoseNode: Nullable<TransformNode>;
  75456. /**
  75457. * Name of the child mesh that can be used to cast a ray from the controller
  75458. */
  75459. static readonly POINTING_POSE: string;
  75460. /**
  75461. * Creates a new PoseEnabledController from a gamepad
  75462. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  75463. */
  75464. constructor(browserGamepad: any);
  75465. private _workingMatrix;
  75466. /**
  75467. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  75468. */
  75469. update(): void;
  75470. /**
  75471. * Updates only the pose device and mesh without doing any button event checking
  75472. */
  75473. protected _updatePoseAndMesh(): void;
  75474. /**
  75475. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  75476. * @param poseData raw pose fromthe device
  75477. */
  75478. updateFromDevice(poseData: DevicePose): void;
  75479. /**
  75480. * @hidden
  75481. */
  75482. _meshAttachedObservable: Observable<AbstractMesh>;
  75483. /**
  75484. * Attaches a mesh to the controller
  75485. * @param mesh the mesh to be attached
  75486. */
  75487. attachToMesh(mesh: AbstractMesh): void;
  75488. /**
  75489. * Attaches the controllers mesh to a camera
  75490. * @param camera the camera the mesh should be attached to
  75491. */
  75492. attachToPoseControlledCamera(camera: TargetCamera): void;
  75493. /**
  75494. * Disposes of the controller
  75495. */
  75496. dispose(): void;
  75497. /**
  75498. * The mesh that is attached to the controller
  75499. */
  75500. readonly mesh: Nullable<AbstractMesh>;
  75501. /**
  75502. * Gets the ray of the controller in the direction the controller is pointing
  75503. * @param length the length the resulting ray should be
  75504. * @returns a ray in the direction the controller is pointing
  75505. */
  75506. getForwardRay(length?: number): Ray;
  75507. }
  75508. }
  75509. declare module BABYLON {
  75510. /**
  75511. * Defines the WebVRController object that represents controllers tracked in 3D space
  75512. */
  75513. export abstract class WebVRController extends PoseEnabledController {
  75514. /**
  75515. * Internal, the default controller model for the controller
  75516. */
  75517. protected _defaultModel: AbstractMesh;
  75518. /**
  75519. * Fired when the trigger state has changed
  75520. */
  75521. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  75522. /**
  75523. * Fired when the main button state has changed
  75524. */
  75525. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  75526. /**
  75527. * Fired when the secondary button state has changed
  75528. */
  75529. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  75530. /**
  75531. * Fired when the pad state has changed
  75532. */
  75533. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  75534. /**
  75535. * Fired when controllers stick values have changed
  75536. */
  75537. onPadValuesChangedObservable: Observable<StickValues>;
  75538. /**
  75539. * Array of button availible on the controller
  75540. */
  75541. protected _buttons: Array<MutableGamepadButton>;
  75542. private _onButtonStateChange;
  75543. /**
  75544. * Fired when a controller button's state has changed
  75545. * @param callback the callback containing the button that was modified
  75546. */
  75547. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  75548. /**
  75549. * X and Y axis corrisponding to the controllers joystick
  75550. */
  75551. pad: StickValues;
  75552. /**
  75553. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  75554. */
  75555. hand: string;
  75556. /**
  75557. * The default controller model for the controller
  75558. */
  75559. readonly defaultModel: AbstractMesh;
  75560. /**
  75561. * Creates a new WebVRController from a gamepad
  75562. * @param vrGamepad the gamepad that the WebVRController should be created from
  75563. */
  75564. constructor(vrGamepad: any);
  75565. /**
  75566. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  75567. */
  75568. update(): void;
  75569. /**
  75570. * Function to be called when a button is modified
  75571. */
  75572. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  75573. /**
  75574. * Loads a mesh and attaches it to the controller
  75575. * @param scene the scene the mesh should be added to
  75576. * @param meshLoaded callback for when the mesh has been loaded
  75577. */
  75578. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  75579. private _setButtonValue;
  75580. private _changes;
  75581. private _checkChanges;
  75582. /**
  75583. * Disposes of th webVRCOntroller
  75584. */
  75585. dispose(): void;
  75586. }
  75587. }
  75588. declare module BABYLON {
  75589. /**
  75590. * The HemisphericLight simulates the ambient environment light,
  75591. * so the passed direction is the light reflection direction, not the incoming direction.
  75592. */
  75593. export class HemisphericLight extends Light {
  75594. /**
  75595. * The groundColor is the light in the opposite direction to the one specified during creation.
  75596. * 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.
  75597. */
  75598. groundColor: Color3;
  75599. /**
  75600. * The light reflection direction, not the incoming direction.
  75601. */
  75602. direction: Vector3;
  75603. /**
  75604. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  75605. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  75606. * The HemisphericLight can't cast shadows.
  75607. * Documentation : https://doc.babylonjs.com/babylon101/lights
  75608. * @param name The friendly name of the light
  75609. * @param direction The direction of the light reflection
  75610. * @param scene The scene the light belongs to
  75611. */
  75612. constructor(name: string, direction: Vector3, scene: Scene);
  75613. protected _buildUniformLayout(): void;
  75614. /**
  75615. * Returns the string "HemisphericLight".
  75616. * @return The class name
  75617. */
  75618. getClassName(): string;
  75619. /**
  75620. * Sets the HemisphericLight direction towards the passed target (Vector3).
  75621. * Returns the updated direction.
  75622. * @param target The target the direction should point to
  75623. * @return The computed direction
  75624. */
  75625. setDirectionToTarget(target: Vector3): Vector3;
  75626. /**
  75627. * Returns the shadow generator associated to the light.
  75628. * @returns Always null for hemispheric lights because it does not support shadows.
  75629. */
  75630. getShadowGenerator(): Nullable<IShadowGenerator>;
  75631. /**
  75632. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  75633. * @param effect The effect to update
  75634. * @param lightIndex The index of the light in the effect to update
  75635. * @returns The hemispheric light
  75636. */
  75637. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  75638. /**
  75639. * Computes the world matrix of the node
  75640. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75641. * @param useWasUpdatedFlag defines a reserved property
  75642. * @returns the world matrix
  75643. */
  75644. computeWorldMatrix(): Matrix;
  75645. /**
  75646. * Returns the integer 3.
  75647. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75648. */
  75649. getTypeID(): number;
  75650. /**
  75651. * Prepares the list of defines specific to the light type.
  75652. * @param defines the list of defines
  75653. * @param lightIndex defines the index of the light for the effect
  75654. */
  75655. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75656. }
  75657. }
  75658. declare module BABYLON {
  75659. /** @hidden */
  75660. export var vrMultiviewToSingleviewPixelShader: {
  75661. name: string;
  75662. shader: string;
  75663. };
  75664. }
  75665. declare module BABYLON {
  75666. /**
  75667. * Renders to multiple views with a single draw call
  75668. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  75669. */
  75670. export class MultiviewRenderTarget extends RenderTargetTexture {
  75671. /**
  75672. * Creates a multiview render target
  75673. * @param scene scene used with the render target
  75674. * @param size the size of the render target (used for each view)
  75675. */
  75676. constructor(scene: Scene, size?: number | {
  75677. width: number;
  75678. height: number;
  75679. } | {
  75680. ratio: number;
  75681. });
  75682. /**
  75683. * @hidden
  75684. * @param faceIndex the face index, if its a cube texture
  75685. */
  75686. _bindFrameBuffer(faceIndex?: number): void;
  75687. /**
  75688. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  75689. * @returns the view count
  75690. */
  75691. getViewCount(): number;
  75692. }
  75693. }
  75694. declare module BABYLON {
  75695. interface Engine {
  75696. /**
  75697. * Creates a new multiview render target
  75698. * @param width defines the width of the texture
  75699. * @param height defines the height of the texture
  75700. * @returns the created multiview texture
  75701. */
  75702. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  75703. /**
  75704. * Binds a multiview framebuffer to be drawn to
  75705. * @param multiviewTexture texture to bind
  75706. */
  75707. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  75708. }
  75709. interface Camera {
  75710. /**
  75711. * @hidden
  75712. * 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)
  75713. */
  75714. _useMultiviewToSingleView: boolean;
  75715. /**
  75716. * @hidden
  75717. * 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)
  75718. */
  75719. _multiviewTexture: Nullable<RenderTargetTexture>;
  75720. /**
  75721. * @hidden
  75722. * ensures the multiview texture of the camera exists and has the specified width/height
  75723. * @param width height to set on the multiview texture
  75724. * @param height width to set on the multiview texture
  75725. */
  75726. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  75727. }
  75728. interface Scene {
  75729. /** @hidden */
  75730. _transformMatrixR: Matrix;
  75731. /** @hidden */
  75732. _multiviewSceneUbo: Nullable<UniformBuffer>;
  75733. /** @hidden */
  75734. _createMultiviewUbo(): void;
  75735. /** @hidden */
  75736. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  75737. /** @hidden */
  75738. _renderMultiviewToSingleView(camera: Camera): void;
  75739. }
  75740. }
  75741. declare module BABYLON {
  75742. /**
  75743. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  75744. * This will not be used for webXR as it supports displaying texture arrays directly
  75745. */
  75746. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  75747. /**
  75748. * Initializes a VRMultiviewToSingleview
  75749. * @param name name of the post process
  75750. * @param camera camera to be applied to
  75751. * @param scaleFactor scaling factor to the size of the output texture
  75752. */
  75753. constructor(name: string, camera: Camera, scaleFactor: number);
  75754. }
  75755. }
  75756. declare module BABYLON {
  75757. interface Engine {
  75758. /** @hidden */
  75759. _vrDisplay: any;
  75760. /** @hidden */
  75761. _vrSupported: boolean;
  75762. /** @hidden */
  75763. _oldSize: Size;
  75764. /** @hidden */
  75765. _oldHardwareScaleFactor: number;
  75766. /** @hidden */
  75767. _vrExclusivePointerMode: boolean;
  75768. /** @hidden */
  75769. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  75770. /** @hidden */
  75771. _onVRDisplayPointerRestricted: () => void;
  75772. /** @hidden */
  75773. _onVRDisplayPointerUnrestricted: () => void;
  75774. /** @hidden */
  75775. _onVrDisplayConnect: Nullable<(display: any) => void>;
  75776. /** @hidden */
  75777. _onVrDisplayDisconnect: Nullable<() => void>;
  75778. /** @hidden */
  75779. _onVrDisplayPresentChange: Nullable<() => void>;
  75780. /**
  75781. * Observable signaled when VR display mode changes
  75782. */
  75783. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  75784. /**
  75785. * Observable signaled when VR request present is complete
  75786. */
  75787. onVRRequestPresentComplete: Observable<boolean>;
  75788. /**
  75789. * Observable signaled when VR request present starts
  75790. */
  75791. onVRRequestPresentStart: Observable<Engine>;
  75792. /**
  75793. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  75794. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  75795. */
  75796. isInVRExclusivePointerMode: boolean;
  75797. /**
  75798. * Gets a boolean indicating if a webVR device was detected
  75799. * @returns true if a webVR device was detected
  75800. */
  75801. isVRDevicePresent(): boolean;
  75802. /**
  75803. * Gets the current webVR device
  75804. * @returns the current webVR device (or null)
  75805. */
  75806. getVRDevice(): any;
  75807. /**
  75808. * Initializes a webVR display and starts listening to display change events
  75809. * The onVRDisplayChangedObservable will be notified upon these changes
  75810. * @returns A promise containing a VRDisplay and if vr is supported
  75811. */
  75812. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  75813. /** @hidden */
  75814. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  75815. /**
  75816. * Call this function to switch to webVR mode
  75817. * Will do nothing if webVR is not supported or if there is no webVR device
  75818. * @see http://doc.babylonjs.com/how_to/webvr_camera
  75819. */
  75820. enableVR(): void;
  75821. /** @hidden */
  75822. _onVRFullScreenTriggered(): void;
  75823. }
  75824. }
  75825. declare module BABYLON {
  75826. /**
  75827. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  75828. * IMPORTANT!! The data is right-hand data.
  75829. * @export
  75830. * @interface DevicePose
  75831. */
  75832. export interface DevicePose {
  75833. /**
  75834. * The position of the device, values in array are [x,y,z].
  75835. */
  75836. readonly position: Nullable<Float32Array>;
  75837. /**
  75838. * The linearVelocity of the device, values in array are [x,y,z].
  75839. */
  75840. readonly linearVelocity: Nullable<Float32Array>;
  75841. /**
  75842. * The linearAcceleration of the device, values in array are [x,y,z].
  75843. */
  75844. readonly linearAcceleration: Nullable<Float32Array>;
  75845. /**
  75846. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  75847. */
  75848. readonly orientation: Nullable<Float32Array>;
  75849. /**
  75850. * The angularVelocity of the device, values in array are [x,y,z].
  75851. */
  75852. readonly angularVelocity: Nullable<Float32Array>;
  75853. /**
  75854. * The angularAcceleration of the device, values in array are [x,y,z].
  75855. */
  75856. readonly angularAcceleration: Nullable<Float32Array>;
  75857. }
  75858. /**
  75859. * Interface representing a pose controlled object in Babylon.
  75860. * A pose controlled object has both regular pose values as well as pose values
  75861. * from an external device such as a VR head mounted display
  75862. */
  75863. export interface PoseControlled {
  75864. /**
  75865. * The position of the object in babylon space.
  75866. */
  75867. position: Vector3;
  75868. /**
  75869. * The rotation quaternion of the object in babylon space.
  75870. */
  75871. rotationQuaternion: Quaternion;
  75872. /**
  75873. * The position of the device in babylon space.
  75874. */
  75875. devicePosition?: Vector3;
  75876. /**
  75877. * The rotation quaternion of the device in babylon space.
  75878. */
  75879. deviceRotationQuaternion: Quaternion;
  75880. /**
  75881. * The raw pose coming from the device.
  75882. */
  75883. rawPose: Nullable<DevicePose>;
  75884. /**
  75885. * The scale of the device to be used when translating from device space to babylon space.
  75886. */
  75887. deviceScaleFactor: number;
  75888. /**
  75889. * Updates the poseControlled values based on the input device pose.
  75890. * @param poseData the pose data to update the object with
  75891. */
  75892. updateFromDevice(poseData: DevicePose): void;
  75893. }
  75894. /**
  75895. * Set of options to customize the webVRCamera
  75896. */
  75897. export interface WebVROptions {
  75898. /**
  75899. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  75900. */
  75901. trackPosition?: boolean;
  75902. /**
  75903. * Sets the scale of the vrDevice in babylon space. (default: 1)
  75904. */
  75905. positionScale?: number;
  75906. /**
  75907. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  75908. */
  75909. displayName?: string;
  75910. /**
  75911. * Should the native controller meshes be initialized. (default: true)
  75912. */
  75913. controllerMeshes?: boolean;
  75914. /**
  75915. * Creating a default HemiLight only on controllers. (default: true)
  75916. */
  75917. defaultLightingOnControllers?: boolean;
  75918. /**
  75919. * If you don't want to use the default VR button of the helper. (default: false)
  75920. */
  75921. useCustomVRButton?: boolean;
  75922. /**
  75923. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  75924. */
  75925. customVRButton?: HTMLButtonElement;
  75926. /**
  75927. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  75928. */
  75929. rayLength?: number;
  75930. /**
  75931. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  75932. */
  75933. defaultHeight?: number;
  75934. /**
  75935. * If multiview should be used if availible (default: false)
  75936. */
  75937. useMultiview?: boolean;
  75938. }
  75939. /**
  75940. * This represents a WebVR camera.
  75941. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  75942. * @example http://doc.babylonjs.com/how_to/webvr_camera
  75943. */
  75944. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  75945. private webVROptions;
  75946. /**
  75947. * @hidden
  75948. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  75949. */
  75950. _vrDevice: any;
  75951. /**
  75952. * The rawPose of the vrDevice.
  75953. */
  75954. rawPose: Nullable<DevicePose>;
  75955. private _onVREnabled;
  75956. private _specsVersion;
  75957. private _attached;
  75958. private _frameData;
  75959. protected _descendants: Array<Node>;
  75960. private _deviceRoomPosition;
  75961. /** @hidden */
  75962. _deviceRoomRotationQuaternion: Quaternion;
  75963. private _standingMatrix;
  75964. /**
  75965. * Represents device position in babylon space.
  75966. */
  75967. devicePosition: Vector3;
  75968. /**
  75969. * Represents device rotation in babylon space.
  75970. */
  75971. deviceRotationQuaternion: Quaternion;
  75972. /**
  75973. * The scale of the device to be used when translating from device space to babylon space.
  75974. */
  75975. deviceScaleFactor: number;
  75976. private _deviceToWorld;
  75977. private _worldToDevice;
  75978. /**
  75979. * References to the webVR controllers for the vrDevice.
  75980. */
  75981. controllers: Array<WebVRController>;
  75982. /**
  75983. * Emits an event when a controller is attached.
  75984. */
  75985. onControllersAttachedObservable: Observable<WebVRController[]>;
  75986. /**
  75987. * Emits an event when a controller's mesh has been loaded;
  75988. */
  75989. onControllerMeshLoadedObservable: Observable<WebVRController>;
  75990. /**
  75991. * Emits an event when the HMD's pose has been updated.
  75992. */
  75993. onPoseUpdatedFromDeviceObservable: Observable<any>;
  75994. private _poseSet;
  75995. /**
  75996. * If the rig cameras be used as parent instead of this camera.
  75997. */
  75998. rigParenting: boolean;
  75999. private _lightOnControllers;
  76000. private _defaultHeight?;
  76001. /**
  76002. * Instantiates a WebVRFreeCamera.
  76003. * @param name The name of the WebVRFreeCamera
  76004. * @param position The starting anchor position for the camera
  76005. * @param scene The scene the camera belongs to
  76006. * @param webVROptions a set of customizable options for the webVRCamera
  76007. */
  76008. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  76009. /**
  76010. * Gets the device distance from the ground in meters.
  76011. * @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.
  76012. */
  76013. deviceDistanceToRoomGround(): number;
  76014. /**
  76015. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  76016. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  76017. */
  76018. useStandingMatrix(callback?: (bool: boolean) => void): void;
  76019. /**
  76020. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  76021. * @returns A promise with a boolean set to if the standing matrix is supported.
  76022. */
  76023. useStandingMatrixAsync(): Promise<boolean>;
  76024. /**
  76025. * Disposes the camera
  76026. */
  76027. dispose(): void;
  76028. /**
  76029. * Gets a vrController by name.
  76030. * @param name The name of the controller to retreive
  76031. * @returns the controller matching the name specified or null if not found
  76032. */
  76033. getControllerByName(name: string): Nullable<WebVRController>;
  76034. private _leftController;
  76035. /**
  76036. * The controller corrisponding to the users left hand.
  76037. */
  76038. readonly leftController: Nullable<WebVRController>;
  76039. private _rightController;
  76040. /**
  76041. * The controller corrisponding to the users right hand.
  76042. */
  76043. readonly rightController: Nullable<WebVRController>;
  76044. /**
  76045. * Casts a ray forward from the vrCamera's gaze.
  76046. * @param length Length of the ray (default: 100)
  76047. * @returns the ray corrisponding to the gaze
  76048. */
  76049. getForwardRay(length?: number): Ray;
  76050. /**
  76051. * @hidden
  76052. * Updates the camera based on device's frame data
  76053. */
  76054. _checkInputs(): void;
  76055. /**
  76056. * Updates the poseControlled values based on the input device pose.
  76057. * @param poseData Pose coming from the device
  76058. */
  76059. updateFromDevice(poseData: DevicePose): void;
  76060. private _htmlElementAttached;
  76061. private _detachIfAttached;
  76062. /**
  76063. * WebVR's attach control will start broadcasting frames to the device.
  76064. * Note that in certain browsers (chrome for example) this function must be called
  76065. * within a user-interaction callback. Example:
  76066. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  76067. *
  76068. * @param element html element to attach the vrDevice to
  76069. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  76070. */
  76071. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76072. /**
  76073. * Detaches the camera from the html element and disables VR
  76074. *
  76075. * @param element html element to detach from
  76076. */
  76077. detachControl(element: HTMLElement): void;
  76078. /**
  76079. * @returns the name of this class
  76080. */
  76081. getClassName(): string;
  76082. /**
  76083. * Calls resetPose on the vrDisplay
  76084. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  76085. */
  76086. resetToCurrentRotation(): void;
  76087. /**
  76088. * @hidden
  76089. * Updates the rig cameras (left and right eye)
  76090. */
  76091. _updateRigCameras(): void;
  76092. private _workingVector;
  76093. private _oneVector;
  76094. private _workingMatrix;
  76095. private updateCacheCalled;
  76096. private _correctPositionIfNotTrackPosition;
  76097. /**
  76098. * @hidden
  76099. * Updates the cached values of the camera
  76100. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  76101. */
  76102. _updateCache(ignoreParentClass?: boolean): void;
  76103. /**
  76104. * @hidden
  76105. * Get current device position in babylon world
  76106. */
  76107. _computeDevicePosition(): void;
  76108. /**
  76109. * Updates the current device position and rotation in the babylon world
  76110. */
  76111. update(): void;
  76112. /**
  76113. * @hidden
  76114. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  76115. * @returns an identity matrix
  76116. */
  76117. _getViewMatrix(): Matrix;
  76118. private _tmpMatrix;
  76119. /**
  76120. * This function is called by the two RIG cameras.
  76121. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  76122. * @hidden
  76123. */
  76124. _getWebVRViewMatrix(): Matrix;
  76125. /** @hidden */
  76126. _getWebVRProjectionMatrix(): Matrix;
  76127. private _onGamepadConnectedObserver;
  76128. private _onGamepadDisconnectedObserver;
  76129. private _updateCacheWhenTrackingDisabledObserver;
  76130. /**
  76131. * Initializes the controllers and their meshes
  76132. */
  76133. initControllers(): void;
  76134. }
  76135. }
  76136. declare module BABYLON {
  76137. /**
  76138. * Size options for a post process
  76139. */
  76140. export type PostProcessOptions = {
  76141. width: number;
  76142. height: number;
  76143. };
  76144. /**
  76145. * PostProcess can be used to apply a shader to a texture after it has been rendered
  76146. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  76147. */
  76148. export class PostProcess {
  76149. /** Name of the PostProcess. */
  76150. name: string;
  76151. /**
  76152. * Gets or sets the unique id of the post process
  76153. */
  76154. uniqueId: number;
  76155. /**
  76156. * Width of the texture to apply the post process on
  76157. */
  76158. width: number;
  76159. /**
  76160. * Height of the texture to apply the post process on
  76161. */
  76162. height: number;
  76163. /**
  76164. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  76165. * @hidden
  76166. */
  76167. _outputTexture: Nullable<InternalTexture>;
  76168. /**
  76169. * Sampling mode used by the shader
  76170. * See https://doc.babylonjs.com/classes/3.1/texture
  76171. */
  76172. renderTargetSamplingMode: number;
  76173. /**
  76174. * Clear color to use when screen clearing
  76175. */
  76176. clearColor: Color4;
  76177. /**
  76178. * If the buffer needs to be cleared before applying the post process. (default: true)
  76179. * Should be set to false if shader will overwrite all previous pixels.
  76180. */
  76181. autoClear: boolean;
  76182. /**
  76183. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  76184. */
  76185. alphaMode: number;
  76186. /**
  76187. * Sets the setAlphaBlendConstants of the babylon engine
  76188. */
  76189. alphaConstants: Color4;
  76190. /**
  76191. * Animations to be used for the post processing
  76192. */
  76193. animations: Animation[];
  76194. /**
  76195. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  76196. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  76197. */
  76198. enablePixelPerfectMode: boolean;
  76199. /**
  76200. * Force the postprocess to be applied without taking in account viewport
  76201. */
  76202. forceFullscreenViewport: boolean;
  76203. /**
  76204. * List of inspectable custom properties (used by the Inspector)
  76205. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76206. */
  76207. inspectableCustomProperties: IInspectable[];
  76208. /**
  76209. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  76210. *
  76211. * | Value | Type | Description |
  76212. * | ----- | ----------------------------------- | ----------- |
  76213. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  76214. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  76215. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  76216. *
  76217. */
  76218. scaleMode: number;
  76219. /**
  76220. * Force textures to be a power of two (default: false)
  76221. */
  76222. alwaysForcePOT: boolean;
  76223. private _samples;
  76224. /**
  76225. * Number of sample textures (default: 1)
  76226. */
  76227. samples: number;
  76228. /**
  76229. * Modify the scale of the post process to be the same as the viewport (default: false)
  76230. */
  76231. adaptScaleToCurrentViewport: boolean;
  76232. private _camera;
  76233. private _scene;
  76234. private _engine;
  76235. private _options;
  76236. private _reusable;
  76237. private _textureType;
  76238. /**
  76239. * Smart array of input and output textures for the post process.
  76240. * @hidden
  76241. */
  76242. _textures: SmartArray<InternalTexture>;
  76243. /**
  76244. * The index in _textures that corresponds to the output texture.
  76245. * @hidden
  76246. */
  76247. _currentRenderTextureInd: number;
  76248. private _effect;
  76249. private _samplers;
  76250. private _fragmentUrl;
  76251. private _vertexUrl;
  76252. private _parameters;
  76253. private _scaleRatio;
  76254. protected _indexParameters: any;
  76255. private _shareOutputWithPostProcess;
  76256. private _texelSize;
  76257. private _forcedOutputTexture;
  76258. /**
  76259. * Returns the fragment url or shader name used in the post process.
  76260. * @returns the fragment url or name in the shader store.
  76261. */
  76262. getEffectName(): string;
  76263. /**
  76264. * An event triggered when the postprocess is activated.
  76265. */
  76266. onActivateObservable: Observable<Camera>;
  76267. private _onActivateObserver;
  76268. /**
  76269. * A function that is added to the onActivateObservable
  76270. */
  76271. onActivate: Nullable<(camera: Camera) => void>;
  76272. /**
  76273. * An event triggered when the postprocess changes its size.
  76274. */
  76275. onSizeChangedObservable: Observable<PostProcess>;
  76276. private _onSizeChangedObserver;
  76277. /**
  76278. * A function that is added to the onSizeChangedObservable
  76279. */
  76280. onSizeChanged: (postProcess: PostProcess) => void;
  76281. /**
  76282. * An event triggered when the postprocess applies its effect.
  76283. */
  76284. onApplyObservable: Observable<Effect>;
  76285. private _onApplyObserver;
  76286. /**
  76287. * A function that is added to the onApplyObservable
  76288. */
  76289. onApply: (effect: Effect) => void;
  76290. /**
  76291. * An event triggered before rendering the postprocess
  76292. */
  76293. onBeforeRenderObservable: Observable<Effect>;
  76294. private _onBeforeRenderObserver;
  76295. /**
  76296. * A function that is added to the onBeforeRenderObservable
  76297. */
  76298. onBeforeRender: (effect: Effect) => void;
  76299. /**
  76300. * An event triggered after rendering the postprocess
  76301. */
  76302. onAfterRenderObservable: Observable<Effect>;
  76303. private _onAfterRenderObserver;
  76304. /**
  76305. * A function that is added to the onAfterRenderObservable
  76306. */
  76307. onAfterRender: (efect: Effect) => void;
  76308. /**
  76309. * 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
  76310. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  76311. */
  76312. inputTexture: InternalTexture;
  76313. /**
  76314. * Gets the camera which post process is applied to.
  76315. * @returns The camera the post process is applied to.
  76316. */
  76317. getCamera(): Camera;
  76318. /**
  76319. * Gets the texel size of the postprocess.
  76320. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  76321. */
  76322. readonly texelSize: Vector2;
  76323. /**
  76324. * Creates a new instance PostProcess
  76325. * @param name The name of the PostProcess.
  76326. * @param fragmentUrl The url of the fragment shader to be used.
  76327. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  76328. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  76329. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  76330. * @param camera The camera to apply the render pass to.
  76331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76332. * @param engine The engine which the post process will be applied. (default: current engine)
  76333. * @param reusable If the post process can be reused on the same frame. (default: false)
  76334. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  76335. * @param textureType Type of textures used when performing the post process. (default: 0)
  76336. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  76337. * @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
  76338. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  76339. */
  76340. constructor(
  76341. /** Name of the PostProcess. */
  76342. 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);
  76343. /**
  76344. * Gets a string idenfifying the name of the class
  76345. * @returns "PostProcess" string
  76346. */
  76347. getClassName(): string;
  76348. /**
  76349. * Gets the engine which this post process belongs to.
  76350. * @returns The engine the post process was enabled with.
  76351. */
  76352. getEngine(): Engine;
  76353. /**
  76354. * The effect that is created when initializing the post process.
  76355. * @returns The created effect corrisponding the the postprocess.
  76356. */
  76357. getEffect(): Effect;
  76358. /**
  76359. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  76360. * @param postProcess The post process to share the output with.
  76361. * @returns This post process.
  76362. */
  76363. shareOutputWith(postProcess: PostProcess): PostProcess;
  76364. /**
  76365. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  76366. * This should be called if the post process that shares output with this post process is disabled/disposed.
  76367. */
  76368. useOwnOutput(): void;
  76369. /**
  76370. * Updates the effect with the current post process compile time values and recompiles the shader.
  76371. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  76372. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  76373. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  76374. * @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
  76375. * @param onCompiled Called when the shader has been compiled.
  76376. * @param onError Called if there is an error when compiling a shader.
  76377. */
  76378. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  76379. /**
  76380. * The post process is reusable if it can be used multiple times within one frame.
  76381. * @returns If the post process is reusable
  76382. */
  76383. isReusable(): boolean;
  76384. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  76385. markTextureDirty(): void;
  76386. /**
  76387. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  76388. * 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.
  76389. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  76390. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  76391. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  76392. * @returns The target texture that was bound to be written to.
  76393. */
  76394. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  76395. /**
  76396. * If the post process is supported.
  76397. */
  76398. readonly isSupported: boolean;
  76399. /**
  76400. * The aspect ratio of the output texture.
  76401. */
  76402. readonly aspectRatio: number;
  76403. /**
  76404. * Get a value indicating if the post-process is ready to be used
  76405. * @returns true if the post-process is ready (shader is compiled)
  76406. */
  76407. isReady(): boolean;
  76408. /**
  76409. * Binds all textures and uniforms to the shader, this will be run on every pass.
  76410. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  76411. */
  76412. apply(): Nullable<Effect>;
  76413. private _disposeTextures;
  76414. /**
  76415. * Disposes the post process.
  76416. * @param camera The camera to dispose the post process on.
  76417. */
  76418. dispose(camera?: Camera): void;
  76419. }
  76420. }
  76421. declare module BABYLON {
  76422. /**
  76423. * PostProcessManager is used to manage one or more post processes or post process pipelines
  76424. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  76425. */
  76426. export class PostProcessManager {
  76427. private _scene;
  76428. private _indexBuffer;
  76429. private _vertexBuffers;
  76430. /**
  76431. * Creates a new instance PostProcess
  76432. * @param scene The scene that the post process is associated with.
  76433. */
  76434. constructor(scene: Scene);
  76435. private _prepareBuffers;
  76436. private _buildIndexBuffer;
  76437. /**
  76438. * Rebuilds the vertex buffers of the manager.
  76439. * @hidden
  76440. */
  76441. _rebuild(): void;
  76442. /**
  76443. * Prepares a frame to be run through a post process.
  76444. * @param sourceTexture The input texture to the post procesess. (default: null)
  76445. * @param postProcesses An array of post processes to be run. (default: null)
  76446. * @returns True if the post processes were able to be run.
  76447. * @hidden
  76448. */
  76449. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  76450. /**
  76451. * Manually render a set of post processes to a texture.
  76452. * @param postProcesses An array of post processes to be run.
  76453. * @param targetTexture The target texture to render to.
  76454. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  76455. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  76456. * @param lodLevel defines which lod of the texture to render to
  76457. */
  76458. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  76459. /**
  76460. * Finalize the result of the output of the postprocesses.
  76461. * @param doNotPresent If true the result will not be displayed to the screen.
  76462. * @param targetTexture The target texture to render to.
  76463. * @param faceIndex The index of the face to bind the target texture to.
  76464. * @param postProcesses The array of post processes to render.
  76465. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  76466. * @hidden
  76467. */
  76468. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  76469. /**
  76470. * Disposes of the post process manager.
  76471. */
  76472. dispose(): void;
  76473. }
  76474. }
  76475. declare module BABYLON {
  76476. interface AbstractScene {
  76477. /**
  76478. * The list of procedural textures added to the scene
  76479. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  76480. */
  76481. proceduralTextures: Array<ProceduralTexture>;
  76482. }
  76483. /**
  76484. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  76485. * in a given scene.
  76486. */
  76487. export class ProceduralTextureSceneComponent implements ISceneComponent {
  76488. /**
  76489. * The component name helpfull to identify the component in the list of scene components.
  76490. */
  76491. readonly name: string;
  76492. /**
  76493. * The scene the component belongs to.
  76494. */
  76495. scene: Scene;
  76496. /**
  76497. * Creates a new instance of the component for the given scene
  76498. * @param scene Defines the scene to register the component in
  76499. */
  76500. constructor(scene: Scene);
  76501. /**
  76502. * Registers the component in a given scene
  76503. */
  76504. register(): void;
  76505. /**
  76506. * Rebuilds the elements related to this component in case of
  76507. * context lost for instance.
  76508. */
  76509. rebuild(): void;
  76510. /**
  76511. * Disposes the component and the associated ressources.
  76512. */
  76513. dispose(): void;
  76514. private _beforeClear;
  76515. }
  76516. }
  76517. declare module BABYLON {
  76518. interface Engine {
  76519. /**
  76520. * Creates a new render target cube texture
  76521. * @param size defines the size of the texture
  76522. * @param options defines the options used to create the texture
  76523. * @returns a new render target cube texture stored in an InternalTexture
  76524. */
  76525. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  76526. }
  76527. }
  76528. declare module BABYLON {
  76529. /** @hidden */
  76530. export var proceduralVertexShader: {
  76531. name: string;
  76532. shader: string;
  76533. };
  76534. }
  76535. declare module BABYLON {
  76536. /**
  76537. * 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.
  76538. * This is the base class of any Procedural texture and contains most of the shareable code.
  76539. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  76540. */
  76541. export class ProceduralTexture extends Texture {
  76542. isCube: boolean;
  76543. /**
  76544. * Define if the texture is enabled or not (disabled texture will not render)
  76545. */
  76546. isEnabled: boolean;
  76547. /**
  76548. * Define if the texture must be cleared before rendering (default is true)
  76549. */
  76550. autoClear: boolean;
  76551. /**
  76552. * Callback called when the texture is generated
  76553. */
  76554. onGenerated: () => void;
  76555. /**
  76556. * Event raised when the texture is generated
  76557. */
  76558. onGeneratedObservable: Observable<ProceduralTexture>;
  76559. /** @hidden */
  76560. _generateMipMaps: boolean;
  76561. /** @hidden **/
  76562. _effect: Effect;
  76563. /** @hidden */
  76564. _textures: {
  76565. [key: string]: Texture;
  76566. };
  76567. private _size;
  76568. private _currentRefreshId;
  76569. private _refreshRate;
  76570. private _vertexBuffers;
  76571. private _indexBuffer;
  76572. private _uniforms;
  76573. private _samplers;
  76574. private _fragment;
  76575. private _floats;
  76576. private _ints;
  76577. private _floatsArrays;
  76578. private _colors3;
  76579. private _colors4;
  76580. private _vectors2;
  76581. private _vectors3;
  76582. private _matrices;
  76583. private _fallbackTexture;
  76584. private _fallbackTextureUsed;
  76585. private _engine;
  76586. private _cachedDefines;
  76587. private _contentUpdateId;
  76588. private _contentData;
  76589. /**
  76590. * Instantiates a new procedural texture.
  76591. * 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.
  76592. * This is the base class of any Procedural texture and contains most of the shareable code.
  76593. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  76594. * @param name Define the name of the texture
  76595. * @param size Define the size of the texture to create
  76596. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  76597. * @param scene Define the scene the texture belongs to
  76598. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  76599. * @param generateMipMaps Define if the texture should creates mip maps or not
  76600. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  76601. */
  76602. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  76603. /**
  76604. * The effect that is created when initializing the post process.
  76605. * @returns The created effect corrisponding the the postprocess.
  76606. */
  76607. getEffect(): Effect;
  76608. /**
  76609. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  76610. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  76611. */
  76612. getContent(): Nullable<ArrayBufferView>;
  76613. private _createIndexBuffer;
  76614. /** @hidden */
  76615. _rebuild(): void;
  76616. /**
  76617. * Resets the texture in order to recreate its associated resources.
  76618. * This can be called in case of context loss
  76619. */
  76620. reset(): void;
  76621. protected _getDefines(): string;
  76622. /**
  76623. * Is the texture ready to be used ? (rendered at least once)
  76624. * @returns true if ready, otherwise, false.
  76625. */
  76626. isReady(): boolean;
  76627. /**
  76628. * Resets the refresh counter of the texture and start bak from scratch.
  76629. * Could be useful to regenerate the texture if it is setup to render only once.
  76630. */
  76631. resetRefreshCounter(): void;
  76632. /**
  76633. * Set the fragment shader to use in order to render the texture.
  76634. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  76635. */
  76636. setFragment(fragment: any): void;
  76637. /**
  76638. * Define the refresh rate of the texture or the rendering frequency.
  76639. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  76640. */
  76641. refreshRate: number;
  76642. /** @hidden */
  76643. _shouldRender(): boolean;
  76644. /**
  76645. * Get the size the texture is rendering at.
  76646. * @returns the size (texture is always squared)
  76647. */
  76648. getRenderSize(): number;
  76649. /**
  76650. * Resize the texture to new value.
  76651. * @param size Define the new size the texture should have
  76652. * @param generateMipMaps Define whether the new texture should create mip maps
  76653. */
  76654. resize(size: number, generateMipMaps: boolean): void;
  76655. private _checkUniform;
  76656. /**
  76657. * Set a texture in the shader program used to render.
  76658. * @param name Define the name of the uniform samplers as defined in the shader
  76659. * @param texture Define the texture to bind to this sampler
  76660. * @return the texture itself allowing "fluent" like uniform updates
  76661. */
  76662. setTexture(name: string, texture: Texture): ProceduralTexture;
  76663. /**
  76664. * Set a float in the shader.
  76665. * @param name Define the name of the uniform as defined in the shader
  76666. * @param value Define the value to give to the uniform
  76667. * @return the texture itself allowing "fluent" like uniform updates
  76668. */
  76669. setFloat(name: string, value: number): ProceduralTexture;
  76670. /**
  76671. * Set a int in the shader.
  76672. * @param name Define the name of the uniform as defined in the shader
  76673. * @param value Define the value to give to the uniform
  76674. * @return the texture itself allowing "fluent" like uniform updates
  76675. */
  76676. setInt(name: string, value: number): ProceduralTexture;
  76677. /**
  76678. * Set an array of floats in the shader.
  76679. * @param name Define the name of the uniform as defined in the shader
  76680. * @param value Define the value to give to the uniform
  76681. * @return the texture itself allowing "fluent" like uniform updates
  76682. */
  76683. setFloats(name: string, value: number[]): ProceduralTexture;
  76684. /**
  76685. * Set a vec3 in the shader from a Color3.
  76686. * @param name Define the name of the uniform as defined in the shader
  76687. * @param value Define the value to give to the uniform
  76688. * @return the texture itself allowing "fluent" like uniform updates
  76689. */
  76690. setColor3(name: string, value: Color3): ProceduralTexture;
  76691. /**
  76692. * Set a vec4 in the shader from a Color4.
  76693. * @param name Define the name of the uniform as defined in the shader
  76694. * @param value Define the value to give to the uniform
  76695. * @return the texture itself allowing "fluent" like uniform updates
  76696. */
  76697. setColor4(name: string, value: Color4): ProceduralTexture;
  76698. /**
  76699. * Set a vec2 in the shader from a Vector2.
  76700. * @param name Define the name of the uniform as defined in the shader
  76701. * @param value Define the value to give to the uniform
  76702. * @return the texture itself allowing "fluent" like uniform updates
  76703. */
  76704. setVector2(name: string, value: Vector2): ProceduralTexture;
  76705. /**
  76706. * Set a vec3 in the shader from a Vector3.
  76707. * @param name Define the name of the uniform as defined in the shader
  76708. * @param value Define the value to give to the uniform
  76709. * @return the texture itself allowing "fluent" like uniform updates
  76710. */
  76711. setVector3(name: string, value: Vector3): ProceduralTexture;
  76712. /**
  76713. * Set a mat4 in the shader from a MAtrix.
  76714. * @param name Define the name of the uniform as defined in the shader
  76715. * @param value Define the value to give to the uniform
  76716. * @return the texture itself allowing "fluent" like uniform updates
  76717. */
  76718. setMatrix(name: string, value: Matrix): ProceduralTexture;
  76719. /**
  76720. * Render the texture to its associated render target.
  76721. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  76722. */
  76723. render(useCameraPostProcess?: boolean): void;
  76724. /**
  76725. * Clone the texture.
  76726. * @returns the cloned texture
  76727. */
  76728. clone(): ProceduralTexture;
  76729. /**
  76730. * Dispose the texture and release its asoociated resources.
  76731. */
  76732. dispose(): void;
  76733. }
  76734. }
  76735. declare module BABYLON {
  76736. /**
  76737. * This represents the base class for particle system in Babylon.
  76738. * 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.
  76739. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  76740. * @example https://doc.babylonjs.com/babylon101/particles
  76741. */
  76742. export class BaseParticleSystem {
  76743. /**
  76744. * Source color is added to the destination color without alpha affecting the result
  76745. */
  76746. static BLENDMODE_ONEONE: number;
  76747. /**
  76748. * Blend current color and particle color using particle’s alpha
  76749. */
  76750. static BLENDMODE_STANDARD: number;
  76751. /**
  76752. * Add current color and particle color multiplied by particle’s alpha
  76753. */
  76754. static BLENDMODE_ADD: number;
  76755. /**
  76756. * Multiply current color with particle color
  76757. */
  76758. static BLENDMODE_MULTIPLY: number;
  76759. /**
  76760. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  76761. */
  76762. static BLENDMODE_MULTIPLYADD: number;
  76763. /**
  76764. * List of animations used by the particle system.
  76765. */
  76766. animations: Animation[];
  76767. /**
  76768. * The id of the Particle system.
  76769. */
  76770. id: string;
  76771. /**
  76772. * The friendly name of the Particle system.
  76773. */
  76774. name: string;
  76775. /**
  76776. * The rendering group used by the Particle system to chose when to render.
  76777. */
  76778. renderingGroupId: number;
  76779. /**
  76780. * The emitter represents the Mesh or position we are attaching the particle system to.
  76781. */
  76782. emitter: Nullable<AbstractMesh | Vector3>;
  76783. /**
  76784. * The maximum number of particles to emit per frame
  76785. */
  76786. emitRate: number;
  76787. /**
  76788. * If you want to launch only a few particles at once, that can be done, as well.
  76789. */
  76790. manualEmitCount: number;
  76791. /**
  76792. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  76793. */
  76794. updateSpeed: number;
  76795. /**
  76796. * The amount of time the particle system is running (depends of the overall update speed).
  76797. */
  76798. targetStopDuration: number;
  76799. /**
  76800. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  76801. */
  76802. disposeOnStop: boolean;
  76803. /**
  76804. * Minimum power of emitting particles.
  76805. */
  76806. minEmitPower: number;
  76807. /**
  76808. * Maximum power of emitting particles.
  76809. */
  76810. maxEmitPower: number;
  76811. /**
  76812. * Minimum life time of emitting particles.
  76813. */
  76814. minLifeTime: number;
  76815. /**
  76816. * Maximum life time of emitting particles.
  76817. */
  76818. maxLifeTime: number;
  76819. /**
  76820. * Minimum Size of emitting particles.
  76821. */
  76822. minSize: number;
  76823. /**
  76824. * Maximum Size of emitting particles.
  76825. */
  76826. maxSize: number;
  76827. /**
  76828. * Minimum scale of emitting particles on X axis.
  76829. */
  76830. minScaleX: number;
  76831. /**
  76832. * Maximum scale of emitting particles on X axis.
  76833. */
  76834. maxScaleX: number;
  76835. /**
  76836. * Minimum scale of emitting particles on Y axis.
  76837. */
  76838. minScaleY: number;
  76839. /**
  76840. * Maximum scale of emitting particles on Y axis.
  76841. */
  76842. maxScaleY: number;
  76843. /**
  76844. * Gets or sets the minimal initial rotation in radians.
  76845. */
  76846. minInitialRotation: number;
  76847. /**
  76848. * Gets or sets the maximal initial rotation in radians.
  76849. */
  76850. maxInitialRotation: number;
  76851. /**
  76852. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  76853. */
  76854. minAngularSpeed: number;
  76855. /**
  76856. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  76857. */
  76858. maxAngularSpeed: number;
  76859. /**
  76860. * The texture used to render each particle. (this can be a spritesheet)
  76861. */
  76862. particleTexture: Nullable<Texture>;
  76863. /**
  76864. * The layer mask we are rendering the particles through.
  76865. */
  76866. layerMask: number;
  76867. /**
  76868. * This can help using your own shader to render the particle system.
  76869. * The according effect will be created
  76870. */
  76871. customShader: any;
  76872. /**
  76873. * By default particle system starts as soon as they are created. This prevents the
  76874. * automatic start to happen and let you decide when to start emitting particles.
  76875. */
  76876. preventAutoStart: boolean;
  76877. private _noiseTexture;
  76878. /**
  76879. * Gets or sets a texture used to add random noise to particle positions
  76880. */
  76881. noiseTexture: Nullable<ProceduralTexture>;
  76882. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  76883. noiseStrength: Vector3;
  76884. /**
  76885. * Callback triggered when the particle animation is ending.
  76886. */
  76887. onAnimationEnd: Nullable<() => void>;
  76888. /**
  76889. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  76890. */
  76891. blendMode: number;
  76892. /**
  76893. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  76894. * to override the particles.
  76895. */
  76896. forceDepthWrite: boolean;
  76897. /** 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 */
  76898. preWarmCycles: number;
  76899. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  76900. preWarmStepOffset: number;
  76901. /**
  76902. * 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)
  76903. */
  76904. spriteCellChangeSpeed: number;
  76905. /**
  76906. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  76907. */
  76908. startSpriteCellID: number;
  76909. /**
  76910. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  76911. */
  76912. endSpriteCellID: number;
  76913. /**
  76914. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  76915. */
  76916. spriteCellWidth: number;
  76917. /**
  76918. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  76919. */
  76920. spriteCellHeight: number;
  76921. /**
  76922. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  76923. */
  76924. spriteRandomStartCell: boolean;
  76925. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  76926. translationPivot: Vector2;
  76927. /** @hidden */
  76928. protected _isAnimationSheetEnabled: boolean;
  76929. /**
  76930. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  76931. */
  76932. beginAnimationOnStart: boolean;
  76933. /**
  76934. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  76935. */
  76936. beginAnimationFrom: number;
  76937. /**
  76938. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  76939. */
  76940. beginAnimationTo: number;
  76941. /**
  76942. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  76943. */
  76944. beginAnimationLoop: boolean;
  76945. /**
  76946. * Gets or sets a world offset applied to all particles
  76947. */
  76948. worldOffset: Vector3;
  76949. /**
  76950. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  76951. */
  76952. isAnimationSheetEnabled: boolean;
  76953. /**
  76954. * Get hosting scene
  76955. * @returns the scene
  76956. */
  76957. getScene(): Scene;
  76958. /**
  76959. * You can use gravity if you want to give an orientation to your particles.
  76960. */
  76961. gravity: Vector3;
  76962. protected _colorGradients: Nullable<Array<ColorGradient>>;
  76963. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  76964. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  76965. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  76966. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  76967. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  76968. protected _dragGradients: Nullable<Array<FactorGradient>>;
  76969. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  76970. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  76971. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  76972. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  76973. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  76974. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  76975. /**
  76976. * Defines the delay in milliseconds before starting the system (0 by default)
  76977. */
  76978. startDelay: number;
  76979. /**
  76980. * Gets the current list of drag gradients.
  76981. * You must use addDragGradient and removeDragGradient to udpate this list
  76982. * @returns the list of drag gradients
  76983. */
  76984. getDragGradients(): Nullable<Array<FactorGradient>>;
  76985. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  76986. limitVelocityDamping: number;
  76987. /**
  76988. * Gets the current list of limit velocity gradients.
  76989. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  76990. * @returns the list of limit velocity gradients
  76991. */
  76992. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  76993. /**
  76994. * Gets the current list of color gradients.
  76995. * You must use addColorGradient and removeColorGradient to udpate this list
  76996. * @returns the list of color gradients
  76997. */
  76998. getColorGradients(): Nullable<Array<ColorGradient>>;
  76999. /**
  77000. * Gets the current list of size gradients.
  77001. * You must use addSizeGradient and removeSizeGradient to udpate this list
  77002. * @returns the list of size gradients
  77003. */
  77004. getSizeGradients(): Nullable<Array<FactorGradient>>;
  77005. /**
  77006. * Gets the current list of color remap gradients.
  77007. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  77008. * @returns the list of color remap gradients
  77009. */
  77010. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  77011. /**
  77012. * Gets the current list of alpha remap gradients.
  77013. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  77014. * @returns the list of alpha remap gradients
  77015. */
  77016. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  77017. /**
  77018. * Gets the current list of life time gradients.
  77019. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  77020. * @returns the list of life time gradients
  77021. */
  77022. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  77023. /**
  77024. * Gets the current list of angular speed gradients.
  77025. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  77026. * @returns the list of angular speed gradients
  77027. */
  77028. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  77029. /**
  77030. * Gets the current list of velocity gradients.
  77031. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  77032. * @returns the list of velocity gradients
  77033. */
  77034. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  77035. /**
  77036. * Gets the current list of start size gradients.
  77037. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  77038. * @returns the list of start size gradients
  77039. */
  77040. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  77041. /**
  77042. * Gets the current list of emit rate gradients.
  77043. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  77044. * @returns the list of emit rate gradients
  77045. */
  77046. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  77047. /**
  77048. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77049. * This only works when particleEmitterTyps is a BoxParticleEmitter
  77050. */
  77051. direction1: Vector3;
  77052. /**
  77053. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77054. * This only works when particleEmitterTyps is a BoxParticleEmitter
  77055. */
  77056. direction2: Vector3;
  77057. /**
  77058. * 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.
  77059. * This only works when particleEmitterTyps is a BoxParticleEmitter
  77060. */
  77061. minEmitBox: Vector3;
  77062. /**
  77063. * 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.
  77064. * This only works when particleEmitterTyps is a BoxParticleEmitter
  77065. */
  77066. maxEmitBox: Vector3;
  77067. /**
  77068. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  77069. */
  77070. color1: Color4;
  77071. /**
  77072. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  77073. */
  77074. color2: Color4;
  77075. /**
  77076. * Color the particle will have at the end of its lifetime
  77077. */
  77078. colorDead: Color4;
  77079. /**
  77080. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  77081. */
  77082. textureMask: Color4;
  77083. /**
  77084. * The particle emitter type defines the emitter used by the particle system.
  77085. * It can be for example box, sphere, or cone...
  77086. */
  77087. particleEmitterType: IParticleEmitterType;
  77088. /** @hidden */
  77089. _isSubEmitter: boolean;
  77090. /**
  77091. * Gets or sets the billboard mode to use when isBillboardBased = true.
  77092. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  77093. */
  77094. billboardMode: number;
  77095. protected _isBillboardBased: boolean;
  77096. /**
  77097. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  77098. */
  77099. isBillboardBased: boolean;
  77100. /**
  77101. * The scene the particle system belongs to.
  77102. */
  77103. protected _scene: Scene;
  77104. /**
  77105. * Local cache of defines for image processing.
  77106. */
  77107. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  77108. /**
  77109. * Default configuration related to image processing available in the standard Material.
  77110. */
  77111. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  77112. /**
  77113. * Gets the image processing configuration used either in this material.
  77114. */
  77115. /**
  77116. * Sets the Default image processing configuration used either in the this material.
  77117. *
  77118. * If sets to null, the scene one is in use.
  77119. */
  77120. imageProcessingConfiguration: ImageProcessingConfiguration;
  77121. /**
  77122. * Attaches a new image processing configuration to the Standard Material.
  77123. * @param configuration
  77124. */
  77125. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  77126. /** @hidden */
  77127. protected _reset(): void;
  77128. /** @hidden */
  77129. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  77130. /**
  77131. * Instantiates a particle system.
  77132. * 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.
  77133. * @param name The name of the particle system
  77134. */
  77135. constructor(name: string);
  77136. /**
  77137. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  77138. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  77139. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  77140. * @returns the emitter
  77141. */
  77142. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  77143. /**
  77144. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  77145. * @param radius The radius of the hemisphere to emit from
  77146. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  77147. * @returns the emitter
  77148. */
  77149. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  77150. /**
  77151. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  77152. * @param radius The radius of the sphere to emit from
  77153. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  77154. * @returns the emitter
  77155. */
  77156. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  77157. /**
  77158. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  77159. * @param radius The radius of the sphere to emit from
  77160. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  77161. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  77162. * @returns the emitter
  77163. */
  77164. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  77165. /**
  77166. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  77167. * @param radius The radius of the emission cylinder
  77168. * @param height The height of the emission cylinder
  77169. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  77170. * @param directionRandomizer How much to randomize the particle direction [0-1]
  77171. * @returns the emitter
  77172. */
  77173. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  77174. /**
  77175. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  77176. * @param radius The radius of the cylinder to emit from
  77177. * @param height The height of the emission cylinder
  77178. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  77179. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  77180. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  77181. * @returns the emitter
  77182. */
  77183. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  77184. /**
  77185. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  77186. * @param radius The radius of the cone to emit from
  77187. * @param angle The base angle of the cone
  77188. * @returns the emitter
  77189. */
  77190. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  77191. /**
  77192. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  77193. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  77194. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  77195. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  77196. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  77197. * @returns the emitter
  77198. */
  77199. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  77200. }
  77201. }
  77202. declare module BABYLON {
  77203. /**
  77204. * Type of sub emitter
  77205. */
  77206. export enum SubEmitterType {
  77207. /**
  77208. * Attached to the particle over it's lifetime
  77209. */
  77210. ATTACHED = 0,
  77211. /**
  77212. * Created when the particle dies
  77213. */
  77214. END = 1
  77215. }
  77216. /**
  77217. * Sub emitter class used to emit particles from an existing particle
  77218. */
  77219. export class SubEmitter {
  77220. /**
  77221. * the particle system to be used by the sub emitter
  77222. */
  77223. particleSystem: ParticleSystem;
  77224. /**
  77225. * Type of the submitter (Default: END)
  77226. */
  77227. type: SubEmitterType;
  77228. /**
  77229. * 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)
  77230. * Note: This only is supported when using an emitter of type Mesh
  77231. */
  77232. inheritDirection: boolean;
  77233. /**
  77234. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  77235. */
  77236. inheritedVelocityAmount: number;
  77237. /**
  77238. * Creates a sub emitter
  77239. * @param particleSystem the particle system to be used by the sub emitter
  77240. */
  77241. constructor(
  77242. /**
  77243. * the particle system to be used by the sub emitter
  77244. */
  77245. particleSystem: ParticleSystem);
  77246. /**
  77247. * Clones the sub emitter
  77248. * @returns the cloned sub emitter
  77249. */
  77250. clone(): SubEmitter;
  77251. /**
  77252. * Serialize current object to a JSON object
  77253. * @returns the serialized object
  77254. */
  77255. serialize(): any;
  77256. /** @hidden */
  77257. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  77258. /**
  77259. * Creates a new SubEmitter from a serialized JSON version
  77260. * @param serializationObject defines the JSON object to read from
  77261. * @param scene defines the hosting scene
  77262. * @param rootUrl defines the rootUrl for data loading
  77263. * @returns a new SubEmitter
  77264. */
  77265. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  77266. /** Release associated resources */
  77267. dispose(): void;
  77268. }
  77269. }
  77270. declare module BABYLON {
  77271. /** @hidden */
  77272. export var clipPlaneFragmentDeclaration: {
  77273. name: string;
  77274. shader: string;
  77275. };
  77276. }
  77277. declare module BABYLON {
  77278. /** @hidden */
  77279. export var imageProcessingDeclaration: {
  77280. name: string;
  77281. shader: string;
  77282. };
  77283. }
  77284. declare module BABYLON {
  77285. /** @hidden */
  77286. export var imageProcessingFunctions: {
  77287. name: string;
  77288. shader: string;
  77289. };
  77290. }
  77291. declare module BABYLON {
  77292. /** @hidden */
  77293. export var clipPlaneFragment: {
  77294. name: string;
  77295. shader: string;
  77296. };
  77297. }
  77298. declare module BABYLON {
  77299. /** @hidden */
  77300. export var particlesPixelShader: {
  77301. name: string;
  77302. shader: string;
  77303. };
  77304. }
  77305. declare module BABYLON {
  77306. /** @hidden */
  77307. export var clipPlaneVertexDeclaration: {
  77308. name: string;
  77309. shader: string;
  77310. };
  77311. }
  77312. declare module BABYLON {
  77313. /** @hidden */
  77314. export var clipPlaneVertex: {
  77315. name: string;
  77316. shader: string;
  77317. };
  77318. }
  77319. declare module BABYLON {
  77320. /** @hidden */
  77321. export var particlesVertexShader: {
  77322. name: string;
  77323. shader: string;
  77324. };
  77325. }
  77326. declare module BABYLON {
  77327. /**
  77328. * This represents a particle system in Babylon.
  77329. * 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.
  77330. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  77331. * @example https://doc.babylonjs.com/babylon101/particles
  77332. */
  77333. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  77334. /**
  77335. * Billboard mode will only apply to Y axis
  77336. */
  77337. static readonly BILLBOARDMODE_Y: number;
  77338. /**
  77339. * Billboard mode will apply to all axes
  77340. */
  77341. static readonly BILLBOARDMODE_ALL: number;
  77342. /**
  77343. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  77344. */
  77345. static readonly BILLBOARDMODE_STRETCHED: number;
  77346. /**
  77347. * This function can be defined to provide custom update for active particles.
  77348. * This function will be called instead of regular update (age, position, color, etc.).
  77349. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  77350. */
  77351. updateFunction: (particles: Particle[]) => void;
  77352. private _emitterWorldMatrix;
  77353. /**
  77354. * This function can be defined to specify initial direction for every new particle.
  77355. * It by default use the emitterType defined function
  77356. */
  77357. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  77358. /**
  77359. * This function can be defined to specify initial position for every new particle.
  77360. * It by default use the emitterType defined function
  77361. */
  77362. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  77363. /**
  77364. * @hidden
  77365. */
  77366. _inheritedVelocityOffset: Vector3;
  77367. /**
  77368. * An event triggered when the system is disposed
  77369. */
  77370. onDisposeObservable: Observable<ParticleSystem>;
  77371. private _onDisposeObserver;
  77372. /**
  77373. * Sets a callback that will be triggered when the system is disposed
  77374. */
  77375. onDispose: () => void;
  77376. private _particles;
  77377. private _epsilon;
  77378. private _capacity;
  77379. private _stockParticles;
  77380. private _newPartsExcess;
  77381. private _vertexData;
  77382. private _vertexBuffer;
  77383. private _vertexBuffers;
  77384. private _spriteBuffer;
  77385. private _indexBuffer;
  77386. private _effect;
  77387. private _customEffect;
  77388. private _cachedDefines;
  77389. private _scaledColorStep;
  77390. private _colorDiff;
  77391. private _scaledDirection;
  77392. private _scaledGravity;
  77393. private _currentRenderId;
  77394. private _alive;
  77395. private _useInstancing;
  77396. private _started;
  77397. private _stopped;
  77398. private _actualFrame;
  77399. private _scaledUpdateSpeed;
  77400. private _vertexBufferSize;
  77401. /** @hidden */
  77402. _currentEmitRateGradient: Nullable<FactorGradient>;
  77403. /** @hidden */
  77404. _currentEmitRate1: number;
  77405. /** @hidden */
  77406. _currentEmitRate2: number;
  77407. /** @hidden */
  77408. _currentStartSizeGradient: Nullable<FactorGradient>;
  77409. /** @hidden */
  77410. _currentStartSize1: number;
  77411. /** @hidden */
  77412. _currentStartSize2: number;
  77413. private readonly _rawTextureWidth;
  77414. private _rampGradientsTexture;
  77415. private _useRampGradients;
  77416. /** Gets or sets a boolean indicating that ramp gradients must be used
  77417. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  77418. */
  77419. useRampGradients: boolean;
  77420. /**
  77421. * 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.
  77422. * 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: [])
  77423. */
  77424. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  77425. private _subEmitters;
  77426. /**
  77427. * @hidden
  77428. * If the particle systems emitter should be disposed when the particle system is disposed
  77429. */
  77430. _disposeEmitterOnDispose: boolean;
  77431. /**
  77432. * The current active Sub-systems, this property is used by the root particle system only.
  77433. */
  77434. activeSubSystems: Array<ParticleSystem>;
  77435. private _rootParticleSystem;
  77436. /**
  77437. * Gets the current list of active particles
  77438. */
  77439. readonly particles: Particle[];
  77440. /**
  77441. * Returns the string "ParticleSystem"
  77442. * @returns a string containing the class name
  77443. */
  77444. getClassName(): string;
  77445. /**
  77446. * Instantiates a particle system.
  77447. * 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.
  77448. * @param name The name of the particle system
  77449. * @param capacity The max number of particles alive at the same time
  77450. * @param scene The scene the particle system belongs to
  77451. * @param customEffect a custom effect used to change the way particles are rendered by default
  77452. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  77453. * @param epsilon Offset used to render the particles
  77454. */
  77455. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  77456. private _addFactorGradient;
  77457. private _removeFactorGradient;
  77458. /**
  77459. * Adds a new life time gradient
  77460. * @param gradient defines the gradient to use (between 0 and 1)
  77461. * @param factor defines the life time factor to affect to the specified gradient
  77462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77463. * @returns the current particle system
  77464. */
  77465. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77466. /**
  77467. * Remove a specific life time gradient
  77468. * @param gradient defines the gradient to remove
  77469. * @returns the current particle system
  77470. */
  77471. removeLifeTimeGradient(gradient: number): IParticleSystem;
  77472. /**
  77473. * Adds a new size gradient
  77474. * @param gradient defines the gradient to use (between 0 and 1)
  77475. * @param factor defines the size factor to affect to the specified gradient
  77476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77477. * @returns the current particle system
  77478. */
  77479. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77480. /**
  77481. * Remove a specific size gradient
  77482. * @param gradient defines the gradient to remove
  77483. * @returns the current particle system
  77484. */
  77485. removeSizeGradient(gradient: number): IParticleSystem;
  77486. /**
  77487. * Adds a new color remap gradient
  77488. * @param gradient defines the gradient to use (between 0 and 1)
  77489. * @param min defines the color remap minimal range
  77490. * @param max defines the color remap maximal range
  77491. * @returns the current particle system
  77492. */
  77493. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  77494. /**
  77495. * Remove a specific color remap gradient
  77496. * @param gradient defines the gradient to remove
  77497. * @returns the current particle system
  77498. */
  77499. removeColorRemapGradient(gradient: number): IParticleSystem;
  77500. /**
  77501. * Adds a new alpha remap gradient
  77502. * @param gradient defines the gradient to use (between 0 and 1)
  77503. * @param min defines the alpha remap minimal range
  77504. * @param max defines the alpha remap maximal range
  77505. * @returns the current particle system
  77506. */
  77507. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  77508. /**
  77509. * Remove a specific alpha remap gradient
  77510. * @param gradient defines the gradient to remove
  77511. * @returns the current particle system
  77512. */
  77513. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  77514. /**
  77515. * Adds a new angular speed gradient
  77516. * @param gradient defines the gradient to use (between 0 and 1)
  77517. * @param factor defines the angular speed to affect to the specified gradient
  77518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77519. * @returns the current particle system
  77520. */
  77521. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77522. /**
  77523. * Remove a specific angular speed gradient
  77524. * @param gradient defines the gradient to remove
  77525. * @returns the current particle system
  77526. */
  77527. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  77528. /**
  77529. * Adds a new velocity gradient
  77530. * @param gradient defines the gradient to use (between 0 and 1)
  77531. * @param factor defines the velocity to affect to the specified gradient
  77532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77533. * @returns the current particle system
  77534. */
  77535. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77536. /**
  77537. * Remove a specific velocity gradient
  77538. * @param gradient defines the gradient to remove
  77539. * @returns the current particle system
  77540. */
  77541. removeVelocityGradient(gradient: number): IParticleSystem;
  77542. /**
  77543. * Adds a new limit velocity gradient
  77544. * @param gradient defines the gradient to use (between 0 and 1)
  77545. * @param factor defines the limit velocity value to affect to the specified gradient
  77546. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77547. * @returns the current particle system
  77548. */
  77549. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77550. /**
  77551. * Remove a specific limit velocity gradient
  77552. * @param gradient defines the gradient to remove
  77553. * @returns the current particle system
  77554. */
  77555. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  77556. /**
  77557. * Adds a new drag gradient
  77558. * @param gradient defines the gradient to use (between 0 and 1)
  77559. * @param factor defines the drag value to affect to the specified gradient
  77560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77561. * @returns the current particle system
  77562. */
  77563. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77564. /**
  77565. * Remove a specific drag gradient
  77566. * @param gradient defines the gradient to remove
  77567. * @returns the current particle system
  77568. */
  77569. removeDragGradient(gradient: number): IParticleSystem;
  77570. /**
  77571. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  77572. * @param gradient defines the gradient to use (between 0 and 1)
  77573. * @param factor defines the emit rate value to affect to the specified gradient
  77574. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77575. * @returns the current particle system
  77576. */
  77577. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77578. /**
  77579. * Remove a specific emit rate gradient
  77580. * @param gradient defines the gradient to remove
  77581. * @returns the current particle system
  77582. */
  77583. removeEmitRateGradient(gradient: number): IParticleSystem;
  77584. /**
  77585. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  77586. * @param gradient defines the gradient to use (between 0 and 1)
  77587. * @param factor defines the start size value to affect to the specified gradient
  77588. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77589. * @returns the current particle system
  77590. */
  77591. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77592. /**
  77593. * Remove a specific start size gradient
  77594. * @param gradient defines the gradient to remove
  77595. * @returns the current particle system
  77596. */
  77597. removeStartSizeGradient(gradient: number): IParticleSystem;
  77598. private _createRampGradientTexture;
  77599. /**
  77600. * Gets the current list of ramp gradients.
  77601. * You must use addRampGradient and removeRampGradient to udpate this list
  77602. * @returns the list of ramp gradients
  77603. */
  77604. getRampGradients(): Nullable<Array<Color3Gradient>>;
  77605. /**
  77606. * Adds a new ramp gradient used to remap particle colors
  77607. * @param gradient defines the gradient to use (between 0 and 1)
  77608. * @param color defines the color to affect to the specified gradient
  77609. * @returns the current particle system
  77610. */
  77611. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  77612. /**
  77613. * Remove a specific ramp gradient
  77614. * @param gradient defines the gradient to remove
  77615. * @returns the current particle system
  77616. */
  77617. removeRampGradient(gradient: number): ParticleSystem;
  77618. /**
  77619. * Adds a new color gradient
  77620. * @param gradient defines the gradient to use (between 0 and 1)
  77621. * @param color1 defines the color to affect to the specified gradient
  77622. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  77623. * @returns this particle system
  77624. */
  77625. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  77626. /**
  77627. * Remove a specific color gradient
  77628. * @param gradient defines the gradient to remove
  77629. * @returns this particle system
  77630. */
  77631. removeColorGradient(gradient: number): IParticleSystem;
  77632. private _fetchR;
  77633. protected _reset(): void;
  77634. private _resetEffect;
  77635. private _createVertexBuffers;
  77636. private _createIndexBuffer;
  77637. /**
  77638. * Gets the maximum number of particles active at the same time.
  77639. * @returns The max number of active particles.
  77640. */
  77641. getCapacity(): number;
  77642. /**
  77643. * Gets whether there are still active particles in the system.
  77644. * @returns True if it is alive, otherwise false.
  77645. */
  77646. isAlive(): boolean;
  77647. /**
  77648. * Gets if the system has been started. (Note: this will still be true after stop is called)
  77649. * @returns True if it has been started, otherwise false.
  77650. */
  77651. isStarted(): boolean;
  77652. private _prepareSubEmitterInternalArray;
  77653. /**
  77654. * Starts the particle system and begins to emit
  77655. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  77656. */
  77657. start(delay?: number): void;
  77658. /**
  77659. * Stops the particle system.
  77660. * @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.
  77661. */
  77662. stop(stopSubEmitters?: boolean): void;
  77663. /**
  77664. * Remove all active particles
  77665. */
  77666. reset(): void;
  77667. /**
  77668. * @hidden (for internal use only)
  77669. */
  77670. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  77671. /**
  77672. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  77673. * Its lifetime will start back at 0.
  77674. */
  77675. recycleParticle: (particle: Particle) => void;
  77676. private _stopSubEmitters;
  77677. private _createParticle;
  77678. private _removeFromRoot;
  77679. private _emitFromParticle;
  77680. private _update;
  77681. /** @hidden */
  77682. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  77683. /** @hidden */
  77684. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  77685. /** @hidden */
  77686. private _getEffect;
  77687. /**
  77688. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  77689. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  77690. */
  77691. animate(preWarmOnly?: boolean): void;
  77692. private _appendParticleVertices;
  77693. /**
  77694. * Rebuilds the particle system.
  77695. */
  77696. rebuild(): void;
  77697. /**
  77698. * Is this system ready to be used/rendered
  77699. * @return true if the system is ready
  77700. */
  77701. isReady(): boolean;
  77702. private _render;
  77703. /**
  77704. * Renders the particle system in its current state.
  77705. * @returns the current number of particles
  77706. */
  77707. render(): number;
  77708. /**
  77709. * Disposes the particle system and free the associated resources
  77710. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  77711. */
  77712. dispose(disposeTexture?: boolean): void;
  77713. /**
  77714. * Clones the particle system.
  77715. * @param name The name of the cloned object
  77716. * @param newEmitter The new emitter to use
  77717. * @returns the cloned particle system
  77718. */
  77719. clone(name: string, newEmitter: any): ParticleSystem;
  77720. /**
  77721. * Serializes the particle system to a JSON object.
  77722. * @returns the JSON object
  77723. */
  77724. serialize(): any;
  77725. /** @hidden */
  77726. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  77727. /** @hidden */
  77728. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  77729. /**
  77730. * Parses a JSON object to create a particle system.
  77731. * @param parsedParticleSystem The JSON object to parse
  77732. * @param scene The scene to create the particle system in
  77733. * @param rootUrl The root url to use to load external dependencies like texture
  77734. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  77735. * @returns the Parsed particle system
  77736. */
  77737. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  77738. }
  77739. }
  77740. declare module BABYLON {
  77741. /**
  77742. * A particle represents one of the element emitted by a particle system.
  77743. * This is mainly define by its coordinates, direction, velocity and age.
  77744. */
  77745. export class Particle {
  77746. /**
  77747. * The particle system the particle belongs to.
  77748. */
  77749. particleSystem: ParticleSystem;
  77750. private static _Count;
  77751. /**
  77752. * Unique ID of the particle
  77753. */
  77754. id: number;
  77755. /**
  77756. * The world position of the particle in the scene.
  77757. */
  77758. position: Vector3;
  77759. /**
  77760. * The world direction of the particle in the scene.
  77761. */
  77762. direction: Vector3;
  77763. /**
  77764. * The color of the particle.
  77765. */
  77766. color: Color4;
  77767. /**
  77768. * The color change of the particle per step.
  77769. */
  77770. colorStep: Color4;
  77771. /**
  77772. * Defines how long will the life of the particle be.
  77773. */
  77774. lifeTime: number;
  77775. /**
  77776. * The current age of the particle.
  77777. */
  77778. age: number;
  77779. /**
  77780. * The current size of the particle.
  77781. */
  77782. size: number;
  77783. /**
  77784. * The current scale of the particle.
  77785. */
  77786. scale: Vector2;
  77787. /**
  77788. * The current angle of the particle.
  77789. */
  77790. angle: number;
  77791. /**
  77792. * Defines how fast is the angle changing.
  77793. */
  77794. angularSpeed: number;
  77795. /**
  77796. * Defines the cell index used by the particle to be rendered from a sprite.
  77797. */
  77798. cellIndex: number;
  77799. /**
  77800. * The information required to support color remapping
  77801. */
  77802. remapData: Vector4;
  77803. /** @hidden */
  77804. _randomCellOffset?: number;
  77805. /** @hidden */
  77806. _initialDirection: Nullable<Vector3>;
  77807. /** @hidden */
  77808. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  77809. /** @hidden */
  77810. _initialStartSpriteCellID: number;
  77811. /** @hidden */
  77812. _initialEndSpriteCellID: number;
  77813. /** @hidden */
  77814. _currentColorGradient: Nullable<ColorGradient>;
  77815. /** @hidden */
  77816. _currentColor1: Color4;
  77817. /** @hidden */
  77818. _currentColor2: Color4;
  77819. /** @hidden */
  77820. _currentSizeGradient: Nullable<FactorGradient>;
  77821. /** @hidden */
  77822. _currentSize1: number;
  77823. /** @hidden */
  77824. _currentSize2: number;
  77825. /** @hidden */
  77826. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  77827. /** @hidden */
  77828. _currentAngularSpeed1: number;
  77829. /** @hidden */
  77830. _currentAngularSpeed2: number;
  77831. /** @hidden */
  77832. _currentVelocityGradient: Nullable<FactorGradient>;
  77833. /** @hidden */
  77834. _currentVelocity1: number;
  77835. /** @hidden */
  77836. _currentVelocity2: number;
  77837. /** @hidden */
  77838. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  77839. /** @hidden */
  77840. _currentLimitVelocity1: number;
  77841. /** @hidden */
  77842. _currentLimitVelocity2: number;
  77843. /** @hidden */
  77844. _currentDragGradient: Nullable<FactorGradient>;
  77845. /** @hidden */
  77846. _currentDrag1: number;
  77847. /** @hidden */
  77848. _currentDrag2: number;
  77849. /** @hidden */
  77850. _randomNoiseCoordinates1: Vector3;
  77851. /** @hidden */
  77852. _randomNoiseCoordinates2: Vector3;
  77853. /**
  77854. * Creates a new instance Particle
  77855. * @param particleSystem the particle system the particle belongs to
  77856. */
  77857. constructor(
  77858. /**
  77859. * The particle system the particle belongs to.
  77860. */
  77861. particleSystem: ParticleSystem);
  77862. private updateCellInfoFromSystem;
  77863. /**
  77864. * Defines how the sprite cell index is updated for the particle
  77865. */
  77866. updateCellIndex(): void;
  77867. /** @hidden */
  77868. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  77869. /** @hidden */
  77870. _inheritParticleInfoToSubEmitters(): void;
  77871. /** @hidden */
  77872. _reset(): void;
  77873. /**
  77874. * Copy the properties of particle to another one.
  77875. * @param other the particle to copy the information to.
  77876. */
  77877. copyTo(other: Particle): void;
  77878. }
  77879. }
  77880. declare module BABYLON {
  77881. /**
  77882. * Particle emitter represents a volume emitting particles.
  77883. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  77884. */
  77885. export interface IParticleEmitterType {
  77886. /**
  77887. * Called by the particle System when the direction is computed for the created particle.
  77888. * @param worldMatrix is the world matrix of the particle system
  77889. * @param directionToUpdate is the direction vector to update with the result
  77890. * @param particle is the particle we are computed the direction for
  77891. */
  77892. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77893. /**
  77894. * Called by the particle System when the position is computed for the created particle.
  77895. * @param worldMatrix is the world matrix of the particle system
  77896. * @param positionToUpdate is the position vector to update with the result
  77897. * @param particle is the particle we are computed the position for
  77898. */
  77899. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  77900. /**
  77901. * Clones the current emitter and returns a copy of it
  77902. * @returns the new emitter
  77903. */
  77904. clone(): IParticleEmitterType;
  77905. /**
  77906. * Called by the GPUParticleSystem to setup the update shader
  77907. * @param effect defines the update shader
  77908. */
  77909. applyToShader(effect: Effect): void;
  77910. /**
  77911. * Returns a string to use to update the GPU particles update shader
  77912. * @returns the effect defines string
  77913. */
  77914. getEffectDefines(): string;
  77915. /**
  77916. * Returns a string representing the class name
  77917. * @returns a string containing the class name
  77918. */
  77919. getClassName(): string;
  77920. /**
  77921. * Serializes the particle system to a JSON object.
  77922. * @returns the JSON object
  77923. */
  77924. serialize(): any;
  77925. /**
  77926. * Parse properties from a JSON object
  77927. * @param serializationObject defines the JSON object
  77928. */
  77929. parse(serializationObject: any): void;
  77930. }
  77931. }
  77932. declare module BABYLON {
  77933. /**
  77934. * Particle emitter emitting particles from the inside of a box.
  77935. * It emits the particles randomly between 2 given directions.
  77936. */
  77937. export class BoxParticleEmitter implements IParticleEmitterType {
  77938. /**
  77939. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77940. */
  77941. direction1: Vector3;
  77942. /**
  77943. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77944. */
  77945. direction2: Vector3;
  77946. /**
  77947. * 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.
  77948. */
  77949. minEmitBox: Vector3;
  77950. /**
  77951. * 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.
  77952. */
  77953. maxEmitBox: Vector3;
  77954. /**
  77955. * Creates a new instance BoxParticleEmitter
  77956. */
  77957. constructor();
  77958. /**
  77959. * Called by the particle System when the direction is computed for the created particle.
  77960. * @param worldMatrix is the world matrix of the particle system
  77961. * @param directionToUpdate is the direction vector to update with the result
  77962. * @param particle is the particle we are computed the direction for
  77963. */
  77964. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77965. /**
  77966. * Called by the particle System when the position is computed for the created particle.
  77967. * @param worldMatrix is the world matrix of the particle system
  77968. * @param positionToUpdate is the position vector to update with the result
  77969. * @param particle is the particle we are computed the position for
  77970. */
  77971. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  77972. /**
  77973. * Clones the current emitter and returns a copy of it
  77974. * @returns the new emitter
  77975. */
  77976. clone(): BoxParticleEmitter;
  77977. /**
  77978. * Called by the GPUParticleSystem to setup the update shader
  77979. * @param effect defines the update shader
  77980. */
  77981. applyToShader(effect: Effect): void;
  77982. /**
  77983. * Returns a string to use to update the GPU particles update shader
  77984. * @returns a string containng the defines string
  77985. */
  77986. getEffectDefines(): string;
  77987. /**
  77988. * Returns the string "BoxParticleEmitter"
  77989. * @returns a string containing the class name
  77990. */
  77991. getClassName(): string;
  77992. /**
  77993. * Serializes the particle system to a JSON object.
  77994. * @returns the JSON object
  77995. */
  77996. serialize(): any;
  77997. /**
  77998. * Parse properties from a JSON object
  77999. * @param serializationObject defines the JSON object
  78000. */
  78001. parse(serializationObject: any): void;
  78002. }
  78003. }
  78004. declare module BABYLON {
  78005. /**
  78006. * Particle emitter emitting particles from the inside of a cone.
  78007. * It emits the particles alongside the cone volume from the base to the particle.
  78008. * The emission direction might be randomized.
  78009. */
  78010. export class ConeParticleEmitter implements IParticleEmitterType {
  78011. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  78012. directionRandomizer: number;
  78013. private _radius;
  78014. private _angle;
  78015. private _height;
  78016. /**
  78017. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  78018. */
  78019. radiusRange: number;
  78020. /**
  78021. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  78022. */
  78023. heightRange: number;
  78024. /**
  78025. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  78026. */
  78027. emitFromSpawnPointOnly: boolean;
  78028. /**
  78029. * Gets or sets the radius of the emission cone
  78030. */
  78031. radius: number;
  78032. /**
  78033. * Gets or sets the angle of the emission cone
  78034. */
  78035. angle: number;
  78036. private _buildHeight;
  78037. /**
  78038. * Creates a new instance ConeParticleEmitter
  78039. * @param radius the radius of the emission cone (1 by default)
  78040. * @param angle the cone base angle (PI by default)
  78041. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  78042. */
  78043. constructor(radius?: number, angle?: number,
  78044. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  78045. directionRandomizer?: number);
  78046. /**
  78047. * Called by the particle System when the direction is computed for the created particle.
  78048. * @param worldMatrix is the world matrix of the particle system
  78049. * @param directionToUpdate is the direction vector to update with the result
  78050. * @param particle is the particle we are computed the direction for
  78051. */
  78052. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78053. /**
  78054. * Called by the particle System when the position is computed for the created particle.
  78055. * @param worldMatrix is the world matrix of the particle system
  78056. * @param positionToUpdate is the position vector to update with the result
  78057. * @param particle is the particle we are computed the position for
  78058. */
  78059. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  78060. /**
  78061. * Clones the current emitter and returns a copy of it
  78062. * @returns the new emitter
  78063. */
  78064. clone(): ConeParticleEmitter;
  78065. /**
  78066. * Called by the GPUParticleSystem to setup the update shader
  78067. * @param effect defines the update shader
  78068. */
  78069. applyToShader(effect: Effect): void;
  78070. /**
  78071. * Returns a string to use to update the GPU particles update shader
  78072. * @returns a string containng the defines string
  78073. */
  78074. getEffectDefines(): string;
  78075. /**
  78076. * Returns the string "ConeParticleEmitter"
  78077. * @returns a string containing the class name
  78078. */
  78079. getClassName(): string;
  78080. /**
  78081. * Serializes the particle system to a JSON object.
  78082. * @returns the JSON object
  78083. */
  78084. serialize(): any;
  78085. /**
  78086. * Parse properties from a JSON object
  78087. * @param serializationObject defines the JSON object
  78088. */
  78089. parse(serializationObject: any): void;
  78090. }
  78091. }
  78092. declare module BABYLON {
  78093. /**
  78094. * Particle emitter emitting particles from the inside of a cylinder.
  78095. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  78096. */
  78097. export class CylinderParticleEmitter implements IParticleEmitterType {
  78098. /**
  78099. * The radius of the emission cylinder.
  78100. */
  78101. radius: number;
  78102. /**
  78103. * The height of the emission cylinder.
  78104. */
  78105. height: number;
  78106. /**
  78107. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78108. */
  78109. radiusRange: number;
  78110. /**
  78111. * How much to randomize the particle direction [0-1].
  78112. */
  78113. directionRandomizer: number;
  78114. /**
  78115. * Creates a new instance CylinderParticleEmitter
  78116. * @param radius the radius of the emission cylinder (1 by default)
  78117. * @param height the height of the emission cylinder (1 by default)
  78118. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  78119. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  78120. */
  78121. constructor(
  78122. /**
  78123. * The radius of the emission cylinder.
  78124. */
  78125. radius?: number,
  78126. /**
  78127. * The height of the emission cylinder.
  78128. */
  78129. height?: number,
  78130. /**
  78131. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78132. */
  78133. radiusRange?: number,
  78134. /**
  78135. * How much to randomize the particle direction [0-1].
  78136. */
  78137. directionRandomizer?: number);
  78138. /**
  78139. * Called by the particle System when the direction is computed for the created particle.
  78140. * @param worldMatrix is the world matrix of the particle system
  78141. * @param directionToUpdate is the direction vector to update with the result
  78142. * @param particle is the particle we are computed the direction for
  78143. */
  78144. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78145. /**
  78146. * Called by the particle System when the position is computed for the created particle.
  78147. * @param worldMatrix is the world matrix of the particle system
  78148. * @param positionToUpdate is the position vector to update with the result
  78149. * @param particle is the particle we are computed the position for
  78150. */
  78151. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  78152. /**
  78153. * Clones the current emitter and returns a copy of it
  78154. * @returns the new emitter
  78155. */
  78156. clone(): CylinderParticleEmitter;
  78157. /**
  78158. * Called by the GPUParticleSystem to setup the update shader
  78159. * @param effect defines the update shader
  78160. */
  78161. applyToShader(effect: Effect): void;
  78162. /**
  78163. * Returns a string to use to update the GPU particles update shader
  78164. * @returns a string containng the defines string
  78165. */
  78166. getEffectDefines(): string;
  78167. /**
  78168. * Returns the string "CylinderParticleEmitter"
  78169. * @returns a string containing the class name
  78170. */
  78171. getClassName(): string;
  78172. /**
  78173. * Serializes the particle system to a JSON object.
  78174. * @returns the JSON object
  78175. */
  78176. serialize(): any;
  78177. /**
  78178. * Parse properties from a JSON object
  78179. * @param serializationObject defines the JSON object
  78180. */
  78181. parse(serializationObject: any): void;
  78182. }
  78183. /**
  78184. * Particle emitter emitting particles from the inside of a cylinder.
  78185. * It emits the particles randomly between two vectors.
  78186. */
  78187. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  78188. /**
  78189. * The min limit of the emission direction.
  78190. */
  78191. direction1: Vector3;
  78192. /**
  78193. * The max limit of the emission direction.
  78194. */
  78195. direction2: Vector3;
  78196. /**
  78197. * Creates a new instance CylinderDirectedParticleEmitter
  78198. * @param radius the radius of the emission cylinder (1 by default)
  78199. * @param height the height of the emission cylinder (1 by default)
  78200. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  78201. * @param direction1 the min limit of the emission direction (up vector by default)
  78202. * @param direction2 the max limit of the emission direction (up vector by default)
  78203. */
  78204. constructor(radius?: number, height?: number, radiusRange?: number,
  78205. /**
  78206. * The min limit of the emission direction.
  78207. */
  78208. direction1?: Vector3,
  78209. /**
  78210. * The max limit of the emission direction.
  78211. */
  78212. direction2?: Vector3);
  78213. /**
  78214. * Called by the particle System when the direction is computed for the created particle.
  78215. * @param worldMatrix is the world matrix of the particle system
  78216. * @param directionToUpdate is the direction vector to update with the result
  78217. * @param particle is the particle we are computed the direction for
  78218. */
  78219. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78220. /**
  78221. * Clones the current emitter and returns a copy of it
  78222. * @returns the new emitter
  78223. */
  78224. clone(): CylinderDirectedParticleEmitter;
  78225. /**
  78226. * Called by the GPUParticleSystem to setup the update shader
  78227. * @param effect defines the update shader
  78228. */
  78229. applyToShader(effect: Effect): void;
  78230. /**
  78231. * Returns a string to use to update the GPU particles update shader
  78232. * @returns a string containng the defines string
  78233. */
  78234. getEffectDefines(): string;
  78235. /**
  78236. * Returns the string "CylinderDirectedParticleEmitter"
  78237. * @returns a string containing the class name
  78238. */
  78239. getClassName(): string;
  78240. /**
  78241. * Serializes the particle system to a JSON object.
  78242. * @returns the JSON object
  78243. */
  78244. serialize(): any;
  78245. /**
  78246. * Parse properties from a JSON object
  78247. * @param serializationObject defines the JSON object
  78248. */
  78249. parse(serializationObject: any): void;
  78250. }
  78251. }
  78252. declare module BABYLON {
  78253. /**
  78254. * Particle emitter emitting particles from the inside of a hemisphere.
  78255. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  78256. */
  78257. export class HemisphericParticleEmitter implements IParticleEmitterType {
  78258. /**
  78259. * The radius of the emission hemisphere.
  78260. */
  78261. radius: number;
  78262. /**
  78263. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78264. */
  78265. radiusRange: number;
  78266. /**
  78267. * How much to randomize the particle direction [0-1].
  78268. */
  78269. directionRandomizer: number;
  78270. /**
  78271. * Creates a new instance HemisphericParticleEmitter
  78272. * @param radius the radius of the emission hemisphere (1 by default)
  78273. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  78274. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  78275. */
  78276. constructor(
  78277. /**
  78278. * The radius of the emission hemisphere.
  78279. */
  78280. radius?: number,
  78281. /**
  78282. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78283. */
  78284. radiusRange?: number,
  78285. /**
  78286. * How much to randomize the particle direction [0-1].
  78287. */
  78288. directionRandomizer?: number);
  78289. /**
  78290. * Called by the particle System when the direction is computed for the created particle.
  78291. * @param worldMatrix is the world matrix of the particle system
  78292. * @param directionToUpdate is the direction vector to update with the result
  78293. * @param particle is the particle we are computed the direction for
  78294. */
  78295. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78296. /**
  78297. * Called by the particle System when the position is computed for the created particle.
  78298. * @param worldMatrix is the world matrix of the particle system
  78299. * @param positionToUpdate is the position vector to update with the result
  78300. * @param particle is the particle we are computed the position for
  78301. */
  78302. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  78303. /**
  78304. * Clones the current emitter and returns a copy of it
  78305. * @returns the new emitter
  78306. */
  78307. clone(): HemisphericParticleEmitter;
  78308. /**
  78309. * Called by the GPUParticleSystem to setup the update shader
  78310. * @param effect defines the update shader
  78311. */
  78312. applyToShader(effect: Effect): void;
  78313. /**
  78314. * Returns a string to use to update the GPU particles update shader
  78315. * @returns a string containng the defines string
  78316. */
  78317. getEffectDefines(): string;
  78318. /**
  78319. * Returns the string "HemisphericParticleEmitter"
  78320. * @returns a string containing the class name
  78321. */
  78322. getClassName(): string;
  78323. /**
  78324. * Serializes the particle system to a JSON object.
  78325. * @returns the JSON object
  78326. */
  78327. serialize(): any;
  78328. /**
  78329. * Parse properties from a JSON object
  78330. * @param serializationObject defines the JSON object
  78331. */
  78332. parse(serializationObject: any): void;
  78333. }
  78334. }
  78335. declare module BABYLON {
  78336. /**
  78337. * Particle emitter emitting particles from a point.
  78338. * It emits the particles randomly between 2 given directions.
  78339. */
  78340. export class PointParticleEmitter implements IParticleEmitterType {
  78341. /**
  78342. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  78343. */
  78344. direction1: Vector3;
  78345. /**
  78346. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  78347. */
  78348. direction2: Vector3;
  78349. /**
  78350. * Creates a new instance PointParticleEmitter
  78351. */
  78352. constructor();
  78353. /**
  78354. * Called by the particle System when the direction is computed for the created particle.
  78355. * @param worldMatrix is the world matrix of the particle system
  78356. * @param directionToUpdate is the direction vector to update with the result
  78357. * @param particle is the particle we are computed the direction for
  78358. */
  78359. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78360. /**
  78361. * Called by the particle System when the position is computed for the created particle.
  78362. * @param worldMatrix is the world matrix of the particle system
  78363. * @param positionToUpdate is the position vector to update with the result
  78364. * @param particle is the particle we are computed the position for
  78365. */
  78366. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  78367. /**
  78368. * Clones the current emitter and returns a copy of it
  78369. * @returns the new emitter
  78370. */
  78371. clone(): PointParticleEmitter;
  78372. /**
  78373. * Called by the GPUParticleSystem to setup the update shader
  78374. * @param effect defines the update shader
  78375. */
  78376. applyToShader(effect: Effect): void;
  78377. /**
  78378. * Returns a string to use to update the GPU particles update shader
  78379. * @returns a string containng the defines string
  78380. */
  78381. getEffectDefines(): string;
  78382. /**
  78383. * Returns the string "PointParticleEmitter"
  78384. * @returns a string containing the class name
  78385. */
  78386. getClassName(): string;
  78387. /**
  78388. * Serializes the particle system to a JSON object.
  78389. * @returns the JSON object
  78390. */
  78391. serialize(): any;
  78392. /**
  78393. * Parse properties from a JSON object
  78394. * @param serializationObject defines the JSON object
  78395. */
  78396. parse(serializationObject: any): void;
  78397. }
  78398. }
  78399. declare module BABYLON {
  78400. /**
  78401. * Particle emitter emitting particles from the inside of a sphere.
  78402. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  78403. */
  78404. export class SphereParticleEmitter implements IParticleEmitterType {
  78405. /**
  78406. * The radius of the emission sphere.
  78407. */
  78408. radius: number;
  78409. /**
  78410. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78411. */
  78412. radiusRange: number;
  78413. /**
  78414. * How much to randomize the particle direction [0-1].
  78415. */
  78416. directionRandomizer: number;
  78417. /**
  78418. * Creates a new instance SphereParticleEmitter
  78419. * @param radius the radius of the emission sphere (1 by default)
  78420. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  78421. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  78422. */
  78423. constructor(
  78424. /**
  78425. * The radius of the emission sphere.
  78426. */
  78427. radius?: number,
  78428. /**
  78429. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78430. */
  78431. radiusRange?: number,
  78432. /**
  78433. * How much to randomize the particle direction [0-1].
  78434. */
  78435. directionRandomizer?: number);
  78436. /**
  78437. * Called by the particle System when the direction is computed for the created particle.
  78438. * @param worldMatrix is the world matrix of the particle system
  78439. * @param directionToUpdate is the direction vector to update with the result
  78440. * @param particle is the particle we are computed the direction for
  78441. */
  78442. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78443. /**
  78444. * Called by the particle System when the position is computed for the created particle.
  78445. * @param worldMatrix is the world matrix of the particle system
  78446. * @param positionToUpdate is the position vector to update with the result
  78447. * @param particle is the particle we are computed the position for
  78448. */
  78449. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  78450. /**
  78451. * Clones the current emitter and returns a copy of it
  78452. * @returns the new emitter
  78453. */
  78454. clone(): SphereParticleEmitter;
  78455. /**
  78456. * Called by the GPUParticleSystem to setup the update shader
  78457. * @param effect defines the update shader
  78458. */
  78459. applyToShader(effect: Effect): void;
  78460. /**
  78461. * Returns a string to use to update the GPU particles update shader
  78462. * @returns a string containng the defines string
  78463. */
  78464. getEffectDefines(): string;
  78465. /**
  78466. * Returns the string "SphereParticleEmitter"
  78467. * @returns a string containing the class name
  78468. */
  78469. getClassName(): string;
  78470. /**
  78471. * Serializes the particle system to a JSON object.
  78472. * @returns the JSON object
  78473. */
  78474. serialize(): any;
  78475. /**
  78476. * Parse properties from a JSON object
  78477. * @param serializationObject defines the JSON object
  78478. */
  78479. parse(serializationObject: any): void;
  78480. }
  78481. /**
  78482. * Particle emitter emitting particles from the inside of a sphere.
  78483. * It emits the particles randomly between two vectors.
  78484. */
  78485. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  78486. /**
  78487. * The min limit of the emission direction.
  78488. */
  78489. direction1: Vector3;
  78490. /**
  78491. * The max limit of the emission direction.
  78492. */
  78493. direction2: Vector3;
  78494. /**
  78495. * Creates a new instance SphereDirectedParticleEmitter
  78496. * @param radius the radius of the emission sphere (1 by default)
  78497. * @param direction1 the min limit of the emission direction (up vector by default)
  78498. * @param direction2 the max limit of the emission direction (up vector by default)
  78499. */
  78500. constructor(radius?: number,
  78501. /**
  78502. * The min limit of the emission direction.
  78503. */
  78504. direction1?: Vector3,
  78505. /**
  78506. * The max limit of the emission direction.
  78507. */
  78508. direction2?: Vector3);
  78509. /**
  78510. * Called by the particle System when the direction is computed for the created particle.
  78511. * @param worldMatrix is the world matrix of the particle system
  78512. * @param directionToUpdate is the direction vector to update with the result
  78513. * @param particle is the particle we are computed the direction for
  78514. */
  78515. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78516. /**
  78517. * Clones the current emitter and returns a copy of it
  78518. * @returns the new emitter
  78519. */
  78520. clone(): SphereDirectedParticleEmitter;
  78521. /**
  78522. * Called by the GPUParticleSystem to setup the update shader
  78523. * @param effect defines the update shader
  78524. */
  78525. applyToShader(effect: Effect): void;
  78526. /**
  78527. * Returns a string to use to update the GPU particles update shader
  78528. * @returns a string containng the defines string
  78529. */
  78530. getEffectDefines(): string;
  78531. /**
  78532. * Returns the string "SphereDirectedParticleEmitter"
  78533. * @returns a string containing the class name
  78534. */
  78535. getClassName(): string;
  78536. /**
  78537. * Serializes the particle system to a JSON object.
  78538. * @returns the JSON object
  78539. */
  78540. serialize(): any;
  78541. /**
  78542. * Parse properties from a JSON object
  78543. * @param serializationObject defines the JSON object
  78544. */
  78545. parse(serializationObject: any): void;
  78546. }
  78547. }
  78548. declare module BABYLON {
  78549. /**
  78550. * Interface representing a particle system in Babylon.js.
  78551. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  78552. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  78553. */
  78554. export interface IParticleSystem {
  78555. /**
  78556. * List of animations used by the particle system.
  78557. */
  78558. animations: Animation[];
  78559. /**
  78560. * The id of the Particle system.
  78561. */
  78562. id: string;
  78563. /**
  78564. * The name of the Particle system.
  78565. */
  78566. name: string;
  78567. /**
  78568. * The emitter represents the Mesh or position we are attaching the particle system to.
  78569. */
  78570. emitter: Nullable<AbstractMesh | Vector3>;
  78571. /**
  78572. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  78573. */
  78574. isBillboardBased: boolean;
  78575. /**
  78576. * The rendering group used by the Particle system to chose when to render.
  78577. */
  78578. renderingGroupId: number;
  78579. /**
  78580. * The layer mask we are rendering the particles through.
  78581. */
  78582. layerMask: number;
  78583. /**
  78584. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  78585. */
  78586. updateSpeed: number;
  78587. /**
  78588. * The amount of time the particle system is running (depends of the overall update speed).
  78589. */
  78590. targetStopDuration: number;
  78591. /**
  78592. * The texture used to render each particle. (this can be a spritesheet)
  78593. */
  78594. particleTexture: Nullable<Texture>;
  78595. /**
  78596. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  78597. */
  78598. blendMode: number;
  78599. /**
  78600. * Minimum life time of emitting particles.
  78601. */
  78602. minLifeTime: number;
  78603. /**
  78604. * Maximum life time of emitting particles.
  78605. */
  78606. maxLifeTime: number;
  78607. /**
  78608. * Minimum Size of emitting particles.
  78609. */
  78610. minSize: number;
  78611. /**
  78612. * Maximum Size of emitting particles.
  78613. */
  78614. maxSize: number;
  78615. /**
  78616. * Minimum scale of emitting particles on X axis.
  78617. */
  78618. minScaleX: number;
  78619. /**
  78620. * Maximum scale of emitting particles on X axis.
  78621. */
  78622. maxScaleX: number;
  78623. /**
  78624. * Minimum scale of emitting particles on Y axis.
  78625. */
  78626. minScaleY: number;
  78627. /**
  78628. * Maximum scale of emitting particles on Y axis.
  78629. */
  78630. maxScaleY: number;
  78631. /**
  78632. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  78633. */
  78634. color1: Color4;
  78635. /**
  78636. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  78637. */
  78638. color2: Color4;
  78639. /**
  78640. * Color the particle will have at the end of its lifetime.
  78641. */
  78642. colorDead: Color4;
  78643. /**
  78644. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  78645. */
  78646. emitRate: number;
  78647. /**
  78648. * You can use gravity if you want to give an orientation to your particles.
  78649. */
  78650. gravity: Vector3;
  78651. /**
  78652. * Minimum power of emitting particles.
  78653. */
  78654. minEmitPower: number;
  78655. /**
  78656. * Maximum power of emitting particles.
  78657. */
  78658. maxEmitPower: number;
  78659. /**
  78660. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  78661. */
  78662. minAngularSpeed: number;
  78663. /**
  78664. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  78665. */
  78666. maxAngularSpeed: number;
  78667. /**
  78668. * Gets or sets the minimal initial rotation in radians.
  78669. */
  78670. minInitialRotation: number;
  78671. /**
  78672. * Gets or sets the maximal initial rotation in radians.
  78673. */
  78674. maxInitialRotation: number;
  78675. /**
  78676. * The particle emitter type defines the emitter used by the particle system.
  78677. * It can be for example box, sphere, or cone...
  78678. */
  78679. particleEmitterType: Nullable<IParticleEmitterType>;
  78680. /**
  78681. * Defines the delay in milliseconds before starting the system (0 by default)
  78682. */
  78683. startDelay: number;
  78684. /**
  78685. * 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
  78686. */
  78687. preWarmCycles: number;
  78688. /**
  78689. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  78690. */
  78691. preWarmStepOffset: number;
  78692. /**
  78693. * 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)
  78694. */
  78695. spriteCellChangeSpeed: number;
  78696. /**
  78697. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  78698. */
  78699. startSpriteCellID: number;
  78700. /**
  78701. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  78702. */
  78703. endSpriteCellID: number;
  78704. /**
  78705. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  78706. */
  78707. spriteCellWidth: number;
  78708. /**
  78709. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  78710. */
  78711. spriteCellHeight: number;
  78712. /**
  78713. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  78714. */
  78715. spriteRandomStartCell: boolean;
  78716. /**
  78717. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  78718. */
  78719. isAnimationSheetEnabled: boolean;
  78720. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  78721. translationPivot: Vector2;
  78722. /**
  78723. * Gets or sets a texture used to add random noise to particle positions
  78724. */
  78725. noiseTexture: Nullable<BaseTexture>;
  78726. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  78727. noiseStrength: Vector3;
  78728. /**
  78729. * Gets or sets the billboard mode to use when isBillboardBased = true.
  78730. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  78731. */
  78732. billboardMode: number;
  78733. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  78734. limitVelocityDamping: number;
  78735. /**
  78736. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  78737. */
  78738. beginAnimationOnStart: boolean;
  78739. /**
  78740. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  78741. */
  78742. beginAnimationFrom: number;
  78743. /**
  78744. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  78745. */
  78746. beginAnimationTo: number;
  78747. /**
  78748. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  78749. */
  78750. beginAnimationLoop: boolean;
  78751. /**
  78752. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  78753. */
  78754. disposeOnStop: boolean;
  78755. /**
  78756. * Gets the maximum number of particles active at the same time.
  78757. * @returns The max number of active particles.
  78758. */
  78759. getCapacity(): number;
  78760. /**
  78761. * Gets if the system has been started. (Note: this will still be true after stop is called)
  78762. * @returns True if it has been started, otherwise false.
  78763. */
  78764. isStarted(): boolean;
  78765. /**
  78766. * Animates the particle system for this frame.
  78767. */
  78768. animate(): void;
  78769. /**
  78770. * Renders the particle system in its current state.
  78771. * @returns the current number of particles
  78772. */
  78773. render(): number;
  78774. /**
  78775. * Dispose the particle system and frees its associated resources.
  78776. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  78777. */
  78778. dispose(disposeTexture?: boolean): void;
  78779. /**
  78780. * Clones the particle system.
  78781. * @param name The name of the cloned object
  78782. * @param newEmitter The new emitter to use
  78783. * @returns the cloned particle system
  78784. */
  78785. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  78786. /**
  78787. * Serializes the particle system to a JSON object.
  78788. * @returns the JSON object
  78789. */
  78790. serialize(): any;
  78791. /**
  78792. * Rebuild the particle system
  78793. */
  78794. rebuild(): void;
  78795. /**
  78796. * Starts the particle system and begins to emit
  78797. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  78798. */
  78799. start(delay?: number): void;
  78800. /**
  78801. * Stops the particle system.
  78802. */
  78803. stop(): void;
  78804. /**
  78805. * Remove all active particles
  78806. */
  78807. reset(): void;
  78808. /**
  78809. * Is this system ready to be used/rendered
  78810. * @return true if the system is ready
  78811. */
  78812. isReady(): boolean;
  78813. /**
  78814. * Adds a new color gradient
  78815. * @param gradient defines the gradient to use (between 0 and 1)
  78816. * @param color1 defines the color to affect to the specified gradient
  78817. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  78818. * @returns the current particle system
  78819. */
  78820. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  78821. /**
  78822. * Remove a specific color gradient
  78823. * @param gradient defines the gradient to remove
  78824. * @returns the current particle system
  78825. */
  78826. removeColorGradient(gradient: number): IParticleSystem;
  78827. /**
  78828. * Adds a new size gradient
  78829. * @param gradient defines the gradient to use (between 0 and 1)
  78830. * @param factor defines the size factor to affect to the specified gradient
  78831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78832. * @returns the current particle system
  78833. */
  78834. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78835. /**
  78836. * Remove a specific size gradient
  78837. * @param gradient defines the gradient to remove
  78838. * @returns the current particle system
  78839. */
  78840. removeSizeGradient(gradient: number): IParticleSystem;
  78841. /**
  78842. * Gets the current list of color gradients.
  78843. * You must use addColorGradient and removeColorGradient to udpate this list
  78844. * @returns the list of color gradients
  78845. */
  78846. getColorGradients(): Nullable<Array<ColorGradient>>;
  78847. /**
  78848. * Gets the current list of size gradients.
  78849. * You must use addSizeGradient and removeSizeGradient to udpate this list
  78850. * @returns the list of size gradients
  78851. */
  78852. getSizeGradients(): Nullable<Array<FactorGradient>>;
  78853. /**
  78854. * Gets the current list of angular speed gradients.
  78855. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  78856. * @returns the list of angular speed gradients
  78857. */
  78858. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  78859. /**
  78860. * Adds a new angular speed gradient
  78861. * @param gradient defines the gradient to use (between 0 and 1)
  78862. * @param factor defines the angular speed to affect to the specified gradient
  78863. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78864. * @returns the current particle system
  78865. */
  78866. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78867. /**
  78868. * Remove a specific angular speed gradient
  78869. * @param gradient defines the gradient to remove
  78870. * @returns the current particle system
  78871. */
  78872. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  78873. /**
  78874. * Gets the current list of velocity gradients.
  78875. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  78876. * @returns the list of velocity gradients
  78877. */
  78878. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  78879. /**
  78880. * Adds a new velocity gradient
  78881. * @param gradient defines the gradient to use (between 0 and 1)
  78882. * @param factor defines the velocity to affect to the specified gradient
  78883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78884. * @returns the current particle system
  78885. */
  78886. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78887. /**
  78888. * Remove a specific velocity gradient
  78889. * @param gradient defines the gradient to remove
  78890. * @returns the current particle system
  78891. */
  78892. removeVelocityGradient(gradient: number): IParticleSystem;
  78893. /**
  78894. * Gets the current list of limit velocity gradients.
  78895. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  78896. * @returns the list of limit velocity gradients
  78897. */
  78898. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  78899. /**
  78900. * Adds a new limit velocity gradient
  78901. * @param gradient defines the gradient to use (between 0 and 1)
  78902. * @param factor defines the limit velocity to affect to the specified gradient
  78903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78904. * @returns the current particle system
  78905. */
  78906. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78907. /**
  78908. * Remove a specific limit velocity gradient
  78909. * @param gradient defines the gradient to remove
  78910. * @returns the current particle system
  78911. */
  78912. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  78913. /**
  78914. * Adds a new drag gradient
  78915. * @param gradient defines the gradient to use (between 0 and 1)
  78916. * @param factor defines the drag to affect to the specified gradient
  78917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78918. * @returns the current particle system
  78919. */
  78920. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78921. /**
  78922. * Remove a specific drag gradient
  78923. * @param gradient defines the gradient to remove
  78924. * @returns the current particle system
  78925. */
  78926. removeDragGradient(gradient: number): IParticleSystem;
  78927. /**
  78928. * Gets the current list of drag gradients.
  78929. * You must use addDragGradient and removeDragGradient to udpate this list
  78930. * @returns the list of drag gradients
  78931. */
  78932. getDragGradients(): Nullable<Array<FactorGradient>>;
  78933. /**
  78934. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  78935. * @param gradient defines the gradient to use (between 0 and 1)
  78936. * @param factor defines the emit rate to affect to the specified gradient
  78937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78938. * @returns the current particle system
  78939. */
  78940. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78941. /**
  78942. * Remove a specific emit rate gradient
  78943. * @param gradient defines the gradient to remove
  78944. * @returns the current particle system
  78945. */
  78946. removeEmitRateGradient(gradient: number): IParticleSystem;
  78947. /**
  78948. * Gets the current list of emit rate gradients.
  78949. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  78950. * @returns the list of emit rate gradients
  78951. */
  78952. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  78953. /**
  78954. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  78955. * @param gradient defines the gradient to use (between 0 and 1)
  78956. * @param factor defines the start size to affect to the specified gradient
  78957. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78958. * @returns the current particle system
  78959. */
  78960. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78961. /**
  78962. * Remove a specific start size gradient
  78963. * @param gradient defines the gradient to remove
  78964. * @returns the current particle system
  78965. */
  78966. removeStartSizeGradient(gradient: number): IParticleSystem;
  78967. /**
  78968. * Gets the current list of start size gradients.
  78969. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  78970. * @returns the list of start size gradients
  78971. */
  78972. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  78973. /**
  78974. * Adds a new life time gradient
  78975. * @param gradient defines the gradient to use (between 0 and 1)
  78976. * @param factor defines the life time factor to affect to the specified gradient
  78977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78978. * @returns the current particle system
  78979. */
  78980. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78981. /**
  78982. * Remove a specific life time gradient
  78983. * @param gradient defines the gradient to remove
  78984. * @returns the current particle system
  78985. */
  78986. removeLifeTimeGradient(gradient: number): IParticleSystem;
  78987. /**
  78988. * Gets the current list of life time gradients.
  78989. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  78990. * @returns the list of life time gradients
  78991. */
  78992. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  78993. /**
  78994. * Gets the current list of color gradients.
  78995. * You must use addColorGradient and removeColorGradient to udpate this list
  78996. * @returns the list of color gradients
  78997. */
  78998. getColorGradients(): Nullable<Array<ColorGradient>>;
  78999. /**
  79000. * Adds a new ramp gradient used to remap particle colors
  79001. * @param gradient defines the gradient to use (between 0 and 1)
  79002. * @param color defines the color to affect to the specified gradient
  79003. * @returns the current particle system
  79004. */
  79005. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  79006. /**
  79007. * Gets the current list of ramp gradients.
  79008. * You must use addRampGradient and removeRampGradient to udpate this list
  79009. * @returns the list of ramp gradients
  79010. */
  79011. getRampGradients(): Nullable<Array<Color3Gradient>>;
  79012. /** Gets or sets a boolean indicating that ramp gradients must be used
  79013. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  79014. */
  79015. useRampGradients: boolean;
  79016. /**
  79017. * Adds a new color remap gradient
  79018. * @param gradient defines the gradient to use (between 0 and 1)
  79019. * @param min defines the color remap minimal range
  79020. * @param max defines the color remap maximal range
  79021. * @returns the current particle system
  79022. */
  79023. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  79024. /**
  79025. * Gets the current list of color remap gradients.
  79026. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  79027. * @returns the list of color remap gradients
  79028. */
  79029. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  79030. /**
  79031. * Adds a new alpha remap gradient
  79032. * @param gradient defines the gradient to use (between 0 and 1)
  79033. * @param min defines the alpha remap minimal range
  79034. * @param max defines the alpha remap maximal range
  79035. * @returns the current particle system
  79036. */
  79037. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  79038. /**
  79039. * Gets the current list of alpha remap gradients.
  79040. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  79041. * @returns the list of alpha remap gradients
  79042. */
  79043. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  79044. /**
  79045. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  79046. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  79047. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  79048. * @returns the emitter
  79049. */
  79050. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  79051. /**
  79052. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  79053. * @param radius The radius of the hemisphere to emit from
  79054. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  79055. * @returns the emitter
  79056. */
  79057. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  79058. /**
  79059. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  79060. * @param radius The radius of the sphere to emit from
  79061. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  79062. * @returns the emitter
  79063. */
  79064. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  79065. /**
  79066. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  79067. * @param radius The radius of the sphere to emit from
  79068. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  79069. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  79070. * @returns the emitter
  79071. */
  79072. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  79073. /**
  79074. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  79075. * @param radius The radius of the emission cylinder
  79076. * @param height The height of the emission cylinder
  79077. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  79078. * @param directionRandomizer How much to randomize the particle direction [0-1]
  79079. * @returns the emitter
  79080. */
  79081. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  79082. /**
  79083. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  79084. * @param radius The radius of the cylinder to emit from
  79085. * @param height The height of the emission cylinder
  79086. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  79087. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  79088. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  79089. * @returns the emitter
  79090. */
  79091. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  79092. /**
  79093. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  79094. * @param radius The radius of the cone to emit from
  79095. * @param angle The base angle of the cone
  79096. * @returns the emitter
  79097. */
  79098. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  79099. /**
  79100. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  79101. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  79102. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  79103. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  79104. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  79105. * @returns the emitter
  79106. */
  79107. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  79108. /**
  79109. * Get hosting scene
  79110. * @returns the scene
  79111. */
  79112. getScene(): Scene;
  79113. }
  79114. }
  79115. declare module BABYLON {
  79116. /**
  79117. * Creates an instance based on a source mesh.
  79118. */
  79119. export class InstancedMesh extends AbstractMesh {
  79120. private _sourceMesh;
  79121. private _currentLOD;
  79122. /** @hidden */
  79123. _indexInSourceMeshInstanceArray: number;
  79124. constructor(name: string, source: Mesh);
  79125. /**
  79126. * Returns the string "InstancedMesh".
  79127. */
  79128. getClassName(): string;
  79129. /** Gets the list of lights affecting that mesh */
  79130. readonly lightSources: Light[];
  79131. _resyncLightSources(): void;
  79132. _resyncLighSource(light: Light): void;
  79133. _removeLightSource(light: Light): void;
  79134. /**
  79135. * If the source mesh receives shadows
  79136. */
  79137. readonly receiveShadows: boolean;
  79138. /**
  79139. * The material of the source mesh
  79140. */
  79141. readonly material: Nullable<Material>;
  79142. /**
  79143. * Visibility of the source mesh
  79144. */
  79145. readonly visibility: number;
  79146. /**
  79147. * Skeleton of the source mesh
  79148. */
  79149. readonly skeleton: Nullable<Skeleton>;
  79150. /**
  79151. * Rendering ground id of the source mesh
  79152. */
  79153. renderingGroupId: number;
  79154. /**
  79155. * Returns the total number of vertices (integer).
  79156. */
  79157. getTotalVertices(): number;
  79158. /**
  79159. * Returns a positive integer : the total number of indices in this mesh geometry.
  79160. * @returns the numner of indices or zero if the mesh has no geometry.
  79161. */
  79162. getTotalIndices(): number;
  79163. /**
  79164. * The source mesh of the instance
  79165. */
  79166. readonly sourceMesh: Mesh;
  79167. /**
  79168. * Is this node ready to be used/rendered
  79169. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  79170. * @return {boolean} is it ready
  79171. */
  79172. isReady(completeCheck?: boolean): boolean;
  79173. /**
  79174. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79175. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  79176. * @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.
  79177. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  79178. */
  79179. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  79180. /**
  79181. * Sets the vertex data of the mesh geometry for the requested `kind`.
  79182. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  79183. * The `data` are either a numeric array either a Float32Array.
  79184. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  79185. * 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).
  79186. * Note that a new underlying VertexBuffer object is created each call.
  79187. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  79188. *
  79189. * Possible `kind` values :
  79190. * - VertexBuffer.PositionKind
  79191. * - VertexBuffer.UVKind
  79192. * - VertexBuffer.UV2Kind
  79193. * - VertexBuffer.UV3Kind
  79194. * - VertexBuffer.UV4Kind
  79195. * - VertexBuffer.UV5Kind
  79196. * - VertexBuffer.UV6Kind
  79197. * - VertexBuffer.ColorKind
  79198. * - VertexBuffer.MatricesIndicesKind
  79199. * - VertexBuffer.MatricesIndicesExtraKind
  79200. * - VertexBuffer.MatricesWeightsKind
  79201. * - VertexBuffer.MatricesWeightsExtraKind
  79202. *
  79203. * Returns the Mesh.
  79204. */
  79205. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  79206. /**
  79207. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  79208. * If the mesh has no geometry, it is simply returned as it is.
  79209. * The `data` are either a numeric array either a Float32Array.
  79210. * No new underlying VertexBuffer object is created.
  79211. * 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.
  79212. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  79213. *
  79214. * Possible `kind` values :
  79215. * - VertexBuffer.PositionKind
  79216. * - VertexBuffer.UVKind
  79217. * - VertexBuffer.UV2Kind
  79218. * - VertexBuffer.UV3Kind
  79219. * - VertexBuffer.UV4Kind
  79220. * - VertexBuffer.UV5Kind
  79221. * - VertexBuffer.UV6Kind
  79222. * - VertexBuffer.ColorKind
  79223. * - VertexBuffer.MatricesIndicesKind
  79224. * - VertexBuffer.MatricesIndicesExtraKind
  79225. * - VertexBuffer.MatricesWeightsKind
  79226. * - VertexBuffer.MatricesWeightsExtraKind
  79227. *
  79228. * Returns the Mesh.
  79229. */
  79230. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  79231. /**
  79232. * Sets the mesh indices.
  79233. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  79234. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  79235. * This method creates a new index buffer each call.
  79236. * Returns the Mesh.
  79237. */
  79238. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  79239. /**
  79240. * Boolean : True if the mesh owns the requested kind of data.
  79241. */
  79242. isVerticesDataPresent(kind: string): boolean;
  79243. /**
  79244. * Returns an array of indices (IndicesArray).
  79245. */
  79246. getIndices(): Nullable<IndicesArray>;
  79247. readonly _positions: Nullable<Vector3[]>;
  79248. /**
  79249. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79250. * This means the mesh underlying bounding box and sphere are recomputed.
  79251. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79252. * @returns the current mesh
  79253. */
  79254. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  79255. /** @hidden */
  79256. _preActivate(): InstancedMesh;
  79257. /** @hidden */
  79258. _activate(renderId: number, intermediateRendering: boolean): boolean;
  79259. /** @hidden */
  79260. _postActivate(): void;
  79261. getWorldMatrix(): Matrix;
  79262. readonly isAnInstance: boolean;
  79263. /**
  79264. * Returns the current associated LOD AbstractMesh.
  79265. */
  79266. getLOD(camera: Camera): AbstractMesh;
  79267. /** @hidden */
  79268. _syncSubMeshes(): InstancedMesh;
  79269. /** @hidden */
  79270. _generatePointsArray(): boolean;
  79271. /**
  79272. * Creates a new InstancedMesh from the current mesh.
  79273. * - name (string) : the cloned mesh name
  79274. * - newParent (optional Node) : the optional Node to parent the clone to.
  79275. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  79276. *
  79277. * Returns the clone.
  79278. */
  79279. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  79280. /**
  79281. * Disposes the InstancedMesh.
  79282. * Returns nothing.
  79283. */
  79284. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79285. }
  79286. }
  79287. declare module BABYLON {
  79288. /**
  79289. * Defines the options associated with the creation of a shader material.
  79290. */
  79291. export interface IShaderMaterialOptions {
  79292. /**
  79293. * Does the material work in alpha blend mode
  79294. */
  79295. needAlphaBlending: boolean;
  79296. /**
  79297. * Does the material work in alpha test mode
  79298. */
  79299. needAlphaTesting: boolean;
  79300. /**
  79301. * The list of attribute names used in the shader
  79302. */
  79303. attributes: string[];
  79304. /**
  79305. * The list of unifrom names used in the shader
  79306. */
  79307. uniforms: string[];
  79308. /**
  79309. * The list of UBO names used in the shader
  79310. */
  79311. uniformBuffers: string[];
  79312. /**
  79313. * The list of sampler names used in the shader
  79314. */
  79315. samplers: string[];
  79316. /**
  79317. * The list of defines used in the shader
  79318. */
  79319. defines: string[];
  79320. }
  79321. /**
  79322. * 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.
  79323. *
  79324. * This returned material effects how the mesh will look based on the code in the shaders.
  79325. *
  79326. * @see http://doc.babylonjs.com/how_to/shader_material
  79327. */
  79328. export class ShaderMaterial extends Material {
  79329. private _shaderPath;
  79330. private _options;
  79331. private _textures;
  79332. private _textureArrays;
  79333. private _floats;
  79334. private _ints;
  79335. private _floatsArrays;
  79336. private _colors3;
  79337. private _colors3Arrays;
  79338. private _colors4;
  79339. private _vectors2;
  79340. private _vectors3;
  79341. private _vectors4;
  79342. private _matrices;
  79343. private _matrices3x3;
  79344. private _matrices2x2;
  79345. private _vectors2Arrays;
  79346. private _vectors3Arrays;
  79347. private _cachedWorldViewMatrix;
  79348. private _cachedWorldViewProjectionMatrix;
  79349. private _renderId;
  79350. /**
  79351. * Instantiate a new shader material.
  79352. * 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.
  79353. * This returned material effects how the mesh will look based on the code in the shaders.
  79354. * @see http://doc.babylonjs.com/how_to/shader_material
  79355. * @param name Define the name of the material in the scene
  79356. * @param scene Define the scene the material belongs to
  79357. * @param shaderPath Defines the route to the shader code in one of three ways:
  79358. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  79359. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  79360. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  79361. * @param options Define the options used to create the shader
  79362. */
  79363. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  79364. /**
  79365. * Gets the options used to compile the shader.
  79366. * They can be modified to trigger a new compilation
  79367. */
  79368. readonly options: IShaderMaterialOptions;
  79369. /**
  79370. * Gets the current class name of the material e.g. "ShaderMaterial"
  79371. * Mainly use in serialization.
  79372. * @returns the class name
  79373. */
  79374. getClassName(): string;
  79375. /**
  79376. * Specifies if the material will require alpha blending
  79377. * @returns a boolean specifying if alpha blending is needed
  79378. */
  79379. needAlphaBlending(): boolean;
  79380. /**
  79381. * Specifies if this material should be rendered in alpha test mode
  79382. * @returns a boolean specifying if an alpha test is needed.
  79383. */
  79384. needAlphaTesting(): boolean;
  79385. private _checkUniform;
  79386. /**
  79387. * Set a texture in the shader.
  79388. * @param name Define the name of the uniform samplers as defined in the shader
  79389. * @param texture Define the texture to bind to this sampler
  79390. * @return the material itself allowing "fluent" like uniform updates
  79391. */
  79392. setTexture(name: string, texture: Texture): ShaderMaterial;
  79393. /**
  79394. * Set a texture array in the shader.
  79395. * @param name Define the name of the uniform sampler array as defined in the shader
  79396. * @param textures Define the list of textures to bind to this sampler
  79397. * @return the material itself allowing "fluent" like uniform updates
  79398. */
  79399. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  79400. /**
  79401. * Set a float in the shader.
  79402. * @param name Define the name of the uniform as defined in the shader
  79403. * @param value Define the value to give to the uniform
  79404. * @return the material itself allowing "fluent" like uniform updates
  79405. */
  79406. setFloat(name: string, value: number): ShaderMaterial;
  79407. /**
  79408. * Set a int in the shader.
  79409. * @param name Define the name of the uniform as defined in the shader
  79410. * @param value Define the value to give to the uniform
  79411. * @return the material itself allowing "fluent" like uniform updates
  79412. */
  79413. setInt(name: string, value: number): ShaderMaterial;
  79414. /**
  79415. * Set an array of floats in the shader.
  79416. * @param name Define the name of the uniform as defined in the shader
  79417. * @param value Define the value to give to the uniform
  79418. * @return the material itself allowing "fluent" like uniform updates
  79419. */
  79420. setFloats(name: string, value: number[]): ShaderMaterial;
  79421. /**
  79422. * Set a vec3 in the shader from a Color3.
  79423. * @param name Define the name of the uniform as defined in the shader
  79424. * @param value Define the value to give to the uniform
  79425. * @return the material itself allowing "fluent" like uniform updates
  79426. */
  79427. setColor3(name: string, value: Color3): ShaderMaterial;
  79428. /**
  79429. * Set a vec3 array in the shader from a Color3 array.
  79430. * @param name Define the name of the uniform as defined in the shader
  79431. * @param value Define the value to give to the uniform
  79432. * @return the material itself allowing "fluent" like uniform updates
  79433. */
  79434. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  79435. /**
  79436. * Set a vec4 in the shader from a Color4.
  79437. * @param name Define the name of the uniform as defined in the shader
  79438. * @param value Define the value to give to the uniform
  79439. * @return the material itself allowing "fluent" like uniform updates
  79440. */
  79441. setColor4(name: string, value: Color4): ShaderMaterial;
  79442. /**
  79443. * Set a vec2 in the shader from a Vector2.
  79444. * @param name Define the name of the uniform as defined in the shader
  79445. * @param value Define the value to give to the uniform
  79446. * @return the material itself allowing "fluent" like uniform updates
  79447. */
  79448. setVector2(name: string, value: Vector2): ShaderMaterial;
  79449. /**
  79450. * Set a vec3 in the shader from a Vector3.
  79451. * @param name Define the name of the uniform as defined in the shader
  79452. * @param value Define the value to give to the uniform
  79453. * @return the material itself allowing "fluent" like uniform updates
  79454. */
  79455. setVector3(name: string, value: Vector3): ShaderMaterial;
  79456. /**
  79457. * Set a vec4 in the shader from a Vector4.
  79458. * @param name Define the name of the uniform as defined in the shader
  79459. * @param value Define the value to give to the uniform
  79460. * @return the material itself allowing "fluent" like uniform updates
  79461. */
  79462. setVector4(name: string, value: Vector4): ShaderMaterial;
  79463. /**
  79464. * Set a mat4 in the shader from a Matrix.
  79465. * @param name Define the name of the uniform as defined in the shader
  79466. * @param value Define the value to give to the uniform
  79467. * @return the material itself allowing "fluent" like uniform updates
  79468. */
  79469. setMatrix(name: string, value: Matrix): ShaderMaterial;
  79470. /**
  79471. * Set a mat3 in the shader from a Float32Array.
  79472. * @param name Define the name of the uniform as defined in the shader
  79473. * @param value Define the value to give to the uniform
  79474. * @return the material itself allowing "fluent" like uniform updates
  79475. */
  79476. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  79477. /**
  79478. * Set a mat2 in the shader from a Float32Array.
  79479. * @param name Define the name of the uniform as defined in the shader
  79480. * @param value Define the value to give to the uniform
  79481. * @return the material itself allowing "fluent" like uniform updates
  79482. */
  79483. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  79484. /**
  79485. * Set a vec2 array in the shader from a number array.
  79486. * @param name Define the name of the uniform as defined in the shader
  79487. * @param value Define the value to give to the uniform
  79488. * @return the material itself allowing "fluent" like uniform updates
  79489. */
  79490. setArray2(name: string, value: number[]): ShaderMaterial;
  79491. /**
  79492. * Set a vec3 array in the shader from a number array.
  79493. * @param name Define the name of the uniform as defined in the shader
  79494. * @param value Define the value to give to the uniform
  79495. * @return the material itself allowing "fluent" like uniform updates
  79496. */
  79497. setArray3(name: string, value: number[]): ShaderMaterial;
  79498. private _checkCache;
  79499. /**
  79500. * Specifies that the submesh is ready to be used
  79501. * @param mesh defines the mesh to check
  79502. * @param subMesh defines which submesh to check
  79503. * @param useInstances specifies that instances should be used
  79504. * @returns a boolean indicating that the submesh is ready or not
  79505. */
  79506. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  79507. /**
  79508. * Checks if the material is ready to render the requested mesh
  79509. * @param mesh Define the mesh to render
  79510. * @param useInstances Define whether or not the material is used with instances
  79511. * @returns true if ready, otherwise false
  79512. */
  79513. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  79514. /**
  79515. * Binds the world matrix to the material
  79516. * @param world defines the world transformation matrix
  79517. */
  79518. bindOnlyWorldMatrix(world: Matrix): void;
  79519. /**
  79520. * Binds the material to the mesh
  79521. * @param world defines the world transformation matrix
  79522. * @param mesh defines the mesh to bind the material to
  79523. */
  79524. bind(world: Matrix, mesh?: Mesh): void;
  79525. /**
  79526. * Gets the active textures from the material
  79527. * @returns an array of textures
  79528. */
  79529. getActiveTextures(): BaseTexture[];
  79530. /**
  79531. * Specifies if the material uses a texture
  79532. * @param texture defines the texture to check against the material
  79533. * @returns a boolean specifying if the material uses the texture
  79534. */
  79535. hasTexture(texture: BaseTexture): boolean;
  79536. /**
  79537. * Makes a duplicate of the material, and gives it a new name
  79538. * @param name defines the new name for the duplicated material
  79539. * @returns the cloned material
  79540. */
  79541. clone(name: string): ShaderMaterial;
  79542. /**
  79543. * Disposes the material
  79544. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79545. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  79546. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  79547. */
  79548. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  79549. /**
  79550. * Serializes this material in a JSON representation
  79551. * @returns the serialized material object
  79552. */
  79553. serialize(): any;
  79554. /**
  79555. * Creates a shader material from parsed shader material data
  79556. * @param source defines the JSON represnetation of the material
  79557. * @param scene defines the hosting scene
  79558. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  79559. * @returns a new material
  79560. */
  79561. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  79562. }
  79563. }
  79564. declare module BABYLON {
  79565. /** @hidden */
  79566. export var colorPixelShader: {
  79567. name: string;
  79568. shader: string;
  79569. };
  79570. }
  79571. declare module BABYLON {
  79572. /** @hidden */
  79573. export var colorVertexShader: {
  79574. name: string;
  79575. shader: string;
  79576. };
  79577. }
  79578. declare module BABYLON {
  79579. /**
  79580. * Line mesh
  79581. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  79582. */
  79583. export class LinesMesh extends Mesh {
  79584. /**
  79585. * If vertex color should be applied to the mesh
  79586. */
  79587. readonly useVertexColor?: boolean | undefined;
  79588. /**
  79589. * If vertex alpha should be applied to the mesh
  79590. */
  79591. readonly useVertexAlpha?: boolean | undefined;
  79592. /**
  79593. * Color of the line (Default: White)
  79594. */
  79595. color: Color3;
  79596. /**
  79597. * Alpha of the line (Default: 1)
  79598. */
  79599. alpha: number;
  79600. /**
  79601. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  79602. * This margin is expressed in world space coordinates, so its value may vary.
  79603. * Default value is 0.1
  79604. */
  79605. intersectionThreshold: number;
  79606. private _colorShader;
  79607. private color4;
  79608. /**
  79609. * Creates a new LinesMesh
  79610. * @param name defines the name
  79611. * @param scene defines the hosting scene
  79612. * @param parent defines the parent mesh if any
  79613. * @param source defines the optional source LinesMesh used to clone data from
  79614. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  79615. * When false, achieved by calling a clone(), also passing False.
  79616. * This will make creation of children, recursive.
  79617. * @param useVertexColor defines if this LinesMesh supports vertex color
  79618. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  79619. */
  79620. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  79621. /**
  79622. * If vertex color should be applied to the mesh
  79623. */
  79624. useVertexColor?: boolean | undefined,
  79625. /**
  79626. * If vertex alpha should be applied to the mesh
  79627. */
  79628. useVertexAlpha?: boolean | undefined);
  79629. private _addClipPlaneDefine;
  79630. private _removeClipPlaneDefine;
  79631. isReady(): boolean;
  79632. /**
  79633. * Returns the string "LineMesh"
  79634. */
  79635. getClassName(): string;
  79636. /**
  79637. * @hidden
  79638. */
  79639. /**
  79640. * @hidden
  79641. */
  79642. material: Material;
  79643. /**
  79644. * @hidden
  79645. */
  79646. readonly checkCollisions: boolean;
  79647. /** @hidden */
  79648. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  79649. /** @hidden */
  79650. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  79651. /**
  79652. * Disposes of the line mesh
  79653. * @param doNotRecurse If children should be disposed
  79654. */
  79655. dispose(doNotRecurse?: boolean): void;
  79656. /**
  79657. * Returns a new LineMesh object cloned from the current one.
  79658. */
  79659. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  79660. /**
  79661. * Creates a new InstancedLinesMesh object from the mesh model.
  79662. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79663. * @param name defines the name of the new instance
  79664. * @returns a new InstancedLinesMesh
  79665. */
  79666. createInstance(name: string): InstancedLinesMesh;
  79667. }
  79668. /**
  79669. * Creates an instance based on a source LinesMesh
  79670. */
  79671. export class InstancedLinesMesh extends InstancedMesh {
  79672. /**
  79673. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  79674. * This margin is expressed in world space coordinates, so its value may vary.
  79675. * Initilized with the intersectionThreshold value of the source LinesMesh
  79676. */
  79677. intersectionThreshold: number;
  79678. constructor(name: string, source: LinesMesh);
  79679. /**
  79680. * Returns the string "InstancedLinesMesh".
  79681. */
  79682. getClassName(): string;
  79683. }
  79684. }
  79685. declare module BABYLON {
  79686. /** @hidden */
  79687. export var linePixelShader: {
  79688. name: string;
  79689. shader: string;
  79690. };
  79691. }
  79692. declare module BABYLON {
  79693. /** @hidden */
  79694. export var lineVertexShader: {
  79695. name: string;
  79696. shader: string;
  79697. };
  79698. }
  79699. declare module BABYLON {
  79700. interface AbstractMesh {
  79701. /**
  79702. * Gets the edgesRenderer associated with the mesh
  79703. */
  79704. edgesRenderer: Nullable<EdgesRenderer>;
  79705. }
  79706. interface LinesMesh {
  79707. /**
  79708. * Enables the edge rendering mode on the mesh.
  79709. * This mode makes the mesh edges visible
  79710. * @param epsilon defines the maximal distance between two angles to detect a face
  79711. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  79712. * @returns the currentAbstractMesh
  79713. * @see https://www.babylonjs-playground.com/#19O9TU#0
  79714. */
  79715. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  79716. }
  79717. interface InstancedLinesMesh {
  79718. /**
  79719. * Enables the edge rendering mode on the mesh.
  79720. * This mode makes the mesh edges visible
  79721. * @param epsilon defines the maximal distance between two angles to detect a face
  79722. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  79723. * @returns the current InstancedLinesMesh
  79724. * @see https://www.babylonjs-playground.com/#19O9TU#0
  79725. */
  79726. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  79727. }
  79728. /**
  79729. * Defines the minimum contract an Edges renderer should follow.
  79730. */
  79731. export interface IEdgesRenderer extends IDisposable {
  79732. /**
  79733. * Gets or sets a boolean indicating if the edgesRenderer is active
  79734. */
  79735. isEnabled: boolean;
  79736. /**
  79737. * Renders the edges of the attached mesh,
  79738. */
  79739. render(): void;
  79740. /**
  79741. * Checks wether or not the edges renderer is ready to render.
  79742. * @return true if ready, otherwise false.
  79743. */
  79744. isReady(): boolean;
  79745. }
  79746. /**
  79747. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  79748. */
  79749. export class EdgesRenderer implements IEdgesRenderer {
  79750. /**
  79751. * Define the size of the edges with an orthographic camera
  79752. */
  79753. edgesWidthScalerForOrthographic: number;
  79754. /**
  79755. * Define the size of the edges with a perspective camera
  79756. */
  79757. edgesWidthScalerForPerspective: number;
  79758. protected _source: AbstractMesh;
  79759. protected _linesPositions: number[];
  79760. protected _linesNormals: number[];
  79761. protected _linesIndices: number[];
  79762. protected _epsilon: number;
  79763. protected _indicesCount: number;
  79764. protected _lineShader: ShaderMaterial;
  79765. protected _ib: DataBuffer;
  79766. protected _buffers: {
  79767. [key: string]: Nullable<VertexBuffer>;
  79768. };
  79769. protected _checkVerticesInsteadOfIndices: boolean;
  79770. private _meshRebuildObserver;
  79771. private _meshDisposeObserver;
  79772. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  79773. isEnabled: boolean;
  79774. /**
  79775. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  79776. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  79777. * @param source Mesh used to create edges
  79778. * @param epsilon sum of angles in adjacency to check for edge
  79779. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  79780. * @param generateEdgesLines - should generate Lines or only prepare resources.
  79781. */
  79782. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  79783. protected _prepareRessources(): void;
  79784. /** @hidden */
  79785. _rebuild(): void;
  79786. /**
  79787. * Releases the required resources for the edges renderer
  79788. */
  79789. dispose(): void;
  79790. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  79791. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  79792. /**
  79793. * Checks if the pair of p0 and p1 is en edge
  79794. * @param faceIndex
  79795. * @param edge
  79796. * @param faceNormals
  79797. * @param p0
  79798. * @param p1
  79799. * @private
  79800. */
  79801. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  79802. /**
  79803. * push line into the position, normal and index buffer
  79804. * @protected
  79805. */
  79806. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  79807. /**
  79808. * Generates lines edges from adjacencjes
  79809. * @private
  79810. */
  79811. _generateEdgesLines(): void;
  79812. /**
  79813. * Checks wether or not the edges renderer is ready to render.
  79814. * @return true if ready, otherwise false.
  79815. */
  79816. isReady(): boolean;
  79817. /**
  79818. * Renders the edges of the attached mesh,
  79819. */
  79820. render(): void;
  79821. }
  79822. /**
  79823. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  79824. */
  79825. export class LineEdgesRenderer extends EdgesRenderer {
  79826. /**
  79827. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  79828. * @param source LineMesh used to generate edges
  79829. * @param epsilon not important (specified angle for edge detection)
  79830. * @param checkVerticesInsteadOfIndices not important for LineMesh
  79831. */
  79832. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  79833. /**
  79834. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  79835. */
  79836. _generateEdgesLines(): void;
  79837. }
  79838. }
  79839. declare module BABYLON {
  79840. /**
  79841. * This represents the object necessary to create a rendering group.
  79842. * This is exclusively used and created by the rendering manager.
  79843. * To modify the behavior, you use the available helpers in your scene or meshes.
  79844. * @hidden
  79845. */
  79846. export class RenderingGroup {
  79847. index: number;
  79848. private static _zeroVector;
  79849. private _scene;
  79850. private _opaqueSubMeshes;
  79851. private _transparentSubMeshes;
  79852. private _alphaTestSubMeshes;
  79853. private _depthOnlySubMeshes;
  79854. private _particleSystems;
  79855. private _spriteManagers;
  79856. private _opaqueSortCompareFn;
  79857. private _alphaTestSortCompareFn;
  79858. private _transparentSortCompareFn;
  79859. private _renderOpaque;
  79860. private _renderAlphaTest;
  79861. private _renderTransparent;
  79862. /** @hidden */
  79863. _edgesRenderers: SmartArray<IEdgesRenderer>;
  79864. onBeforeTransparentRendering: () => void;
  79865. /**
  79866. * Set the opaque sort comparison function.
  79867. * If null the sub meshes will be render in the order they were created
  79868. */
  79869. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  79870. /**
  79871. * Set the alpha test sort comparison function.
  79872. * If null the sub meshes will be render in the order they were created
  79873. */
  79874. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  79875. /**
  79876. * Set the transparent sort comparison function.
  79877. * If null the sub meshes will be render in the order they were created
  79878. */
  79879. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  79880. /**
  79881. * Creates a new rendering group.
  79882. * @param index The rendering group index
  79883. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  79884. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  79885. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  79886. */
  79887. 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>);
  79888. /**
  79889. * Render all the sub meshes contained in the group.
  79890. * @param customRenderFunction Used to override the default render behaviour of the group.
  79891. * @returns true if rendered some submeshes.
  79892. */
  79893. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  79894. /**
  79895. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  79896. * @param subMeshes The submeshes to render
  79897. */
  79898. private renderOpaqueSorted;
  79899. /**
  79900. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  79901. * @param subMeshes The submeshes to render
  79902. */
  79903. private renderAlphaTestSorted;
  79904. /**
  79905. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  79906. * @param subMeshes The submeshes to render
  79907. */
  79908. private renderTransparentSorted;
  79909. /**
  79910. * Renders the submeshes in a specified order.
  79911. * @param subMeshes The submeshes to sort before render
  79912. * @param sortCompareFn The comparison function use to sort
  79913. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  79914. * @param transparent Specifies to activate blending if true
  79915. */
  79916. private static renderSorted;
  79917. /**
  79918. * Renders the submeshes in the order they were dispatched (no sort applied).
  79919. * @param subMeshes The submeshes to render
  79920. */
  79921. private static renderUnsorted;
  79922. /**
  79923. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  79924. * are rendered back to front if in the same alpha index.
  79925. *
  79926. * @param a The first submesh
  79927. * @param b The second submesh
  79928. * @returns The result of the comparison
  79929. */
  79930. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  79931. /**
  79932. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  79933. * are rendered back to front.
  79934. *
  79935. * @param a The first submesh
  79936. * @param b The second submesh
  79937. * @returns The result of the comparison
  79938. */
  79939. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  79940. /**
  79941. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  79942. * are rendered front to back (prevent overdraw).
  79943. *
  79944. * @param a The first submesh
  79945. * @param b The second submesh
  79946. * @returns The result of the comparison
  79947. */
  79948. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  79949. /**
  79950. * Resets the different lists of submeshes to prepare a new frame.
  79951. */
  79952. prepare(): void;
  79953. dispose(): void;
  79954. /**
  79955. * Inserts the submesh in its correct queue depending on its material.
  79956. * @param subMesh The submesh to dispatch
  79957. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  79958. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  79959. */
  79960. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  79961. dispatchSprites(spriteManager: ISpriteManager): void;
  79962. dispatchParticles(particleSystem: IParticleSystem): void;
  79963. private _renderParticles;
  79964. private _renderSprites;
  79965. }
  79966. }
  79967. declare module BABYLON {
  79968. /**
  79969. * Interface describing the different options available in the rendering manager
  79970. * regarding Auto Clear between groups.
  79971. */
  79972. export interface IRenderingManagerAutoClearSetup {
  79973. /**
  79974. * Defines whether or not autoclear is enable.
  79975. */
  79976. autoClear: boolean;
  79977. /**
  79978. * Defines whether or not to autoclear the depth buffer.
  79979. */
  79980. depth: boolean;
  79981. /**
  79982. * Defines whether or not to autoclear the stencil buffer.
  79983. */
  79984. stencil: boolean;
  79985. }
  79986. /**
  79987. * This class is used by the onRenderingGroupObservable
  79988. */
  79989. export class RenderingGroupInfo {
  79990. /**
  79991. * The Scene that being rendered
  79992. */
  79993. scene: Scene;
  79994. /**
  79995. * The camera currently used for the rendering pass
  79996. */
  79997. camera: Nullable<Camera>;
  79998. /**
  79999. * The ID of the renderingGroup being processed
  80000. */
  80001. renderingGroupId: number;
  80002. }
  80003. /**
  80004. * This is the manager responsible of all the rendering for meshes sprites and particles.
  80005. * It is enable to manage the different groups as well as the different necessary sort functions.
  80006. * This should not be used directly aside of the few static configurations
  80007. */
  80008. export class RenderingManager {
  80009. /**
  80010. * The max id used for rendering groups (not included)
  80011. */
  80012. static MAX_RENDERINGGROUPS: number;
  80013. /**
  80014. * The min id used for rendering groups (included)
  80015. */
  80016. static MIN_RENDERINGGROUPS: number;
  80017. /**
  80018. * Used to globally prevent autoclearing scenes.
  80019. */
  80020. static AUTOCLEAR: boolean;
  80021. /**
  80022. * @hidden
  80023. */
  80024. _useSceneAutoClearSetup: boolean;
  80025. private _scene;
  80026. private _renderingGroups;
  80027. private _depthStencilBufferAlreadyCleaned;
  80028. private _autoClearDepthStencil;
  80029. private _customOpaqueSortCompareFn;
  80030. private _customAlphaTestSortCompareFn;
  80031. private _customTransparentSortCompareFn;
  80032. private _renderingGroupInfo;
  80033. /**
  80034. * Instantiates a new rendering group for a particular scene
  80035. * @param scene Defines the scene the groups belongs to
  80036. */
  80037. constructor(scene: Scene);
  80038. private _clearDepthStencilBuffer;
  80039. /**
  80040. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  80041. * @hidden
  80042. */
  80043. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  80044. /**
  80045. * Resets the different information of the group to prepare a new frame
  80046. * @hidden
  80047. */
  80048. reset(): void;
  80049. /**
  80050. * Dispose and release the group and its associated resources.
  80051. * @hidden
  80052. */
  80053. dispose(): void;
  80054. /**
  80055. * Clear the info related to rendering groups preventing retention points during dispose.
  80056. */
  80057. freeRenderingGroups(): void;
  80058. private _prepareRenderingGroup;
  80059. /**
  80060. * Add a sprite manager to the rendering manager in order to render it this frame.
  80061. * @param spriteManager Define the sprite manager to render
  80062. */
  80063. dispatchSprites(spriteManager: ISpriteManager): void;
  80064. /**
  80065. * Add a particle system to the rendering manager in order to render it this frame.
  80066. * @param particleSystem Define the particle system to render
  80067. */
  80068. dispatchParticles(particleSystem: IParticleSystem): void;
  80069. /**
  80070. * Add a submesh to the manager in order to render it this frame
  80071. * @param subMesh The submesh to dispatch
  80072. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  80073. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  80074. */
  80075. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  80076. /**
  80077. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  80078. * This allowed control for front to back rendering or reversly depending of the special needs.
  80079. *
  80080. * @param renderingGroupId The rendering group id corresponding to its index
  80081. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  80082. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  80083. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  80084. */
  80085. 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;
  80086. /**
  80087. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  80088. *
  80089. * @param renderingGroupId The rendering group id corresponding to its index
  80090. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  80091. * @param depth Automatically clears depth between groups if true and autoClear is true.
  80092. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  80093. */
  80094. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  80095. /**
  80096. * Gets the current auto clear configuration for one rendering group of the rendering
  80097. * manager.
  80098. * @param index the rendering group index to get the information for
  80099. * @returns The auto clear setup for the requested rendering group
  80100. */
  80101. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  80102. }
  80103. }
  80104. declare module BABYLON {
  80105. /**
  80106. * This Helps creating a texture that will be created from a camera in your scene.
  80107. * It is basically a dynamic texture that could be used to create special effects for instance.
  80108. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  80109. */
  80110. export class RenderTargetTexture extends Texture {
  80111. isCube: boolean;
  80112. /**
  80113. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  80114. */
  80115. static readonly REFRESHRATE_RENDER_ONCE: number;
  80116. /**
  80117. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  80118. */
  80119. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  80120. /**
  80121. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  80122. * the central point of your effect and can save a lot of performances.
  80123. */
  80124. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  80125. /**
  80126. * Use this predicate to dynamically define the list of mesh you want to render.
  80127. * If set, the renderList property will be overwritten.
  80128. */
  80129. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  80130. private _renderList;
  80131. /**
  80132. * Use this list to define the list of mesh you want to render.
  80133. */
  80134. renderList: Nullable<Array<AbstractMesh>>;
  80135. private _hookArray;
  80136. /**
  80137. * Define if particles should be rendered in your texture.
  80138. */
  80139. renderParticles: boolean;
  80140. /**
  80141. * Define if sprites should be rendered in your texture.
  80142. */
  80143. renderSprites: boolean;
  80144. /**
  80145. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  80146. */
  80147. coordinatesMode: number;
  80148. /**
  80149. * Define the camera used to render the texture.
  80150. */
  80151. activeCamera: Nullable<Camera>;
  80152. /**
  80153. * Override the render function of the texture with your own one.
  80154. */
  80155. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  80156. /**
  80157. * Define if camera post processes should be use while rendering the texture.
  80158. */
  80159. useCameraPostProcesses: boolean;
  80160. /**
  80161. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  80162. */
  80163. ignoreCameraViewport: boolean;
  80164. private _postProcessManager;
  80165. private _postProcesses;
  80166. private _resizeObserver;
  80167. /**
  80168. * An event triggered when the texture is unbind.
  80169. */
  80170. onBeforeBindObservable: Observable<RenderTargetTexture>;
  80171. /**
  80172. * An event triggered when the texture is unbind.
  80173. */
  80174. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  80175. private _onAfterUnbindObserver;
  80176. /**
  80177. * Set a after unbind callback in the texture.
  80178. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  80179. */
  80180. onAfterUnbind: () => void;
  80181. /**
  80182. * An event triggered before rendering the texture
  80183. */
  80184. onBeforeRenderObservable: Observable<number>;
  80185. private _onBeforeRenderObserver;
  80186. /**
  80187. * Set a before render callback in the texture.
  80188. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  80189. */
  80190. onBeforeRender: (faceIndex: number) => void;
  80191. /**
  80192. * An event triggered after rendering the texture
  80193. */
  80194. onAfterRenderObservable: Observable<number>;
  80195. private _onAfterRenderObserver;
  80196. /**
  80197. * Set a after render callback in the texture.
  80198. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  80199. */
  80200. onAfterRender: (faceIndex: number) => void;
  80201. /**
  80202. * An event triggered after the texture clear
  80203. */
  80204. onClearObservable: Observable<Engine>;
  80205. private _onClearObserver;
  80206. /**
  80207. * Set a clear callback in the texture.
  80208. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  80209. */
  80210. onClear: (Engine: Engine) => void;
  80211. /**
  80212. * Define the clear color of the Render Target if it should be different from the scene.
  80213. */
  80214. clearColor: Color4;
  80215. protected _size: number | {
  80216. width: number;
  80217. height: number;
  80218. };
  80219. protected _initialSizeParameter: number | {
  80220. width: number;
  80221. height: number;
  80222. } | {
  80223. ratio: number;
  80224. };
  80225. protected _sizeRatio: Nullable<number>;
  80226. /** @hidden */
  80227. _generateMipMaps: boolean;
  80228. protected _renderingManager: RenderingManager;
  80229. /** @hidden */
  80230. _waitingRenderList: string[];
  80231. protected _doNotChangeAspectRatio: boolean;
  80232. protected _currentRefreshId: number;
  80233. protected _refreshRate: number;
  80234. protected _textureMatrix: Matrix;
  80235. protected _samples: number;
  80236. protected _renderTargetOptions: RenderTargetCreationOptions;
  80237. /**
  80238. * Gets render target creation options that were used.
  80239. */
  80240. readonly renderTargetOptions: RenderTargetCreationOptions;
  80241. protected _engine: Engine;
  80242. protected _onRatioRescale(): void;
  80243. /**
  80244. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  80245. * It must define where the camera used to render the texture is set
  80246. */
  80247. boundingBoxPosition: Vector3;
  80248. private _boundingBoxSize;
  80249. /**
  80250. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  80251. * When defined, the cubemap will switch to local mode
  80252. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80253. * @example https://www.babylonjs-playground.com/#RNASML
  80254. */
  80255. boundingBoxSize: Vector3;
  80256. /**
  80257. * In case the RTT has been created with a depth texture, get the associated
  80258. * depth texture.
  80259. * Otherwise, return null.
  80260. */
  80261. depthStencilTexture: Nullable<InternalTexture>;
  80262. /**
  80263. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  80264. * or used a shadow, depth texture...
  80265. * @param name The friendly name of the texture
  80266. * @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)
  80267. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  80268. * @param generateMipMaps True if mip maps need to be generated after render.
  80269. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  80270. * @param type The type of the buffer in the RTT (int, half float, float...)
  80271. * @param isCube True if a cube texture needs to be created
  80272. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  80273. * @param generateDepthBuffer True to generate a depth buffer
  80274. * @param generateStencilBuffer True to generate a stencil buffer
  80275. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  80276. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  80277. * @param delayAllocation if the texture allocation should be delayed (default: false)
  80278. */
  80279. constructor(name: string, size: number | {
  80280. width: number;
  80281. height: number;
  80282. } | {
  80283. ratio: number;
  80284. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  80285. /**
  80286. * Creates a depth stencil texture.
  80287. * This is only available in WebGL 2 or with the depth texture extension available.
  80288. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  80289. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  80290. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  80291. */
  80292. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  80293. private _processSizeParameter;
  80294. /**
  80295. * Define the number of samples to use in case of MSAA.
  80296. * It defaults to one meaning no MSAA has been enabled.
  80297. */
  80298. samples: number;
  80299. /**
  80300. * Resets the refresh counter of the texture and start bak from scratch.
  80301. * Could be useful to regenerate the texture if it is setup to render only once.
  80302. */
  80303. resetRefreshCounter(): void;
  80304. /**
  80305. * Define the refresh rate of the texture or the rendering frequency.
  80306. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  80307. */
  80308. refreshRate: number;
  80309. /**
  80310. * Adds a post process to the render target rendering passes.
  80311. * @param postProcess define the post process to add
  80312. */
  80313. addPostProcess(postProcess: PostProcess): void;
  80314. /**
  80315. * Clear all the post processes attached to the render target
  80316. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  80317. */
  80318. clearPostProcesses(dispose?: boolean): void;
  80319. /**
  80320. * Remove one of the post process from the list of attached post processes to the texture
  80321. * @param postProcess define the post process to remove from the list
  80322. */
  80323. removePostProcess(postProcess: PostProcess): void;
  80324. /** @hidden */
  80325. _shouldRender(): boolean;
  80326. /**
  80327. * Gets the actual render size of the texture.
  80328. * @returns the width of the render size
  80329. */
  80330. getRenderSize(): number;
  80331. /**
  80332. * Gets the actual render width of the texture.
  80333. * @returns the width of the render size
  80334. */
  80335. getRenderWidth(): number;
  80336. /**
  80337. * Gets the actual render height of the texture.
  80338. * @returns the height of the render size
  80339. */
  80340. getRenderHeight(): number;
  80341. /**
  80342. * Get if the texture can be rescaled or not.
  80343. */
  80344. readonly canRescale: boolean;
  80345. /**
  80346. * Resize the texture using a ratio.
  80347. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  80348. */
  80349. scale(ratio: number): void;
  80350. /**
  80351. * Get the texture reflection matrix used to rotate/transform the reflection.
  80352. * @returns the reflection matrix
  80353. */
  80354. getReflectionTextureMatrix(): Matrix;
  80355. /**
  80356. * Resize the texture to a new desired size.
  80357. * Be carrefull as it will recreate all the data in the new texture.
  80358. * @param size Define the new size. It can be:
  80359. * - a number for squared texture,
  80360. * - an object containing { width: number, height: number }
  80361. * - or an object containing a ratio { ratio: number }
  80362. */
  80363. resize(size: number | {
  80364. width: number;
  80365. height: number;
  80366. } | {
  80367. ratio: number;
  80368. }): void;
  80369. /**
  80370. * Renders all the objects from the render list into the texture.
  80371. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  80372. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  80373. */
  80374. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  80375. private _bestReflectionRenderTargetDimension;
  80376. /**
  80377. * @hidden
  80378. * @param faceIndex face index to bind to if this is a cubetexture
  80379. */
  80380. _bindFrameBuffer(faceIndex?: number): void;
  80381. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  80382. private renderToTarget;
  80383. /**
  80384. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  80385. * This allowed control for front to back rendering or reversly depending of the special needs.
  80386. *
  80387. * @param renderingGroupId The rendering group id corresponding to its index
  80388. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  80389. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  80390. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  80391. */
  80392. 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;
  80393. /**
  80394. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  80395. *
  80396. * @param renderingGroupId The rendering group id corresponding to its index
  80397. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  80398. */
  80399. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  80400. /**
  80401. * Clones the texture.
  80402. * @returns the cloned texture
  80403. */
  80404. clone(): RenderTargetTexture;
  80405. /**
  80406. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  80407. * @returns The JSON representation of the texture
  80408. */
  80409. serialize(): any;
  80410. /**
  80411. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  80412. */
  80413. disposeFramebufferObjects(): void;
  80414. /**
  80415. * Dispose the texture and release its associated resources.
  80416. */
  80417. dispose(): void;
  80418. /** @hidden */
  80419. _rebuild(): void;
  80420. /**
  80421. * Clear the info related to rendering groups preventing retention point in material dispose.
  80422. */
  80423. freeRenderingGroups(): void;
  80424. /**
  80425. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80426. * @returns the view count
  80427. */
  80428. getViewCount(): number;
  80429. }
  80430. }
  80431. declare module BABYLON {
  80432. /**
  80433. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80434. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80435. * You can then easily use it as a reflectionTexture on a flat surface.
  80436. * In case the surface is not a plane, please consider relying on reflection probes.
  80437. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80438. */
  80439. export class MirrorTexture extends RenderTargetTexture {
  80440. private scene;
  80441. /**
  80442. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  80443. * 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.
  80444. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80445. */
  80446. mirrorPlane: Plane;
  80447. /**
  80448. * Define the blur ratio used to blur the reflection if needed.
  80449. */
  80450. blurRatio: number;
  80451. /**
  80452. * Define the adaptive blur kernel used to blur the reflection if needed.
  80453. * This will autocompute the closest best match for the `blurKernel`
  80454. */
  80455. adaptiveBlurKernel: number;
  80456. /**
  80457. * Define the blur kernel used to blur the reflection if needed.
  80458. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80459. */
  80460. blurKernel: number;
  80461. /**
  80462. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  80463. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80464. */
  80465. blurKernelX: number;
  80466. /**
  80467. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  80468. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80469. */
  80470. blurKernelY: number;
  80471. private _autoComputeBlurKernel;
  80472. protected _onRatioRescale(): void;
  80473. private _updateGammaSpace;
  80474. private _imageProcessingConfigChangeObserver;
  80475. private _transformMatrix;
  80476. private _mirrorMatrix;
  80477. private _savedViewMatrix;
  80478. private _blurX;
  80479. private _blurY;
  80480. private _adaptiveBlurKernel;
  80481. private _blurKernelX;
  80482. private _blurKernelY;
  80483. private _blurRatio;
  80484. /**
  80485. * Instantiates a Mirror Texture.
  80486. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80487. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80488. * You can then easily use it as a reflectionTexture on a flat surface.
  80489. * In case the surface is not a plane, please consider relying on reflection probes.
  80490. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80491. * @param name
  80492. * @param size
  80493. * @param scene
  80494. * @param generateMipMaps
  80495. * @param type
  80496. * @param samplingMode
  80497. * @param generateDepthBuffer
  80498. */
  80499. constructor(name: string, size: number | {
  80500. width: number;
  80501. height: number;
  80502. } | {
  80503. ratio: number;
  80504. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  80505. private _preparePostProcesses;
  80506. /**
  80507. * Clone the mirror texture.
  80508. * @returns the cloned texture
  80509. */
  80510. clone(): MirrorTexture;
  80511. /**
  80512. * Serialize the texture to a JSON representation you could use in Parse later on
  80513. * @returns the serialized JSON representation
  80514. */
  80515. serialize(): any;
  80516. /**
  80517. * Dispose the texture and release its associated resources.
  80518. */
  80519. dispose(): void;
  80520. }
  80521. }
  80522. declare module BABYLON {
  80523. /**
  80524. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80525. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80526. */
  80527. export class Texture extends BaseTexture {
  80528. /** @hidden */
  80529. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  80530. /** @hidden */
  80531. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  80532. /** @hidden */
  80533. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  80534. /** nearest is mag = nearest and min = nearest and mip = linear */
  80535. static readonly NEAREST_SAMPLINGMODE: number;
  80536. /** nearest is mag = nearest and min = nearest and mip = linear */
  80537. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  80538. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80539. static readonly BILINEAR_SAMPLINGMODE: number;
  80540. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80541. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  80542. /** Trilinear is mag = linear and min = linear and mip = linear */
  80543. static readonly TRILINEAR_SAMPLINGMODE: number;
  80544. /** Trilinear is mag = linear and min = linear and mip = linear */
  80545. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  80546. /** mag = nearest and min = nearest and mip = nearest */
  80547. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  80548. /** mag = nearest and min = linear and mip = nearest */
  80549. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  80550. /** mag = nearest and min = linear and mip = linear */
  80551. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  80552. /** mag = nearest and min = linear and mip = none */
  80553. static readonly NEAREST_LINEAR: number;
  80554. /** mag = nearest and min = nearest and mip = none */
  80555. static readonly NEAREST_NEAREST: number;
  80556. /** mag = linear and min = nearest and mip = nearest */
  80557. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  80558. /** mag = linear and min = nearest and mip = linear */
  80559. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  80560. /** mag = linear and min = linear and mip = none */
  80561. static readonly LINEAR_LINEAR: number;
  80562. /** mag = linear and min = nearest and mip = none */
  80563. static readonly LINEAR_NEAREST: number;
  80564. /** Explicit coordinates mode */
  80565. static readonly EXPLICIT_MODE: number;
  80566. /** Spherical coordinates mode */
  80567. static readonly SPHERICAL_MODE: number;
  80568. /** Planar coordinates mode */
  80569. static readonly PLANAR_MODE: number;
  80570. /** Cubic coordinates mode */
  80571. static readonly CUBIC_MODE: number;
  80572. /** Projection coordinates mode */
  80573. static readonly PROJECTION_MODE: number;
  80574. /** Inverse Cubic coordinates mode */
  80575. static readonly SKYBOX_MODE: number;
  80576. /** Inverse Cubic coordinates mode */
  80577. static readonly INVCUBIC_MODE: number;
  80578. /** Equirectangular coordinates mode */
  80579. static readonly EQUIRECTANGULAR_MODE: number;
  80580. /** Equirectangular Fixed coordinates mode */
  80581. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  80582. /** Equirectangular Fixed Mirrored coordinates mode */
  80583. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80584. /** Texture is not repeating outside of 0..1 UVs */
  80585. static readonly CLAMP_ADDRESSMODE: number;
  80586. /** Texture is repeating outside of 0..1 UVs */
  80587. static readonly WRAP_ADDRESSMODE: number;
  80588. /** Texture is repeating and mirrored */
  80589. static readonly MIRROR_ADDRESSMODE: number;
  80590. /**
  80591. * 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
  80592. */
  80593. static UseSerializedUrlIfAny: boolean;
  80594. /**
  80595. * Define the url of the texture.
  80596. */
  80597. url: Nullable<string>;
  80598. /**
  80599. * Define an offset on the texture to offset the u coordinates of the UVs
  80600. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80601. */
  80602. uOffset: number;
  80603. /**
  80604. * Define an offset on the texture to offset the v coordinates of the UVs
  80605. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80606. */
  80607. vOffset: number;
  80608. /**
  80609. * Define an offset on the texture to scale the u coordinates of the UVs
  80610. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80611. */
  80612. uScale: number;
  80613. /**
  80614. * Define an offset on the texture to scale the v coordinates of the UVs
  80615. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80616. */
  80617. vScale: number;
  80618. /**
  80619. * Define an offset on the texture to rotate around the u coordinates of the UVs
  80620. * @see http://doc.babylonjs.com/how_to/more_materials
  80621. */
  80622. uAng: number;
  80623. /**
  80624. * Define an offset on the texture to rotate around the v coordinates of the UVs
  80625. * @see http://doc.babylonjs.com/how_to/more_materials
  80626. */
  80627. vAng: number;
  80628. /**
  80629. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  80630. * @see http://doc.babylonjs.com/how_to/more_materials
  80631. */
  80632. wAng: number;
  80633. /**
  80634. * Defines the center of rotation (U)
  80635. */
  80636. uRotationCenter: number;
  80637. /**
  80638. * Defines the center of rotation (V)
  80639. */
  80640. vRotationCenter: number;
  80641. /**
  80642. * Defines the center of rotation (W)
  80643. */
  80644. wRotationCenter: number;
  80645. /**
  80646. * Are mip maps generated for this texture or not.
  80647. */
  80648. readonly noMipmap: boolean;
  80649. /**
  80650. * List of inspectable custom properties (used by the Inspector)
  80651. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80652. */
  80653. inspectableCustomProperties: Nullable<IInspectable[]>;
  80654. private _noMipmap;
  80655. /** @hidden */
  80656. _invertY: boolean;
  80657. private _rowGenerationMatrix;
  80658. private _cachedTextureMatrix;
  80659. private _projectionModeMatrix;
  80660. private _t0;
  80661. private _t1;
  80662. private _t2;
  80663. private _cachedUOffset;
  80664. private _cachedVOffset;
  80665. private _cachedUScale;
  80666. private _cachedVScale;
  80667. private _cachedUAng;
  80668. private _cachedVAng;
  80669. private _cachedWAng;
  80670. private _cachedProjectionMatrixId;
  80671. private _cachedCoordinatesMode;
  80672. /** @hidden */
  80673. protected _initialSamplingMode: number;
  80674. /** @hidden */
  80675. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  80676. private _deleteBuffer;
  80677. protected _format: Nullable<number>;
  80678. private _delayedOnLoad;
  80679. private _delayedOnError;
  80680. /**
  80681. * Observable triggered once the texture has been loaded.
  80682. */
  80683. onLoadObservable: Observable<Texture>;
  80684. protected _isBlocking: boolean;
  80685. /**
  80686. * Is the texture preventing material to render while loading.
  80687. * If false, a default texture will be used instead of the loading one during the preparation step.
  80688. */
  80689. isBlocking: boolean;
  80690. /**
  80691. * Get the current sampling mode associated with the texture.
  80692. */
  80693. readonly samplingMode: number;
  80694. /**
  80695. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  80696. */
  80697. readonly invertY: boolean;
  80698. /**
  80699. * Instantiates a new texture.
  80700. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80701. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80702. * @param url define the url of the picture to load as a texture
  80703. * @param scene define the scene the texture will belong to
  80704. * @param noMipmap define if the texture will require mip maps or not
  80705. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80706. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80707. * @param onLoad define a callback triggered when the texture has been loaded
  80708. * @param onError define a callback triggered when an error occurred during the loading session
  80709. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80710. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80711. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80712. */
  80713. 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);
  80714. /**
  80715. * Update the url (and optional buffer) of this texture if url was null during construction.
  80716. * @param url the url of the texture
  80717. * @param buffer the buffer of the texture (defaults to null)
  80718. * @param onLoad callback called when the texture is loaded (defaults to null)
  80719. */
  80720. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  80721. /**
  80722. * Finish the loading sequence of a texture flagged as delayed load.
  80723. * @hidden
  80724. */
  80725. delayLoad(): void;
  80726. private _prepareRowForTextureGeneration;
  80727. /**
  80728. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  80729. * @returns the transform matrix of the texture.
  80730. */
  80731. getTextureMatrix(): Matrix;
  80732. /**
  80733. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  80734. * @returns The reflection texture transform
  80735. */
  80736. getReflectionTextureMatrix(): Matrix;
  80737. /**
  80738. * Clones the texture.
  80739. * @returns the cloned texture
  80740. */
  80741. clone(): Texture;
  80742. /**
  80743. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  80744. * @returns The JSON representation of the texture
  80745. */
  80746. serialize(): any;
  80747. /**
  80748. * Get the current class name of the texture useful for serialization or dynamic coding.
  80749. * @returns "Texture"
  80750. */
  80751. getClassName(): string;
  80752. /**
  80753. * Dispose the texture and release its associated resources.
  80754. */
  80755. dispose(): void;
  80756. /**
  80757. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  80758. * @param parsedTexture Define the JSON representation of the texture
  80759. * @param scene Define the scene the parsed texture should be instantiated in
  80760. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  80761. * @returns The parsed texture if successful
  80762. */
  80763. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  80764. /**
  80765. * Creates a texture from its base 64 representation.
  80766. * @param data Define the base64 payload without the data: prefix
  80767. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80768. * @param scene Define the scene the texture should belong to
  80769. * @param noMipmap Forces the texture to not create mip map information if true
  80770. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80771. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80772. * @param onLoad define a callback triggered when the texture has been loaded
  80773. * @param onError define a callback triggered when an error occurred during the loading session
  80774. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80775. * @returns the created texture
  80776. */
  80777. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  80778. /**
  80779. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  80780. * @param data Define the base64 payload without the data: prefix
  80781. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80782. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80783. * @param scene Define the scene the texture should belong to
  80784. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80785. * @param noMipmap Forces the texture to not create mip map information if true
  80786. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80787. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80788. * @param onLoad define a callback triggered when the texture has been loaded
  80789. * @param onError define a callback triggered when an error occurred during the loading session
  80790. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80791. * @returns the created texture
  80792. */
  80793. 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;
  80794. }
  80795. }
  80796. declare module BABYLON {
  80797. interface Engine {
  80798. /**
  80799. * Creates a raw texture
  80800. * @param data defines the data to store in the texture
  80801. * @param width defines the width of the texture
  80802. * @param height defines the height of the texture
  80803. * @param format defines the format of the data
  80804. * @param generateMipMaps defines if the engine should generate the mip levels
  80805. * @param invertY defines if data must be stored with Y axis inverted
  80806. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80807. * @param compression defines the compression used (null by default)
  80808. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80809. * @returns the raw texture inside an InternalTexture
  80810. */
  80811. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80812. /**
  80813. * Update a raw texture
  80814. * @param texture defines the texture to update
  80815. * @param data defines the data to store in the texture
  80816. * @param format defines the format of the data
  80817. * @param invertY defines if data must be stored with Y axis inverted
  80818. */
  80819. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80820. /**
  80821. * Update a raw texture
  80822. * @param texture defines the texture to update
  80823. * @param data defines the data to store in the texture
  80824. * @param format defines the format of the data
  80825. * @param invertY defines if data must be stored with Y axis inverted
  80826. * @param compression defines the compression used (null by default)
  80827. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80828. */
  80829. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80830. /**
  80831. * Creates a new raw cube texture
  80832. * @param data defines the array of data to use to create each face
  80833. * @param size defines the size of the textures
  80834. * @param format defines the format of the data
  80835. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80836. * @param generateMipMaps defines if the engine should generate the mip levels
  80837. * @param invertY defines if data must be stored with Y axis inverted
  80838. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80839. * @param compression defines the compression used (null by default)
  80840. * @returns the cube texture as an InternalTexture
  80841. */
  80842. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80843. /**
  80844. * Update a raw cube texture
  80845. * @param texture defines the texture to udpdate
  80846. * @param data defines the data to store
  80847. * @param format defines the data format
  80848. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80849. * @param invertY defines if data must be stored with Y axis inverted
  80850. */
  80851. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  80852. /**
  80853. * Update a raw cube texture
  80854. * @param texture defines the texture to udpdate
  80855. * @param data defines the data to store
  80856. * @param format defines the data format
  80857. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80858. * @param invertY defines if data must be stored with Y axis inverted
  80859. * @param compression defines the compression used (null by default)
  80860. */
  80861. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  80862. /**
  80863. * Update a raw cube texture
  80864. * @param texture defines the texture to udpdate
  80865. * @param data defines the data to store
  80866. * @param format defines the data format
  80867. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80868. * @param invertY defines if data must be stored with Y axis inverted
  80869. * @param compression defines the compression used (null by default)
  80870. * @param level defines which level of the texture to update
  80871. */
  80872. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  80873. /**
  80874. * Creates a new raw cube texture from a specified url
  80875. * @param url defines the url where the data is located
  80876. * @param scene defines the current scene
  80877. * @param size defines the size of the textures
  80878. * @param format defines the format of the data
  80879. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80880. * @param noMipmap defines if the engine should avoid generating the mip levels
  80881. * @param callback defines a callback used to extract texture data from loaded data
  80882. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80883. * @param onLoad defines a callback called when texture is loaded
  80884. * @param onError defines a callback called if there is an error
  80885. * @returns the cube texture as an InternalTexture
  80886. */
  80887. 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;
  80888. /**
  80889. * Creates a new raw cube texture from a specified url
  80890. * @param url defines the url where the data is located
  80891. * @param scene defines the current scene
  80892. * @param size defines the size of the textures
  80893. * @param format defines the format of the data
  80894. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80895. * @param noMipmap defines if the engine should avoid generating the mip levels
  80896. * @param callback defines a callback used to extract texture data from loaded data
  80897. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80898. * @param onLoad defines a callback called when texture is loaded
  80899. * @param onError defines a callback called if there is an error
  80900. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80901. * @param invertY defines if data must be stored with Y axis inverted
  80902. * @returns the cube texture as an InternalTexture
  80903. */
  80904. 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;
  80905. /**
  80906. * Creates a new raw 3D texture
  80907. * @param data defines the data used to create the texture
  80908. * @param width defines the width of the texture
  80909. * @param height defines the height of the texture
  80910. * @param depth defines the depth of the texture
  80911. * @param format defines the format of the texture
  80912. * @param generateMipMaps defines if the engine must generate mip levels
  80913. * @param invertY defines if data must be stored with Y axis inverted
  80914. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80915. * @param compression defines the compressed used (can be null)
  80916. * @param textureType defines the compressed used (can be null)
  80917. * @returns a new raw 3D texture (stored in an InternalTexture)
  80918. */
  80919. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80920. /**
  80921. * Update a raw 3D texture
  80922. * @param texture defines the texture to update
  80923. * @param data defines the data to store
  80924. * @param format defines the data format
  80925. * @param invertY defines if data must be stored with Y axis inverted
  80926. */
  80927. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80928. /**
  80929. * Update a raw 3D texture
  80930. * @param texture defines the texture to update
  80931. * @param data defines the data to store
  80932. * @param format defines the data format
  80933. * @param invertY defines if data must be stored with Y axis inverted
  80934. * @param compression defines the used compression (can be null)
  80935. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80936. */
  80937. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80938. }
  80939. }
  80940. declare module BABYLON {
  80941. /**
  80942. * Raw texture can help creating a texture directly from an array of data.
  80943. * This can be super useful if you either get the data from an uncompressed source or
  80944. * if you wish to create your texture pixel by pixel.
  80945. */
  80946. export class RawTexture extends Texture {
  80947. /**
  80948. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80949. */
  80950. format: number;
  80951. private _engine;
  80952. /**
  80953. * Instantiates a new RawTexture.
  80954. * Raw texture can help creating a texture directly from an array of data.
  80955. * This can be super useful if you either get the data from an uncompressed source or
  80956. * if you wish to create your texture pixel by pixel.
  80957. * @param data define the array of data to use to create the texture
  80958. * @param width define the width of the texture
  80959. * @param height define the height of the texture
  80960. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80961. * @param scene define the scene the texture belongs to
  80962. * @param generateMipMaps define whether mip maps should be generated or not
  80963. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80964. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80965. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80966. */
  80967. constructor(data: ArrayBufferView, width: number, height: number,
  80968. /**
  80969. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80970. */
  80971. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  80972. /**
  80973. * Updates the texture underlying data.
  80974. * @param data Define the new data of the texture
  80975. */
  80976. update(data: ArrayBufferView): void;
  80977. /**
  80978. * Creates a luminance texture from some data.
  80979. * @param data Define the texture data
  80980. * @param width Define the width of the texture
  80981. * @param height Define the height of the texture
  80982. * @param scene Define the scene the texture belongs to
  80983. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80984. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80985. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80986. * @returns the luminance texture
  80987. */
  80988. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80989. /**
  80990. * Creates a luminance alpha texture from some data.
  80991. * @param data Define the texture data
  80992. * @param width Define the width of the texture
  80993. * @param height Define the height of the texture
  80994. * @param scene Define the scene the texture belongs to
  80995. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80996. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80997. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80998. * @returns the luminance alpha texture
  80999. */
  81000. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81001. /**
  81002. * Creates an alpha texture from some data.
  81003. * @param data Define the texture data
  81004. * @param width Define the width of the texture
  81005. * @param height Define the height of the texture
  81006. * @param scene Define the scene the texture belongs to
  81007. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81008. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81009. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81010. * @returns the alpha texture
  81011. */
  81012. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81013. /**
  81014. * Creates a RGB texture from some data.
  81015. * @param data Define the texture data
  81016. * @param width Define the width of the texture
  81017. * @param height Define the height of the texture
  81018. * @param scene Define the scene the texture belongs to
  81019. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81020. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81021. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81022. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81023. * @returns the RGB alpha texture
  81024. */
  81025. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81026. /**
  81027. * Creates a RGBA texture from some data.
  81028. * @param data Define the texture data
  81029. * @param width Define the width of the texture
  81030. * @param height Define the height of the texture
  81031. * @param scene Define the scene the texture belongs to
  81032. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81033. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81034. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81035. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81036. * @returns the RGBA texture
  81037. */
  81038. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81039. /**
  81040. * Creates a R texture from some data.
  81041. * @param data Define the texture data
  81042. * @param width Define the width of the texture
  81043. * @param height Define the height of the texture
  81044. * @param scene Define the scene the texture belongs to
  81045. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81046. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81047. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81048. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81049. * @returns the R texture
  81050. */
  81051. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81052. }
  81053. }
  81054. declare module BABYLON {
  81055. /**
  81056. * Defines a runtime animation
  81057. */
  81058. export class RuntimeAnimation {
  81059. private _events;
  81060. /**
  81061. * The current frame of the runtime animation
  81062. */
  81063. private _currentFrame;
  81064. /**
  81065. * The animation used by the runtime animation
  81066. */
  81067. private _animation;
  81068. /**
  81069. * The target of the runtime animation
  81070. */
  81071. private _target;
  81072. /**
  81073. * The initiating animatable
  81074. */
  81075. private _host;
  81076. /**
  81077. * The original value of the runtime animation
  81078. */
  81079. private _originalValue;
  81080. /**
  81081. * The original blend value of the runtime animation
  81082. */
  81083. private _originalBlendValue;
  81084. /**
  81085. * The offsets cache of the runtime animation
  81086. */
  81087. private _offsetsCache;
  81088. /**
  81089. * The high limits cache of the runtime animation
  81090. */
  81091. private _highLimitsCache;
  81092. /**
  81093. * Specifies if the runtime animation has been stopped
  81094. */
  81095. private _stopped;
  81096. /**
  81097. * The blending factor of the runtime animation
  81098. */
  81099. private _blendingFactor;
  81100. /**
  81101. * The BabylonJS scene
  81102. */
  81103. private _scene;
  81104. /**
  81105. * The current value of the runtime animation
  81106. */
  81107. private _currentValue;
  81108. /** @hidden */
  81109. _animationState: _IAnimationState;
  81110. /**
  81111. * The active target of the runtime animation
  81112. */
  81113. private _activeTargets;
  81114. private _currentActiveTarget;
  81115. private _directTarget;
  81116. /**
  81117. * The target path of the runtime animation
  81118. */
  81119. private _targetPath;
  81120. /**
  81121. * The weight of the runtime animation
  81122. */
  81123. private _weight;
  81124. /**
  81125. * The ratio offset of the runtime animation
  81126. */
  81127. private _ratioOffset;
  81128. /**
  81129. * The previous delay of the runtime animation
  81130. */
  81131. private _previousDelay;
  81132. /**
  81133. * The previous ratio of the runtime animation
  81134. */
  81135. private _previousRatio;
  81136. private _enableBlending;
  81137. private _keys;
  81138. private _minFrame;
  81139. private _maxFrame;
  81140. private _minValue;
  81141. private _maxValue;
  81142. private _targetIsArray;
  81143. /**
  81144. * Gets the current frame of the runtime animation
  81145. */
  81146. readonly currentFrame: number;
  81147. /**
  81148. * Gets the weight of the runtime animation
  81149. */
  81150. readonly weight: number;
  81151. /**
  81152. * Gets the current value of the runtime animation
  81153. */
  81154. readonly currentValue: any;
  81155. /**
  81156. * Gets the target path of the runtime animation
  81157. */
  81158. readonly targetPath: string;
  81159. /**
  81160. * Gets the actual target of the runtime animation
  81161. */
  81162. readonly target: any;
  81163. /** @hidden */
  81164. _onLoop: () => void;
  81165. /**
  81166. * Create a new RuntimeAnimation object
  81167. * @param target defines the target of the animation
  81168. * @param animation defines the source animation object
  81169. * @param scene defines the hosting scene
  81170. * @param host defines the initiating Animatable
  81171. */
  81172. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  81173. private _preparePath;
  81174. /**
  81175. * Gets the animation from the runtime animation
  81176. */
  81177. readonly animation: Animation;
  81178. /**
  81179. * Resets the runtime animation to the beginning
  81180. * @param restoreOriginal defines whether to restore the target property to the original value
  81181. */
  81182. reset(restoreOriginal?: boolean): void;
  81183. /**
  81184. * Specifies if the runtime animation is stopped
  81185. * @returns Boolean specifying if the runtime animation is stopped
  81186. */
  81187. isStopped(): boolean;
  81188. /**
  81189. * Disposes of the runtime animation
  81190. */
  81191. dispose(): void;
  81192. /**
  81193. * Apply the interpolated value to the target
  81194. * @param currentValue defines the value computed by the animation
  81195. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  81196. */
  81197. setValue(currentValue: any, weight: number): void;
  81198. private _getOriginalValues;
  81199. private _setValue;
  81200. /**
  81201. * Gets the loop pmode of the runtime animation
  81202. * @returns Loop Mode
  81203. */
  81204. private _getCorrectLoopMode;
  81205. /**
  81206. * Move the current animation to a given frame
  81207. * @param frame defines the frame to move to
  81208. */
  81209. goToFrame(frame: number): void;
  81210. /**
  81211. * @hidden Internal use only
  81212. */
  81213. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  81214. /**
  81215. * Execute the current animation
  81216. * @param delay defines the delay to add to the current frame
  81217. * @param from defines the lower bound of the animation range
  81218. * @param to defines the upper bound of the animation range
  81219. * @param loop defines if the current animation must loop
  81220. * @param speedRatio defines the current speed ratio
  81221. * @param weight defines the weight of the animation (default is -1 so no weight)
  81222. * @param onLoop optional callback called when animation loops
  81223. * @returns a boolean indicating if the animation is running
  81224. */
  81225. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  81226. }
  81227. }
  81228. declare module BABYLON {
  81229. /**
  81230. * Class used to store an actual running animation
  81231. */
  81232. export class Animatable {
  81233. /** defines the target object */
  81234. target: any;
  81235. /** defines the starting frame number (default is 0) */
  81236. fromFrame: number;
  81237. /** defines the ending frame number (default is 100) */
  81238. toFrame: number;
  81239. /** defines if the animation must loop (default is false) */
  81240. loopAnimation: boolean;
  81241. /** defines a callback to call when animation ends if it is not looping */
  81242. onAnimationEnd?: (() => void) | null | undefined;
  81243. /** defines a callback to call when animation loops */
  81244. onAnimationLoop?: (() => void) | null | undefined;
  81245. private _localDelayOffset;
  81246. private _pausedDelay;
  81247. private _runtimeAnimations;
  81248. private _paused;
  81249. private _scene;
  81250. private _speedRatio;
  81251. private _weight;
  81252. private _syncRoot;
  81253. /**
  81254. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  81255. * This will only apply for non looping animation (default is true)
  81256. */
  81257. disposeOnEnd: boolean;
  81258. /**
  81259. * Gets a boolean indicating if the animation has started
  81260. */
  81261. animationStarted: boolean;
  81262. /**
  81263. * Observer raised when the animation ends
  81264. */
  81265. onAnimationEndObservable: Observable<Animatable>;
  81266. /**
  81267. * Observer raised when the animation loops
  81268. */
  81269. onAnimationLoopObservable: Observable<Animatable>;
  81270. /**
  81271. * Gets the root Animatable used to synchronize and normalize animations
  81272. */
  81273. readonly syncRoot: Nullable<Animatable>;
  81274. /**
  81275. * Gets the current frame of the first RuntimeAnimation
  81276. * Used to synchronize Animatables
  81277. */
  81278. readonly masterFrame: number;
  81279. /**
  81280. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  81281. */
  81282. weight: number;
  81283. /**
  81284. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  81285. */
  81286. speedRatio: number;
  81287. /**
  81288. * Creates a new Animatable
  81289. * @param scene defines the hosting scene
  81290. * @param target defines the target object
  81291. * @param fromFrame defines the starting frame number (default is 0)
  81292. * @param toFrame defines the ending frame number (default is 100)
  81293. * @param loopAnimation defines if the animation must loop (default is false)
  81294. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  81295. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  81296. * @param animations defines a group of animation to add to the new Animatable
  81297. * @param onAnimationLoop defines a callback to call when animation loops
  81298. */
  81299. constructor(scene: Scene,
  81300. /** defines the target object */
  81301. target: any,
  81302. /** defines the starting frame number (default is 0) */
  81303. fromFrame?: number,
  81304. /** defines the ending frame number (default is 100) */
  81305. toFrame?: number,
  81306. /** defines if the animation must loop (default is false) */
  81307. loopAnimation?: boolean, speedRatio?: number,
  81308. /** defines a callback to call when animation ends if it is not looping */
  81309. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  81310. /** defines a callback to call when animation loops */
  81311. onAnimationLoop?: (() => void) | null | undefined);
  81312. /**
  81313. * Synchronize and normalize current Animatable with a source Animatable
  81314. * This is useful when using animation weights and when animations are not of the same length
  81315. * @param root defines the root Animatable to synchronize with
  81316. * @returns the current Animatable
  81317. */
  81318. syncWith(root: Animatable): Animatable;
  81319. /**
  81320. * Gets the list of runtime animations
  81321. * @returns an array of RuntimeAnimation
  81322. */
  81323. getAnimations(): RuntimeAnimation[];
  81324. /**
  81325. * Adds more animations to the current animatable
  81326. * @param target defines the target of the animations
  81327. * @param animations defines the new animations to add
  81328. */
  81329. appendAnimations(target: any, animations: Animation[]): void;
  81330. /**
  81331. * Gets the source animation for a specific property
  81332. * @param property defines the propertyu to look for
  81333. * @returns null or the source animation for the given property
  81334. */
  81335. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  81336. /**
  81337. * Gets the runtime animation for a specific property
  81338. * @param property defines the propertyu to look for
  81339. * @returns null or the runtime animation for the given property
  81340. */
  81341. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  81342. /**
  81343. * Resets the animatable to its original state
  81344. */
  81345. reset(): void;
  81346. /**
  81347. * Allows the animatable to blend with current running animations
  81348. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81349. * @param blendingSpeed defines the blending speed to use
  81350. */
  81351. enableBlending(blendingSpeed: number): void;
  81352. /**
  81353. * Disable animation blending
  81354. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81355. */
  81356. disableBlending(): void;
  81357. /**
  81358. * Jump directly to a given frame
  81359. * @param frame defines the frame to jump to
  81360. */
  81361. goToFrame(frame: number): void;
  81362. /**
  81363. * Pause the animation
  81364. */
  81365. pause(): void;
  81366. /**
  81367. * Restart the animation
  81368. */
  81369. restart(): void;
  81370. private _raiseOnAnimationEnd;
  81371. /**
  81372. * Stop and delete the current animation
  81373. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  81374. * @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)
  81375. */
  81376. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  81377. /**
  81378. * Wait asynchronously for the animation to end
  81379. * @returns a promise which will be fullfilled when the animation ends
  81380. */
  81381. waitAsync(): Promise<Animatable>;
  81382. /** @hidden */
  81383. _animate(delay: number): boolean;
  81384. }
  81385. interface Scene {
  81386. /** @hidden */
  81387. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  81388. /** @hidden */
  81389. _processLateAnimationBindingsForMatrices(holder: {
  81390. totalWeight: number;
  81391. animations: RuntimeAnimation[];
  81392. originalValue: Matrix;
  81393. }): any;
  81394. /** @hidden */
  81395. _processLateAnimationBindingsForQuaternions(holder: {
  81396. totalWeight: number;
  81397. animations: RuntimeAnimation[];
  81398. originalValue: Quaternion;
  81399. }, refQuaternion: Quaternion): Quaternion;
  81400. /** @hidden */
  81401. _processLateAnimationBindings(): void;
  81402. /**
  81403. * Will start the animation sequence of a given target
  81404. * @param target defines the target
  81405. * @param from defines from which frame should animation start
  81406. * @param to defines until which frame should animation run.
  81407. * @param weight defines the weight to apply to the animation (1.0 by default)
  81408. * @param loop defines if the animation loops
  81409. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81410. * @param onAnimationEnd defines the function to be executed when the animation ends
  81411. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81412. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81413. * @param onAnimationLoop defines the callback to call when an animation loops
  81414. * @returns the animatable object created for this animation
  81415. */
  81416. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81417. /**
  81418. * Will start the animation sequence of a given target
  81419. * @param target defines the target
  81420. * @param from defines from which frame should animation start
  81421. * @param to defines until which frame should animation run.
  81422. * @param loop defines if the animation loops
  81423. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81424. * @param onAnimationEnd defines the function to be executed when the animation ends
  81425. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81426. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81427. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  81428. * @param onAnimationLoop defines the callback to call when an animation loops
  81429. * @returns the animatable object created for this animation
  81430. */
  81431. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81432. /**
  81433. * Will start the animation sequence of a given target and its hierarchy
  81434. * @param target defines the target
  81435. * @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.
  81436. * @param from defines from which frame should animation start
  81437. * @param to defines until which frame should animation run.
  81438. * @param loop defines if the animation loops
  81439. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81440. * @param onAnimationEnd defines the function to be executed when the animation ends
  81441. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81442. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81443. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81444. * @param onAnimationLoop defines the callback to call when an animation loops
  81445. * @returns the list of created animatables
  81446. */
  81447. 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[];
  81448. /**
  81449. * Begin a new animation on a given node
  81450. * @param target defines the target where the animation will take place
  81451. * @param animations defines the list of animations to start
  81452. * @param from defines the initial value
  81453. * @param to defines the final value
  81454. * @param loop defines if you want animation to loop (off by default)
  81455. * @param speedRatio defines the speed ratio to apply to all animations
  81456. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81457. * @param onAnimationLoop defines the callback to call when an animation loops
  81458. * @returns the list of created animatables
  81459. */
  81460. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  81461. /**
  81462. * Begin a new animation on a given node and its hierarchy
  81463. * @param target defines the root node where the animation will take place
  81464. * @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.
  81465. * @param animations defines the list of animations to start
  81466. * @param from defines the initial value
  81467. * @param to defines the final value
  81468. * @param loop defines if you want animation to loop (off by default)
  81469. * @param speedRatio defines the speed ratio to apply to all animations
  81470. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81471. * @param onAnimationLoop defines the callback to call when an animation loops
  81472. * @returns the list of animatables created for all nodes
  81473. */
  81474. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  81475. /**
  81476. * Gets the animatable associated with a specific target
  81477. * @param target defines the target of the animatable
  81478. * @returns the required animatable if found
  81479. */
  81480. getAnimatableByTarget(target: any): Nullable<Animatable>;
  81481. /**
  81482. * Gets all animatables associated with a given target
  81483. * @param target defines the target to look animatables for
  81484. * @returns an array of Animatables
  81485. */
  81486. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  81487. /**
  81488. * Stops and removes all animations that have been applied to the scene
  81489. */
  81490. stopAllAnimations(): void;
  81491. }
  81492. interface Bone {
  81493. /**
  81494. * Copy an animation range from another bone
  81495. * @param source defines the source bone
  81496. * @param rangeName defines the range name to copy
  81497. * @param frameOffset defines the frame offset
  81498. * @param rescaleAsRequired defines if rescaling must be applied if required
  81499. * @param skelDimensionsRatio defines the scaling ratio
  81500. * @returns true if operation was successful
  81501. */
  81502. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  81503. }
  81504. }
  81505. declare module BABYLON {
  81506. /**
  81507. * Class used to handle skinning animations
  81508. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81509. */
  81510. export class Skeleton implements IAnimatable {
  81511. /** defines the skeleton name */
  81512. name: string;
  81513. /** defines the skeleton Id */
  81514. id: string;
  81515. /**
  81516. * Defines the list of child bones
  81517. */
  81518. bones: Bone[];
  81519. /**
  81520. * Defines an estimate of the dimension of the skeleton at rest
  81521. */
  81522. dimensionsAtRest: Vector3;
  81523. /**
  81524. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  81525. */
  81526. needInitialSkinMatrix: boolean;
  81527. /**
  81528. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  81529. */
  81530. overrideMesh: Nullable<AbstractMesh>;
  81531. /**
  81532. * Gets the list of animations attached to this skeleton
  81533. */
  81534. animations: Array<Animation>;
  81535. private _scene;
  81536. private _isDirty;
  81537. private _transformMatrices;
  81538. private _transformMatrixTexture;
  81539. private _meshesWithPoseMatrix;
  81540. private _animatables;
  81541. private _identity;
  81542. private _synchronizedWithMesh;
  81543. private _ranges;
  81544. private _lastAbsoluteTransformsUpdateId;
  81545. private _canUseTextureForBones;
  81546. private _uniqueId;
  81547. /** @hidden */
  81548. _numBonesWithLinkedTransformNode: number;
  81549. /** @hidden */
  81550. _hasWaitingData: Nullable<boolean>;
  81551. /**
  81552. * Specifies if the skeleton should be serialized
  81553. */
  81554. doNotSerialize: boolean;
  81555. private _useTextureToStoreBoneMatrices;
  81556. /**
  81557. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  81558. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  81559. */
  81560. useTextureToStoreBoneMatrices: boolean;
  81561. private _animationPropertiesOverride;
  81562. /**
  81563. * Gets or sets the animation properties override
  81564. */
  81565. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81566. /**
  81567. * List of inspectable custom properties (used by the Inspector)
  81568. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81569. */
  81570. inspectableCustomProperties: IInspectable[];
  81571. /**
  81572. * An observable triggered before computing the skeleton's matrices
  81573. */
  81574. onBeforeComputeObservable: Observable<Skeleton>;
  81575. /**
  81576. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  81577. */
  81578. readonly isUsingTextureForMatrices: boolean;
  81579. /**
  81580. * Gets the unique ID of this skeleton
  81581. */
  81582. readonly uniqueId: number;
  81583. /**
  81584. * Creates a new skeleton
  81585. * @param name defines the skeleton name
  81586. * @param id defines the skeleton Id
  81587. * @param scene defines the hosting scene
  81588. */
  81589. constructor(
  81590. /** defines the skeleton name */
  81591. name: string,
  81592. /** defines the skeleton Id */
  81593. id: string, scene: Scene);
  81594. /**
  81595. * Gets the current object class name.
  81596. * @return the class name
  81597. */
  81598. getClassName(): string;
  81599. /**
  81600. * Returns an array containing the root bones
  81601. * @returns an array containing the root bones
  81602. */
  81603. getChildren(): Array<Bone>;
  81604. /**
  81605. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  81606. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81607. * @returns a Float32Array containing matrices data
  81608. */
  81609. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  81610. /**
  81611. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  81612. * @returns a raw texture containing the data
  81613. */
  81614. getTransformMatrixTexture(): Nullable<RawTexture>;
  81615. /**
  81616. * Gets the current hosting scene
  81617. * @returns a scene object
  81618. */
  81619. getScene(): Scene;
  81620. /**
  81621. * Gets a string representing the current skeleton data
  81622. * @param fullDetails defines a boolean indicating if we want a verbose version
  81623. * @returns a string representing the current skeleton data
  81624. */
  81625. toString(fullDetails?: boolean): string;
  81626. /**
  81627. * Get bone's index searching by name
  81628. * @param name defines bone's name to search for
  81629. * @return the indice of the bone. Returns -1 if not found
  81630. */
  81631. getBoneIndexByName(name: string): number;
  81632. /**
  81633. * Creater a new animation range
  81634. * @param name defines the name of the range
  81635. * @param from defines the start key
  81636. * @param to defines the end key
  81637. */
  81638. createAnimationRange(name: string, from: number, to: number): void;
  81639. /**
  81640. * Delete a specific animation range
  81641. * @param name defines the name of the range
  81642. * @param deleteFrames defines if frames must be removed as well
  81643. */
  81644. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81645. /**
  81646. * Gets a specific animation range
  81647. * @param name defines the name of the range to look for
  81648. * @returns the requested animation range or null if not found
  81649. */
  81650. getAnimationRange(name: string): Nullable<AnimationRange>;
  81651. /**
  81652. * Gets the list of all animation ranges defined on this skeleton
  81653. * @returns an array
  81654. */
  81655. getAnimationRanges(): Nullable<AnimationRange>[];
  81656. /**
  81657. * Copy animation range from a source skeleton.
  81658. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81659. * @param source defines the source skeleton
  81660. * @param name defines the name of the range to copy
  81661. * @param rescaleAsRequired defines if rescaling must be applied if required
  81662. * @returns true if operation was successful
  81663. */
  81664. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81665. /**
  81666. * Forces the skeleton to go to rest pose
  81667. */
  81668. returnToRest(): void;
  81669. private _getHighestAnimationFrame;
  81670. /**
  81671. * Begin a specific animation range
  81672. * @param name defines the name of the range to start
  81673. * @param loop defines if looping must be turned on (false by default)
  81674. * @param speedRatio defines the speed ratio to apply (1 by default)
  81675. * @param onAnimationEnd defines a callback which will be called when animation will end
  81676. * @returns a new animatable
  81677. */
  81678. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81679. /** @hidden */
  81680. _markAsDirty(): void;
  81681. /** @hidden */
  81682. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81683. /** @hidden */
  81684. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81685. private _computeTransformMatrices;
  81686. /**
  81687. * Build all resources required to render a skeleton
  81688. */
  81689. prepare(): void;
  81690. /**
  81691. * Gets the list of animatables currently running for this skeleton
  81692. * @returns an array of animatables
  81693. */
  81694. getAnimatables(): IAnimatable[];
  81695. /**
  81696. * Clone the current skeleton
  81697. * @param name defines the name of the new skeleton
  81698. * @param id defines the id of the new skeleton
  81699. * @returns the new skeleton
  81700. */
  81701. clone(name: string, id: string): Skeleton;
  81702. /**
  81703. * Enable animation blending for this skeleton
  81704. * @param blendingSpeed defines the blending speed to apply
  81705. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81706. */
  81707. enableBlending(blendingSpeed?: number): void;
  81708. /**
  81709. * Releases all resources associated with the current skeleton
  81710. */
  81711. dispose(): void;
  81712. /**
  81713. * Serialize the skeleton in a JSON object
  81714. * @returns a JSON object
  81715. */
  81716. serialize(): any;
  81717. /**
  81718. * Creates a new skeleton from serialized data
  81719. * @param parsedSkeleton defines the serialized data
  81720. * @param scene defines the hosting scene
  81721. * @returns a new skeleton
  81722. */
  81723. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  81724. /**
  81725. * Compute all node absolute transforms
  81726. * @param forceUpdate defines if computation must be done even if cache is up to date
  81727. */
  81728. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  81729. /**
  81730. * Gets the root pose matrix
  81731. * @returns a matrix
  81732. */
  81733. getPoseMatrix(): Nullable<Matrix>;
  81734. /**
  81735. * Sorts bones per internal index
  81736. */
  81737. sortBones(): void;
  81738. private _sortBones;
  81739. }
  81740. }
  81741. declare module BABYLON {
  81742. /**
  81743. * Defines a target to use with MorphTargetManager
  81744. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  81745. */
  81746. export class MorphTarget implements IAnimatable {
  81747. /** defines the name of the target */
  81748. name: string;
  81749. /**
  81750. * Gets or sets the list of animations
  81751. */
  81752. animations: Animation[];
  81753. private _scene;
  81754. private _positions;
  81755. private _normals;
  81756. private _tangents;
  81757. private _influence;
  81758. /**
  81759. * Observable raised when the influence changes
  81760. */
  81761. onInfluenceChanged: Observable<boolean>;
  81762. /** @hidden */
  81763. _onDataLayoutChanged: Observable<void>;
  81764. /**
  81765. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  81766. */
  81767. influence: number;
  81768. /**
  81769. * Gets or sets the id of the morph Target
  81770. */
  81771. id: string;
  81772. private _animationPropertiesOverride;
  81773. /**
  81774. * Gets or sets the animation properties override
  81775. */
  81776. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81777. /**
  81778. * Creates a new MorphTarget
  81779. * @param name defines the name of the target
  81780. * @param influence defines the influence to use
  81781. * @param scene defines the scene the morphtarget belongs to
  81782. */
  81783. constructor(
  81784. /** defines the name of the target */
  81785. name: string, influence?: number, scene?: Nullable<Scene>);
  81786. /**
  81787. * Gets a boolean defining if the target contains position data
  81788. */
  81789. readonly hasPositions: boolean;
  81790. /**
  81791. * Gets a boolean defining if the target contains normal data
  81792. */
  81793. readonly hasNormals: boolean;
  81794. /**
  81795. * Gets a boolean defining if the target contains tangent data
  81796. */
  81797. readonly hasTangents: boolean;
  81798. /**
  81799. * Affects position data to this target
  81800. * @param data defines the position data to use
  81801. */
  81802. setPositions(data: Nullable<FloatArray>): void;
  81803. /**
  81804. * Gets the position data stored in this target
  81805. * @returns a FloatArray containing the position data (or null if not present)
  81806. */
  81807. getPositions(): Nullable<FloatArray>;
  81808. /**
  81809. * Affects normal data to this target
  81810. * @param data defines the normal data to use
  81811. */
  81812. setNormals(data: Nullable<FloatArray>): void;
  81813. /**
  81814. * Gets the normal data stored in this target
  81815. * @returns a FloatArray containing the normal data (or null if not present)
  81816. */
  81817. getNormals(): Nullable<FloatArray>;
  81818. /**
  81819. * Affects tangent data to this target
  81820. * @param data defines the tangent data to use
  81821. */
  81822. setTangents(data: Nullable<FloatArray>): void;
  81823. /**
  81824. * Gets the tangent data stored in this target
  81825. * @returns a FloatArray containing the tangent data (or null if not present)
  81826. */
  81827. getTangents(): Nullable<FloatArray>;
  81828. /**
  81829. * Serializes the current target into a Serialization object
  81830. * @returns the serialized object
  81831. */
  81832. serialize(): any;
  81833. /**
  81834. * Returns the string "MorphTarget"
  81835. * @returns "MorphTarget"
  81836. */
  81837. getClassName(): string;
  81838. /**
  81839. * Creates a new target from serialized data
  81840. * @param serializationObject defines the serialized data to use
  81841. * @returns a new MorphTarget
  81842. */
  81843. static Parse(serializationObject: any): MorphTarget;
  81844. /**
  81845. * Creates a MorphTarget from mesh data
  81846. * @param mesh defines the source mesh
  81847. * @param name defines the name to use for the new target
  81848. * @param influence defines the influence to attach to the target
  81849. * @returns a new MorphTarget
  81850. */
  81851. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  81852. }
  81853. }
  81854. declare module BABYLON {
  81855. /**
  81856. * This class is used to deform meshes using morphing between different targets
  81857. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  81858. */
  81859. export class MorphTargetManager {
  81860. private _targets;
  81861. private _targetInfluenceChangedObservers;
  81862. private _targetDataLayoutChangedObservers;
  81863. private _activeTargets;
  81864. private _scene;
  81865. private _influences;
  81866. private _supportsNormals;
  81867. private _supportsTangents;
  81868. private _vertexCount;
  81869. private _uniqueId;
  81870. private _tempInfluences;
  81871. /**
  81872. * Creates a new MorphTargetManager
  81873. * @param scene defines the current scene
  81874. */
  81875. constructor(scene?: Nullable<Scene>);
  81876. /**
  81877. * Gets the unique ID of this manager
  81878. */
  81879. readonly uniqueId: number;
  81880. /**
  81881. * Gets the number of vertices handled by this manager
  81882. */
  81883. readonly vertexCount: number;
  81884. /**
  81885. * Gets a boolean indicating if this manager supports morphing of normals
  81886. */
  81887. readonly supportsNormals: boolean;
  81888. /**
  81889. * Gets a boolean indicating if this manager supports morphing of tangents
  81890. */
  81891. readonly supportsTangents: boolean;
  81892. /**
  81893. * Gets the number of targets stored in this manager
  81894. */
  81895. readonly numTargets: number;
  81896. /**
  81897. * Gets the number of influencers (ie. the number of targets with influences > 0)
  81898. */
  81899. readonly numInfluencers: number;
  81900. /**
  81901. * Gets the list of influences (one per target)
  81902. */
  81903. readonly influences: Float32Array;
  81904. /**
  81905. * Gets the active target at specified index. An active target is a target with an influence > 0
  81906. * @param index defines the index to check
  81907. * @returns the requested target
  81908. */
  81909. getActiveTarget(index: number): MorphTarget;
  81910. /**
  81911. * Gets the target at specified index
  81912. * @param index defines the index to check
  81913. * @returns the requested target
  81914. */
  81915. getTarget(index: number): MorphTarget;
  81916. /**
  81917. * Add a new target to this manager
  81918. * @param target defines the target to add
  81919. */
  81920. addTarget(target: MorphTarget): void;
  81921. /**
  81922. * Removes a target from the manager
  81923. * @param target defines the target to remove
  81924. */
  81925. removeTarget(target: MorphTarget): void;
  81926. /**
  81927. * Serializes the current manager into a Serialization object
  81928. * @returns the serialized object
  81929. */
  81930. serialize(): any;
  81931. private _syncActiveTargets;
  81932. /**
  81933. * Syncrhonize the targets with all the meshes using this morph target manager
  81934. */
  81935. synchronize(): void;
  81936. /**
  81937. * Creates a new MorphTargetManager from serialized data
  81938. * @param serializationObject defines the serialized data
  81939. * @param scene defines the hosting scene
  81940. * @returns the new MorphTargetManager
  81941. */
  81942. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  81943. }
  81944. }
  81945. declare module BABYLON {
  81946. /**
  81947. * Class used to represent a specific level of detail of a mesh
  81948. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  81949. */
  81950. export class MeshLODLevel {
  81951. /** Defines the distance where this level should star being displayed */
  81952. distance: number;
  81953. /** Defines the mesh to use to render this level */
  81954. mesh: Nullable<Mesh>;
  81955. /**
  81956. * Creates a new LOD level
  81957. * @param distance defines the distance where this level should star being displayed
  81958. * @param mesh defines the mesh to use to render this level
  81959. */
  81960. constructor(
  81961. /** Defines the distance where this level should star being displayed */
  81962. distance: number,
  81963. /** Defines the mesh to use to render this level */
  81964. mesh: Nullable<Mesh>);
  81965. }
  81966. }
  81967. declare module BABYLON {
  81968. /**
  81969. * Mesh representing the gorund
  81970. */
  81971. export class GroundMesh extends Mesh {
  81972. /** If octree should be generated */
  81973. generateOctree: boolean;
  81974. private _heightQuads;
  81975. /** @hidden */
  81976. _subdivisionsX: number;
  81977. /** @hidden */
  81978. _subdivisionsY: number;
  81979. /** @hidden */
  81980. _width: number;
  81981. /** @hidden */
  81982. _height: number;
  81983. /** @hidden */
  81984. _minX: number;
  81985. /** @hidden */
  81986. _maxX: number;
  81987. /** @hidden */
  81988. _minZ: number;
  81989. /** @hidden */
  81990. _maxZ: number;
  81991. constructor(name: string, scene: Scene);
  81992. /**
  81993. * "GroundMesh"
  81994. * @returns "GroundMesh"
  81995. */
  81996. getClassName(): string;
  81997. /**
  81998. * The minimum of x and y subdivisions
  81999. */
  82000. readonly subdivisions: number;
  82001. /**
  82002. * X subdivisions
  82003. */
  82004. readonly subdivisionsX: number;
  82005. /**
  82006. * Y subdivisions
  82007. */
  82008. readonly subdivisionsY: number;
  82009. /**
  82010. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  82011. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  82012. * @param chunksCount the number of subdivisions for x and y
  82013. * @param octreeBlocksSize (Default: 32)
  82014. */
  82015. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  82016. /**
  82017. * Returns a height (y) value in the Worl system :
  82018. * the ground altitude at the coordinates (x, z) expressed in the World system.
  82019. * @param x x coordinate
  82020. * @param z z coordinate
  82021. * @returns the ground y position if (x, z) are outside the ground surface.
  82022. */
  82023. getHeightAtCoordinates(x: number, z: number): number;
  82024. /**
  82025. * Returns a normalized vector (Vector3) orthogonal to the ground
  82026. * at the ground coordinates (x, z) expressed in the World system.
  82027. * @param x x coordinate
  82028. * @param z z coordinate
  82029. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  82030. */
  82031. getNormalAtCoordinates(x: number, z: number): Vector3;
  82032. /**
  82033. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  82034. * at the ground coordinates (x, z) expressed in the World system.
  82035. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  82036. * @param x x coordinate
  82037. * @param z z coordinate
  82038. * @param ref vector to store the result
  82039. * @returns the GroundMesh.
  82040. */
  82041. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  82042. /**
  82043. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  82044. * if the ground has been updated.
  82045. * This can be used in the render loop.
  82046. * @returns the GroundMesh.
  82047. */
  82048. updateCoordinateHeights(): GroundMesh;
  82049. private _getFacetAt;
  82050. private _initHeightQuads;
  82051. private _computeHeightQuads;
  82052. /**
  82053. * Serializes this ground mesh
  82054. * @param serializationObject object to write serialization to
  82055. */
  82056. serialize(serializationObject: any): void;
  82057. /**
  82058. * Parses a serialized ground mesh
  82059. * @param parsedMesh the serialized mesh
  82060. * @param scene the scene to create the ground mesh in
  82061. * @returns the created ground mesh
  82062. */
  82063. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  82064. }
  82065. }
  82066. declare module BABYLON {
  82067. /**
  82068. * Interface for Physics-Joint data
  82069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82070. */
  82071. export interface PhysicsJointData {
  82072. /**
  82073. * The main pivot of the joint
  82074. */
  82075. mainPivot?: Vector3;
  82076. /**
  82077. * The connected pivot of the joint
  82078. */
  82079. connectedPivot?: Vector3;
  82080. /**
  82081. * The main axis of the joint
  82082. */
  82083. mainAxis?: Vector3;
  82084. /**
  82085. * The connected axis of the joint
  82086. */
  82087. connectedAxis?: Vector3;
  82088. /**
  82089. * The collision of the joint
  82090. */
  82091. collision?: boolean;
  82092. /**
  82093. * Native Oimo/Cannon/Energy data
  82094. */
  82095. nativeParams?: any;
  82096. }
  82097. /**
  82098. * This is a holder class for the physics joint created by the physics plugin
  82099. * It holds a set of functions to control the underlying joint
  82100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82101. */
  82102. export class PhysicsJoint {
  82103. /**
  82104. * The type of the physics joint
  82105. */
  82106. type: number;
  82107. /**
  82108. * The data for the physics joint
  82109. */
  82110. jointData: PhysicsJointData;
  82111. private _physicsJoint;
  82112. protected _physicsPlugin: IPhysicsEnginePlugin;
  82113. /**
  82114. * Initializes the physics joint
  82115. * @param type The type of the physics joint
  82116. * @param jointData The data for the physics joint
  82117. */
  82118. constructor(
  82119. /**
  82120. * The type of the physics joint
  82121. */
  82122. type: number,
  82123. /**
  82124. * The data for the physics joint
  82125. */
  82126. jointData: PhysicsJointData);
  82127. /**
  82128. * Gets the physics joint
  82129. */
  82130. /**
  82131. * Sets the physics joint
  82132. */
  82133. physicsJoint: any;
  82134. /**
  82135. * Sets the physics plugin
  82136. */
  82137. physicsPlugin: IPhysicsEnginePlugin;
  82138. /**
  82139. * Execute a function that is physics-plugin specific.
  82140. * @param {Function} func the function that will be executed.
  82141. * It accepts two parameters: the physics world and the physics joint
  82142. */
  82143. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  82144. /**
  82145. * Distance-Joint type
  82146. */
  82147. static DistanceJoint: number;
  82148. /**
  82149. * Hinge-Joint type
  82150. */
  82151. static HingeJoint: number;
  82152. /**
  82153. * Ball-and-Socket joint type
  82154. */
  82155. static BallAndSocketJoint: number;
  82156. /**
  82157. * Wheel-Joint type
  82158. */
  82159. static WheelJoint: number;
  82160. /**
  82161. * Slider-Joint type
  82162. */
  82163. static SliderJoint: number;
  82164. /**
  82165. * Prismatic-Joint type
  82166. */
  82167. static PrismaticJoint: number;
  82168. /**
  82169. * Universal-Joint type
  82170. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  82171. */
  82172. static UniversalJoint: number;
  82173. /**
  82174. * Hinge-Joint 2 type
  82175. */
  82176. static Hinge2Joint: number;
  82177. /**
  82178. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  82179. */
  82180. static PointToPointJoint: number;
  82181. /**
  82182. * Spring-Joint type
  82183. */
  82184. static SpringJoint: number;
  82185. /**
  82186. * Lock-Joint type
  82187. */
  82188. static LockJoint: number;
  82189. }
  82190. /**
  82191. * A class representing a physics distance joint
  82192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82193. */
  82194. export class DistanceJoint extends PhysicsJoint {
  82195. /**
  82196. *
  82197. * @param jointData The data for the Distance-Joint
  82198. */
  82199. constructor(jointData: DistanceJointData);
  82200. /**
  82201. * Update the predefined distance.
  82202. * @param maxDistance The maximum preferred distance
  82203. * @param minDistance The minimum preferred distance
  82204. */
  82205. updateDistance(maxDistance: number, minDistance?: number): void;
  82206. }
  82207. /**
  82208. * Represents a Motor-Enabled Joint
  82209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82210. */
  82211. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  82212. /**
  82213. * Initializes the Motor-Enabled Joint
  82214. * @param type The type of the joint
  82215. * @param jointData The physica joint data for the joint
  82216. */
  82217. constructor(type: number, jointData: PhysicsJointData);
  82218. /**
  82219. * Set the motor values.
  82220. * Attention, this function is plugin specific. Engines won't react 100% the same.
  82221. * @param force the force to apply
  82222. * @param maxForce max force for this motor.
  82223. */
  82224. setMotor(force?: number, maxForce?: number): void;
  82225. /**
  82226. * Set the motor's limits.
  82227. * Attention, this function is plugin specific. Engines won't react 100% the same.
  82228. * @param upperLimit The upper limit of the motor
  82229. * @param lowerLimit The lower limit of the motor
  82230. */
  82231. setLimit(upperLimit: number, lowerLimit?: number): void;
  82232. }
  82233. /**
  82234. * This class represents a single physics Hinge-Joint
  82235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82236. */
  82237. export class HingeJoint extends MotorEnabledJoint {
  82238. /**
  82239. * Initializes the Hinge-Joint
  82240. * @param jointData The joint data for the Hinge-Joint
  82241. */
  82242. constructor(jointData: PhysicsJointData);
  82243. /**
  82244. * Set the motor values.
  82245. * Attention, this function is plugin specific. Engines won't react 100% the same.
  82246. * @param {number} force the force to apply
  82247. * @param {number} maxForce max force for this motor.
  82248. */
  82249. setMotor(force?: number, maxForce?: number): void;
  82250. /**
  82251. * Set the motor's limits.
  82252. * Attention, this function is plugin specific. Engines won't react 100% the same.
  82253. * @param upperLimit The upper limit of the motor
  82254. * @param lowerLimit The lower limit of the motor
  82255. */
  82256. setLimit(upperLimit: number, lowerLimit?: number): void;
  82257. }
  82258. /**
  82259. * This class represents a dual hinge physics joint (same as wheel joint)
  82260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82261. */
  82262. export class Hinge2Joint extends MotorEnabledJoint {
  82263. /**
  82264. * Initializes the Hinge2-Joint
  82265. * @param jointData The joint data for the Hinge2-Joint
  82266. */
  82267. constructor(jointData: PhysicsJointData);
  82268. /**
  82269. * Set the motor values.
  82270. * Attention, this function is plugin specific. Engines won't react 100% the same.
  82271. * @param {number} targetSpeed the speed the motor is to reach
  82272. * @param {number} maxForce max force for this motor.
  82273. * @param {motorIndex} the motor's index, 0 or 1.
  82274. */
  82275. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  82276. /**
  82277. * Set the motor limits.
  82278. * Attention, this function is plugin specific. Engines won't react 100% the same.
  82279. * @param {number} upperLimit the upper limit
  82280. * @param {number} lowerLimit lower limit
  82281. * @param {motorIndex} the motor's index, 0 or 1.
  82282. */
  82283. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  82284. }
  82285. /**
  82286. * Interface for a motor enabled joint
  82287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82288. */
  82289. export interface IMotorEnabledJoint {
  82290. /**
  82291. * Physics joint
  82292. */
  82293. physicsJoint: any;
  82294. /**
  82295. * Sets the motor of the motor-enabled joint
  82296. * @param force The force of the motor
  82297. * @param maxForce The maximum force of the motor
  82298. * @param motorIndex The index of the motor
  82299. */
  82300. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  82301. /**
  82302. * Sets the limit of the motor
  82303. * @param upperLimit The upper limit of the motor
  82304. * @param lowerLimit The lower limit of the motor
  82305. * @param motorIndex The index of the motor
  82306. */
  82307. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  82308. }
  82309. /**
  82310. * Joint data for a Distance-Joint
  82311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82312. */
  82313. export interface DistanceJointData extends PhysicsJointData {
  82314. /**
  82315. * Max distance the 2 joint objects can be apart
  82316. */
  82317. maxDistance: number;
  82318. }
  82319. /**
  82320. * Joint data from a spring joint
  82321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82322. */
  82323. export interface SpringJointData extends PhysicsJointData {
  82324. /**
  82325. * Length of the spring
  82326. */
  82327. length: number;
  82328. /**
  82329. * Stiffness of the spring
  82330. */
  82331. stiffness: number;
  82332. /**
  82333. * Damping of the spring
  82334. */
  82335. damping: number;
  82336. /** this callback will be called when applying the force to the impostors. */
  82337. forceApplicationCallback: () => void;
  82338. }
  82339. }
  82340. declare module BABYLON {
  82341. /**
  82342. * Holds the data for the raycast result
  82343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82344. */
  82345. export class PhysicsRaycastResult {
  82346. private _hasHit;
  82347. private _hitDistance;
  82348. private _hitNormalWorld;
  82349. private _hitPointWorld;
  82350. private _rayFromWorld;
  82351. private _rayToWorld;
  82352. /**
  82353. * Gets if there was a hit
  82354. */
  82355. readonly hasHit: boolean;
  82356. /**
  82357. * Gets the distance from the hit
  82358. */
  82359. readonly hitDistance: number;
  82360. /**
  82361. * Gets the hit normal/direction in the world
  82362. */
  82363. readonly hitNormalWorld: Vector3;
  82364. /**
  82365. * Gets the hit point in the world
  82366. */
  82367. readonly hitPointWorld: Vector3;
  82368. /**
  82369. * Gets the ray "start point" of the ray in the world
  82370. */
  82371. readonly rayFromWorld: Vector3;
  82372. /**
  82373. * Gets the ray "end point" of the ray in the world
  82374. */
  82375. readonly rayToWorld: Vector3;
  82376. /**
  82377. * Sets the hit data (normal & point in world space)
  82378. * @param hitNormalWorld defines the normal in world space
  82379. * @param hitPointWorld defines the point in world space
  82380. */
  82381. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  82382. /**
  82383. * Sets the distance from the start point to the hit point
  82384. * @param distance
  82385. */
  82386. setHitDistance(distance: number): void;
  82387. /**
  82388. * Calculates the distance manually
  82389. */
  82390. calculateHitDistance(): void;
  82391. /**
  82392. * Resets all the values to default
  82393. * @param from The from point on world space
  82394. * @param to The to point on world space
  82395. */
  82396. reset(from?: Vector3, to?: Vector3): void;
  82397. }
  82398. /**
  82399. * Interface for the size containing width and height
  82400. */
  82401. interface IXYZ {
  82402. /**
  82403. * X
  82404. */
  82405. x: number;
  82406. /**
  82407. * Y
  82408. */
  82409. y: number;
  82410. /**
  82411. * Z
  82412. */
  82413. z: number;
  82414. }
  82415. }
  82416. declare module BABYLON {
  82417. /**
  82418. * Interface used to describe a physics joint
  82419. */
  82420. export interface PhysicsImpostorJoint {
  82421. /** Defines the main impostor to which the joint is linked */
  82422. mainImpostor: PhysicsImpostor;
  82423. /** Defines the impostor that is connected to the main impostor using this joint */
  82424. connectedImpostor: PhysicsImpostor;
  82425. /** Defines the joint itself */
  82426. joint: PhysicsJoint;
  82427. }
  82428. /** @hidden */
  82429. export interface IPhysicsEnginePlugin {
  82430. world: any;
  82431. name: string;
  82432. setGravity(gravity: Vector3): void;
  82433. setTimeStep(timeStep: number): void;
  82434. getTimeStep(): number;
  82435. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  82436. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  82437. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  82438. generatePhysicsBody(impostor: PhysicsImpostor): void;
  82439. removePhysicsBody(impostor: PhysicsImpostor): void;
  82440. generateJoint(joint: PhysicsImpostorJoint): void;
  82441. removeJoint(joint: PhysicsImpostorJoint): void;
  82442. isSupported(): boolean;
  82443. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  82444. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  82445. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  82446. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  82447. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  82448. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  82449. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  82450. getBodyMass(impostor: PhysicsImpostor): number;
  82451. getBodyFriction(impostor: PhysicsImpostor): number;
  82452. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  82453. getBodyRestitution(impostor: PhysicsImpostor): number;
  82454. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  82455. getBodyPressure?(impostor: PhysicsImpostor): number;
  82456. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  82457. getBodyStiffness?(impostor: PhysicsImpostor): number;
  82458. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  82459. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  82460. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  82461. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  82462. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  82463. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  82464. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  82465. sleepBody(impostor: PhysicsImpostor): void;
  82466. wakeUpBody(impostor: PhysicsImpostor): void;
  82467. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  82468. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  82469. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  82470. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  82471. getRadius(impostor: PhysicsImpostor): number;
  82472. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  82473. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  82474. dispose(): void;
  82475. }
  82476. /**
  82477. * Interface used to define a physics engine
  82478. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  82479. */
  82480. export interface IPhysicsEngine {
  82481. /**
  82482. * Gets the gravity vector used by the simulation
  82483. */
  82484. gravity: Vector3;
  82485. /**
  82486. * Sets the gravity vector used by the simulation
  82487. * @param gravity defines the gravity vector to use
  82488. */
  82489. setGravity(gravity: Vector3): void;
  82490. /**
  82491. * Set the time step of the physics engine.
  82492. * Default is 1/60.
  82493. * To slow it down, enter 1/600 for example.
  82494. * To speed it up, 1/30
  82495. * @param newTimeStep the new timestep to apply to this world.
  82496. */
  82497. setTimeStep(newTimeStep: number): void;
  82498. /**
  82499. * Get the time step of the physics engine.
  82500. * @returns the current time step
  82501. */
  82502. getTimeStep(): number;
  82503. /**
  82504. * Release all resources
  82505. */
  82506. dispose(): void;
  82507. /**
  82508. * Gets the name of the current physics plugin
  82509. * @returns the name of the plugin
  82510. */
  82511. getPhysicsPluginName(): string;
  82512. /**
  82513. * Adding a new impostor for the impostor tracking.
  82514. * This will be done by the impostor itself.
  82515. * @param impostor the impostor to add
  82516. */
  82517. addImpostor(impostor: PhysicsImpostor): void;
  82518. /**
  82519. * Remove an impostor from the engine.
  82520. * This impostor and its mesh will not longer be updated by the physics engine.
  82521. * @param impostor the impostor to remove
  82522. */
  82523. removeImpostor(impostor: PhysicsImpostor): void;
  82524. /**
  82525. * Add a joint to the physics engine
  82526. * @param mainImpostor defines the main impostor to which the joint is added.
  82527. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  82528. * @param joint defines the joint that will connect both impostors.
  82529. */
  82530. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  82531. /**
  82532. * Removes a joint from the simulation
  82533. * @param mainImpostor defines the impostor used with the joint
  82534. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  82535. * @param joint defines the joint to remove
  82536. */
  82537. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  82538. /**
  82539. * Gets the current plugin used to run the simulation
  82540. * @returns current plugin
  82541. */
  82542. getPhysicsPlugin(): IPhysicsEnginePlugin;
  82543. /**
  82544. * Gets the list of physic impostors
  82545. * @returns an array of PhysicsImpostor
  82546. */
  82547. getImpostors(): Array<PhysicsImpostor>;
  82548. /**
  82549. * Gets the impostor for a physics enabled object
  82550. * @param object defines the object impersonated by the impostor
  82551. * @returns the PhysicsImpostor or null if not found
  82552. */
  82553. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  82554. /**
  82555. * Gets the impostor for a physics body object
  82556. * @param body defines physics body used by the impostor
  82557. * @returns the PhysicsImpostor or null if not found
  82558. */
  82559. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  82560. /**
  82561. * Does a raycast in the physics world
  82562. * @param from when should the ray start?
  82563. * @param to when should the ray end?
  82564. * @returns PhysicsRaycastResult
  82565. */
  82566. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  82567. /**
  82568. * Called by the scene. No need to call it.
  82569. * @param delta defines the timespam between frames
  82570. */
  82571. _step(delta: number): void;
  82572. }
  82573. }
  82574. declare module BABYLON {
  82575. /**
  82576. * The interface for the physics imposter parameters
  82577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82578. */
  82579. export interface PhysicsImpostorParameters {
  82580. /**
  82581. * The mass of the physics imposter
  82582. */
  82583. mass: number;
  82584. /**
  82585. * The friction of the physics imposter
  82586. */
  82587. friction?: number;
  82588. /**
  82589. * The coefficient of restitution of the physics imposter
  82590. */
  82591. restitution?: number;
  82592. /**
  82593. * The native options of the physics imposter
  82594. */
  82595. nativeOptions?: any;
  82596. /**
  82597. * Specifies if the parent should be ignored
  82598. */
  82599. ignoreParent?: boolean;
  82600. /**
  82601. * Specifies if bi-directional transformations should be disabled
  82602. */
  82603. disableBidirectionalTransformation?: boolean;
  82604. /**
  82605. * The pressure inside the physics imposter, soft object only
  82606. */
  82607. pressure?: number;
  82608. /**
  82609. * The stiffness the physics imposter, soft object only
  82610. */
  82611. stiffness?: number;
  82612. /**
  82613. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  82614. */
  82615. velocityIterations?: number;
  82616. /**
  82617. * The number of iterations used in maintaining consistent vertex positions, soft object only
  82618. */
  82619. positionIterations?: number;
  82620. /**
  82621. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  82622. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  82623. * Add to fix multiple points
  82624. */
  82625. fixedPoints?: number;
  82626. /**
  82627. * The collision margin around a soft object
  82628. */
  82629. margin?: number;
  82630. /**
  82631. * The collision margin around a soft object
  82632. */
  82633. damping?: number;
  82634. /**
  82635. * The path for a rope based on an extrusion
  82636. */
  82637. path?: any;
  82638. /**
  82639. * The shape of an extrusion used for a rope based on an extrusion
  82640. */
  82641. shape?: any;
  82642. }
  82643. /**
  82644. * Interface for a physics-enabled object
  82645. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82646. */
  82647. export interface IPhysicsEnabledObject {
  82648. /**
  82649. * The position of the physics-enabled object
  82650. */
  82651. position: Vector3;
  82652. /**
  82653. * The rotation of the physics-enabled object
  82654. */
  82655. rotationQuaternion: Nullable<Quaternion>;
  82656. /**
  82657. * The scale of the physics-enabled object
  82658. */
  82659. scaling: Vector3;
  82660. /**
  82661. * The rotation of the physics-enabled object
  82662. */
  82663. rotation?: Vector3;
  82664. /**
  82665. * The parent of the physics-enabled object
  82666. */
  82667. parent?: any;
  82668. /**
  82669. * The bounding info of the physics-enabled object
  82670. * @returns The bounding info of the physics-enabled object
  82671. */
  82672. getBoundingInfo(): BoundingInfo;
  82673. /**
  82674. * Computes the world matrix
  82675. * @param force Specifies if the world matrix should be computed by force
  82676. * @returns A world matrix
  82677. */
  82678. computeWorldMatrix(force: boolean): Matrix;
  82679. /**
  82680. * Gets the world matrix
  82681. * @returns A world matrix
  82682. */
  82683. getWorldMatrix?(): Matrix;
  82684. /**
  82685. * Gets the child meshes
  82686. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  82687. * @returns An array of abstract meshes
  82688. */
  82689. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  82690. /**
  82691. * Gets the vertex data
  82692. * @param kind The type of vertex data
  82693. * @returns A nullable array of numbers, or a float32 array
  82694. */
  82695. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  82696. /**
  82697. * Gets the indices from the mesh
  82698. * @returns A nullable array of index arrays
  82699. */
  82700. getIndices?(): Nullable<IndicesArray>;
  82701. /**
  82702. * Gets the scene from the mesh
  82703. * @returns the indices array or null
  82704. */
  82705. getScene?(): Scene;
  82706. /**
  82707. * Gets the absolute position from the mesh
  82708. * @returns the absolute position
  82709. */
  82710. getAbsolutePosition(): Vector3;
  82711. /**
  82712. * Gets the absolute pivot point from the mesh
  82713. * @returns the absolute pivot point
  82714. */
  82715. getAbsolutePivotPoint(): Vector3;
  82716. /**
  82717. * Rotates the mesh
  82718. * @param axis The axis of rotation
  82719. * @param amount The amount of rotation
  82720. * @param space The space of the rotation
  82721. * @returns The rotation transform node
  82722. */
  82723. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  82724. /**
  82725. * Translates the mesh
  82726. * @param axis The axis of translation
  82727. * @param distance The distance of translation
  82728. * @param space The space of the translation
  82729. * @returns The transform node
  82730. */
  82731. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  82732. /**
  82733. * Sets the absolute position of the mesh
  82734. * @param absolutePosition The absolute position of the mesh
  82735. * @returns The transform node
  82736. */
  82737. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  82738. /**
  82739. * Gets the class name of the mesh
  82740. * @returns The class name
  82741. */
  82742. getClassName(): string;
  82743. }
  82744. /**
  82745. * Represents a physics imposter
  82746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82747. */
  82748. export class PhysicsImpostor {
  82749. /**
  82750. * The physics-enabled object used as the physics imposter
  82751. */
  82752. object: IPhysicsEnabledObject;
  82753. /**
  82754. * The type of the physics imposter
  82755. */
  82756. type: number;
  82757. private _options;
  82758. private _scene?;
  82759. /**
  82760. * The default object size of the imposter
  82761. */
  82762. static DEFAULT_OBJECT_SIZE: Vector3;
  82763. /**
  82764. * The identity quaternion of the imposter
  82765. */
  82766. static IDENTITY_QUATERNION: Quaternion;
  82767. /** @hidden */
  82768. _pluginData: any;
  82769. private _physicsEngine;
  82770. private _physicsBody;
  82771. private _bodyUpdateRequired;
  82772. private _onBeforePhysicsStepCallbacks;
  82773. private _onAfterPhysicsStepCallbacks;
  82774. /** @hidden */
  82775. _onPhysicsCollideCallbacks: Array<{
  82776. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  82777. otherImpostors: Array<PhysicsImpostor>;
  82778. }>;
  82779. private _deltaPosition;
  82780. private _deltaRotation;
  82781. private _deltaRotationConjugated;
  82782. /** @hidden */
  82783. _isFromLine: boolean;
  82784. private _parent;
  82785. private _isDisposed;
  82786. private static _tmpVecs;
  82787. private static _tmpQuat;
  82788. /**
  82789. * Specifies if the physics imposter is disposed
  82790. */
  82791. readonly isDisposed: boolean;
  82792. /**
  82793. * Gets the mass of the physics imposter
  82794. */
  82795. mass: number;
  82796. /**
  82797. * Gets the coefficient of friction
  82798. */
  82799. /**
  82800. * Sets the coefficient of friction
  82801. */
  82802. friction: number;
  82803. /**
  82804. * Gets the coefficient of restitution
  82805. */
  82806. /**
  82807. * Sets the coefficient of restitution
  82808. */
  82809. restitution: number;
  82810. /**
  82811. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  82812. */
  82813. /**
  82814. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  82815. */
  82816. pressure: number;
  82817. /**
  82818. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  82819. */
  82820. /**
  82821. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  82822. */
  82823. stiffness: number;
  82824. /**
  82825. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  82826. */
  82827. /**
  82828. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  82829. */
  82830. velocityIterations: number;
  82831. /**
  82832. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  82833. */
  82834. /**
  82835. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  82836. */
  82837. positionIterations: number;
  82838. /**
  82839. * The unique id of the physics imposter
  82840. * set by the physics engine when adding this impostor to the array
  82841. */
  82842. uniqueId: number;
  82843. /**
  82844. * @hidden
  82845. */
  82846. soft: boolean;
  82847. /**
  82848. * @hidden
  82849. */
  82850. segments: number;
  82851. private _joints;
  82852. /**
  82853. * Initializes the physics imposter
  82854. * @param object The physics-enabled object used as the physics imposter
  82855. * @param type The type of the physics imposter
  82856. * @param _options The options for the physics imposter
  82857. * @param _scene The Babylon scene
  82858. */
  82859. constructor(
  82860. /**
  82861. * The physics-enabled object used as the physics imposter
  82862. */
  82863. object: IPhysicsEnabledObject,
  82864. /**
  82865. * The type of the physics imposter
  82866. */
  82867. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  82868. /**
  82869. * This function will completly initialize this impostor.
  82870. * It will create a new body - but only if this mesh has no parent.
  82871. * If it has, this impostor will not be used other than to define the impostor
  82872. * of the child mesh.
  82873. * @hidden
  82874. */
  82875. _init(): void;
  82876. private _getPhysicsParent;
  82877. /**
  82878. * Should a new body be generated.
  82879. * @returns boolean specifying if body initialization is required
  82880. */
  82881. isBodyInitRequired(): boolean;
  82882. /**
  82883. * Sets the updated scaling
  82884. * @param updated Specifies if the scaling is updated
  82885. */
  82886. setScalingUpdated(): void;
  82887. /**
  82888. * Force a regeneration of this or the parent's impostor's body.
  82889. * Use under cautious - This will remove all joints already implemented.
  82890. */
  82891. forceUpdate(): void;
  82892. /**
  82893. * Gets the body that holds this impostor. Either its own, or its parent.
  82894. */
  82895. /**
  82896. * Set the physics body. Used mainly by the physics engine/plugin
  82897. */
  82898. physicsBody: any;
  82899. /**
  82900. * Get the parent of the physics imposter
  82901. * @returns Physics imposter or null
  82902. */
  82903. /**
  82904. * Sets the parent of the physics imposter
  82905. */
  82906. parent: Nullable<PhysicsImpostor>;
  82907. /**
  82908. * Resets the update flags
  82909. */
  82910. resetUpdateFlags(): void;
  82911. /**
  82912. * Gets the object extend size
  82913. * @returns the object extend size
  82914. */
  82915. getObjectExtendSize(): Vector3;
  82916. /**
  82917. * Gets the object center
  82918. * @returns The object center
  82919. */
  82920. getObjectCenter(): Vector3;
  82921. /**
  82922. * Get a specific parametes from the options parameter
  82923. * @param paramName The object parameter name
  82924. * @returns The object parameter
  82925. */
  82926. getParam(paramName: string): any;
  82927. /**
  82928. * Sets a specific parameter in the options given to the physics plugin
  82929. * @param paramName The parameter name
  82930. * @param value The value of the parameter
  82931. */
  82932. setParam(paramName: string, value: number): void;
  82933. /**
  82934. * Specifically change the body's mass option. Won't recreate the physics body object
  82935. * @param mass The mass of the physics imposter
  82936. */
  82937. setMass(mass: number): void;
  82938. /**
  82939. * Gets the linear velocity
  82940. * @returns linear velocity or null
  82941. */
  82942. getLinearVelocity(): Nullable<Vector3>;
  82943. /**
  82944. * Sets the linear velocity
  82945. * @param velocity linear velocity or null
  82946. */
  82947. setLinearVelocity(velocity: Nullable<Vector3>): void;
  82948. /**
  82949. * Gets the angular velocity
  82950. * @returns angular velocity or null
  82951. */
  82952. getAngularVelocity(): Nullable<Vector3>;
  82953. /**
  82954. * Sets the angular velocity
  82955. * @param velocity The velocity or null
  82956. */
  82957. setAngularVelocity(velocity: Nullable<Vector3>): void;
  82958. /**
  82959. * Execute a function with the physics plugin native code
  82960. * Provide a function the will have two variables - the world object and the physics body object
  82961. * @param func The function to execute with the physics plugin native code
  82962. */
  82963. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  82964. /**
  82965. * Register a function that will be executed before the physics world is stepping forward
  82966. * @param func The function to execute before the physics world is stepped forward
  82967. */
  82968. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  82969. /**
  82970. * Unregister a function that will be executed before the physics world is stepping forward
  82971. * @param func The function to execute before the physics world is stepped forward
  82972. */
  82973. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  82974. /**
  82975. * Register a function that will be executed after the physics step
  82976. * @param func The function to execute after physics step
  82977. */
  82978. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  82979. /**
  82980. * Unregisters a function that will be executed after the physics step
  82981. * @param func The function to execute after physics step
  82982. */
  82983. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  82984. /**
  82985. * register a function that will be executed when this impostor collides against a different body
  82986. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  82987. * @param func Callback that is executed on collision
  82988. */
  82989. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  82990. /**
  82991. * Unregisters the physics imposter on contact
  82992. * @param collideAgainst The physics object to collide against
  82993. * @param func Callback to execute on collision
  82994. */
  82995. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  82996. private _tmpQuat;
  82997. private _tmpQuat2;
  82998. /**
  82999. * Get the parent rotation
  83000. * @returns The parent rotation
  83001. */
  83002. getParentsRotation(): Quaternion;
  83003. /**
  83004. * this function is executed by the physics engine.
  83005. */
  83006. beforeStep: () => void;
  83007. /**
  83008. * this function is executed by the physics engine
  83009. */
  83010. afterStep: () => void;
  83011. /**
  83012. * Legacy collision detection event support
  83013. */
  83014. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  83015. /**
  83016. * event and body object due to cannon's event-based architecture.
  83017. */
  83018. onCollide: (e: {
  83019. body: any;
  83020. }) => void;
  83021. /**
  83022. * Apply a force
  83023. * @param force The force to apply
  83024. * @param contactPoint The contact point for the force
  83025. * @returns The physics imposter
  83026. */
  83027. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  83028. /**
  83029. * Apply an impulse
  83030. * @param force The impulse force
  83031. * @param contactPoint The contact point for the impulse force
  83032. * @returns The physics imposter
  83033. */
  83034. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  83035. /**
  83036. * A help function to create a joint
  83037. * @param otherImpostor A physics imposter used to create a joint
  83038. * @param jointType The type of joint
  83039. * @param jointData The data for the joint
  83040. * @returns The physics imposter
  83041. */
  83042. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  83043. /**
  83044. * Add a joint to this impostor with a different impostor
  83045. * @param otherImpostor A physics imposter used to add a joint
  83046. * @param joint The joint to add
  83047. * @returns The physics imposter
  83048. */
  83049. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  83050. /**
  83051. * Add an anchor to a cloth impostor
  83052. * @param otherImpostor rigid impostor to anchor to
  83053. * @param width ratio across width from 0 to 1
  83054. * @param height ratio up height from 0 to 1
  83055. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  83056. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  83057. * @returns impostor the soft imposter
  83058. */
  83059. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  83060. /**
  83061. * Add a hook to a rope impostor
  83062. * @param otherImpostor rigid impostor to anchor to
  83063. * @param length ratio across rope from 0 to 1
  83064. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  83065. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  83066. * @returns impostor the rope imposter
  83067. */
  83068. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  83069. /**
  83070. * Will keep this body still, in a sleep mode.
  83071. * @returns the physics imposter
  83072. */
  83073. sleep(): PhysicsImpostor;
  83074. /**
  83075. * Wake the body up.
  83076. * @returns The physics imposter
  83077. */
  83078. wakeUp(): PhysicsImpostor;
  83079. /**
  83080. * Clones the physics imposter
  83081. * @param newObject The physics imposter clones to this physics-enabled object
  83082. * @returns A nullable physics imposter
  83083. */
  83084. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  83085. /**
  83086. * Disposes the physics imposter
  83087. */
  83088. dispose(): void;
  83089. /**
  83090. * Sets the delta position
  83091. * @param position The delta position amount
  83092. */
  83093. setDeltaPosition(position: Vector3): void;
  83094. /**
  83095. * Sets the delta rotation
  83096. * @param rotation The delta rotation amount
  83097. */
  83098. setDeltaRotation(rotation: Quaternion): void;
  83099. /**
  83100. * Gets the box size of the physics imposter and stores the result in the input parameter
  83101. * @param result Stores the box size
  83102. * @returns The physics imposter
  83103. */
  83104. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  83105. /**
  83106. * Gets the radius of the physics imposter
  83107. * @returns Radius of the physics imposter
  83108. */
  83109. getRadius(): number;
  83110. /**
  83111. * Sync a bone with this impostor
  83112. * @param bone The bone to sync to the impostor.
  83113. * @param boneMesh The mesh that the bone is influencing.
  83114. * @param jointPivot The pivot of the joint / bone in local space.
  83115. * @param distToJoint Optional distance from the impostor to the joint.
  83116. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  83117. */
  83118. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  83119. /**
  83120. * Sync impostor to a bone
  83121. * @param bone The bone that the impostor will be synced to.
  83122. * @param boneMesh The mesh that the bone is influencing.
  83123. * @param jointPivot The pivot of the joint / bone in local space.
  83124. * @param distToJoint Optional distance from the impostor to the joint.
  83125. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  83126. * @param boneAxis Optional vector3 axis the bone is aligned with
  83127. */
  83128. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  83129. /**
  83130. * No-Imposter type
  83131. */
  83132. static NoImpostor: number;
  83133. /**
  83134. * Sphere-Imposter type
  83135. */
  83136. static SphereImpostor: number;
  83137. /**
  83138. * Box-Imposter type
  83139. */
  83140. static BoxImpostor: number;
  83141. /**
  83142. * Plane-Imposter type
  83143. */
  83144. static PlaneImpostor: number;
  83145. /**
  83146. * Mesh-imposter type
  83147. */
  83148. static MeshImpostor: number;
  83149. /**
  83150. * Cylinder-Imposter type
  83151. */
  83152. static CylinderImpostor: number;
  83153. /**
  83154. * Particle-Imposter type
  83155. */
  83156. static ParticleImpostor: number;
  83157. /**
  83158. * Heightmap-Imposter type
  83159. */
  83160. static HeightmapImpostor: number;
  83161. /**
  83162. * ConvexHull-Impostor type (Ammo.js plugin only)
  83163. */
  83164. static ConvexHullImpostor: number;
  83165. /**
  83166. * Rope-Imposter type
  83167. */
  83168. static RopeImpostor: number;
  83169. /**
  83170. * Cloth-Imposter type
  83171. */
  83172. static ClothImpostor: number;
  83173. /**
  83174. * Softbody-Imposter type
  83175. */
  83176. static SoftbodyImpostor: number;
  83177. }
  83178. }
  83179. declare module BABYLON {
  83180. /**
  83181. * @hidden
  83182. **/
  83183. export class _CreationDataStorage {
  83184. closePath?: boolean;
  83185. closeArray?: boolean;
  83186. idx: number[];
  83187. dashSize: number;
  83188. gapSize: number;
  83189. path3D: Path3D;
  83190. pathArray: Vector3[][];
  83191. arc: number;
  83192. radius: number;
  83193. cap: number;
  83194. tessellation: number;
  83195. }
  83196. /**
  83197. * @hidden
  83198. **/
  83199. class _InstanceDataStorage {
  83200. visibleInstances: any;
  83201. batchCache: _InstancesBatch;
  83202. instancesBufferSize: number;
  83203. instancesBuffer: Nullable<Buffer>;
  83204. instancesData: Float32Array;
  83205. overridenInstanceCount: number;
  83206. isFrozen: boolean;
  83207. previousBatch: _InstancesBatch;
  83208. hardwareInstancedRendering: boolean;
  83209. sideOrientation: number;
  83210. }
  83211. /**
  83212. * @hidden
  83213. **/
  83214. export class _InstancesBatch {
  83215. mustReturn: boolean;
  83216. visibleInstances: Nullable<InstancedMesh[]>[];
  83217. renderSelf: boolean[];
  83218. hardwareInstancedRendering: boolean[];
  83219. }
  83220. /**
  83221. * Class used to represent renderable models
  83222. */
  83223. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  83224. /**
  83225. * Mesh side orientation : usually the external or front surface
  83226. */
  83227. static readonly FRONTSIDE: number;
  83228. /**
  83229. * Mesh side orientation : usually the internal or back surface
  83230. */
  83231. static readonly BACKSIDE: number;
  83232. /**
  83233. * Mesh side orientation : both internal and external or front and back surfaces
  83234. */
  83235. static readonly DOUBLESIDE: number;
  83236. /**
  83237. * Mesh side orientation : by default, `FRONTSIDE`
  83238. */
  83239. static readonly DEFAULTSIDE: number;
  83240. /**
  83241. * Mesh cap setting : no cap
  83242. */
  83243. static readonly NO_CAP: number;
  83244. /**
  83245. * Mesh cap setting : one cap at the beginning of the mesh
  83246. */
  83247. static readonly CAP_START: number;
  83248. /**
  83249. * Mesh cap setting : one cap at the end of the mesh
  83250. */
  83251. static readonly CAP_END: number;
  83252. /**
  83253. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  83254. */
  83255. static readonly CAP_ALL: number;
  83256. /**
  83257. * Mesh pattern setting : no flip or rotate
  83258. */
  83259. static readonly NO_FLIP: number;
  83260. /**
  83261. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  83262. */
  83263. static readonly FLIP_TILE: number;
  83264. /**
  83265. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  83266. */
  83267. static readonly ROTATE_TILE: number;
  83268. /**
  83269. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  83270. */
  83271. static readonly FLIP_ROW: number;
  83272. /**
  83273. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  83274. */
  83275. static readonly ROTATE_ROW: number;
  83276. /**
  83277. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  83278. */
  83279. static readonly FLIP_N_ROTATE_TILE: number;
  83280. /**
  83281. * Mesh pattern setting : rotate pattern and rotate
  83282. */
  83283. static readonly FLIP_N_ROTATE_ROW: number;
  83284. /**
  83285. * Mesh tile positioning : part tiles same on left/right or top/bottom
  83286. */
  83287. static readonly CENTER: number;
  83288. /**
  83289. * Mesh tile positioning : part tiles on left
  83290. */
  83291. static readonly LEFT: number;
  83292. /**
  83293. * Mesh tile positioning : part tiles on right
  83294. */
  83295. static readonly RIGHT: number;
  83296. /**
  83297. * Mesh tile positioning : part tiles on top
  83298. */
  83299. static readonly TOP: number;
  83300. /**
  83301. * Mesh tile positioning : part tiles on bottom
  83302. */
  83303. static readonly BOTTOM: number;
  83304. /**
  83305. * Gets the default side orientation.
  83306. * @param orientation the orientation to value to attempt to get
  83307. * @returns the default orientation
  83308. * @hidden
  83309. */
  83310. static _GetDefaultSideOrientation(orientation?: number): number;
  83311. private _internalMeshDataInfo;
  83312. /**
  83313. * An event triggered before rendering the mesh
  83314. */
  83315. readonly onBeforeRenderObservable: Observable<Mesh>;
  83316. /**
  83317. * An event triggered before binding the mesh
  83318. */
  83319. readonly onBeforeBindObservable: Observable<Mesh>;
  83320. /**
  83321. * An event triggered after rendering the mesh
  83322. */
  83323. readonly onAfterRenderObservable: Observable<Mesh>;
  83324. /**
  83325. * An event triggered before drawing the mesh
  83326. */
  83327. readonly onBeforeDrawObservable: Observable<Mesh>;
  83328. private _onBeforeDrawObserver;
  83329. /**
  83330. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  83331. */
  83332. onBeforeDraw: () => void;
  83333. /**
  83334. * Gets the delay loading state of the mesh (when delay loading is turned on)
  83335. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  83336. */
  83337. delayLoadState: number;
  83338. /**
  83339. * Gets the list of instances created from this mesh
  83340. * it is not supposed to be modified manually.
  83341. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  83342. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83343. */
  83344. instances: InstancedMesh[];
  83345. /**
  83346. * Gets the file containing delay loading data for this mesh
  83347. */
  83348. delayLoadingFile: string;
  83349. /** @hidden */
  83350. _binaryInfo: any;
  83351. /**
  83352. * User defined function used to change how LOD level selection is done
  83353. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  83354. */
  83355. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  83356. /**
  83357. * Gets or sets the morph target manager
  83358. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  83359. */
  83360. morphTargetManager: Nullable<MorphTargetManager>;
  83361. /** @hidden */
  83362. _creationDataStorage: Nullable<_CreationDataStorage>;
  83363. /** @hidden */
  83364. _geometry: Nullable<Geometry>;
  83365. /** @hidden */
  83366. _delayInfo: Array<string>;
  83367. /** @hidden */
  83368. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  83369. /** @hidden */
  83370. _instanceDataStorage: _InstanceDataStorage;
  83371. private _effectiveMaterial;
  83372. /** @hidden */
  83373. _shouldGenerateFlatShading: boolean;
  83374. /** @hidden */
  83375. _originalBuilderSideOrientation: number;
  83376. /**
  83377. * Use this property to change the original side orientation defined at construction time
  83378. */
  83379. overrideMaterialSideOrientation: Nullable<number>;
  83380. /**
  83381. * Gets the source mesh (the one used to clone this one from)
  83382. */
  83383. readonly source: Nullable<Mesh>;
  83384. /**
  83385. * Gets or sets a boolean indicating that this mesh does not use index buffer
  83386. */
  83387. isUnIndexed: boolean;
  83388. /**
  83389. * @constructor
  83390. * @param name The value used by scene.getMeshByName() to do a lookup.
  83391. * @param scene The scene to add this mesh to.
  83392. * @param parent The parent of this mesh, if it has one
  83393. * @param source An optional Mesh from which geometry is shared, cloned.
  83394. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83395. * When false, achieved by calling a clone(), also passing False.
  83396. * This will make creation of children, recursive.
  83397. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  83398. */
  83399. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  83400. /**
  83401. * Gets the class name
  83402. * @returns the string "Mesh".
  83403. */
  83404. getClassName(): string;
  83405. /** @hidden */
  83406. readonly _isMesh: boolean;
  83407. /**
  83408. * Returns a description of this mesh
  83409. * @param fullDetails define if full details about this mesh must be used
  83410. * @returns a descriptive string representing this mesh
  83411. */
  83412. toString(fullDetails?: boolean): string;
  83413. /** @hidden */
  83414. _unBindEffect(): void;
  83415. /**
  83416. * Gets a boolean indicating if this mesh has LOD
  83417. */
  83418. readonly hasLODLevels: boolean;
  83419. /**
  83420. * Gets the list of MeshLODLevel associated with the current mesh
  83421. * @returns an array of MeshLODLevel
  83422. */
  83423. getLODLevels(): MeshLODLevel[];
  83424. private _sortLODLevels;
  83425. /**
  83426. * Add a mesh as LOD level triggered at the given distance.
  83427. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83428. * @param distance The distance from the center of the object to show this level
  83429. * @param mesh The mesh to be added as LOD level (can be null)
  83430. * @return This mesh (for chaining)
  83431. */
  83432. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  83433. /**
  83434. * Returns the LOD level mesh at the passed distance or null if not found.
  83435. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83436. * @param distance The distance from the center of the object to show this level
  83437. * @returns a Mesh or `null`
  83438. */
  83439. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  83440. /**
  83441. * Remove a mesh from the LOD array
  83442. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83443. * @param mesh defines the mesh to be removed
  83444. * @return This mesh (for chaining)
  83445. */
  83446. removeLODLevel(mesh: Mesh): Mesh;
  83447. /**
  83448. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  83449. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83450. * @param camera defines the camera to use to compute distance
  83451. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  83452. * @return This mesh (for chaining)
  83453. */
  83454. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  83455. /**
  83456. * Gets the mesh internal Geometry object
  83457. */
  83458. readonly geometry: Nullable<Geometry>;
  83459. /**
  83460. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  83461. * @returns the total number of vertices
  83462. */
  83463. getTotalVertices(): number;
  83464. /**
  83465. * Returns the content of an associated vertex buffer
  83466. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  83467. * - VertexBuffer.PositionKind
  83468. * - VertexBuffer.UVKind
  83469. * - VertexBuffer.UV2Kind
  83470. * - VertexBuffer.UV3Kind
  83471. * - VertexBuffer.UV4Kind
  83472. * - VertexBuffer.UV5Kind
  83473. * - VertexBuffer.UV6Kind
  83474. * - VertexBuffer.ColorKind
  83475. * - VertexBuffer.MatricesIndicesKind
  83476. * - VertexBuffer.MatricesIndicesExtraKind
  83477. * - VertexBuffer.MatricesWeightsKind
  83478. * - VertexBuffer.MatricesWeightsExtraKind
  83479. * @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
  83480. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  83481. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  83482. */
  83483. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  83484. /**
  83485. * Returns the mesh VertexBuffer object from the requested `kind`
  83486. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  83487. * - VertexBuffer.PositionKind
  83488. * - VertexBuffer.NormalKind
  83489. * - VertexBuffer.UVKind
  83490. * - VertexBuffer.UV2Kind
  83491. * - VertexBuffer.UV3Kind
  83492. * - VertexBuffer.UV4Kind
  83493. * - VertexBuffer.UV5Kind
  83494. * - VertexBuffer.UV6Kind
  83495. * - VertexBuffer.ColorKind
  83496. * - VertexBuffer.MatricesIndicesKind
  83497. * - VertexBuffer.MatricesIndicesExtraKind
  83498. * - VertexBuffer.MatricesWeightsKind
  83499. * - VertexBuffer.MatricesWeightsExtraKind
  83500. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  83501. */
  83502. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  83503. /**
  83504. * Tests if a specific vertex buffer is associated with this mesh
  83505. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  83506. * - VertexBuffer.PositionKind
  83507. * - VertexBuffer.NormalKind
  83508. * - VertexBuffer.UVKind
  83509. * - VertexBuffer.UV2Kind
  83510. * - VertexBuffer.UV3Kind
  83511. * - VertexBuffer.UV4Kind
  83512. * - VertexBuffer.UV5Kind
  83513. * - VertexBuffer.UV6Kind
  83514. * - VertexBuffer.ColorKind
  83515. * - VertexBuffer.MatricesIndicesKind
  83516. * - VertexBuffer.MatricesIndicesExtraKind
  83517. * - VertexBuffer.MatricesWeightsKind
  83518. * - VertexBuffer.MatricesWeightsExtraKind
  83519. * @returns a boolean
  83520. */
  83521. isVerticesDataPresent(kind: string): boolean;
  83522. /**
  83523. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  83524. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  83525. * - VertexBuffer.PositionKind
  83526. * - VertexBuffer.UVKind
  83527. * - VertexBuffer.UV2Kind
  83528. * - VertexBuffer.UV3Kind
  83529. * - VertexBuffer.UV4Kind
  83530. * - VertexBuffer.UV5Kind
  83531. * - VertexBuffer.UV6Kind
  83532. * - VertexBuffer.ColorKind
  83533. * - VertexBuffer.MatricesIndicesKind
  83534. * - VertexBuffer.MatricesIndicesExtraKind
  83535. * - VertexBuffer.MatricesWeightsKind
  83536. * - VertexBuffer.MatricesWeightsExtraKind
  83537. * @returns a boolean
  83538. */
  83539. isVertexBufferUpdatable(kind: string): boolean;
  83540. /**
  83541. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  83542. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  83543. * - VertexBuffer.PositionKind
  83544. * - VertexBuffer.NormalKind
  83545. * - VertexBuffer.UVKind
  83546. * - VertexBuffer.UV2Kind
  83547. * - VertexBuffer.UV3Kind
  83548. * - VertexBuffer.UV4Kind
  83549. * - VertexBuffer.UV5Kind
  83550. * - VertexBuffer.UV6Kind
  83551. * - VertexBuffer.ColorKind
  83552. * - VertexBuffer.MatricesIndicesKind
  83553. * - VertexBuffer.MatricesIndicesExtraKind
  83554. * - VertexBuffer.MatricesWeightsKind
  83555. * - VertexBuffer.MatricesWeightsExtraKind
  83556. * @returns an array of strings
  83557. */
  83558. getVerticesDataKinds(): string[];
  83559. /**
  83560. * Returns a positive integer : the total number of indices in this mesh geometry.
  83561. * @returns the numner of indices or zero if the mesh has no geometry.
  83562. */
  83563. getTotalIndices(): number;
  83564. /**
  83565. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83566. * @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.
  83567. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  83568. * @returns the indices array or an empty array if the mesh has no geometry
  83569. */
  83570. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  83571. readonly isBlocked: boolean;
  83572. /**
  83573. * Determine if the current mesh is ready to be rendered
  83574. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83575. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  83576. * @returns true if all associated assets are ready (material, textures, shaders)
  83577. */
  83578. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  83579. /**
  83580. * 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.
  83581. */
  83582. readonly areNormalsFrozen: boolean;
  83583. /**
  83584. * 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.
  83585. * @returns the current mesh
  83586. */
  83587. freezeNormals(): Mesh;
  83588. /**
  83589. * 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
  83590. * @returns the current mesh
  83591. */
  83592. unfreezeNormals(): Mesh;
  83593. /**
  83594. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  83595. */
  83596. overridenInstanceCount: number;
  83597. /** @hidden */
  83598. _preActivate(): Mesh;
  83599. /** @hidden */
  83600. _preActivateForIntermediateRendering(renderId: number): Mesh;
  83601. /** @hidden */
  83602. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  83603. /**
  83604. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83605. * This means the mesh underlying bounding box and sphere are recomputed.
  83606. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83607. * @returns the current mesh
  83608. */
  83609. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  83610. /** @hidden */
  83611. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  83612. /**
  83613. * This function will subdivide the mesh into multiple submeshes
  83614. * @param count defines the expected number of submeshes
  83615. */
  83616. subdivide(count: number): void;
  83617. /**
  83618. * Copy a FloatArray into a specific associated vertex buffer
  83619. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  83620. * - VertexBuffer.PositionKind
  83621. * - VertexBuffer.UVKind
  83622. * - VertexBuffer.UV2Kind
  83623. * - VertexBuffer.UV3Kind
  83624. * - VertexBuffer.UV4Kind
  83625. * - VertexBuffer.UV5Kind
  83626. * - VertexBuffer.UV6Kind
  83627. * - VertexBuffer.ColorKind
  83628. * - VertexBuffer.MatricesIndicesKind
  83629. * - VertexBuffer.MatricesIndicesExtraKind
  83630. * - VertexBuffer.MatricesWeightsKind
  83631. * - VertexBuffer.MatricesWeightsExtraKind
  83632. * @param data defines the data source
  83633. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  83634. * @param stride defines the data stride size (can be null)
  83635. * @returns the current mesh
  83636. */
  83637. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  83638. /**
  83639. * Flags an associated vertex buffer as updatable
  83640. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  83641. * - VertexBuffer.PositionKind
  83642. * - VertexBuffer.UVKind
  83643. * - VertexBuffer.UV2Kind
  83644. * - VertexBuffer.UV3Kind
  83645. * - VertexBuffer.UV4Kind
  83646. * - VertexBuffer.UV5Kind
  83647. * - VertexBuffer.UV6Kind
  83648. * - VertexBuffer.ColorKind
  83649. * - VertexBuffer.MatricesIndicesKind
  83650. * - VertexBuffer.MatricesIndicesExtraKind
  83651. * - VertexBuffer.MatricesWeightsKind
  83652. * - VertexBuffer.MatricesWeightsExtraKind
  83653. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  83654. */
  83655. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  83656. /**
  83657. * Sets the mesh global Vertex Buffer
  83658. * @param buffer defines the buffer to use
  83659. * @returns the current mesh
  83660. */
  83661. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  83662. /**
  83663. * Update a specific associated vertex buffer
  83664. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  83665. * - VertexBuffer.PositionKind
  83666. * - VertexBuffer.UVKind
  83667. * - VertexBuffer.UV2Kind
  83668. * - VertexBuffer.UV3Kind
  83669. * - VertexBuffer.UV4Kind
  83670. * - VertexBuffer.UV5Kind
  83671. * - VertexBuffer.UV6Kind
  83672. * - VertexBuffer.ColorKind
  83673. * - VertexBuffer.MatricesIndicesKind
  83674. * - VertexBuffer.MatricesIndicesExtraKind
  83675. * - VertexBuffer.MatricesWeightsKind
  83676. * - VertexBuffer.MatricesWeightsExtraKind
  83677. * @param data defines the data source
  83678. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  83679. * @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)
  83680. * @returns the current mesh
  83681. */
  83682. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  83683. /**
  83684. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  83685. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  83686. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  83687. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  83688. * @returns the current mesh
  83689. */
  83690. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  83691. /**
  83692. * Creates a un-shared specific occurence of the geometry for the mesh.
  83693. * @returns the current mesh
  83694. */
  83695. makeGeometryUnique(): Mesh;
  83696. /**
  83697. * Set the index buffer of this mesh
  83698. * @param indices defines the source data
  83699. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  83700. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  83701. * @returns the current mesh
  83702. */
  83703. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  83704. /**
  83705. * Update the current index buffer
  83706. * @param indices defines the source data
  83707. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83708. * @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)
  83709. * @returns the current mesh
  83710. */
  83711. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  83712. /**
  83713. * Invert the geometry to move from a right handed system to a left handed one.
  83714. * @returns the current mesh
  83715. */
  83716. toLeftHanded(): Mesh;
  83717. /** @hidden */
  83718. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  83719. /** @hidden */
  83720. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  83721. /**
  83722. * Registers for this mesh a javascript function called just before the rendering process
  83723. * @param func defines the function to call before rendering this mesh
  83724. * @returns the current mesh
  83725. */
  83726. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  83727. /**
  83728. * Disposes a previously registered javascript function called before the rendering
  83729. * @param func defines the function to remove
  83730. * @returns the current mesh
  83731. */
  83732. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  83733. /**
  83734. * Registers for this mesh a javascript function called just after the rendering is complete
  83735. * @param func defines the function to call after rendering this mesh
  83736. * @returns the current mesh
  83737. */
  83738. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  83739. /**
  83740. * Disposes a previously registered javascript function called after the rendering.
  83741. * @param func defines the function to remove
  83742. * @returns the current mesh
  83743. */
  83744. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  83745. /** @hidden */
  83746. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  83747. /** @hidden */
  83748. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  83749. /** @hidden */
  83750. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  83751. /** @hidden */
  83752. _freeze(): void;
  83753. /** @hidden */
  83754. _unFreeze(): void;
  83755. /**
  83756. * 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
  83757. * @param subMesh defines the subMesh to render
  83758. * @param enableAlphaMode defines if alpha mode can be changed
  83759. * @returns the current mesh
  83760. */
  83761. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  83762. private _onBeforeDraw;
  83763. /**
  83764. * Renormalize the mesh and patch it up if there are no weights
  83765. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  83766. * However in the case of zero weights then we set just a single influence to 1.
  83767. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  83768. */
  83769. cleanMatrixWeights(): void;
  83770. private normalizeSkinFourWeights;
  83771. private normalizeSkinWeightsAndExtra;
  83772. /**
  83773. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  83774. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  83775. * the user know there was an issue with importing the mesh
  83776. * @returns a validation object with skinned, valid and report string
  83777. */
  83778. validateSkinning(): {
  83779. skinned: boolean;
  83780. valid: boolean;
  83781. report: string;
  83782. };
  83783. /** @hidden */
  83784. _checkDelayState(): Mesh;
  83785. private _queueLoad;
  83786. /**
  83787. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  83788. * A mesh is in the frustum if its bounding box intersects the frustum
  83789. * @param frustumPlanes defines the frustum to test
  83790. * @returns true if the mesh is in the frustum planes
  83791. */
  83792. isInFrustum(frustumPlanes: Plane[]): boolean;
  83793. /**
  83794. * Sets the mesh material by the material or multiMaterial `id` property
  83795. * @param id is a string identifying the material or the multiMaterial
  83796. * @returns the current mesh
  83797. */
  83798. setMaterialByID(id: string): Mesh;
  83799. /**
  83800. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  83801. * @returns an array of IAnimatable
  83802. */
  83803. getAnimatables(): IAnimatable[];
  83804. /**
  83805. * Modifies the mesh geometry according to the passed transformation matrix.
  83806. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  83807. * The mesh normals are modified using the same transformation.
  83808. * Note that, under the hood, this method sets a new VertexBuffer each call.
  83809. * @param transform defines the transform matrix to use
  83810. * @see http://doc.babylonjs.com/resources/baking_transformations
  83811. * @returns the current mesh
  83812. */
  83813. bakeTransformIntoVertices(transform: Matrix): Mesh;
  83814. /**
  83815. * Modifies the mesh geometry according to its own current World Matrix.
  83816. * The mesh World Matrix is then reset.
  83817. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  83818. * Note that, under the hood, this method sets a new VertexBuffer each call.
  83819. * @see http://doc.babylonjs.com/resources/baking_transformations
  83820. * @returns the current mesh
  83821. */
  83822. bakeCurrentTransformIntoVertices(): Mesh;
  83823. /** @hidden */
  83824. readonly _positions: Nullable<Vector3[]>;
  83825. /** @hidden */
  83826. _resetPointsArrayCache(): Mesh;
  83827. /** @hidden */
  83828. _generatePointsArray(): boolean;
  83829. /**
  83830. * Returns a new Mesh object generated from the current mesh properties.
  83831. * This method must not get confused with createInstance()
  83832. * @param name is a string, the name given to the new mesh
  83833. * @param newParent can be any Node object (default `null`)
  83834. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  83835. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  83836. * @returns a new mesh
  83837. */
  83838. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  83839. /**
  83840. * Releases resources associated with this mesh.
  83841. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83842. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83843. */
  83844. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83845. /**
  83846. * Modifies the mesh geometry according to a displacement map.
  83847. * 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.
  83848. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  83849. * @param url is a string, the URL from the image file is to be downloaded.
  83850. * @param minHeight is the lower limit of the displacement.
  83851. * @param maxHeight is the upper limit of the displacement.
  83852. * @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.
  83853. * @param uvOffset is an optional vector2 used to offset UV.
  83854. * @param uvScale is an optional vector2 used to scale UV.
  83855. * @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.
  83856. * @returns the Mesh.
  83857. */
  83858. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  83859. /**
  83860. * Modifies the mesh geometry according to a displacementMap buffer.
  83861. * 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.
  83862. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  83863. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  83864. * @param heightMapWidth is the width of the buffer image.
  83865. * @param heightMapHeight is the height of the buffer image.
  83866. * @param minHeight is the lower limit of the displacement.
  83867. * @param maxHeight is the upper limit of the displacement.
  83868. * @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.
  83869. * @param uvOffset is an optional vector2 used to offset UV.
  83870. * @param uvScale is an optional vector2 used to scale UV.
  83871. * @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.
  83872. * @returns the Mesh.
  83873. */
  83874. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  83875. /**
  83876. * Modify the mesh to get a flat shading rendering.
  83877. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  83878. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  83879. * @returns current mesh
  83880. */
  83881. convertToFlatShadedMesh(): Mesh;
  83882. /**
  83883. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  83884. * In other words, more vertices, no more indices and a single bigger VBO.
  83885. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  83886. * @returns current mesh
  83887. */
  83888. convertToUnIndexedMesh(): Mesh;
  83889. /**
  83890. * Inverses facet orientations.
  83891. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  83892. * @param flipNormals will also inverts the normals
  83893. * @returns current mesh
  83894. */
  83895. flipFaces(flipNormals?: boolean): Mesh;
  83896. /**
  83897. * Increase the number of facets and hence vertices in a mesh
  83898. * Vertex normals are interpolated from existing vertex normals
  83899. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  83900. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  83901. */
  83902. increaseVertices(numberPerEdge: number): void;
  83903. /**
  83904. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  83905. * This will undo any application of covertToFlatShadedMesh
  83906. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  83907. */
  83908. forceSharedVertices(): void;
  83909. /** @hidden */
  83910. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  83911. /** @hidden */
  83912. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  83913. /**
  83914. * Creates a new InstancedMesh object from the mesh model.
  83915. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83916. * @param name defines the name of the new instance
  83917. * @returns a new InstancedMesh
  83918. */
  83919. createInstance(name: string): InstancedMesh;
  83920. /**
  83921. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  83922. * After this call, all the mesh instances have the same submeshes than the current mesh.
  83923. * @returns the current mesh
  83924. */
  83925. synchronizeInstances(): Mesh;
  83926. /**
  83927. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  83928. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  83929. * This should be used together with the simplification to avoid disappearing triangles.
  83930. * @param successCallback an optional success callback to be called after the optimization finished.
  83931. * @returns the current mesh
  83932. */
  83933. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  83934. /**
  83935. * Serialize current mesh
  83936. * @param serializationObject defines the object which will receive the serialization data
  83937. */
  83938. serialize(serializationObject: any): void;
  83939. /** @hidden */
  83940. _syncGeometryWithMorphTargetManager(): void;
  83941. /** @hidden */
  83942. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  83943. /**
  83944. * Returns a new Mesh object parsed from the source provided.
  83945. * @param parsedMesh is the source
  83946. * @param scene defines the hosting scene
  83947. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  83948. * @returns a new Mesh
  83949. */
  83950. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  83951. /**
  83952. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  83953. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  83954. * @param name defines the name of the mesh to create
  83955. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  83956. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  83957. * @param closePath creates a seam between the first and the last points of each path of the path array
  83958. * @param offset is taken in account only if the `pathArray` is containing a single path
  83959. * @param scene defines the hosting scene
  83960. * @param updatable defines if the mesh must be flagged as updatable
  83961. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83962. * @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)
  83963. * @returns a new Mesh
  83964. */
  83965. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  83966. /**
  83967. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  83968. * @param name defines the name of the mesh to create
  83969. * @param radius sets the radius size (float) of the polygon (default 0.5)
  83970. * @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
  83971. * @param scene defines the hosting scene
  83972. * @param updatable defines if the mesh must be flagged as updatable
  83973. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83974. * @returns a new Mesh
  83975. */
  83976. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  83977. /**
  83978. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  83979. * @param name defines the name of the mesh to create
  83980. * @param size sets the size (float) of each box side (default 1)
  83981. * @param scene defines the hosting scene
  83982. * @param updatable defines if the mesh must be flagged as updatable
  83983. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83984. * @returns a new Mesh
  83985. */
  83986. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  83987. /**
  83988. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  83989. * @param name defines the name of the mesh to create
  83990. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  83991. * @param diameter sets the diameter size (float) of the sphere (default 1)
  83992. * @param scene defines the hosting scene
  83993. * @param updatable defines if the mesh must be flagged as updatable
  83994. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83995. * @returns a new Mesh
  83996. */
  83997. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  83998. /**
  83999. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  84000. * @param name defines the name of the mesh to create
  84001. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  84002. * @param diameter sets the diameter size (float) of the sphere (default 1)
  84003. * @param scene defines the hosting scene
  84004. * @returns a new Mesh
  84005. */
  84006. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  84007. /**
  84008. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  84009. * @param name defines the name of the mesh to create
  84010. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  84011. * @param diameterTop set the top cap diameter (floats, default 1)
  84012. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  84013. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  84014. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  84015. * @param scene defines the hosting scene
  84016. * @param updatable defines if the mesh must be flagged as updatable
  84017. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84018. * @returns a new Mesh
  84019. */
  84020. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  84021. /**
  84022. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  84023. * @param name defines the name of the mesh to create
  84024. * @param diameter sets the diameter size (float) of the torus (default 1)
  84025. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  84026. * @param tessellation sets the number of torus sides (postive integer, default 16)
  84027. * @param scene defines the hosting scene
  84028. * @param updatable defines if the mesh must be flagged as updatable
  84029. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84030. * @returns a new Mesh
  84031. */
  84032. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  84033. /**
  84034. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  84035. * @param name defines the name of the mesh to create
  84036. * @param radius sets the global radius size (float) of the torus knot (default 2)
  84037. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  84038. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  84039. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  84040. * @param p the number of windings on X axis (positive integers, default 2)
  84041. * @param q the number of windings on Y axis (positive integers, default 3)
  84042. * @param scene defines the hosting scene
  84043. * @param updatable defines if the mesh must be flagged as updatable
  84044. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84045. * @returns a new Mesh
  84046. */
  84047. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  84048. /**
  84049. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  84050. * @param name defines the name of the mesh to create
  84051. * @param points is an array successive Vector3
  84052. * @param scene defines the hosting scene
  84053. * @param updatable defines if the mesh must be flagged as updatable
  84054. * @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).
  84055. * @returns a new Mesh
  84056. */
  84057. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  84058. /**
  84059. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  84060. * @param name defines the name of the mesh to create
  84061. * @param points is an array successive Vector3
  84062. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  84063. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  84064. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  84065. * @param scene defines the hosting scene
  84066. * @param updatable defines if the mesh must be flagged as updatable
  84067. * @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)
  84068. * @returns a new Mesh
  84069. */
  84070. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  84071. /**
  84072. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  84073. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  84074. * 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.
  84075. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84076. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  84077. * Remember you can only change the shape positions, not their number when updating a polygon.
  84078. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  84079. * @param name defines the name of the mesh to create
  84080. * @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
  84081. * @param scene defines the hosting scene
  84082. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  84083. * @param updatable defines if the mesh must be flagged as updatable
  84084. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84085. * @param earcutInjection can be used to inject your own earcut reference
  84086. * @returns a new Mesh
  84087. */
  84088. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  84089. /**
  84090. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  84091. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  84092. * @param name defines the name of the mesh to create
  84093. * @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
  84094. * @param depth defines the height of extrusion
  84095. * @param scene defines the hosting scene
  84096. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  84097. * @param updatable defines if the mesh must be flagged as updatable
  84098. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84099. * @param earcutInjection can be used to inject your own earcut reference
  84100. * @returns a new Mesh
  84101. */
  84102. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  84103. /**
  84104. * Creates an extruded shape mesh.
  84105. * 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
  84106. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  84107. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  84108. * @param name defines the name of the mesh to create
  84109. * @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
  84110. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  84111. * @param scale is the value to scale the shape
  84112. * @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
  84113. * @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
  84114. * @param scene defines the hosting scene
  84115. * @param updatable defines if the mesh must be flagged as updatable
  84116. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84117. * @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)
  84118. * @returns a new Mesh
  84119. */
  84120. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  84121. /**
  84122. * Creates an custom extruded shape mesh.
  84123. * The custom extrusion is a parametric shape.
  84124. * It has no predefined shape. Its final shape will depend on the input parameters.
  84125. * Please consider using the same method from the MeshBuilder class instead
  84126. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  84127. * @param name defines the name of the mesh to create
  84128. * @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
  84129. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  84130. * @param scaleFunction is a custom Javascript function called on each path point
  84131. * @param rotationFunction is a custom Javascript function called on each path point
  84132. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  84133. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  84134. * @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
  84135. * @param scene defines the hosting scene
  84136. * @param updatable defines if the mesh must be flagged as updatable
  84137. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84138. * @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)
  84139. * @returns a new Mesh
  84140. */
  84141. 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;
  84142. /**
  84143. * Creates lathe mesh.
  84144. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  84145. * Please consider using the same method from the MeshBuilder class instead
  84146. * @param name defines the name of the mesh to create
  84147. * @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
  84148. * @param radius is the radius value of the lathe
  84149. * @param tessellation is the side number of the lathe.
  84150. * @param scene defines the hosting scene
  84151. * @param updatable defines if the mesh must be flagged as updatable
  84152. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84153. * @returns a new Mesh
  84154. */
  84155. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  84156. /**
  84157. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  84158. * @param name defines the name of the mesh to create
  84159. * @param size sets the size (float) of both sides of the plane at once (default 1)
  84160. * @param scene defines the hosting scene
  84161. * @param updatable defines if the mesh must be flagged as updatable
  84162. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84163. * @returns a new Mesh
  84164. */
  84165. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  84166. /**
  84167. * Creates a ground mesh.
  84168. * Please consider using the same method from the MeshBuilder class instead
  84169. * @param name defines the name of the mesh to create
  84170. * @param width set the width of the ground
  84171. * @param height set the height of the ground
  84172. * @param subdivisions sets the number of subdivisions per side
  84173. * @param scene defines the hosting scene
  84174. * @param updatable defines if the mesh must be flagged as updatable
  84175. * @returns a new Mesh
  84176. */
  84177. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  84178. /**
  84179. * Creates a tiled ground mesh.
  84180. * Please consider using the same method from the MeshBuilder class instead
  84181. * @param name defines the name of the mesh to create
  84182. * @param xmin set the ground minimum X coordinate
  84183. * @param zmin set the ground minimum Y coordinate
  84184. * @param xmax set the ground maximum X coordinate
  84185. * @param zmax set the ground maximum Z coordinate
  84186. * @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
  84187. * @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
  84188. * @param scene defines the hosting scene
  84189. * @param updatable defines if the mesh must be flagged as updatable
  84190. * @returns a new Mesh
  84191. */
  84192. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  84193. w: number;
  84194. h: number;
  84195. }, precision: {
  84196. w: number;
  84197. h: number;
  84198. }, scene: Scene, updatable?: boolean): Mesh;
  84199. /**
  84200. * Creates a ground mesh from a height map.
  84201. * Please consider using the same method from the MeshBuilder class instead
  84202. * @see http://doc.babylonjs.com/babylon101/height_map
  84203. * @param name defines the name of the mesh to create
  84204. * @param url sets the URL of the height map image resource
  84205. * @param width set the ground width size
  84206. * @param height set the ground height size
  84207. * @param subdivisions sets the number of subdivision per side
  84208. * @param minHeight is the minimum altitude on the ground
  84209. * @param maxHeight is the maximum altitude on the ground
  84210. * @param scene defines the hosting scene
  84211. * @param updatable defines if the mesh must be flagged as updatable
  84212. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  84213. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  84214. * @returns a new Mesh
  84215. */
  84216. 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;
  84217. /**
  84218. * Creates a tube mesh.
  84219. * The tube is a parametric shape.
  84220. * It has no predefined shape. Its final shape will depend on the input parameters.
  84221. * Please consider using the same method from the MeshBuilder class instead
  84222. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  84223. * @param name defines the name of the mesh to create
  84224. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  84225. * @param radius sets the tube radius size
  84226. * @param tessellation is the number of sides on the tubular surface
  84227. * @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
  84228. * @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
  84229. * @param scene defines the hosting scene
  84230. * @param updatable defines if the mesh must be flagged as updatable
  84231. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84232. * @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)
  84233. * @returns a new Mesh
  84234. */
  84235. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  84236. (i: number, distance: number): number;
  84237. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  84238. /**
  84239. * Creates a polyhedron mesh.
  84240. * Please consider using the same method from the MeshBuilder class instead.
  84241. * * 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
  84242. * * The parameter `size` (positive float, default 1) sets the polygon size
  84243. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  84244. * * 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`
  84245. * * 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
  84246. * * 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)`)
  84247. * * 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
  84248. * * 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
  84249. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84250. * * If you create a double-sided mesh, you can choose what parts of 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
  84251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  84252. * @param name defines the name of the mesh to create
  84253. * @param options defines the options used to create the mesh
  84254. * @param scene defines the hosting scene
  84255. * @returns a new Mesh
  84256. */
  84257. static CreatePolyhedron(name: string, options: {
  84258. type?: number;
  84259. size?: number;
  84260. sizeX?: number;
  84261. sizeY?: number;
  84262. sizeZ?: number;
  84263. custom?: any;
  84264. faceUV?: Vector4[];
  84265. faceColors?: Color4[];
  84266. updatable?: boolean;
  84267. sideOrientation?: number;
  84268. }, scene: Scene): Mesh;
  84269. /**
  84270. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  84271. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  84272. * * 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`)
  84273. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  84274. * * 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
  84275. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84276. * * If you create a double-sided mesh, you can choose what parts of 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
  84277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  84278. * @param name defines the name of the mesh
  84279. * @param options defines the options used to create the mesh
  84280. * @param scene defines the hosting scene
  84281. * @returns a new Mesh
  84282. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  84283. */
  84284. static CreateIcoSphere(name: string, options: {
  84285. radius?: number;
  84286. flat?: boolean;
  84287. subdivisions?: number;
  84288. sideOrientation?: number;
  84289. updatable?: boolean;
  84290. }, scene: Scene): Mesh;
  84291. /**
  84292. * Creates a decal mesh.
  84293. * Please consider using the same method from the MeshBuilder class instead.
  84294. * A decal is a mesh usually applied as a model onto the surface of another mesh
  84295. * @param name defines the name of the mesh
  84296. * @param sourceMesh defines the mesh receiving the decal
  84297. * @param position sets the position of the decal in world coordinates
  84298. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  84299. * @param size sets the decal scaling
  84300. * @param angle sets the angle to rotate the decal
  84301. * @returns a new Mesh
  84302. */
  84303. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  84304. /**
  84305. * Prepare internal position array for software CPU skinning
  84306. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  84307. */
  84308. setPositionsForCPUSkinning(): Float32Array;
  84309. /**
  84310. * Prepare internal normal array for software CPU skinning
  84311. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  84312. */
  84313. setNormalsForCPUSkinning(): Float32Array;
  84314. /**
  84315. * Updates the vertex buffer by applying transformation from the bones
  84316. * @param skeleton defines the skeleton to apply to current mesh
  84317. * @returns the current mesh
  84318. */
  84319. applySkeleton(skeleton: Skeleton): Mesh;
  84320. /**
  84321. * 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
  84322. * @param meshes defines the list of meshes to scan
  84323. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  84324. */
  84325. static MinMax(meshes: AbstractMesh[]): {
  84326. min: Vector3;
  84327. max: Vector3;
  84328. };
  84329. /**
  84330. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  84331. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  84332. * @returns a vector3
  84333. */
  84334. static Center(meshesOrMinMaxVector: {
  84335. min: Vector3;
  84336. max: Vector3;
  84337. } | AbstractMesh[]): Vector3;
  84338. /**
  84339. * Merge the array of meshes into a single mesh for performance reasons.
  84340. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  84341. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  84342. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  84343. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  84344. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  84345. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  84346. * @returns a new mesh
  84347. */
  84348. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  84349. /** @hidden */
  84350. addInstance(instance: InstancedMesh): void;
  84351. /** @hidden */
  84352. removeInstance(instance: InstancedMesh): void;
  84353. }
  84354. }
  84355. declare module BABYLON {
  84356. /**
  84357. * Base class for the main features of a material in Babylon.js
  84358. */
  84359. export class Material implements IAnimatable {
  84360. /**
  84361. * Returns the triangle fill mode
  84362. */
  84363. static readonly TriangleFillMode: number;
  84364. /**
  84365. * Returns the wireframe mode
  84366. */
  84367. static readonly WireFrameFillMode: number;
  84368. /**
  84369. * Returns the point fill mode
  84370. */
  84371. static readonly PointFillMode: number;
  84372. /**
  84373. * Returns the point list draw mode
  84374. */
  84375. static readonly PointListDrawMode: number;
  84376. /**
  84377. * Returns the line list draw mode
  84378. */
  84379. static readonly LineListDrawMode: number;
  84380. /**
  84381. * Returns the line loop draw mode
  84382. */
  84383. static readonly LineLoopDrawMode: number;
  84384. /**
  84385. * Returns the line strip draw mode
  84386. */
  84387. static readonly LineStripDrawMode: number;
  84388. /**
  84389. * Returns the triangle strip draw mode
  84390. */
  84391. static readonly TriangleStripDrawMode: number;
  84392. /**
  84393. * Returns the triangle fan draw mode
  84394. */
  84395. static readonly TriangleFanDrawMode: number;
  84396. /**
  84397. * Stores the clock-wise side orientation
  84398. */
  84399. static readonly ClockWiseSideOrientation: number;
  84400. /**
  84401. * Stores the counter clock-wise side orientation
  84402. */
  84403. static readonly CounterClockWiseSideOrientation: number;
  84404. /**
  84405. * The dirty texture flag value
  84406. */
  84407. static readonly TextureDirtyFlag: number;
  84408. /**
  84409. * The dirty light flag value
  84410. */
  84411. static readonly LightDirtyFlag: number;
  84412. /**
  84413. * The dirty fresnel flag value
  84414. */
  84415. static readonly FresnelDirtyFlag: number;
  84416. /**
  84417. * The dirty attribute flag value
  84418. */
  84419. static readonly AttributesDirtyFlag: number;
  84420. /**
  84421. * The dirty misc flag value
  84422. */
  84423. static readonly MiscDirtyFlag: number;
  84424. /**
  84425. * The all dirty flag value
  84426. */
  84427. static readonly AllDirtyFlag: number;
  84428. /**
  84429. * The ID of the material
  84430. */
  84431. id: string;
  84432. /**
  84433. * Gets or sets the unique id of the material
  84434. */
  84435. uniqueId: number;
  84436. /**
  84437. * The name of the material
  84438. */
  84439. name: string;
  84440. /**
  84441. * Gets or sets user defined metadata
  84442. */
  84443. metadata: any;
  84444. /**
  84445. * For internal use only. Please do not use.
  84446. */
  84447. reservedDataStore: any;
  84448. /**
  84449. * Specifies if the ready state should be checked on each call
  84450. */
  84451. checkReadyOnEveryCall: boolean;
  84452. /**
  84453. * Specifies if the ready state should be checked once
  84454. */
  84455. checkReadyOnlyOnce: boolean;
  84456. /**
  84457. * The state of the material
  84458. */
  84459. state: string;
  84460. /**
  84461. * The alpha value of the material
  84462. */
  84463. protected _alpha: number;
  84464. /**
  84465. * List of inspectable custom properties (used by the Inspector)
  84466. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84467. */
  84468. inspectableCustomProperties: IInspectable[];
  84469. /**
  84470. * Sets the alpha value of the material
  84471. */
  84472. /**
  84473. * Gets the alpha value of the material
  84474. */
  84475. alpha: number;
  84476. /**
  84477. * Specifies if back face culling is enabled
  84478. */
  84479. protected _backFaceCulling: boolean;
  84480. /**
  84481. * Sets the back-face culling state
  84482. */
  84483. /**
  84484. * Gets the back-face culling state
  84485. */
  84486. backFaceCulling: boolean;
  84487. /**
  84488. * Stores the value for side orientation
  84489. */
  84490. sideOrientation: number;
  84491. /**
  84492. * Callback triggered when the material is compiled
  84493. */
  84494. onCompiled: Nullable<(effect: Effect) => void>;
  84495. /**
  84496. * Callback triggered when an error occurs
  84497. */
  84498. onError: Nullable<(effect: Effect, errors: string) => void>;
  84499. /**
  84500. * Callback triggered to get the render target textures
  84501. */
  84502. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84503. /**
  84504. * Gets a boolean indicating that current material needs to register RTT
  84505. */
  84506. readonly hasRenderTargetTextures: boolean;
  84507. /**
  84508. * Specifies if the material should be serialized
  84509. */
  84510. doNotSerialize: boolean;
  84511. /**
  84512. * @hidden
  84513. */
  84514. _storeEffectOnSubMeshes: boolean;
  84515. /**
  84516. * Stores the animations for the material
  84517. */
  84518. animations: Nullable<Array<Animation>>;
  84519. /**
  84520. * An event triggered when the material is disposed
  84521. */
  84522. onDisposeObservable: Observable<Material>;
  84523. /**
  84524. * An observer which watches for dispose events
  84525. */
  84526. private _onDisposeObserver;
  84527. private _onUnBindObservable;
  84528. /**
  84529. * Called during a dispose event
  84530. */
  84531. onDispose: () => void;
  84532. private _onBindObservable;
  84533. /**
  84534. * An event triggered when the material is bound
  84535. */
  84536. readonly onBindObservable: Observable<AbstractMesh>;
  84537. /**
  84538. * An observer which watches for bind events
  84539. */
  84540. private _onBindObserver;
  84541. /**
  84542. * Called during a bind event
  84543. */
  84544. onBind: (Mesh: AbstractMesh) => void;
  84545. /**
  84546. * An event triggered when the material is unbound
  84547. */
  84548. readonly onUnBindObservable: Observable<Material>;
  84549. /**
  84550. * Stores the value of the alpha mode
  84551. */
  84552. private _alphaMode;
  84553. /**
  84554. * Sets the value of the alpha mode.
  84555. *
  84556. * | Value | Type | Description |
  84557. * | --- | --- | --- |
  84558. * | 0 | ALPHA_DISABLE | |
  84559. * | 1 | ALPHA_ADD | |
  84560. * | 2 | ALPHA_COMBINE | |
  84561. * | 3 | ALPHA_SUBTRACT | |
  84562. * | 4 | ALPHA_MULTIPLY | |
  84563. * | 5 | ALPHA_MAXIMIZED | |
  84564. * | 6 | ALPHA_ONEONE | |
  84565. * | 7 | ALPHA_PREMULTIPLIED | |
  84566. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84567. * | 9 | ALPHA_INTERPOLATE | |
  84568. * | 10 | ALPHA_SCREENMODE | |
  84569. *
  84570. */
  84571. /**
  84572. * Gets the value of the alpha mode
  84573. */
  84574. alphaMode: number;
  84575. /**
  84576. * Stores the state of the need depth pre-pass value
  84577. */
  84578. private _needDepthPrePass;
  84579. /**
  84580. * Sets the need depth pre-pass value
  84581. */
  84582. /**
  84583. * Gets the depth pre-pass value
  84584. */
  84585. needDepthPrePass: boolean;
  84586. /**
  84587. * Specifies if depth writing should be disabled
  84588. */
  84589. disableDepthWrite: boolean;
  84590. /**
  84591. * Specifies if depth writing should be forced
  84592. */
  84593. forceDepthWrite: boolean;
  84594. /**
  84595. * Specifies if there should be a separate pass for culling
  84596. */
  84597. separateCullingPass: boolean;
  84598. /**
  84599. * Stores the state specifing if fog should be enabled
  84600. */
  84601. private _fogEnabled;
  84602. /**
  84603. * Sets the state for enabling fog
  84604. */
  84605. /**
  84606. * Gets the value of the fog enabled state
  84607. */
  84608. fogEnabled: boolean;
  84609. /**
  84610. * Stores the size of points
  84611. */
  84612. pointSize: number;
  84613. /**
  84614. * Stores the z offset value
  84615. */
  84616. zOffset: number;
  84617. /**
  84618. * Gets a value specifying if wireframe mode is enabled
  84619. */
  84620. /**
  84621. * Sets the state of wireframe mode
  84622. */
  84623. wireframe: boolean;
  84624. /**
  84625. * Gets the value specifying if point clouds are enabled
  84626. */
  84627. /**
  84628. * Sets the state of point cloud mode
  84629. */
  84630. pointsCloud: boolean;
  84631. /**
  84632. * Gets the material fill mode
  84633. */
  84634. /**
  84635. * Sets the material fill mode
  84636. */
  84637. fillMode: number;
  84638. /**
  84639. * @hidden
  84640. * Stores the effects for the material
  84641. */
  84642. _effect: Nullable<Effect>;
  84643. /**
  84644. * @hidden
  84645. * Specifies if the material was previously ready
  84646. */
  84647. _wasPreviouslyReady: boolean;
  84648. /**
  84649. * Specifies if uniform buffers should be used
  84650. */
  84651. private _useUBO;
  84652. /**
  84653. * Stores a reference to the scene
  84654. */
  84655. private _scene;
  84656. /**
  84657. * Stores the fill mode state
  84658. */
  84659. private _fillMode;
  84660. /**
  84661. * Specifies if the depth write state should be cached
  84662. */
  84663. private _cachedDepthWriteState;
  84664. /**
  84665. * Stores the uniform buffer
  84666. */
  84667. protected _uniformBuffer: UniformBuffer;
  84668. /** @hidden */
  84669. _indexInSceneMaterialArray: number;
  84670. /** @hidden */
  84671. meshMap: Nullable<{
  84672. [id: string]: AbstractMesh | undefined;
  84673. }>;
  84674. /**
  84675. * Creates a material instance
  84676. * @param name defines the name of the material
  84677. * @param scene defines the scene to reference
  84678. * @param doNotAdd specifies if the material should be added to the scene
  84679. */
  84680. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84681. /**
  84682. * Returns a string representation of the current material
  84683. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84684. * @returns a string with material information
  84685. */
  84686. toString(fullDetails?: boolean): string;
  84687. /**
  84688. * Gets the class name of the material
  84689. * @returns a string with the class name of the material
  84690. */
  84691. getClassName(): string;
  84692. /**
  84693. * Specifies if updates for the material been locked
  84694. */
  84695. readonly isFrozen: boolean;
  84696. /**
  84697. * Locks updates for the material
  84698. */
  84699. freeze(): void;
  84700. /**
  84701. * Unlocks updates for the material
  84702. */
  84703. unfreeze(): void;
  84704. /**
  84705. * Specifies if the material is ready to be used
  84706. * @param mesh defines the mesh to check
  84707. * @param useInstances specifies if instances should be used
  84708. * @returns a boolean indicating if the material is ready to be used
  84709. */
  84710. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84711. /**
  84712. * Specifies that the submesh is ready to be used
  84713. * @param mesh defines the mesh to check
  84714. * @param subMesh defines which submesh to check
  84715. * @param useInstances specifies that instances should be used
  84716. * @returns a boolean indicating that the submesh is ready or not
  84717. */
  84718. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84719. /**
  84720. * Returns the material effect
  84721. * @returns the effect associated with the material
  84722. */
  84723. getEffect(): Nullable<Effect>;
  84724. /**
  84725. * Returns the current scene
  84726. * @returns a Scene
  84727. */
  84728. getScene(): Scene;
  84729. /**
  84730. * Specifies if the material will require alpha blending
  84731. * @returns a boolean specifying if alpha blending is needed
  84732. */
  84733. needAlphaBlending(): boolean;
  84734. /**
  84735. * Specifies if the mesh will require alpha blending
  84736. * @param mesh defines the mesh to check
  84737. * @returns a boolean specifying if alpha blending is needed for the mesh
  84738. */
  84739. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  84740. /**
  84741. * Specifies if this material should be rendered in alpha test mode
  84742. * @returns a boolean specifying if an alpha test is needed.
  84743. */
  84744. needAlphaTesting(): boolean;
  84745. /**
  84746. * Gets the texture used for the alpha test
  84747. * @returns the texture to use for alpha testing
  84748. */
  84749. getAlphaTestTexture(): Nullable<BaseTexture>;
  84750. /**
  84751. * Marks the material to indicate that it needs to be re-calculated
  84752. */
  84753. markDirty(): void;
  84754. /** @hidden */
  84755. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  84756. /**
  84757. * Binds the material to the mesh
  84758. * @param world defines the world transformation matrix
  84759. * @param mesh defines the mesh to bind the material to
  84760. */
  84761. bind(world: Matrix, mesh?: Mesh): void;
  84762. /**
  84763. * Binds the submesh to the material
  84764. * @param world defines the world transformation matrix
  84765. * @param mesh defines the mesh containing the submesh
  84766. * @param subMesh defines the submesh to bind the material to
  84767. */
  84768. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  84769. /**
  84770. * Binds the world matrix to the material
  84771. * @param world defines the world transformation matrix
  84772. */
  84773. bindOnlyWorldMatrix(world: Matrix): void;
  84774. /**
  84775. * Binds the scene's uniform buffer to the effect.
  84776. * @param effect defines the effect to bind to the scene uniform buffer
  84777. * @param sceneUbo defines the uniform buffer storing scene data
  84778. */
  84779. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  84780. /**
  84781. * Binds the view matrix to the effect
  84782. * @param effect defines the effect to bind the view matrix to
  84783. */
  84784. bindView(effect: Effect): void;
  84785. /**
  84786. * Binds the view projection matrix to the effect
  84787. * @param effect defines the effect to bind the view projection matrix to
  84788. */
  84789. bindViewProjection(effect: Effect): void;
  84790. /**
  84791. * Specifies if material alpha testing should be turned on for the mesh
  84792. * @param mesh defines the mesh to check
  84793. */
  84794. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  84795. /**
  84796. * Processes to execute after binding the material to a mesh
  84797. * @param mesh defines the rendered mesh
  84798. */
  84799. protected _afterBind(mesh?: Mesh): void;
  84800. /**
  84801. * Unbinds the material from the mesh
  84802. */
  84803. unbind(): void;
  84804. /**
  84805. * Gets the active textures from the material
  84806. * @returns an array of textures
  84807. */
  84808. getActiveTextures(): BaseTexture[];
  84809. /**
  84810. * Specifies if the material uses a texture
  84811. * @param texture defines the texture to check against the material
  84812. * @returns a boolean specifying if the material uses the texture
  84813. */
  84814. hasTexture(texture: BaseTexture): boolean;
  84815. /**
  84816. * Makes a duplicate of the material, and gives it a new name
  84817. * @param name defines the new name for the duplicated material
  84818. * @returns the cloned material
  84819. */
  84820. clone(name: string): Nullable<Material>;
  84821. /**
  84822. * Gets the meshes bound to the material
  84823. * @returns an array of meshes bound to the material
  84824. */
  84825. getBindedMeshes(): AbstractMesh[];
  84826. /**
  84827. * Force shader compilation
  84828. * @param mesh defines the mesh associated with this material
  84829. * @param onCompiled defines a function to execute once the material is compiled
  84830. * @param options defines the options to configure the compilation
  84831. */
  84832. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  84833. clipPlane: boolean;
  84834. }>): void;
  84835. /**
  84836. * Force shader compilation
  84837. * @param mesh defines the mesh that will use this material
  84838. * @param options defines additional options for compiling the shaders
  84839. * @returns a promise that resolves when the compilation completes
  84840. */
  84841. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  84842. clipPlane: boolean;
  84843. }>): Promise<void>;
  84844. private static readonly _AllDirtyCallBack;
  84845. private static readonly _ImageProcessingDirtyCallBack;
  84846. private static readonly _TextureDirtyCallBack;
  84847. private static readonly _FresnelDirtyCallBack;
  84848. private static readonly _MiscDirtyCallBack;
  84849. private static readonly _LightsDirtyCallBack;
  84850. private static readonly _AttributeDirtyCallBack;
  84851. private static _FresnelAndMiscDirtyCallBack;
  84852. private static _TextureAndMiscDirtyCallBack;
  84853. private static readonly _DirtyCallbackArray;
  84854. private static readonly _RunDirtyCallBacks;
  84855. /**
  84856. * Marks a define in the material to indicate that it needs to be re-computed
  84857. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  84858. */
  84859. markAsDirty(flag: number): void;
  84860. /**
  84861. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  84862. * @param func defines a function which checks material defines against the submeshes
  84863. */
  84864. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  84865. /**
  84866. * Indicates that we need to re-calculated for all submeshes
  84867. */
  84868. protected _markAllSubMeshesAsAllDirty(): void;
  84869. /**
  84870. * Indicates that image processing needs to be re-calculated for all submeshes
  84871. */
  84872. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  84873. /**
  84874. * Indicates that textures need to be re-calculated for all submeshes
  84875. */
  84876. protected _markAllSubMeshesAsTexturesDirty(): void;
  84877. /**
  84878. * Indicates that fresnel needs to be re-calculated for all submeshes
  84879. */
  84880. protected _markAllSubMeshesAsFresnelDirty(): void;
  84881. /**
  84882. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  84883. */
  84884. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  84885. /**
  84886. * Indicates that lights need to be re-calculated for all submeshes
  84887. */
  84888. protected _markAllSubMeshesAsLightsDirty(): void;
  84889. /**
  84890. * Indicates that attributes need to be re-calculated for all submeshes
  84891. */
  84892. protected _markAllSubMeshesAsAttributesDirty(): void;
  84893. /**
  84894. * Indicates that misc needs to be re-calculated for all submeshes
  84895. */
  84896. protected _markAllSubMeshesAsMiscDirty(): void;
  84897. /**
  84898. * Indicates that textures and misc need to be re-calculated for all submeshes
  84899. */
  84900. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  84901. /**
  84902. * Disposes the material
  84903. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84904. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84905. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84906. */
  84907. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84908. /** @hidden */
  84909. private releaseVertexArrayObject;
  84910. /**
  84911. * Serializes this material
  84912. * @returns the serialized material object
  84913. */
  84914. serialize(): any;
  84915. /**
  84916. * Creates a material from parsed material data
  84917. * @param parsedMaterial defines parsed material data
  84918. * @param scene defines the hosting scene
  84919. * @param rootUrl defines the root URL to use to load textures
  84920. * @returns a new material
  84921. */
  84922. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  84923. }
  84924. }
  84925. declare module BABYLON {
  84926. /**
  84927. * Base class for submeshes
  84928. */
  84929. export class BaseSubMesh {
  84930. /** @hidden */
  84931. _materialDefines: Nullable<MaterialDefines>;
  84932. /** @hidden */
  84933. _materialEffect: Nullable<Effect>;
  84934. /**
  84935. * Gets associated effect
  84936. */
  84937. readonly effect: Nullable<Effect>;
  84938. /**
  84939. * Sets associated effect (effect used to render this submesh)
  84940. * @param effect defines the effect to associate with
  84941. * @param defines defines the set of defines used to compile this effect
  84942. */
  84943. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  84944. }
  84945. /**
  84946. * Defines a subdivision inside a mesh
  84947. */
  84948. export class SubMesh extends BaseSubMesh implements ICullable {
  84949. /** the material index to use */
  84950. materialIndex: number;
  84951. /** vertex index start */
  84952. verticesStart: number;
  84953. /** vertices count */
  84954. verticesCount: number;
  84955. /** index start */
  84956. indexStart: number;
  84957. /** indices count */
  84958. indexCount: number;
  84959. /** @hidden */
  84960. _linesIndexCount: number;
  84961. private _mesh;
  84962. private _renderingMesh;
  84963. private _boundingInfo;
  84964. private _linesIndexBuffer;
  84965. /** @hidden */
  84966. _lastColliderWorldVertices: Nullable<Vector3[]>;
  84967. /** @hidden */
  84968. _trianglePlanes: Plane[];
  84969. /** @hidden */
  84970. _lastColliderTransformMatrix: Nullable<Matrix>;
  84971. /** @hidden */
  84972. _renderId: number;
  84973. /** @hidden */
  84974. _alphaIndex: number;
  84975. /** @hidden */
  84976. _distanceToCamera: number;
  84977. /** @hidden */
  84978. _id: number;
  84979. private _currentMaterial;
  84980. /**
  84981. * Add a new submesh to a mesh
  84982. * @param materialIndex defines the material index to use
  84983. * @param verticesStart defines vertex index start
  84984. * @param verticesCount defines vertices count
  84985. * @param indexStart defines index start
  84986. * @param indexCount defines indices count
  84987. * @param mesh defines the parent mesh
  84988. * @param renderingMesh defines an optional rendering mesh
  84989. * @param createBoundingBox defines if bounding box should be created for this submesh
  84990. * @returns the new submesh
  84991. */
  84992. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  84993. /**
  84994. * Creates a new submesh
  84995. * @param materialIndex defines the material index to use
  84996. * @param verticesStart defines vertex index start
  84997. * @param verticesCount defines vertices count
  84998. * @param indexStart defines index start
  84999. * @param indexCount defines indices count
  85000. * @param mesh defines the parent mesh
  85001. * @param renderingMesh defines an optional rendering mesh
  85002. * @param createBoundingBox defines if bounding box should be created for this submesh
  85003. */
  85004. constructor(
  85005. /** the material index to use */
  85006. materialIndex: number,
  85007. /** vertex index start */
  85008. verticesStart: number,
  85009. /** vertices count */
  85010. verticesCount: number,
  85011. /** index start */
  85012. indexStart: number,
  85013. /** indices count */
  85014. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85015. /**
  85016. * Returns true if this submesh covers the entire parent mesh
  85017. * @ignorenaming
  85018. */
  85019. readonly IsGlobal: boolean;
  85020. /**
  85021. * Returns the submesh BoudingInfo object
  85022. * @returns current bounding info (or mesh's one if the submesh is global)
  85023. */
  85024. getBoundingInfo(): BoundingInfo;
  85025. /**
  85026. * Sets the submesh BoundingInfo
  85027. * @param boundingInfo defines the new bounding info to use
  85028. * @returns the SubMesh
  85029. */
  85030. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85031. /**
  85032. * Returns the mesh of the current submesh
  85033. * @return the parent mesh
  85034. */
  85035. getMesh(): AbstractMesh;
  85036. /**
  85037. * Returns the rendering mesh of the submesh
  85038. * @returns the rendering mesh (could be different from parent mesh)
  85039. */
  85040. getRenderingMesh(): Mesh;
  85041. /**
  85042. * Returns the submesh material
  85043. * @returns null or the current material
  85044. */
  85045. getMaterial(): Nullable<Material>;
  85046. /**
  85047. * Sets a new updated BoundingInfo object to the submesh
  85048. * @param data defines an optional position array to use to determine the bounding info
  85049. * @returns the SubMesh
  85050. */
  85051. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85052. /** @hidden */
  85053. _checkCollision(collider: Collider): boolean;
  85054. /**
  85055. * Updates the submesh BoundingInfo
  85056. * @param world defines the world matrix to use to update the bounding info
  85057. * @returns the submesh
  85058. */
  85059. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85060. /**
  85061. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85062. * @param frustumPlanes defines the frustum planes
  85063. * @returns true if the submesh is intersecting with the frustum
  85064. */
  85065. isInFrustum(frustumPlanes: Plane[]): boolean;
  85066. /**
  85067. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85068. * @param frustumPlanes defines the frustum planes
  85069. * @returns true if the submesh is inside the frustum
  85070. */
  85071. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85072. /**
  85073. * Renders the submesh
  85074. * @param enableAlphaMode defines if alpha needs to be used
  85075. * @returns the submesh
  85076. */
  85077. render(enableAlphaMode: boolean): SubMesh;
  85078. /**
  85079. * @hidden
  85080. */
  85081. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85082. /**
  85083. * Checks if the submesh intersects with a ray
  85084. * @param ray defines the ray to test
  85085. * @returns true is the passed ray intersects the submesh bounding box
  85086. */
  85087. canIntersects(ray: Ray): boolean;
  85088. /**
  85089. * Intersects current submesh with a ray
  85090. * @param ray defines the ray to test
  85091. * @param positions defines mesh's positions array
  85092. * @param indices defines mesh's indices array
  85093. * @param fastCheck defines if only bounding info should be used
  85094. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85095. * @returns intersection info or null if no intersection
  85096. */
  85097. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85098. /** @hidden */
  85099. private _intersectLines;
  85100. /** @hidden */
  85101. private _intersectUnIndexedLines;
  85102. /** @hidden */
  85103. private _intersectTriangles;
  85104. /** @hidden */
  85105. private _intersectUnIndexedTriangles;
  85106. /** @hidden */
  85107. _rebuild(): void;
  85108. /**
  85109. * Creates a new submesh from the passed mesh
  85110. * @param newMesh defines the new hosting mesh
  85111. * @param newRenderingMesh defines an optional rendering mesh
  85112. * @returns the new submesh
  85113. */
  85114. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85115. /**
  85116. * Release associated resources
  85117. */
  85118. dispose(): void;
  85119. /**
  85120. * Gets the class name
  85121. * @returns the string "SubMesh".
  85122. */
  85123. getClassName(): string;
  85124. /**
  85125. * Creates a new submesh from indices data
  85126. * @param materialIndex the index of the main mesh material
  85127. * @param startIndex the index where to start the copy in the mesh indices array
  85128. * @param indexCount the number of indices to copy then from the startIndex
  85129. * @param mesh the main mesh to create the submesh from
  85130. * @param renderingMesh the optional rendering mesh
  85131. * @returns a new submesh
  85132. */
  85133. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85134. }
  85135. }
  85136. declare module BABYLON {
  85137. /**
  85138. * Class used to store geometry data (vertex buffers + index buffer)
  85139. */
  85140. export class Geometry implements IGetSetVerticesData {
  85141. /**
  85142. * Gets or sets the ID of the geometry
  85143. */
  85144. id: string;
  85145. /**
  85146. * Gets or sets the unique ID of the geometry
  85147. */
  85148. uniqueId: number;
  85149. /**
  85150. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85151. */
  85152. delayLoadState: number;
  85153. /**
  85154. * Gets the file containing the data to load when running in delay load state
  85155. */
  85156. delayLoadingFile: Nullable<string>;
  85157. /**
  85158. * Callback called when the geometry is updated
  85159. */
  85160. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85161. private _scene;
  85162. private _engine;
  85163. private _meshes;
  85164. private _totalVertices;
  85165. /** @hidden */
  85166. _indices: IndicesArray;
  85167. /** @hidden */
  85168. _vertexBuffers: {
  85169. [key: string]: VertexBuffer;
  85170. };
  85171. private _isDisposed;
  85172. private _extend;
  85173. private _boundingBias;
  85174. /** @hidden */
  85175. _delayInfo: Array<string>;
  85176. private _indexBuffer;
  85177. private _indexBufferIsUpdatable;
  85178. /** @hidden */
  85179. _boundingInfo: Nullable<BoundingInfo>;
  85180. /** @hidden */
  85181. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85182. /** @hidden */
  85183. _softwareSkinningFrameId: number;
  85184. private _vertexArrayObjects;
  85185. private _updatable;
  85186. /** @hidden */
  85187. _positions: Nullable<Vector3[]>;
  85188. /**
  85189. * 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
  85190. */
  85191. /**
  85192. * 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
  85193. */
  85194. boundingBias: Vector2;
  85195. /**
  85196. * Static function used to attach a new empty geometry to a mesh
  85197. * @param mesh defines the mesh to attach the geometry to
  85198. * @returns the new Geometry
  85199. */
  85200. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85201. /**
  85202. * Creates a new geometry
  85203. * @param id defines the unique ID
  85204. * @param scene defines the hosting scene
  85205. * @param vertexData defines the VertexData used to get geometry data
  85206. * @param updatable defines if geometry must be updatable (false by default)
  85207. * @param mesh defines the mesh that will be associated with the geometry
  85208. */
  85209. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85210. /**
  85211. * Gets the current extend of the geometry
  85212. */
  85213. readonly extend: {
  85214. minimum: Vector3;
  85215. maximum: Vector3;
  85216. };
  85217. /**
  85218. * Gets the hosting scene
  85219. * @returns the hosting Scene
  85220. */
  85221. getScene(): Scene;
  85222. /**
  85223. * Gets the hosting engine
  85224. * @returns the hosting Engine
  85225. */
  85226. getEngine(): Engine;
  85227. /**
  85228. * Defines if the geometry is ready to use
  85229. * @returns true if the geometry is ready to be used
  85230. */
  85231. isReady(): boolean;
  85232. /**
  85233. * Gets a value indicating that the geometry should not be serialized
  85234. */
  85235. readonly doNotSerialize: boolean;
  85236. /** @hidden */
  85237. _rebuild(): void;
  85238. /**
  85239. * Affects all geometry data in one call
  85240. * @param vertexData defines the geometry data
  85241. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85242. */
  85243. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85244. /**
  85245. * Set specific vertex data
  85246. * @param kind defines the data kind (Position, normal, etc...)
  85247. * @param data defines the vertex data to use
  85248. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85249. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85250. */
  85251. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85252. /**
  85253. * Removes a specific vertex data
  85254. * @param kind defines the data kind (Position, normal, etc...)
  85255. */
  85256. removeVerticesData(kind: string): void;
  85257. /**
  85258. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85259. * @param buffer defines the vertex buffer to use
  85260. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85261. */
  85262. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85263. /**
  85264. * Update a specific vertex buffer
  85265. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85266. * It will do nothing if the buffer is not updatable
  85267. * @param kind defines the data kind (Position, normal, etc...)
  85268. * @param data defines the data to use
  85269. * @param offset defines the offset in the target buffer where to store the data
  85270. * @param useBytes set to true if the offset is in bytes
  85271. */
  85272. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85273. /**
  85274. * Update a specific vertex buffer
  85275. * This function will create a new buffer if the current one is not updatable
  85276. * @param kind defines the data kind (Position, normal, etc...)
  85277. * @param data defines the data to use
  85278. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85279. */
  85280. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85281. private _updateBoundingInfo;
  85282. /** @hidden */
  85283. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85284. /**
  85285. * Gets total number of vertices
  85286. * @returns the total number of vertices
  85287. */
  85288. getTotalVertices(): number;
  85289. /**
  85290. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85291. * @param kind defines the data kind (Position, normal, etc...)
  85292. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85293. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85294. * @returns a float array containing vertex data
  85295. */
  85296. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85297. /**
  85298. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85299. * @param kind defines the data kind (Position, normal, etc...)
  85300. * @returns true if the vertex buffer with the specified kind is updatable
  85301. */
  85302. isVertexBufferUpdatable(kind: string): boolean;
  85303. /**
  85304. * Gets a specific vertex buffer
  85305. * @param kind defines the data kind (Position, normal, etc...)
  85306. * @returns a VertexBuffer
  85307. */
  85308. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85309. /**
  85310. * Returns all vertex buffers
  85311. * @return an object holding all vertex buffers indexed by kind
  85312. */
  85313. getVertexBuffers(): Nullable<{
  85314. [key: string]: VertexBuffer;
  85315. }>;
  85316. /**
  85317. * Gets a boolean indicating if specific vertex buffer is present
  85318. * @param kind defines the data kind (Position, normal, etc...)
  85319. * @returns true if data is present
  85320. */
  85321. isVerticesDataPresent(kind: string): boolean;
  85322. /**
  85323. * Gets a list of all attached data kinds (Position, normal, etc...)
  85324. * @returns a list of string containing all kinds
  85325. */
  85326. getVerticesDataKinds(): string[];
  85327. /**
  85328. * Update index buffer
  85329. * @param indices defines the indices to store in the index buffer
  85330. * @param offset defines the offset in the target buffer where to store the data
  85331. * @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)
  85332. */
  85333. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85334. /**
  85335. * Creates a new index buffer
  85336. * @param indices defines the indices to store in the index buffer
  85337. * @param totalVertices defines the total number of vertices (could be null)
  85338. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85339. */
  85340. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85341. /**
  85342. * Return the total number of indices
  85343. * @returns the total number of indices
  85344. */
  85345. getTotalIndices(): number;
  85346. /**
  85347. * Gets the index buffer array
  85348. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85349. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85350. * @returns the index buffer array
  85351. */
  85352. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85353. /**
  85354. * Gets the index buffer
  85355. * @return the index buffer
  85356. */
  85357. getIndexBuffer(): Nullable<DataBuffer>;
  85358. /** @hidden */
  85359. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85360. /**
  85361. * Release the associated resources for a specific mesh
  85362. * @param mesh defines the source mesh
  85363. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85364. */
  85365. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85366. /**
  85367. * Apply current geometry to a given mesh
  85368. * @param mesh defines the mesh to apply geometry to
  85369. */
  85370. applyToMesh(mesh: Mesh): void;
  85371. private _updateExtend;
  85372. private _applyToMesh;
  85373. private notifyUpdate;
  85374. /**
  85375. * Load the geometry if it was flagged as delay loaded
  85376. * @param scene defines the hosting scene
  85377. * @param onLoaded defines a callback called when the geometry is loaded
  85378. */
  85379. load(scene: Scene, onLoaded?: () => void): void;
  85380. private _queueLoad;
  85381. /**
  85382. * Invert the geometry to move from a right handed system to a left handed one.
  85383. */
  85384. toLeftHanded(): void;
  85385. /** @hidden */
  85386. _resetPointsArrayCache(): void;
  85387. /** @hidden */
  85388. _generatePointsArray(): boolean;
  85389. /**
  85390. * Gets a value indicating if the geometry is disposed
  85391. * @returns true if the geometry was disposed
  85392. */
  85393. isDisposed(): boolean;
  85394. private _disposeVertexArrayObjects;
  85395. /**
  85396. * Free all associated resources
  85397. */
  85398. dispose(): void;
  85399. /**
  85400. * Clone the current geometry into a new geometry
  85401. * @param id defines the unique ID of the new geometry
  85402. * @returns a new geometry object
  85403. */
  85404. copy(id: string): Geometry;
  85405. /**
  85406. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85407. * @return a JSON representation of the current geometry data (without the vertices data)
  85408. */
  85409. serialize(): any;
  85410. private toNumberArray;
  85411. /**
  85412. * Serialize all vertices data into a JSON oject
  85413. * @returns a JSON representation of the current geometry data
  85414. */
  85415. serializeVerticeData(): any;
  85416. /**
  85417. * Extracts a clone of a mesh geometry
  85418. * @param mesh defines the source mesh
  85419. * @param id defines the unique ID of the new geometry object
  85420. * @returns the new geometry object
  85421. */
  85422. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85423. /**
  85424. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85425. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85426. * Be aware Math.random() could cause collisions, but:
  85427. * "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"
  85428. * @returns a string containing a new GUID
  85429. */
  85430. static RandomId(): string;
  85431. /** @hidden */
  85432. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85433. private static _CleanMatricesWeights;
  85434. /**
  85435. * Create a new geometry from persisted data (Using .babylon file format)
  85436. * @param parsedVertexData defines the persisted data
  85437. * @param scene defines the hosting scene
  85438. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85439. * @returns the new geometry object
  85440. */
  85441. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85442. }
  85443. }
  85444. declare module BABYLON {
  85445. /**
  85446. * Define an interface for all classes that will get and set the data on vertices
  85447. */
  85448. export interface IGetSetVerticesData {
  85449. /**
  85450. * Gets a boolean indicating if specific vertex data is present
  85451. * @param kind defines the vertex data kind to use
  85452. * @returns true is data kind is present
  85453. */
  85454. isVerticesDataPresent(kind: string): boolean;
  85455. /**
  85456. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85457. * @param kind defines the data kind (Position, normal, etc...)
  85458. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85459. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85460. * @returns a float array containing vertex data
  85461. */
  85462. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85463. /**
  85464. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85465. * @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.
  85466. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85467. * @returns the indices array or an empty array if the mesh has no geometry
  85468. */
  85469. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85470. /**
  85471. * Set specific vertex data
  85472. * @param kind defines the data kind (Position, normal, etc...)
  85473. * @param data defines the vertex data to use
  85474. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85475. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85476. */
  85477. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85478. /**
  85479. * Update a specific associated vertex buffer
  85480. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85481. * - VertexBuffer.PositionKind
  85482. * - VertexBuffer.UVKind
  85483. * - VertexBuffer.UV2Kind
  85484. * - VertexBuffer.UV3Kind
  85485. * - VertexBuffer.UV4Kind
  85486. * - VertexBuffer.UV5Kind
  85487. * - VertexBuffer.UV6Kind
  85488. * - VertexBuffer.ColorKind
  85489. * - VertexBuffer.MatricesIndicesKind
  85490. * - VertexBuffer.MatricesIndicesExtraKind
  85491. * - VertexBuffer.MatricesWeightsKind
  85492. * - VertexBuffer.MatricesWeightsExtraKind
  85493. * @param data defines the data source
  85494. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85495. * @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)
  85496. */
  85497. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85498. /**
  85499. * Creates a new index buffer
  85500. * @param indices defines the indices to store in the index buffer
  85501. * @param totalVertices defines the total number of vertices (could be null)
  85502. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85503. */
  85504. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85505. }
  85506. /**
  85507. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85508. */
  85509. export class VertexData {
  85510. /**
  85511. * Mesh side orientation : usually the external or front surface
  85512. */
  85513. static readonly FRONTSIDE: number;
  85514. /**
  85515. * Mesh side orientation : usually the internal or back surface
  85516. */
  85517. static readonly BACKSIDE: number;
  85518. /**
  85519. * Mesh side orientation : both internal and external or front and back surfaces
  85520. */
  85521. static readonly DOUBLESIDE: number;
  85522. /**
  85523. * Mesh side orientation : by default, `FRONTSIDE`
  85524. */
  85525. static readonly DEFAULTSIDE: number;
  85526. /**
  85527. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85528. */
  85529. positions: Nullable<FloatArray>;
  85530. /**
  85531. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85532. */
  85533. normals: Nullable<FloatArray>;
  85534. /**
  85535. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85536. */
  85537. tangents: Nullable<FloatArray>;
  85538. /**
  85539. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85540. */
  85541. uvs: Nullable<FloatArray>;
  85542. /**
  85543. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85544. */
  85545. uvs2: Nullable<FloatArray>;
  85546. /**
  85547. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85548. */
  85549. uvs3: Nullable<FloatArray>;
  85550. /**
  85551. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85552. */
  85553. uvs4: Nullable<FloatArray>;
  85554. /**
  85555. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85556. */
  85557. uvs5: Nullable<FloatArray>;
  85558. /**
  85559. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85560. */
  85561. uvs6: Nullable<FloatArray>;
  85562. /**
  85563. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85564. */
  85565. colors: Nullable<FloatArray>;
  85566. /**
  85567. * 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).
  85568. */
  85569. matricesIndices: Nullable<FloatArray>;
  85570. /**
  85571. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85572. */
  85573. matricesWeights: Nullable<FloatArray>;
  85574. /**
  85575. * An array extending the number of possible indices
  85576. */
  85577. matricesIndicesExtra: Nullable<FloatArray>;
  85578. /**
  85579. * An array extending the number of possible weights when the number of indices is extended
  85580. */
  85581. matricesWeightsExtra: Nullable<FloatArray>;
  85582. /**
  85583. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85584. */
  85585. indices: Nullable<IndicesArray>;
  85586. /**
  85587. * Uses the passed data array to set the set the values for the specified kind of data
  85588. * @param data a linear array of floating numbers
  85589. * @param kind the type of data that is being set, eg positions, colors etc
  85590. */
  85591. set(data: FloatArray, kind: string): void;
  85592. /**
  85593. * Associates the vertexData to the passed Mesh.
  85594. * Sets it as updatable or not (default `false`)
  85595. * @param mesh the mesh the vertexData is applied to
  85596. * @param updatable when used and having the value true allows new data to update the vertexData
  85597. * @returns the VertexData
  85598. */
  85599. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85600. /**
  85601. * Associates the vertexData to the passed Geometry.
  85602. * Sets it as updatable or not (default `false`)
  85603. * @param geometry the geometry the vertexData is applied to
  85604. * @param updatable when used and having the value true allows new data to update the vertexData
  85605. * @returns VertexData
  85606. */
  85607. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85608. /**
  85609. * Updates the associated mesh
  85610. * @param mesh the mesh to be updated
  85611. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85612. * @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
  85613. * @returns VertexData
  85614. */
  85615. updateMesh(mesh: Mesh): VertexData;
  85616. /**
  85617. * Updates the associated geometry
  85618. * @param geometry the geometry to be updated
  85619. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85620. * @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
  85621. * @returns VertexData.
  85622. */
  85623. updateGeometry(geometry: Geometry): VertexData;
  85624. private _applyTo;
  85625. private _update;
  85626. /**
  85627. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85628. * @param matrix the transforming matrix
  85629. * @returns the VertexData
  85630. */
  85631. transform(matrix: Matrix): VertexData;
  85632. /**
  85633. * Merges the passed VertexData into the current one
  85634. * @param other the VertexData to be merged into the current one
  85635. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85636. * @returns the modified VertexData
  85637. */
  85638. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85639. private _mergeElement;
  85640. private _validate;
  85641. /**
  85642. * Serializes the VertexData
  85643. * @returns a serialized object
  85644. */
  85645. serialize(): any;
  85646. /**
  85647. * Extracts the vertexData from a mesh
  85648. * @param mesh the mesh from which to extract the VertexData
  85649. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85650. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85651. * @returns the object VertexData associated to the passed mesh
  85652. */
  85653. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85654. /**
  85655. * Extracts the vertexData from the geometry
  85656. * @param geometry the geometry from which to extract the VertexData
  85657. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85658. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85659. * @returns the object VertexData associated to the passed mesh
  85660. */
  85661. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85662. private static _ExtractFrom;
  85663. /**
  85664. * Creates the VertexData for a Ribbon
  85665. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85666. * * pathArray array of paths, each of which an array of successive Vector3
  85667. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85668. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85669. * * 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
  85670. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85671. * * 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)
  85672. * * 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)
  85673. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85674. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85675. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85676. * @returns the VertexData of the ribbon
  85677. */
  85678. static CreateRibbon(options: {
  85679. pathArray: Vector3[][];
  85680. closeArray?: boolean;
  85681. closePath?: boolean;
  85682. offset?: number;
  85683. sideOrientation?: number;
  85684. frontUVs?: Vector4;
  85685. backUVs?: Vector4;
  85686. invertUV?: boolean;
  85687. uvs?: Vector2[];
  85688. colors?: Color4[];
  85689. }): VertexData;
  85690. /**
  85691. * Creates the VertexData for a box
  85692. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85693. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85694. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85695. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85696. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85697. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85698. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85699. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85700. * * 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)
  85701. * * 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)
  85702. * @returns the VertexData of the box
  85703. */
  85704. static CreateBox(options: {
  85705. size?: number;
  85706. width?: number;
  85707. height?: number;
  85708. depth?: number;
  85709. faceUV?: Vector4[];
  85710. faceColors?: Color4[];
  85711. sideOrientation?: number;
  85712. frontUVs?: Vector4;
  85713. backUVs?: Vector4;
  85714. }): VertexData;
  85715. /**
  85716. * Creates the VertexData for a tiled box
  85717. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85718. * * faceTiles sets the pattern, tile size and number of tiles for a face
  85719. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85720. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85721. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85722. * @returns the VertexData of the box
  85723. */
  85724. static CreateTiledBox(options: {
  85725. pattern?: number;
  85726. width?: number;
  85727. height?: number;
  85728. depth?: number;
  85729. tileSize?: number;
  85730. tileWidth?: number;
  85731. tileHeight?: number;
  85732. alignHorizontal?: number;
  85733. alignVertical?: number;
  85734. faceUV?: Vector4[];
  85735. faceColors?: Color4[];
  85736. sideOrientation?: number;
  85737. }): VertexData;
  85738. /**
  85739. * Creates the VertexData for a tiled plane
  85740. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85741. * * pattern a limited pattern arrangement depending on the number
  85742. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  85743. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  85744. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  85745. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85746. * * 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)
  85747. * * 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)
  85748. * @returns the VertexData of the tiled plane
  85749. */
  85750. static CreateTiledPlane(options: {
  85751. pattern?: number;
  85752. tileSize?: number;
  85753. tileWidth?: number;
  85754. tileHeight?: number;
  85755. size?: number;
  85756. width?: number;
  85757. height?: number;
  85758. alignHorizontal?: number;
  85759. alignVertical?: number;
  85760. sideOrientation?: number;
  85761. frontUVs?: Vector4;
  85762. backUVs?: Vector4;
  85763. }): VertexData;
  85764. /**
  85765. * Creates the VertexData for an ellipsoid, defaults to a sphere
  85766. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85767. * * segments sets the number of horizontal strips optional, default 32
  85768. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  85769. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  85770. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  85771. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  85772. * * 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
  85773. * * 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
  85774. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85775. * * 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)
  85776. * * 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)
  85777. * @returns the VertexData of the ellipsoid
  85778. */
  85779. static CreateSphere(options: {
  85780. segments?: number;
  85781. diameter?: number;
  85782. diameterX?: number;
  85783. diameterY?: number;
  85784. diameterZ?: number;
  85785. arc?: number;
  85786. slice?: number;
  85787. sideOrientation?: number;
  85788. frontUVs?: Vector4;
  85789. backUVs?: Vector4;
  85790. }): VertexData;
  85791. /**
  85792. * Creates the VertexData for a cylinder, cone or prism
  85793. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85794. * * height sets the height (y direction) of the cylinder, optional, default 2
  85795. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  85796. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  85797. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  85798. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85799. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  85800. * * 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
  85801. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85802. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85803. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  85804. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  85805. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85806. * * 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)
  85807. * * 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)
  85808. * @returns the VertexData of the cylinder, cone or prism
  85809. */
  85810. static CreateCylinder(options: {
  85811. height?: number;
  85812. diameterTop?: number;
  85813. diameterBottom?: number;
  85814. diameter?: number;
  85815. tessellation?: number;
  85816. subdivisions?: number;
  85817. arc?: number;
  85818. faceColors?: Color4[];
  85819. faceUV?: Vector4[];
  85820. hasRings?: boolean;
  85821. enclose?: boolean;
  85822. sideOrientation?: number;
  85823. frontUVs?: Vector4;
  85824. backUVs?: Vector4;
  85825. }): VertexData;
  85826. /**
  85827. * Creates the VertexData for a torus
  85828. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85829. * * diameter the diameter of the torus, optional default 1
  85830. * * thickness the diameter of the tube forming the torus, optional default 0.5
  85831. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85832. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85833. * * 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)
  85834. * * 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)
  85835. * @returns the VertexData of the torus
  85836. */
  85837. static CreateTorus(options: {
  85838. diameter?: number;
  85839. thickness?: number;
  85840. tessellation?: number;
  85841. sideOrientation?: number;
  85842. frontUVs?: Vector4;
  85843. backUVs?: Vector4;
  85844. }): VertexData;
  85845. /**
  85846. * Creates the VertexData of the LineSystem
  85847. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  85848. * - lines an array of lines, each line being an array of successive Vector3
  85849. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  85850. * @returns the VertexData of the LineSystem
  85851. */
  85852. static CreateLineSystem(options: {
  85853. lines: Vector3[][];
  85854. colors?: Nullable<Color4[][]>;
  85855. }): VertexData;
  85856. /**
  85857. * Create the VertexData for a DashedLines
  85858. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  85859. * - points an array successive Vector3
  85860. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  85861. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  85862. * - dashNb the intended total number of dashes, optional, default 200
  85863. * @returns the VertexData for the DashedLines
  85864. */
  85865. static CreateDashedLines(options: {
  85866. points: Vector3[];
  85867. dashSize?: number;
  85868. gapSize?: number;
  85869. dashNb?: number;
  85870. }): VertexData;
  85871. /**
  85872. * Creates the VertexData for a Ground
  85873. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85874. * - width the width (x direction) of the ground, optional, default 1
  85875. * - height the height (z direction) of the ground, optional, default 1
  85876. * - subdivisions the number of subdivisions per side, optional, default 1
  85877. * @returns the VertexData of the Ground
  85878. */
  85879. static CreateGround(options: {
  85880. width?: number;
  85881. height?: number;
  85882. subdivisions?: number;
  85883. subdivisionsX?: number;
  85884. subdivisionsY?: number;
  85885. }): VertexData;
  85886. /**
  85887. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  85888. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85889. * * xmin the ground minimum X coordinate, optional, default -1
  85890. * * zmin the ground minimum Z coordinate, optional, default -1
  85891. * * xmax the ground maximum X coordinate, optional, default 1
  85892. * * zmax the ground maximum Z coordinate, optional, default 1
  85893. * * 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}
  85894. * * 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}
  85895. * @returns the VertexData of the TiledGround
  85896. */
  85897. static CreateTiledGround(options: {
  85898. xmin: number;
  85899. zmin: number;
  85900. xmax: number;
  85901. zmax: number;
  85902. subdivisions?: {
  85903. w: number;
  85904. h: number;
  85905. };
  85906. precision?: {
  85907. w: number;
  85908. h: number;
  85909. };
  85910. }): VertexData;
  85911. /**
  85912. * Creates the VertexData of the Ground designed from a heightmap
  85913. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  85914. * * width the width (x direction) of the ground
  85915. * * height the height (z direction) of the ground
  85916. * * subdivisions the number of subdivisions per side
  85917. * * minHeight the minimum altitude on the ground, optional, default 0
  85918. * * maxHeight the maximum altitude on the ground, optional default 1
  85919. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  85920. * * buffer the array holding the image color data
  85921. * * bufferWidth the width of image
  85922. * * bufferHeight the height of image
  85923. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  85924. * @returns the VertexData of the Ground designed from a heightmap
  85925. */
  85926. static CreateGroundFromHeightMap(options: {
  85927. width: number;
  85928. height: number;
  85929. subdivisions: number;
  85930. minHeight: number;
  85931. maxHeight: number;
  85932. colorFilter: Color3;
  85933. buffer: Uint8Array;
  85934. bufferWidth: number;
  85935. bufferHeight: number;
  85936. alphaFilter: number;
  85937. }): VertexData;
  85938. /**
  85939. * Creates the VertexData for a Plane
  85940. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  85941. * * size sets the width and height of the plane to the value of size, optional default 1
  85942. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  85943. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  85944. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85945. * * 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)
  85946. * * 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)
  85947. * @returns the VertexData of the box
  85948. */
  85949. static CreatePlane(options: {
  85950. size?: number;
  85951. width?: number;
  85952. height?: number;
  85953. sideOrientation?: number;
  85954. frontUVs?: Vector4;
  85955. backUVs?: Vector4;
  85956. }): VertexData;
  85957. /**
  85958. * Creates the VertexData of the Disc or regular Polygon
  85959. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  85960. * * radius the radius of the disc, optional default 0.5
  85961. * * tessellation the number of polygon sides, optional, default 64
  85962. * * 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
  85963. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85964. * * 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)
  85965. * * 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)
  85966. * @returns the VertexData of the box
  85967. */
  85968. static CreateDisc(options: {
  85969. radius?: number;
  85970. tessellation?: number;
  85971. arc?: number;
  85972. sideOrientation?: number;
  85973. frontUVs?: Vector4;
  85974. backUVs?: Vector4;
  85975. }): VertexData;
  85976. /**
  85977. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  85978. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  85979. * @param polygon a mesh built from polygonTriangulation.build()
  85980. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85981. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85982. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85983. * @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)
  85984. * @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)
  85985. * @returns the VertexData of the Polygon
  85986. */
  85987. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  85988. /**
  85989. * Creates the VertexData of the IcoSphere
  85990. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  85991. * * radius the radius of the IcoSphere, optional default 1
  85992. * * radiusX allows stretching in the x direction, optional, default radius
  85993. * * radiusY allows stretching in the y direction, optional, default radius
  85994. * * radiusZ allows stretching in the z direction, optional, default radius
  85995. * * flat when true creates a flat shaded mesh, optional, default true
  85996. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85997. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85998. * * 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)
  85999. * * 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)
  86000. * @returns the VertexData of the IcoSphere
  86001. */
  86002. static CreateIcoSphere(options: {
  86003. radius?: number;
  86004. radiusX?: number;
  86005. radiusY?: number;
  86006. radiusZ?: number;
  86007. flat?: boolean;
  86008. subdivisions?: number;
  86009. sideOrientation?: number;
  86010. frontUVs?: Vector4;
  86011. backUVs?: Vector4;
  86012. }): VertexData;
  86013. /**
  86014. * Creates the VertexData for a Polyhedron
  86015. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86016. * * type provided types are:
  86017. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86018. * * 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)
  86019. * * size the size of the IcoSphere, optional default 1
  86020. * * sizeX allows stretching in the x direction, optional, default size
  86021. * * sizeY allows stretching in the y direction, optional, default size
  86022. * * sizeZ allows stretching in the z direction, optional, default size
  86023. * * 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
  86024. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86025. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86026. * * flat when true creates a flat shaded mesh, optional, default true
  86027. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86028. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86029. * * 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)
  86030. * * 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)
  86031. * @returns the VertexData of the Polyhedron
  86032. */
  86033. static CreatePolyhedron(options: {
  86034. type?: number;
  86035. size?: number;
  86036. sizeX?: number;
  86037. sizeY?: number;
  86038. sizeZ?: number;
  86039. custom?: any;
  86040. faceUV?: Vector4[];
  86041. faceColors?: Color4[];
  86042. flat?: boolean;
  86043. sideOrientation?: number;
  86044. frontUVs?: Vector4;
  86045. backUVs?: Vector4;
  86046. }): VertexData;
  86047. /**
  86048. * Creates the VertexData for a TorusKnot
  86049. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86050. * * radius the radius of the torus knot, optional, default 2
  86051. * * tube the thickness of the tube, optional, default 0.5
  86052. * * radialSegments the number of sides on each tube segments, optional, default 32
  86053. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86054. * * p the number of windings around the z axis, optional, default 2
  86055. * * q the number of windings around the x axis, optional, default 3
  86056. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86057. * * 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)
  86058. * * 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)
  86059. * @returns the VertexData of the Torus Knot
  86060. */
  86061. static CreateTorusKnot(options: {
  86062. radius?: number;
  86063. tube?: number;
  86064. radialSegments?: number;
  86065. tubularSegments?: number;
  86066. p?: number;
  86067. q?: number;
  86068. sideOrientation?: number;
  86069. frontUVs?: Vector4;
  86070. backUVs?: Vector4;
  86071. }): VertexData;
  86072. /**
  86073. * Compute normals for given positions and indices
  86074. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86075. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86076. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86077. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86078. * * facetNormals : optional array of facet normals (vector3)
  86079. * * facetPositions : optional array of facet positions (vector3)
  86080. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86081. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86082. * * bInfo : optional bounding info, required for facetPartitioning computation
  86083. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86084. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86085. * * useRightHandedSystem: optional boolean to for right handed system computation
  86086. * * depthSort : optional boolean to enable the facet depth sort computation
  86087. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86088. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86089. */
  86090. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86091. facetNormals?: any;
  86092. facetPositions?: any;
  86093. facetPartitioning?: any;
  86094. ratio?: number;
  86095. bInfo?: any;
  86096. bbSize?: Vector3;
  86097. subDiv?: any;
  86098. useRightHandedSystem?: boolean;
  86099. depthSort?: boolean;
  86100. distanceTo?: Vector3;
  86101. depthSortedFacets?: any;
  86102. }): void;
  86103. /** @hidden */
  86104. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86105. /**
  86106. * Applies VertexData created from the imported parameters to the geometry
  86107. * @param parsedVertexData the parsed data from an imported file
  86108. * @param geometry the geometry to apply the VertexData to
  86109. */
  86110. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86111. }
  86112. }
  86113. declare module BABYLON {
  86114. /**
  86115. * Class containing static functions to help procedurally build meshes
  86116. */
  86117. export class DiscBuilder {
  86118. /**
  86119. * Creates a plane polygonal mesh. By default, this is a disc
  86120. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86121. * * 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
  86122. * * 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
  86123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  86125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86126. * @param name defines the name of the mesh
  86127. * @param options defines the options used to create the mesh
  86128. * @param scene defines the hosting scene
  86129. * @returns the plane polygonal mesh
  86130. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86131. */
  86132. static CreateDisc(name: string, options: {
  86133. radius?: number;
  86134. tessellation?: number;
  86135. arc?: number;
  86136. updatable?: boolean;
  86137. sideOrientation?: number;
  86138. frontUVs?: Vector4;
  86139. backUVs?: Vector4;
  86140. }, scene?: Nullable<Scene>): Mesh;
  86141. }
  86142. }
  86143. declare module BABYLON {
  86144. /**
  86145. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  86146. *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.
  86147. * The SPS is also a particle system. It provides some methods to manage the particles.
  86148. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  86149. *
  86150. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  86151. */
  86152. export class SolidParticleSystem implements IDisposable {
  86153. /**
  86154. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  86155. * Example : var p = SPS.particles[i];
  86156. */
  86157. particles: SolidParticle[];
  86158. /**
  86159. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  86160. */
  86161. nbParticles: number;
  86162. /**
  86163. * If the particles must ever face the camera (default false). Useful for planar particles.
  86164. */
  86165. billboard: boolean;
  86166. /**
  86167. * Recompute normals when adding a shape
  86168. */
  86169. recomputeNormals: boolean;
  86170. /**
  86171. * This a counter ofr your own usage. It's not set by any SPS functions.
  86172. */
  86173. counter: number;
  86174. /**
  86175. * The SPS name. This name is also given to the underlying mesh.
  86176. */
  86177. name: string;
  86178. /**
  86179. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  86180. */
  86181. mesh: Mesh;
  86182. /**
  86183. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  86184. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  86185. */
  86186. vars: any;
  86187. /**
  86188. * This array is populated when the SPS is set as 'pickable'.
  86189. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  86190. * Each element of this array is an object `{idx: int, faceId: int}`.
  86191. * `idx` is the picked particle index in the `SPS.particles` array
  86192. * `faceId` is the picked face index counted within this particle.
  86193. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  86194. */
  86195. pickedParticles: {
  86196. idx: number;
  86197. faceId: number;
  86198. }[];
  86199. /**
  86200. * This array is populated when `enableDepthSort` is set to true.
  86201. * Each element of this array is an instance of the class DepthSortedParticle.
  86202. */
  86203. depthSortedParticles: DepthSortedParticle[];
  86204. /**
  86205. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  86206. * @hidden
  86207. */
  86208. _bSphereOnly: boolean;
  86209. /**
  86210. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  86211. * @hidden
  86212. */
  86213. _bSphereRadiusFactor: number;
  86214. private _scene;
  86215. private _positions;
  86216. private _indices;
  86217. private _normals;
  86218. private _colors;
  86219. private _uvs;
  86220. private _indices32;
  86221. private _positions32;
  86222. private _normals32;
  86223. private _fixedNormal32;
  86224. private _colors32;
  86225. private _uvs32;
  86226. private _index;
  86227. private _updatable;
  86228. private _pickable;
  86229. private _isVisibilityBoxLocked;
  86230. private _alwaysVisible;
  86231. private _depthSort;
  86232. private _shapeCounter;
  86233. private _copy;
  86234. private _color;
  86235. private _computeParticleColor;
  86236. private _computeParticleTexture;
  86237. private _computeParticleRotation;
  86238. private _computeParticleVertex;
  86239. private _computeBoundingBox;
  86240. private _depthSortParticles;
  86241. private _camera;
  86242. private _mustUnrotateFixedNormals;
  86243. private _particlesIntersect;
  86244. private _needs32Bits;
  86245. /**
  86246. * Creates a SPS (Solid Particle System) object.
  86247. * @param name (String) is the SPS name, this will be the underlying mesh name.
  86248. * @param scene (Scene) is the scene in which the SPS is added.
  86249. * @param options defines the options of the sps e.g.
  86250. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  86251. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  86252. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  86253. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  86254. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  86255. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  86256. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  86257. */
  86258. constructor(name: string, scene: Scene, options?: {
  86259. updatable?: boolean;
  86260. isPickable?: boolean;
  86261. enableDepthSort?: boolean;
  86262. particleIntersection?: boolean;
  86263. boundingSphereOnly?: boolean;
  86264. bSphereRadiusFactor?: number;
  86265. });
  86266. /**
  86267. * Builds the SPS underlying mesh. Returns a standard Mesh.
  86268. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  86269. * @returns the created mesh
  86270. */
  86271. buildMesh(): Mesh;
  86272. /**
  86273. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  86274. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  86275. * Thus the particles generated from `digest()` have their property `position` set yet.
  86276. * @param mesh ( Mesh ) is the mesh to be digested
  86277. * @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
  86278. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  86279. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  86280. * @returns the current SPS
  86281. */
  86282. digest(mesh: Mesh, options?: {
  86283. facetNb?: number;
  86284. number?: number;
  86285. delta?: number;
  86286. }): SolidParticleSystem;
  86287. private _unrotateFixedNormals;
  86288. private _resetCopy;
  86289. private _meshBuilder;
  86290. private _posToShape;
  86291. private _uvsToShapeUV;
  86292. private _addParticle;
  86293. /**
  86294. * Adds some particles to the SPS from the model shape. Returns the shape id.
  86295. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  86296. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  86297. * @param nb (positive integer) the number of particles to be created from this model
  86298. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  86299. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  86300. * @returns the number of shapes in the system
  86301. */
  86302. addShape(mesh: Mesh, nb: number, options?: {
  86303. positionFunction?: any;
  86304. vertexFunction?: any;
  86305. }): number;
  86306. private _rebuildParticle;
  86307. /**
  86308. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  86309. * @returns the SPS.
  86310. */
  86311. rebuildMesh(): SolidParticleSystem;
  86312. /**
  86313. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  86314. * This method calls `updateParticle()` for each particle of the SPS.
  86315. * For an animated SPS, it is usually called within the render loop.
  86316. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  86317. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  86318. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  86319. * @returns the SPS.
  86320. */
  86321. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  86322. /**
  86323. * Disposes the SPS.
  86324. */
  86325. dispose(): void;
  86326. /**
  86327. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  86328. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86329. * @returns the SPS.
  86330. */
  86331. refreshVisibleSize(): SolidParticleSystem;
  86332. /**
  86333. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  86334. * @param size the size (float) of the visibility box
  86335. * note : this doesn't lock the SPS mesh bounding box.
  86336. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86337. */
  86338. setVisibilityBox(size: number): void;
  86339. /**
  86340. * Gets whether the SPS as always visible or not
  86341. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86342. */
  86343. /**
  86344. * Sets the SPS as always visible or not
  86345. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86346. */
  86347. isAlwaysVisible: boolean;
  86348. /**
  86349. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86350. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86351. */
  86352. /**
  86353. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86354. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86355. */
  86356. isVisibilityBoxLocked: boolean;
  86357. /**
  86358. * Tells to `setParticles()` to compute the particle rotations or not.
  86359. * Default value : true. The SPS is faster when it's set to false.
  86360. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86361. */
  86362. /**
  86363. * Gets if `setParticles()` computes the particle rotations or not.
  86364. * Default value : true. The SPS is faster when it's set to false.
  86365. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86366. */
  86367. computeParticleRotation: boolean;
  86368. /**
  86369. * Tells to `setParticles()` to compute the particle colors or not.
  86370. * Default value : true. The SPS is faster when it's set to false.
  86371. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86372. */
  86373. /**
  86374. * Gets if `setParticles()` computes the particle colors or not.
  86375. * Default value : true. The SPS is faster when it's set to false.
  86376. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86377. */
  86378. computeParticleColor: boolean;
  86379. /**
  86380. * Gets if `setParticles()` computes the particle textures or not.
  86381. * Default value : true. The SPS is faster when it's set to false.
  86382. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  86383. */
  86384. computeParticleTexture: boolean;
  86385. /**
  86386. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  86387. * Default value : false. The SPS is faster when it's set to false.
  86388. * Note : the particle custom vertex positions aren't stored values.
  86389. */
  86390. /**
  86391. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  86392. * Default value : false. The SPS is faster when it's set to false.
  86393. * Note : the particle custom vertex positions aren't stored values.
  86394. */
  86395. computeParticleVertex: boolean;
  86396. /**
  86397. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  86398. */
  86399. /**
  86400. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  86401. */
  86402. computeBoundingBox: boolean;
  86403. /**
  86404. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  86405. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86406. * Default : `true`
  86407. */
  86408. /**
  86409. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  86410. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86411. * Default : `true`
  86412. */
  86413. depthSortParticles: boolean;
  86414. /**
  86415. * This function does nothing. It may be overwritten to set all the particle first values.
  86416. * The SPS doesn't call this function, you may have to call it by your own.
  86417. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86418. */
  86419. initParticles(): void;
  86420. /**
  86421. * This function does nothing. It may be overwritten to recycle a particle.
  86422. * The SPS doesn't call this function, you may have to call it by your own.
  86423. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86424. * @param particle The particle to recycle
  86425. * @returns the recycled particle
  86426. */
  86427. recycleParticle(particle: SolidParticle): SolidParticle;
  86428. /**
  86429. * Updates a particle : this function should be overwritten by the user.
  86430. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  86431. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86432. * @example : just set a particle position or velocity and recycle conditions
  86433. * @param particle The particle to update
  86434. * @returns the updated particle
  86435. */
  86436. updateParticle(particle: SolidParticle): SolidParticle;
  86437. /**
  86438. * Updates a vertex of a particle : it can be overwritten by the user.
  86439. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  86440. * @param particle the current particle
  86441. * @param vertex the current index of the current particle
  86442. * @param pt the index of the current vertex in the particle shape
  86443. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  86444. * @example : just set a vertex particle position
  86445. * @returns the updated vertex
  86446. */
  86447. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  86448. /**
  86449. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  86450. * This does nothing and may be overwritten by the user.
  86451. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86452. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86453. * @param update the boolean update value actually passed to setParticles()
  86454. */
  86455. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86456. /**
  86457. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  86458. * This will be passed three parameters.
  86459. * This does nothing and may be overwritten by the user.
  86460. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86461. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86462. * @param update the boolean update value actually passed to setParticles()
  86463. */
  86464. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86465. }
  86466. }
  86467. declare module BABYLON {
  86468. /**
  86469. * Represents one particle of a solid particle system.
  86470. */
  86471. export class SolidParticle {
  86472. /**
  86473. * particle global index
  86474. */
  86475. idx: number;
  86476. /**
  86477. * The color of the particle
  86478. */
  86479. color: Nullable<Color4>;
  86480. /**
  86481. * The world space position of the particle.
  86482. */
  86483. position: Vector3;
  86484. /**
  86485. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  86486. */
  86487. rotation: Vector3;
  86488. /**
  86489. * The world space rotation quaternion of the particle.
  86490. */
  86491. rotationQuaternion: Nullable<Quaternion>;
  86492. /**
  86493. * The scaling of the particle.
  86494. */
  86495. scaling: Vector3;
  86496. /**
  86497. * The uvs of the particle.
  86498. */
  86499. uvs: Vector4;
  86500. /**
  86501. * The current speed of the particle.
  86502. */
  86503. velocity: Vector3;
  86504. /**
  86505. * The pivot point in the particle local space.
  86506. */
  86507. pivot: Vector3;
  86508. /**
  86509. * Must the particle be translated from its pivot point in its local space ?
  86510. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  86511. * Default : false
  86512. */
  86513. translateFromPivot: boolean;
  86514. /**
  86515. * Is the particle active or not ?
  86516. */
  86517. alive: boolean;
  86518. /**
  86519. * Is the particle visible or not ?
  86520. */
  86521. isVisible: boolean;
  86522. /**
  86523. * Index of this particle in the global "positions" array (Internal use)
  86524. * @hidden
  86525. */
  86526. _pos: number;
  86527. /**
  86528. * @hidden Index of this particle in the global "indices" array (Internal use)
  86529. */
  86530. _ind: number;
  86531. /**
  86532. * @hidden ModelShape of this particle (Internal use)
  86533. */
  86534. _model: ModelShape;
  86535. /**
  86536. * ModelShape id of this particle
  86537. */
  86538. shapeId: number;
  86539. /**
  86540. * Index of the particle in its shape id (Internal use)
  86541. */
  86542. idxInShape: number;
  86543. /**
  86544. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  86545. */
  86546. _modelBoundingInfo: BoundingInfo;
  86547. /**
  86548. * @hidden Particle BoundingInfo object (Internal use)
  86549. */
  86550. _boundingInfo: BoundingInfo;
  86551. /**
  86552. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  86553. */
  86554. _sps: SolidParticleSystem;
  86555. /**
  86556. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  86557. */
  86558. _stillInvisible: boolean;
  86559. /**
  86560. * @hidden Last computed particle rotation matrix
  86561. */
  86562. _rotationMatrix: number[];
  86563. /**
  86564. * Parent particle Id, if any.
  86565. * Default null.
  86566. */
  86567. parentId: Nullable<number>;
  86568. /**
  86569. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  86570. * The possible values are :
  86571. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  86572. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86573. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  86574. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  86575. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86576. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  86577. * */
  86578. cullingStrategy: number;
  86579. /**
  86580. * @hidden Internal global position in the SPS.
  86581. */
  86582. _globalPosition: Vector3;
  86583. /**
  86584. * Creates a Solid Particle object.
  86585. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  86586. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  86587. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  86588. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  86589. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  86590. * @param shapeId (integer) is the model shape identifier in the SPS.
  86591. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  86592. * @param sps defines the sps it is associated to
  86593. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  86594. */
  86595. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  86596. /**
  86597. * Legacy support, changed scale to scaling
  86598. */
  86599. /**
  86600. * Legacy support, changed scale to scaling
  86601. */
  86602. scale: Vector3;
  86603. /**
  86604. * Legacy support, changed quaternion to rotationQuaternion
  86605. */
  86606. /**
  86607. * Legacy support, changed quaternion to rotationQuaternion
  86608. */
  86609. quaternion: Nullable<Quaternion>;
  86610. /**
  86611. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  86612. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  86613. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  86614. * @returns true if it intersects
  86615. */
  86616. intersectsMesh(target: Mesh | SolidParticle): boolean;
  86617. /**
  86618. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  86619. * A particle is in the frustum if its bounding box intersects the frustum
  86620. * @param frustumPlanes defines the frustum to test
  86621. * @returns true if the particle is in the frustum planes
  86622. */
  86623. isInFrustum(frustumPlanes: Plane[]): boolean;
  86624. /**
  86625. * get the rotation matrix of the particle
  86626. * @hidden
  86627. */
  86628. getRotationMatrix(m: Matrix): void;
  86629. }
  86630. /**
  86631. * Represents the shape of the model used by one particle of a solid particle system.
  86632. * SPS internal tool, don't use it manually.
  86633. */
  86634. export class ModelShape {
  86635. /**
  86636. * The shape id
  86637. * @hidden
  86638. */
  86639. shapeID: number;
  86640. /**
  86641. * flat array of model positions (internal use)
  86642. * @hidden
  86643. */
  86644. _shape: Vector3[];
  86645. /**
  86646. * flat array of model UVs (internal use)
  86647. * @hidden
  86648. */
  86649. _shapeUV: number[];
  86650. /**
  86651. * length of the shape in the model indices array (internal use)
  86652. * @hidden
  86653. */
  86654. _indicesLength: number;
  86655. /**
  86656. * Custom position function (internal use)
  86657. * @hidden
  86658. */
  86659. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  86660. /**
  86661. * Custom vertex function (internal use)
  86662. * @hidden
  86663. */
  86664. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  86665. /**
  86666. * 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.
  86667. * SPS internal tool, don't use it manually.
  86668. * @hidden
  86669. */
  86670. 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>);
  86671. }
  86672. /**
  86673. * Represents a Depth Sorted Particle in the solid particle system.
  86674. */
  86675. export class DepthSortedParticle {
  86676. /**
  86677. * Index of the particle in the "indices" array
  86678. */
  86679. ind: number;
  86680. /**
  86681. * Length of the particle shape in the "indices" array
  86682. */
  86683. indicesLength: number;
  86684. /**
  86685. * Squared distance from the particle to the camera
  86686. */
  86687. sqDistance: number;
  86688. }
  86689. }
  86690. declare module BABYLON {
  86691. /**
  86692. * @hidden
  86693. */
  86694. export class _MeshCollisionData {
  86695. _checkCollisions: boolean;
  86696. _collisionMask: number;
  86697. _collisionGroup: number;
  86698. _collider: Nullable<Collider>;
  86699. _oldPositionForCollisions: Vector3;
  86700. _diffPositionForCollisions: Vector3;
  86701. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  86702. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  86703. }
  86704. }
  86705. declare module BABYLON {
  86706. /** @hidden */
  86707. class _FacetDataStorage {
  86708. facetPositions: Vector3[];
  86709. facetNormals: Vector3[];
  86710. facetPartitioning: number[][];
  86711. facetNb: number;
  86712. partitioningSubdivisions: number;
  86713. partitioningBBoxRatio: number;
  86714. facetDataEnabled: boolean;
  86715. facetParameters: any;
  86716. bbSize: Vector3;
  86717. subDiv: {
  86718. max: number;
  86719. X: number;
  86720. Y: number;
  86721. Z: number;
  86722. };
  86723. facetDepthSort: boolean;
  86724. facetDepthSortEnabled: boolean;
  86725. depthSortedIndices: IndicesArray;
  86726. depthSortedFacets: {
  86727. ind: number;
  86728. sqDistance: number;
  86729. }[];
  86730. facetDepthSortFunction: (f1: {
  86731. ind: number;
  86732. sqDistance: number;
  86733. }, f2: {
  86734. ind: number;
  86735. sqDistance: number;
  86736. }) => number;
  86737. facetDepthSortFrom: Vector3;
  86738. facetDepthSortOrigin: Vector3;
  86739. invertedMatrix: Matrix;
  86740. }
  86741. /**
  86742. * @hidden
  86743. **/
  86744. class _InternalAbstractMeshDataInfo {
  86745. _hasVertexAlpha: boolean;
  86746. _useVertexColors: boolean;
  86747. _numBoneInfluencers: number;
  86748. _applyFog: boolean;
  86749. _receiveShadows: boolean;
  86750. _facetData: _FacetDataStorage;
  86751. _visibility: number;
  86752. _skeleton: Nullable<Skeleton>;
  86753. _layerMask: number;
  86754. _computeBonesUsingShaders: boolean;
  86755. _isActive: boolean;
  86756. _onlyForInstances: boolean;
  86757. _isActiveIntermediate: boolean;
  86758. _onlyForInstancesIntermediate: boolean;
  86759. }
  86760. /**
  86761. * Class used to store all common mesh properties
  86762. */
  86763. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  86764. /** No occlusion */
  86765. static OCCLUSION_TYPE_NONE: number;
  86766. /** Occlusion set to optimisitic */
  86767. static OCCLUSION_TYPE_OPTIMISTIC: number;
  86768. /** Occlusion set to strict */
  86769. static OCCLUSION_TYPE_STRICT: number;
  86770. /** Use an accurante occlusion algorithm */
  86771. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  86772. /** Use a conservative occlusion algorithm */
  86773. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  86774. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  86775. * Test order :
  86776. * Is the bounding sphere outside the frustum ?
  86777. * If not, are the bounding box vertices outside the frustum ?
  86778. * It not, then the cullable object is in the frustum.
  86779. */
  86780. static readonly CULLINGSTRATEGY_STANDARD: number;
  86781. /** Culling strategy : Bounding Sphere Only.
  86782. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  86783. * It's also less accurate than the standard because some not visible objects can still be selected.
  86784. * Test : is the bounding sphere outside the frustum ?
  86785. * If not, then the cullable object is in the frustum.
  86786. */
  86787. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  86788. /** Culling strategy : Optimistic Inclusion.
  86789. * This in an inclusion test first, then the standard exclusion test.
  86790. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  86791. * 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.
  86792. * Anyway, it's as accurate as the standard strategy.
  86793. * Test :
  86794. * Is the cullable object bounding sphere center in the frustum ?
  86795. * If not, apply the default culling strategy.
  86796. */
  86797. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  86798. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  86799. * This in an inclusion test first, then the bounding sphere only exclusion test.
  86800. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  86801. * 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.
  86802. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  86803. * Test :
  86804. * Is the cullable object bounding sphere center in the frustum ?
  86805. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  86806. */
  86807. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  86808. /**
  86809. * No billboard
  86810. */
  86811. static readonly BILLBOARDMODE_NONE: number;
  86812. /** Billboard on X axis */
  86813. static readonly BILLBOARDMODE_X: number;
  86814. /** Billboard on Y axis */
  86815. static readonly BILLBOARDMODE_Y: number;
  86816. /** Billboard on Z axis */
  86817. static readonly BILLBOARDMODE_Z: number;
  86818. /** Billboard on all axes */
  86819. static readonly BILLBOARDMODE_ALL: number;
  86820. /** @hidden */
  86821. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  86822. /**
  86823. * The culling strategy to use to check whether the mesh must be rendered or not.
  86824. * This value can be changed at any time and will be used on the next render mesh selection.
  86825. * The possible values are :
  86826. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  86827. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86828. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  86829. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  86830. * Please read each static variable documentation to get details about the culling process.
  86831. * */
  86832. cullingStrategy: number;
  86833. /**
  86834. * Gets the number of facets in the mesh
  86835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  86836. */
  86837. readonly facetNb: number;
  86838. /**
  86839. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  86840. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  86841. */
  86842. partitioningSubdivisions: number;
  86843. /**
  86844. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  86845. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  86846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  86847. */
  86848. partitioningBBoxRatio: number;
  86849. /**
  86850. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  86851. * Works only for updatable meshes.
  86852. * Doesn't work with multi-materials
  86853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  86854. */
  86855. mustDepthSortFacets: boolean;
  86856. /**
  86857. * The location (Vector3) where the facet depth sort must be computed from.
  86858. * By default, the active camera position.
  86859. * Used only when facet depth sort is enabled
  86860. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  86861. */
  86862. facetDepthSortFrom: Vector3;
  86863. /**
  86864. * gets a boolean indicating if facetData is enabled
  86865. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  86866. */
  86867. readonly isFacetDataEnabled: boolean;
  86868. /** @hidden */
  86869. _updateNonUniformScalingState(value: boolean): boolean;
  86870. /**
  86871. * An event triggered when this mesh collides with another one
  86872. */
  86873. onCollideObservable: Observable<AbstractMesh>;
  86874. /** Set a function to call when this mesh collides with another one */
  86875. onCollide: () => void;
  86876. /**
  86877. * An event triggered when the collision's position changes
  86878. */
  86879. onCollisionPositionChangeObservable: Observable<Vector3>;
  86880. /** Set a function to call when the collision's position changes */
  86881. onCollisionPositionChange: () => void;
  86882. /**
  86883. * An event triggered when material is changed
  86884. */
  86885. onMaterialChangedObservable: Observable<AbstractMesh>;
  86886. /**
  86887. * Gets or sets the orientation for POV movement & rotation
  86888. */
  86889. definedFacingForward: boolean;
  86890. /** @hidden */
  86891. _occlusionQuery: Nullable<WebGLQuery>;
  86892. /** @hidden */
  86893. _renderingGroup: Nullable<RenderingGroup>;
  86894. /**
  86895. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  86896. */
  86897. /**
  86898. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  86899. */
  86900. visibility: number;
  86901. /** Gets or sets the alpha index used to sort transparent meshes
  86902. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  86903. */
  86904. alphaIndex: number;
  86905. /**
  86906. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  86907. */
  86908. isVisible: boolean;
  86909. /**
  86910. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  86911. */
  86912. isPickable: boolean;
  86913. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  86914. showSubMeshesBoundingBox: boolean;
  86915. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  86916. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  86917. */
  86918. isBlocker: boolean;
  86919. /**
  86920. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  86921. */
  86922. enablePointerMoveEvents: boolean;
  86923. /**
  86924. * Specifies the rendering group id for this mesh (0 by default)
  86925. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  86926. */
  86927. renderingGroupId: number;
  86928. private _material;
  86929. /** Gets or sets current material */
  86930. material: Nullable<Material>;
  86931. /**
  86932. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  86933. * @see http://doc.babylonjs.com/babylon101/shadows
  86934. */
  86935. receiveShadows: boolean;
  86936. /** Defines color to use when rendering outline */
  86937. outlineColor: Color3;
  86938. /** Define width to use when rendering outline */
  86939. outlineWidth: number;
  86940. /** Defines color to use when rendering overlay */
  86941. overlayColor: Color3;
  86942. /** Defines alpha to use when rendering overlay */
  86943. overlayAlpha: number;
  86944. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  86945. hasVertexAlpha: boolean;
  86946. /** 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) */
  86947. useVertexColors: boolean;
  86948. /**
  86949. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  86950. */
  86951. computeBonesUsingShaders: boolean;
  86952. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  86953. numBoneInfluencers: number;
  86954. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  86955. applyFog: boolean;
  86956. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  86957. useOctreeForRenderingSelection: boolean;
  86958. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  86959. useOctreeForPicking: boolean;
  86960. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  86961. useOctreeForCollisions: boolean;
  86962. /**
  86963. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  86964. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  86965. */
  86966. layerMask: number;
  86967. /**
  86968. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  86969. */
  86970. alwaysSelectAsActiveMesh: boolean;
  86971. /**
  86972. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  86973. */
  86974. doNotSyncBoundingInfo: boolean;
  86975. /**
  86976. * Gets or sets the current action manager
  86977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86978. */
  86979. actionManager: Nullable<AbstractActionManager>;
  86980. private _meshCollisionData;
  86981. /**
  86982. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  86983. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  86984. */
  86985. ellipsoid: Vector3;
  86986. /**
  86987. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  86988. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  86989. */
  86990. ellipsoidOffset: Vector3;
  86991. /**
  86992. * Gets or sets a collision mask used to mask collisions (default is -1).
  86993. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  86994. */
  86995. collisionMask: number;
  86996. /**
  86997. * Gets or sets the current collision group mask (-1 by default).
  86998. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  86999. */
  87000. collisionGroup: number;
  87001. /**
  87002. * Defines edge width used when edgesRenderer is enabled
  87003. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87004. */
  87005. edgesWidth: number;
  87006. /**
  87007. * Defines edge color used when edgesRenderer is enabled
  87008. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87009. */
  87010. edgesColor: Color4;
  87011. /** @hidden */
  87012. _edgesRenderer: Nullable<IEdgesRenderer>;
  87013. /** @hidden */
  87014. _masterMesh: Nullable<AbstractMesh>;
  87015. /** @hidden */
  87016. _boundingInfo: Nullable<BoundingInfo>;
  87017. /** @hidden */
  87018. _renderId: number;
  87019. /**
  87020. * Gets or sets the list of subMeshes
  87021. * @see http://doc.babylonjs.com/how_to/multi_materials
  87022. */
  87023. subMeshes: SubMesh[];
  87024. /** @hidden */
  87025. _intersectionsInProgress: AbstractMesh[];
  87026. /** @hidden */
  87027. _unIndexed: boolean;
  87028. /** @hidden */
  87029. _lightSources: Light[];
  87030. /** Gets the list of lights affecting that mesh */
  87031. readonly lightSources: Light[];
  87032. /** @hidden */
  87033. readonly _positions: Nullable<Vector3[]>;
  87034. /** @hidden */
  87035. _waitingData: {
  87036. lods: Nullable<any>;
  87037. actions: Nullable<any>;
  87038. freezeWorldMatrix: Nullable<boolean>;
  87039. };
  87040. /** @hidden */
  87041. _bonesTransformMatrices: Nullable<Float32Array>;
  87042. /**
  87043. * Gets or sets a skeleton to apply skining transformations
  87044. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87045. */
  87046. skeleton: Nullable<Skeleton>;
  87047. /**
  87048. * An event triggered when the mesh is rebuilt.
  87049. */
  87050. onRebuildObservable: Observable<AbstractMesh>;
  87051. /**
  87052. * Creates a new AbstractMesh
  87053. * @param name defines the name of the mesh
  87054. * @param scene defines the hosting scene
  87055. */
  87056. constructor(name: string, scene?: Nullable<Scene>);
  87057. /**
  87058. * Returns the string "AbstractMesh"
  87059. * @returns "AbstractMesh"
  87060. */
  87061. getClassName(): string;
  87062. /**
  87063. * Gets a string representation of the current mesh
  87064. * @param fullDetails defines a boolean indicating if full details must be included
  87065. * @returns a string representation of the current mesh
  87066. */
  87067. toString(fullDetails?: boolean): string;
  87068. /**
  87069. * @hidden
  87070. */
  87071. protected _getEffectiveParent(): Nullable<Node>;
  87072. /** @hidden */
  87073. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87074. /** @hidden */
  87075. _rebuild(): void;
  87076. /** @hidden */
  87077. _resyncLightSources(): void;
  87078. /** @hidden */
  87079. _resyncLighSource(light: Light): void;
  87080. /** @hidden */
  87081. _unBindEffect(): void;
  87082. /** @hidden */
  87083. _removeLightSource(light: Light): void;
  87084. private _markSubMeshesAsDirty;
  87085. /** @hidden */
  87086. _markSubMeshesAsLightDirty(): void;
  87087. /** @hidden */
  87088. _markSubMeshesAsAttributesDirty(): void;
  87089. /** @hidden */
  87090. _markSubMeshesAsMiscDirty(): void;
  87091. /**
  87092. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  87093. */
  87094. scaling: Vector3;
  87095. /**
  87096. * Returns true if the mesh is blocked. Implemented by child classes
  87097. */
  87098. readonly isBlocked: boolean;
  87099. /**
  87100. * Returns the mesh itself by default. Implemented by child classes
  87101. * @param camera defines the camera to use to pick the right LOD level
  87102. * @returns the currentAbstractMesh
  87103. */
  87104. getLOD(camera: Camera): Nullable<AbstractMesh>;
  87105. /**
  87106. * Returns 0 by default. Implemented by child classes
  87107. * @returns an integer
  87108. */
  87109. getTotalVertices(): number;
  87110. /**
  87111. * Returns a positive integer : the total number of indices in this mesh geometry.
  87112. * @returns the numner of indices or zero if the mesh has no geometry.
  87113. */
  87114. getTotalIndices(): number;
  87115. /**
  87116. * Returns null by default. Implemented by child classes
  87117. * @returns null
  87118. */
  87119. getIndices(): Nullable<IndicesArray>;
  87120. /**
  87121. * Returns the array of the requested vertex data kind. Implemented by child classes
  87122. * @param kind defines the vertex data kind to use
  87123. * @returns null
  87124. */
  87125. getVerticesData(kind: string): Nullable<FloatArray>;
  87126. /**
  87127. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87128. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87129. * Note that a new underlying VertexBuffer object is created each call.
  87130. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87131. * @param kind defines vertex data kind:
  87132. * * VertexBuffer.PositionKind
  87133. * * VertexBuffer.UVKind
  87134. * * VertexBuffer.UV2Kind
  87135. * * VertexBuffer.UV3Kind
  87136. * * VertexBuffer.UV4Kind
  87137. * * VertexBuffer.UV5Kind
  87138. * * VertexBuffer.UV6Kind
  87139. * * VertexBuffer.ColorKind
  87140. * * VertexBuffer.MatricesIndicesKind
  87141. * * VertexBuffer.MatricesIndicesExtraKind
  87142. * * VertexBuffer.MatricesWeightsKind
  87143. * * VertexBuffer.MatricesWeightsExtraKind
  87144. * @param data defines the data source
  87145. * @param updatable defines if the data must be flagged as updatable (or static)
  87146. * @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
  87147. * @returns the current mesh
  87148. */
  87149. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87150. /**
  87151. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87152. * If the mesh has no geometry, it is simply returned as it is.
  87153. * @param kind defines vertex data kind:
  87154. * * VertexBuffer.PositionKind
  87155. * * VertexBuffer.UVKind
  87156. * * VertexBuffer.UV2Kind
  87157. * * VertexBuffer.UV3Kind
  87158. * * VertexBuffer.UV4Kind
  87159. * * VertexBuffer.UV5Kind
  87160. * * VertexBuffer.UV6Kind
  87161. * * VertexBuffer.ColorKind
  87162. * * VertexBuffer.MatricesIndicesKind
  87163. * * VertexBuffer.MatricesIndicesExtraKind
  87164. * * VertexBuffer.MatricesWeightsKind
  87165. * * VertexBuffer.MatricesWeightsExtraKind
  87166. * @param data defines the data source
  87167. * @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
  87168. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  87169. * @returns the current mesh
  87170. */
  87171. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  87172. /**
  87173. * Sets the mesh indices,
  87174. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87175. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  87176. * @param totalVertices Defines the total number of vertices
  87177. * @returns the current mesh
  87178. */
  87179. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  87180. /**
  87181. * Gets a boolean indicating if specific vertex data is present
  87182. * @param kind defines the vertex data kind to use
  87183. * @returns true is data kind is present
  87184. */
  87185. isVerticesDataPresent(kind: string): boolean;
  87186. /**
  87187. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  87188. * @returns a BoundingInfo
  87189. */
  87190. getBoundingInfo(): BoundingInfo;
  87191. /**
  87192. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87193. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87194. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87195. * @returns the current mesh
  87196. */
  87197. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  87198. /**
  87199. * Overwrite the current bounding info
  87200. * @param boundingInfo defines the new bounding info
  87201. * @returns the current mesh
  87202. */
  87203. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  87204. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  87205. readonly useBones: boolean;
  87206. /** @hidden */
  87207. _preActivate(): void;
  87208. /** @hidden */
  87209. _preActivateForIntermediateRendering(renderId: number): void;
  87210. /** @hidden */
  87211. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87212. /** @hidden */
  87213. _postActivate(): void;
  87214. /** @hidden */
  87215. _freeze(): void;
  87216. /** @hidden */
  87217. _unFreeze(): void;
  87218. /**
  87219. * Gets the current world matrix
  87220. * @returns a Matrix
  87221. */
  87222. getWorldMatrix(): Matrix;
  87223. /** @hidden */
  87224. _getWorldMatrixDeterminant(): number;
  87225. /**
  87226. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  87227. */
  87228. readonly isAnInstance: boolean;
  87229. /**
  87230. * Perform relative position change from the point of view of behind the front of the mesh.
  87231. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87232. * Supports definition of mesh facing forward or backward
  87233. * @param amountRight defines the distance on the right axis
  87234. * @param amountUp defines the distance on the up axis
  87235. * @param amountForward defines the distance on the forward axis
  87236. * @returns the current mesh
  87237. */
  87238. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  87239. /**
  87240. * Calculate relative position change from the point of view of behind the front of the mesh.
  87241. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87242. * Supports definition of mesh facing forward or backward
  87243. * @param amountRight defines the distance on the right axis
  87244. * @param amountUp defines the distance on the up axis
  87245. * @param amountForward defines the distance on the forward axis
  87246. * @returns the new displacement vector
  87247. */
  87248. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  87249. /**
  87250. * Perform relative rotation change from the point of view of behind the front of the mesh.
  87251. * Supports definition of mesh facing forward or backward
  87252. * @param flipBack defines the flip
  87253. * @param twirlClockwise defines the twirl
  87254. * @param tiltRight defines the tilt
  87255. * @returns the current mesh
  87256. */
  87257. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  87258. /**
  87259. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  87260. * Supports definition of mesh facing forward or backward.
  87261. * @param flipBack defines the flip
  87262. * @param twirlClockwise defines the twirl
  87263. * @param tiltRight defines the tilt
  87264. * @returns the new rotation vector
  87265. */
  87266. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  87267. /**
  87268. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87269. * This means the mesh underlying bounding box and sphere are recomputed.
  87270. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87271. * @returns the current mesh
  87272. */
  87273. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  87274. /** @hidden */
  87275. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  87276. /** @hidden */
  87277. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  87278. /** @hidden */
  87279. _updateBoundingInfo(): AbstractMesh;
  87280. /** @hidden */
  87281. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  87282. /** @hidden */
  87283. protected _afterComputeWorldMatrix(): void;
  87284. /** @hidden */
  87285. readonly _effectiveMesh: AbstractMesh;
  87286. /**
  87287. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87288. * A mesh is in the frustum if its bounding box intersects the frustum
  87289. * @param frustumPlanes defines the frustum to test
  87290. * @returns true if the mesh is in the frustum planes
  87291. */
  87292. isInFrustum(frustumPlanes: Plane[]): boolean;
  87293. /**
  87294. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  87295. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  87296. * @param frustumPlanes defines the frustum to test
  87297. * @returns true if the mesh is completely in the frustum planes
  87298. */
  87299. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87300. /**
  87301. * True if the mesh intersects another mesh or a SolidParticle object
  87302. * @param mesh defines a target mesh or SolidParticle to test
  87303. * @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)
  87304. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  87305. * @returns true if there is an intersection
  87306. */
  87307. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  87308. /**
  87309. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  87310. * @param point defines the point to test
  87311. * @returns true if there is an intersection
  87312. */
  87313. intersectsPoint(point: Vector3): boolean;
  87314. /**
  87315. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  87316. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87317. */
  87318. checkCollisions: boolean;
  87319. /**
  87320. * Gets Collider object used to compute collisions (not physics)
  87321. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87322. */
  87323. readonly collider: Nullable<Collider>;
  87324. /**
  87325. * Move the mesh using collision engine
  87326. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87327. * @param displacement defines the requested displacement vector
  87328. * @returns the current mesh
  87329. */
  87330. moveWithCollisions(displacement: Vector3): AbstractMesh;
  87331. private _onCollisionPositionChange;
  87332. /** @hidden */
  87333. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  87334. /** @hidden */
  87335. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  87336. /** @hidden */
  87337. _checkCollision(collider: Collider): AbstractMesh;
  87338. /** @hidden */
  87339. _generatePointsArray(): boolean;
  87340. /**
  87341. * Checks if the passed Ray intersects with the mesh
  87342. * @param ray defines the ray to use
  87343. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  87344. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87345. * @returns the picking info
  87346. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87347. */
  87348. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  87349. /**
  87350. * Clones the current mesh
  87351. * @param name defines the mesh name
  87352. * @param newParent defines the new mesh parent
  87353. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  87354. * @returns the new mesh
  87355. */
  87356. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87357. /**
  87358. * Disposes all the submeshes of the current meshnp
  87359. * @returns the current mesh
  87360. */
  87361. releaseSubMeshes(): AbstractMesh;
  87362. /**
  87363. * Releases resources associated with this abstract mesh.
  87364. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87365. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87366. */
  87367. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87368. /**
  87369. * Adds the passed mesh as a child to the current mesh
  87370. * @param mesh defines the child mesh
  87371. * @returns the current mesh
  87372. */
  87373. addChild(mesh: AbstractMesh): AbstractMesh;
  87374. /**
  87375. * Removes the passed mesh from the current mesh children list
  87376. * @param mesh defines the child mesh
  87377. * @returns the current mesh
  87378. */
  87379. removeChild(mesh: AbstractMesh): AbstractMesh;
  87380. /** @hidden */
  87381. private _initFacetData;
  87382. /**
  87383. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  87384. * This method can be called within the render loop.
  87385. * 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
  87386. * @returns the current mesh
  87387. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87388. */
  87389. updateFacetData(): AbstractMesh;
  87390. /**
  87391. * Returns the facetLocalNormals array.
  87392. * The normals are expressed in the mesh local spac
  87393. * @returns an array of Vector3
  87394. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87395. */
  87396. getFacetLocalNormals(): Vector3[];
  87397. /**
  87398. * Returns the facetLocalPositions array.
  87399. * The facet positions are expressed in the mesh local space
  87400. * @returns an array of Vector3
  87401. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87402. */
  87403. getFacetLocalPositions(): Vector3[];
  87404. /**
  87405. * Returns the facetLocalPartioning array
  87406. * @returns an array of array of numbers
  87407. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87408. */
  87409. getFacetLocalPartitioning(): number[][];
  87410. /**
  87411. * Returns the i-th facet position in the world system.
  87412. * This method allocates a new Vector3 per call
  87413. * @param i defines the facet index
  87414. * @returns a new Vector3
  87415. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87416. */
  87417. getFacetPosition(i: number): Vector3;
  87418. /**
  87419. * Sets the reference Vector3 with the i-th facet position in the world system
  87420. * @param i defines the facet index
  87421. * @param ref defines the target vector
  87422. * @returns the current mesh
  87423. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87424. */
  87425. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  87426. /**
  87427. * Returns the i-th facet normal in the world system.
  87428. * This method allocates a new Vector3 per call
  87429. * @param i defines the facet index
  87430. * @returns a new Vector3
  87431. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87432. */
  87433. getFacetNormal(i: number): Vector3;
  87434. /**
  87435. * Sets the reference Vector3 with the i-th facet normal in the world system
  87436. * @param i defines the facet index
  87437. * @param ref defines the target vector
  87438. * @returns the current mesh
  87439. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87440. */
  87441. getFacetNormalToRef(i: number, ref: Vector3): this;
  87442. /**
  87443. * 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)
  87444. * @param x defines x coordinate
  87445. * @param y defines y coordinate
  87446. * @param z defines z coordinate
  87447. * @returns the array of facet indexes
  87448. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87449. */
  87450. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  87451. /**
  87452. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  87453. * @param projected sets as the (x,y,z) world projection on the facet
  87454. * @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
  87455. * @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
  87456. * @param x defines x coordinate
  87457. * @param y defines y coordinate
  87458. * @param z defines z coordinate
  87459. * @returns the face index if found (or null instead)
  87460. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87461. */
  87462. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87463. /**
  87464. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  87465. * @param projected sets as the (x,y,z) local projection on the facet
  87466. * @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
  87467. * @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
  87468. * @param x defines x coordinate
  87469. * @param y defines y coordinate
  87470. * @param z defines z coordinate
  87471. * @returns the face index if found (or null instead)
  87472. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87473. */
  87474. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87475. /**
  87476. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  87477. * @returns the parameters
  87478. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87479. */
  87480. getFacetDataParameters(): any;
  87481. /**
  87482. * Disables the feature FacetData and frees the related memory
  87483. * @returns the current mesh
  87484. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87485. */
  87486. disableFacetData(): AbstractMesh;
  87487. /**
  87488. * Updates the AbstractMesh indices array
  87489. * @param indices defines the data source
  87490. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87491. * @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)
  87492. * @returns the current mesh
  87493. */
  87494. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  87495. /**
  87496. * Creates new normals data for the mesh
  87497. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  87498. * @returns the current mesh
  87499. */
  87500. createNormals(updatable: boolean): AbstractMesh;
  87501. /**
  87502. * Align the mesh with a normal
  87503. * @param normal defines the normal to use
  87504. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  87505. * @returns the current mesh
  87506. */
  87507. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  87508. /** @hidden */
  87509. _checkOcclusionQuery(): boolean;
  87510. /**
  87511. * Disables the mesh edge rendering mode
  87512. * @returns the currentAbstractMesh
  87513. */
  87514. disableEdgesRendering(): AbstractMesh;
  87515. /**
  87516. * Enables the edge rendering mode on the mesh.
  87517. * This mode makes the mesh edges visible
  87518. * @param epsilon defines the maximal distance between two angles to detect a face
  87519. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87520. * @returns the currentAbstractMesh
  87521. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87522. */
  87523. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87524. }
  87525. }
  87526. declare module BABYLON {
  87527. /**
  87528. * Interface used to define ActionEvent
  87529. */
  87530. export interface IActionEvent {
  87531. /** The mesh or sprite that triggered the action */
  87532. source: any;
  87533. /** The X mouse cursor position at the time of the event */
  87534. pointerX: number;
  87535. /** The Y mouse cursor position at the time of the event */
  87536. pointerY: number;
  87537. /** The mesh that is currently pointed at (can be null) */
  87538. meshUnderPointer: Nullable<AbstractMesh>;
  87539. /** the original (browser) event that triggered the ActionEvent */
  87540. sourceEvent?: any;
  87541. /** additional data for the event */
  87542. additionalData?: any;
  87543. }
  87544. /**
  87545. * ActionEvent is the event being sent when an action is triggered.
  87546. */
  87547. export class ActionEvent implements IActionEvent {
  87548. /** The mesh or sprite that triggered the action */
  87549. source: any;
  87550. /** The X mouse cursor position at the time of the event */
  87551. pointerX: number;
  87552. /** The Y mouse cursor position at the time of the event */
  87553. pointerY: number;
  87554. /** The mesh that is currently pointed at (can be null) */
  87555. meshUnderPointer: Nullable<AbstractMesh>;
  87556. /** the original (browser) event that triggered the ActionEvent */
  87557. sourceEvent?: any;
  87558. /** additional data for the event */
  87559. additionalData?: any;
  87560. /**
  87561. * Creates a new ActionEvent
  87562. * @param source The mesh or sprite that triggered the action
  87563. * @param pointerX The X mouse cursor position at the time of the event
  87564. * @param pointerY The Y mouse cursor position at the time of the event
  87565. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  87566. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  87567. * @param additionalData additional data for the event
  87568. */
  87569. constructor(
  87570. /** The mesh or sprite that triggered the action */
  87571. source: any,
  87572. /** The X mouse cursor position at the time of the event */
  87573. pointerX: number,
  87574. /** The Y mouse cursor position at the time of the event */
  87575. pointerY: number,
  87576. /** The mesh that is currently pointed at (can be null) */
  87577. meshUnderPointer: Nullable<AbstractMesh>,
  87578. /** the original (browser) event that triggered the ActionEvent */
  87579. sourceEvent?: any,
  87580. /** additional data for the event */
  87581. additionalData?: any);
  87582. /**
  87583. * Helper function to auto-create an ActionEvent from a source mesh.
  87584. * @param source The source mesh that triggered the event
  87585. * @param evt The original (browser) event
  87586. * @param additionalData additional data for the event
  87587. * @returns the new ActionEvent
  87588. */
  87589. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  87590. /**
  87591. * Helper function to auto-create an ActionEvent from a source sprite
  87592. * @param source The source sprite that triggered the event
  87593. * @param scene Scene associated with the sprite
  87594. * @param evt The original (browser) event
  87595. * @param additionalData additional data for the event
  87596. * @returns the new ActionEvent
  87597. */
  87598. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  87599. /**
  87600. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  87601. * @param scene the scene where the event occurred
  87602. * @param evt The original (browser) event
  87603. * @returns the new ActionEvent
  87604. */
  87605. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  87606. /**
  87607. * Helper function to auto-create an ActionEvent from a primitive
  87608. * @param prim defines the target primitive
  87609. * @param pointerPos defines the pointer position
  87610. * @param evt The original (browser) event
  87611. * @param additionalData additional data for the event
  87612. * @returns the new ActionEvent
  87613. */
  87614. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  87615. }
  87616. }
  87617. declare module BABYLON {
  87618. /**
  87619. * Abstract class used to decouple action Manager from scene and meshes.
  87620. * Do not instantiate.
  87621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87622. */
  87623. export abstract class AbstractActionManager implements IDisposable {
  87624. /** Gets the list of active triggers */
  87625. static Triggers: {
  87626. [key: string]: number;
  87627. };
  87628. /** Gets the cursor to use when hovering items */
  87629. hoverCursor: string;
  87630. /** Gets the list of actions */
  87631. actions: IAction[];
  87632. /**
  87633. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  87634. */
  87635. isRecursive: boolean;
  87636. /**
  87637. * Releases all associated resources
  87638. */
  87639. abstract dispose(): void;
  87640. /**
  87641. * Does this action manager has pointer triggers
  87642. */
  87643. abstract readonly hasPointerTriggers: boolean;
  87644. /**
  87645. * Does this action manager has pick triggers
  87646. */
  87647. abstract readonly hasPickTriggers: boolean;
  87648. /**
  87649. * Process a specific trigger
  87650. * @param trigger defines the trigger to process
  87651. * @param evt defines the event details to be processed
  87652. */
  87653. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  87654. /**
  87655. * Does this action manager handles actions of any of the given triggers
  87656. * @param triggers defines the triggers to be tested
  87657. * @return a boolean indicating whether one (or more) of the triggers is handled
  87658. */
  87659. abstract hasSpecificTriggers(triggers: number[]): boolean;
  87660. /**
  87661. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87662. * speed.
  87663. * @param triggerA defines the trigger to be tested
  87664. * @param triggerB defines the trigger to be tested
  87665. * @return a boolean indicating whether one (or more) of the triggers is handled
  87666. */
  87667. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87668. /**
  87669. * Does this action manager handles actions of a given trigger
  87670. * @param trigger defines the trigger to be tested
  87671. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87672. * @return whether the trigger is handled
  87673. */
  87674. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87675. /**
  87676. * Serialize this manager to a JSON object
  87677. * @param name defines the property name to store this manager
  87678. * @returns a JSON representation of this manager
  87679. */
  87680. abstract serialize(name: string): any;
  87681. /**
  87682. * Registers an action to this action manager
  87683. * @param action defines the action to be registered
  87684. * @return the action amended (prepared) after registration
  87685. */
  87686. abstract registerAction(action: IAction): Nullable<IAction>;
  87687. /**
  87688. * Unregisters an action to this action manager
  87689. * @param action defines the action to be unregistered
  87690. * @return a boolean indicating whether the action has been unregistered
  87691. */
  87692. abstract unregisterAction(action: IAction): Boolean;
  87693. /**
  87694. * Does exist one action manager with at least one trigger
  87695. **/
  87696. static readonly HasTriggers: boolean;
  87697. /**
  87698. * Does exist one action manager with at least one pick trigger
  87699. **/
  87700. static readonly HasPickTriggers: boolean;
  87701. /**
  87702. * Does exist one action manager that handles actions of a given trigger
  87703. * @param trigger defines the trigger to be tested
  87704. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  87705. **/
  87706. static HasSpecificTrigger(trigger: number): boolean;
  87707. }
  87708. }
  87709. declare module BABYLON {
  87710. /**
  87711. * Defines how a node can be built from a string name.
  87712. */
  87713. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  87714. /**
  87715. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  87716. */
  87717. export class Node implements IBehaviorAware<Node> {
  87718. /** @hidden */
  87719. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  87720. private static _NodeConstructors;
  87721. /**
  87722. * Add a new node constructor
  87723. * @param type defines the type name of the node to construct
  87724. * @param constructorFunc defines the constructor function
  87725. */
  87726. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  87727. /**
  87728. * Returns a node constructor based on type name
  87729. * @param type defines the type name
  87730. * @param name defines the new node name
  87731. * @param scene defines the hosting scene
  87732. * @param options defines optional options to transmit to constructors
  87733. * @returns the new constructor or null
  87734. */
  87735. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  87736. /**
  87737. * Gets or sets the name of the node
  87738. */
  87739. name: string;
  87740. /**
  87741. * Gets or sets the id of the node
  87742. */
  87743. id: string;
  87744. /**
  87745. * Gets or sets the unique id of the node
  87746. */
  87747. uniqueId: number;
  87748. /**
  87749. * Gets or sets a string used to store user defined state for the node
  87750. */
  87751. state: string;
  87752. /**
  87753. * Gets or sets an object used to store user defined information for the node
  87754. */
  87755. metadata: any;
  87756. /**
  87757. * For internal use only. Please do not use.
  87758. */
  87759. reservedDataStore: any;
  87760. /**
  87761. * List of inspectable custom properties (used by the Inspector)
  87762. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87763. */
  87764. inspectableCustomProperties: IInspectable[];
  87765. /**
  87766. * Gets or sets a boolean used to define if the node must be serialized
  87767. */
  87768. doNotSerialize: boolean;
  87769. /** @hidden */
  87770. _isDisposed: boolean;
  87771. /**
  87772. * Gets a list of Animations associated with the node
  87773. */
  87774. animations: Animation[];
  87775. protected _ranges: {
  87776. [name: string]: Nullable<AnimationRange>;
  87777. };
  87778. /**
  87779. * Callback raised when the node is ready to be used
  87780. */
  87781. onReady: Nullable<(node: Node) => void>;
  87782. private _isEnabled;
  87783. private _isParentEnabled;
  87784. private _isReady;
  87785. /** @hidden */
  87786. _currentRenderId: number;
  87787. private _parentUpdateId;
  87788. /** @hidden */
  87789. _childUpdateId: number;
  87790. /** @hidden */
  87791. _waitingParentId: Nullable<string>;
  87792. /** @hidden */
  87793. _scene: Scene;
  87794. /** @hidden */
  87795. _cache: any;
  87796. private _parentNode;
  87797. private _children;
  87798. /** @hidden */
  87799. _worldMatrix: Matrix;
  87800. /** @hidden */
  87801. _worldMatrixDeterminant: number;
  87802. /** @hidden */
  87803. _worldMatrixDeterminantIsDirty: boolean;
  87804. /** @hidden */
  87805. private _sceneRootNodesIndex;
  87806. /**
  87807. * Gets a boolean indicating if the node has been disposed
  87808. * @returns true if the node was disposed
  87809. */
  87810. isDisposed(): boolean;
  87811. /**
  87812. * Gets or sets the parent of the node (without keeping the current position in the scene)
  87813. * @see https://doc.babylonjs.com/how_to/parenting
  87814. */
  87815. parent: Nullable<Node>;
  87816. private addToSceneRootNodes;
  87817. private removeFromSceneRootNodes;
  87818. private _animationPropertiesOverride;
  87819. /**
  87820. * Gets or sets the animation properties override
  87821. */
  87822. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87823. /**
  87824. * Gets a string idenfifying the name of the class
  87825. * @returns "Node" string
  87826. */
  87827. getClassName(): string;
  87828. /** @hidden */
  87829. readonly _isNode: boolean;
  87830. /**
  87831. * An event triggered when the mesh is disposed
  87832. */
  87833. onDisposeObservable: Observable<Node>;
  87834. private _onDisposeObserver;
  87835. /**
  87836. * Sets a callback that will be raised when the node will be disposed
  87837. */
  87838. onDispose: () => void;
  87839. /**
  87840. * Creates a new Node
  87841. * @param name the name and id to be given to this node
  87842. * @param scene the scene this node will be added to
  87843. * @param addToRootNodes the node will be added to scene.rootNodes
  87844. */
  87845. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  87846. /**
  87847. * Gets the scene of the node
  87848. * @returns a scene
  87849. */
  87850. getScene(): Scene;
  87851. /**
  87852. * Gets the engine of the node
  87853. * @returns a Engine
  87854. */
  87855. getEngine(): Engine;
  87856. private _behaviors;
  87857. /**
  87858. * Attach a behavior to the node
  87859. * @see http://doc.babylonjs.com/features/behaviour
  87860. * @param behavior defines the behavior to attach
  87861. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  87862. * @returns the current Node
  87863. */
  87864. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  87865. /**
  87866. * Remove an attached behavior
  87867. * @see http://doc.babylonjs.com/features/behaviour
  87868. * @param behavior defines the behavior to attach
  87869. * @returns the current Node
  87870. */
  87871. removeBehavior(behavior: Behavior<Node>): Node;
  87872. /**
  87873. * Gets the list of attached behaviors
  87874. * @see http://doc.babylonjs.com/features/behaviour
  87875. */
  87876. readonly behaviors: Behavior<Node>[];
  87877. /**
  87878. * Gets an attached behavior by name
  87879. * @param name defines the name of the behavior to look for
  87880. * @see http://doc.babylonjs.com/features/behaviour
  87881. * @returns null if behavior was not found else the requested behavior
  87882. */
  87883. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  87884. /**
  87885. * Returns the latest update of the World matrix
  87886. * @returns a Matrix
  87887. */
  87888. getWorldMatrix(): Matrix;
  87889. /** @hidden */
  87890. _getWorldMatrixDeterminant(): number;
  87891. /**
  87892. * Returns directly the latest state of the mesh World matrix.
  87893. * A Matrix is returned.
  87894. */
  87895. readonly worldMatrixFromCache: Matrix;
  87896. /** @hidden */
  87897. _initCache(): void;
  87898. /** @hidden */
  87899. updateCache(force?: boolean): void;
  87900. /** @hidden */
  87901. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87902. /** @hidden */
  87903. _updateCache(ignoreParentClass?: boolean): void;
  87904. /** @hidden */
  87905. _isSynchronized(): boolean;
  87906. /** @hidden */
  87907. _markSyncedWithParent(): void;
  87908. /** @hidden */
  87909. isSynchronizedWithParent(): boolean;
  87910. /** @hidden */
  87911. isSynchronized(): boolean;
  87912. /**
  87913. * Is this node ready to be used/rendered
  87914. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87915. * @return true if the node is ready
  87916. */
  87917. isReady(completeCheck?: boolean): boolean;
  87918. /**
  87919. * Is this node enabled?
  87920. * 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
  87921. * @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
  87922. * @return whether this node (and its parent) is enabled
  87923. */
  87924. isEnabled(checkAncestors?: boolean): boolean;
  87925. /** @hidden */
  87926. protected _syncParentEnabledState(): void;
  87927. /**
  87928. * Set the enabled state of this node
  87929. * @param value defines the new enabled state
  87930. */
  87931. setEnabled(value: boolean): void;
  87932. /**
  87933. * Is this node a descendant of the given node?
  87934. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  87935. * @param ancestor defines the parent node to inspect
  87936. * @returns a boolean indicating if this node is a descendant of the given node
  87937. */
  87938. isDescendantOf(ancestor: Node): boolean;
  87939. /** @hidden */
  87940. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  87941. /**
  87942. * Will return all nodes that have this node as ascendant
  87943. * @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
  87944. * @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
  87945. * @return all children nodes of all types
  87946. */
  87947. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  87948. /**
  87949. * Get all child-meshes of this node
  87950. * @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)
  87951. * @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
  87952. * @returns an array of AbstractMesh
  87953. */
  87954. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  87955. /**
  87956. * Get all direct children of this node
  87957. * @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
  87958. * @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)
  87959. * @returns an array of Node
  87960. */
  87961. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  87962. /** @hidden */
  87963. _setReady(state: boolean): void;
  87964. /**
  87965. * Get an animation by name
  87966. * @param name defines the name of the animation to look for
  87967. * @returns null if not found else the requested animation
  87968. */
  87969. getAnimationByName(name: string): Nullable<Animation>;
  87970. /**
  87971. * Creates an animation range for this node
  87972. * @param name defines the name of the range
  87973. * @param from defines the starting key
  87974. * @param to defines the end key
  87975. */
  87976. createAnimationRange(name: string, from: number, to: number): void;
  87977. /**
  87978. * Delete a specific animation range
  87979. * @param name defines the name of the range to delete
  87980. * @param deleteFrames defines if animation frames from the range must be deleted as well
  87981. */
  87982. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  87983. /**
  87984. * Get an animation range by name
  87985. * @param name defines the name of the animation range to look for
  87986. * @returns null if not found else the requested animation range
  87987. */
  87988. getAnimationRange(name: string): Nullable<AnimationRange>;
  87989. /**
  87990. * Gets the list of all animation ranges defined on this node
  87991. * @returns an array
  87992. */
  87993. getAnimationRanges(): Nullable<AnimationRange>[];
  87994. /**
  87995. * Will start the animation sequence
  87996. * @param name defines the range frames for animation sequence
  87997. * @param loop defines if the animation should loop (false by default)
  87998. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  87999. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  88000. * @returns the object created for this animation. If range does not exist, it will return null
  88001. */
  88002. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88003. /**
  88004. * Serialize animation ranges into a JSON compatible object
  88005. * @returns serialization object
  88006. */
  88007. serializeAnimationRanges(): any;
  88008. /**
  88009. * Computes the world matrix of the node
  88010. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88011. * @returns the world matrix
  88012. */
  88013. computeWorldMatrix(force?: boolean): Matrix;
  88014. /**
  88015. * Releases resources associated with this node.
  88016. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88017. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88018. */
  88019. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88020. /**
  88021. * Parse animation range data from a serialization object and store them into a given node
  88022. * @param node defines where to store the animation ranges
  88023. * @param parsedNode defines the serialization object to read data from
  88024. * @param scene defines the hosting scene
  88025. */
  88026. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  88027. /**
  88028. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  88029. * @param includeDescendants Include bounding info from descendants as well (true by default)
  88030. * @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
  88031. * @returns the new bounding vectors
  88032. */
  88033. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  88034. min: Vector3;
  88035. max: Vector3;
  88036. };
  88037. }
  88038. }
  88039. declare module BABYLON {
  88040. /**
  88041. * @hidden
  88042. */
  88043. export class _IAnimationState {
  88044. key: number;
  88045. repeatCount: number;
  88046. workValue?: any;
  88047. loopMode?: number;
  88048. offsetValue?: any;
  88049. highLimitValue?: any;
  88050. }
  88051. /**
  88052. * Class used to store any kind of animation
  88053. */
  88054. export class Animation {
  88055. /**Name of the animation */
  88056. name: string;
  88057. /**Property to animate */
  88058. targetProperty: string;
  88059. /**The frames per second of the animation */
  88060. framePerSecond: number;
  88061. /**The data type of the animation */
  88062. dataType: number;
  88063. /**The loop mode of the animation */
  88064. loopMode?: number | undefined;
  88065. /**Specifies if blending should be enabled */
  88066. enableBlending?: boolean | undefined;
  88067. /**
  88068. * Use matrix interpolation instead of using direct key value when animating matrices
  88069. */
  88070. static AllowMatricesInterpolation: boolean;
  88071. /**
  88072. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  88073. */
  88074. static AllowMatrixDecomposeForInterpolation: boolean;
  88075. /**
  88076. * Stores the key frames of the animation
  88077. */
  88078. private _keys;
  88079. /**
  88080. * Stores the easing function of the animation
  88081. */
  88082. private _easingFunction;
  88083. /**
  88084. * @hidden Internal use only
  88085. */
  88086. _runtimeAnimations: RuntimeAnimation[];
  88087. /**
  88088. * The set of event that will be linked to this animation
  88089. */
  88090. private _events;
  88091. /**
  88092. * Stores an array of target property paths
  88093. */
  88094. targetPropertyPath: string[];
  88095. /**
  88096. * Stores the blending speed of the animation
  88097. */
  88098. blendingSpeed: number;
  88099. /**
  88100. * Stores the animation ranges for the animation
  88101. */
  88102. private _ranges;
  88103. /**
  88104. * @hidden Internal use
  88105. */
  88106. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  88107. /**
  88108. * Sets up an animation
  88109. * @param property The property to animate
  88110. * @param animationType The animation type to apply
  88111. * @param framePerSecond The frames per second of the animation
  88112. * @param easingFunction The easing function used in the animation
  88113. * @returns The created animation
  88114. */
  88115. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  88116. /**
  88117. * Create and start an animation on a node
  88118. * @param name defines the name of the global animation that will be run on all nodes
  88119. * @param node defines the root node where the animation will take place
  88120. * @param targetProperty defines property to animate
  88121. * @param framePerSecond defines the number of frame per second yo use
  88122. * @param totalFrame defines the number of frames in total
  88123. * @param from defines the initial value
  88124. * @param to defines the final value
  88125. * @param loopMode defines which loop mode you want to use (off by default)
  88126. * @param easingFunction defines the easing function to use (linear by default)
  88127. * @param onAnimationEnd defines the callback to call when animation end
  88128. * @returns the animatable created for this animation
  88129. */
  88130. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88131. /**
  88132. * Create and start an animation on a node and its descendants
  88133. * @param name defines the name of the global animation that will be run on all nodes
  88134. * @param node defines the root node where the animation will take place
  88135. * @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
  88136. * @param targetProperty defines property to animate
  88137. * @param framePerSecond defines the number of frame per second to use
  88138. * @param totalFrame defines the number of frames in total
  88139. * @param from defines the initial value
  88140. * @param to defines the final value
  88141. * @param loopMode defines which loop mode you want to use (off by default)
  88142. * @param easingFunction defines the easing function to use (linear by default)
  88143. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88144. * @returns the list of animatables created for all nodes
  88145. * @example https://www.babylonjs-playground.com/#MH0VLI
  88146. */
  88147. 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[]>;
  88148. /**
  88149. * Creates a new animation, merges it with the existing animations and starts it
  88150. * @param name Name of the animation
  88151. * @param node Node which contains the scene that begins the animations
  88152. * @param targetProperty Specifies which property to animate
  88153. * @param framePerSecond The frames per second of the animation
  88154. * @param totalFrame The total number of frames
  88155. * @param from The frame at the beginning of the animation
  88156. * @param to The frame at the end of the animation
  88157. * @param loopMode Specifies the loop mode of the animation
  88158. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  88159. * @param onAnimationEnd Callback to run once the animation is complete
  88160. * @returns Nullable animation
  88161. */
  88162. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88163. /**
  88164. * Transition property of an host to the target Value
  88165. * @param property The property to transition
  88166. * @param targetValue The target Value of the property
  88167. * @param host The object where the property to animate belongs
  88168. * @param scene Scene used to run the animation
  88169. * @param frameRate Framerate (in frame/s) to use
  88170. * @param transition The transition type we want to use
  88171. * @param duration The duration of the animation, in milliseconds
  88172. * @param onAnimationEnd Callback trigger at the end of the animation
  88173. * @returns Nullable animation
  88174. */
  88175. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  88176. /**
  88177. * Return the array of runtime animations currently using this animation
  88178. */
  88179. readonly runtimeAnimations: RuntimeAnimation[];
  88180. /**
  88181. * Specifies if any of the runtime animations are currently running
  88182. */
  88183. readonly hasRunningRuntimeAnimations: boolean;
  88184. /**
  88185. * Initializes the animation
  88186. * @param name Name of the animation
  88187. * @param targetProperty Property to animate
  88188. * @param framePerSecond The frames per second of the animation
  88189. * @param dataType The data type of the animation
  88190. * @param loopMode The loop mode of the animation
  88191. * @param enableBlending Specifies if blending should be enabled
  88192. */
  88193. constructor(
  88194. /**Name of the animation */
  88195. name: string,
  88196. /**Property to animate */
  88197. targetProperty: string,
  88198. /**The frames per second of the animation */
  88199. framePerSecond: number,
  88200. /**The data type of the animation */
  88201. dataType: number,
  88202. /**The loop mode of the animation */
  88203. loopMode?: number | undefined,
  88204. /**Specifies if blending should be enabled */
  88205. enableBlending?: boolean | undefined);
  88206. /**
  88207. * Converts the animation to a string
  88208. * @param fullDetails support for multiple levels of logging within scene loading
  88209. * @returns String form of the animation
  88210. */
  88211. toString(fullDetails?: boolean): string;
  88212. /**
  88213. * Add an event to this animation
  88214. * @param event Event to add
  88215. */
  88216. addEvent(event: AnimationEvent): void;
  88217. /**
  88218. * Remove all events found at the given frame
  88219. * @param frame The frame to remove events from
  88220. */
  88221. removeEvents(frame: number): void;
  88222. /**
  88223. * Retrieves all the events from the animation
  88224. * @returns Events from the animation
  88225. */
  88226. getEvents(): AnimationEvent[];
  88227. /**
  88228. * Creates an animation range
  88229. * @param name Name of the animation range
  88230. * @param from Starting frame of the animation range
  88231. * @param to Ending frame of the animation
  88232. */
  88233. createRange(name: string, from: number, to: number): void;
  88234. /**
  88235. * Deletes an animation range by name
  88236. * @param name Name of the animation range to delete
  88237. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  88238. */
  88239. deleteRange(name: string, deleteFrames?: boolean): void;
  88240. /**
  88241. * Gets the animation range by name, or null if not defined
  88242. * @param name Name of the animation range
  88243. * @returns Nullable animation range
  88244. */
  88245. getRange(name: string): Nullable<AnimationRange>;
  88246. /**
  88247. * Gets the key frames from the animation
  88248. * @returns The key frames of the animation
  88249. */
  88250. getKeys(): Array<IAnimationKey>;
  88251. /**
  88252. * Gets the highest frame rate of the animation
  88253. * @returns Highest frame rate of the animation
  88254. */
  88255. getHighestFrame(): number;
  88256. /**
  88257. * Gets the easing function of the animation
  88258. * @returns Easing function of the animation
  88259. */
  88260. getEasingFunction(): IEasingFunction;
  88261. /**
  88262. * Sets the easing function of the animation
  88263. * @param easingFunction A custom mathematical formula for animation
  88264. */
  88265. setEasingFunction(easingFunction: EasingFunction): void;
  88266. /**
  88267. * Interpolates a scalar linearly
  88268. * @param startValue Start value of the animation curve
  88269. * @param endValue End value of the animation curve
  88270. * @param gradient Scalar amount to interpolate
  88271. * @returns Interpolated scalar value
  88272. */
  88273. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  88274. /**
  88275. * Interpolates a scalar cubically
  88276. * @param startValue Start value of the animation curve
  88277. * @param outTangent End tangent of the animation
  88278. * @param endValue End value of the animation curve
  88279. * @param inTangent Start tangent of the animation curve
  88280. * @param gradient Scalar amount to interpolate
  88281. * @returns Interpolated scalar value
  88282. */
  88283. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  88284. /**
  88285. * Interpolates a quaternion using a spherical linear interpolation
  88286. * @param startValue Start value of the animation curve
  88287. * @param endValue End value of the animation curve
  88288. * @param gradient Scalar amount to interpolate
  88289. * @returns Interpolated quaternion value
  88290. */
  88291. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  88292. /**
  88293. * Interpolates a quaternion cubically
  88294. * @param startValue Start value of the animation curve
  88295. * @param outTangent End tangent of the animation curve
  88296. * @param endValue End value of the animation curve
  88297. * @param inTangent Start tangent of the animation curve
  88298. * @param gradient Scalar amount to interpolate
  88299. * @returns Interpolated quaternion value
  88300. */
  88301. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  88302. /**
  88303. * Interpolates a Vector3 linearl
  88304. * @param startValue Start value of the animation curve
  88305. * @param endValue End value of the animation curve
  88306. * @param gradient Scalar amount to interpolate
  88307. * @returns Interpolated scalar value
  88308. */
  88309. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  88310. /**
  88311. * Interpolates a Vector3 cubically
  88312. * @param startValue Start value of the animation curve
  88313. * @param outTangent End tangent of the animation
  88314. * @param endValue End value of the animation curve
  88315. * @param inTangent Start tangent of the animation curve
  88316. * @param gradient Scalar amount to interpolate
  88317. * @returns InterpolatedVector3 value
  88318. */
  88319. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  88320. /**
  88321. * Interpolates a Vector2 linearly
  88322. * @param startValue Start value of the animation curve
  88323. * @param endValue End value of the animation curve
  88324. * @param gradient Scalar amount to interpolate
  88325. * @returns Interpolated Vector2 value
  88326. */
  88327. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  88328. /**
  88329. * Interpolates a Vector2 cubically
  88330. * @param startValue Start value of the animation curve
  88331. * @param outTangent End tangent of the animation
  88332. * @param endValue End value of the animation curve
  88333. * @param inTangent Start tangent of the animation curve
  88334. * @param gradient Scalar amount to interpolate
  88335. * @returns Interpolated Vector2 value
  88336. */
  88337. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  88338. /**
  88339. * Interpolates a size linearly
  88340. * @param startValue Start value of the animation curve
  88341. * @param endValue End value of the animation curve
  88342. * @param gradient Scalar amount to interpolate
  88343. * @returns Interpolated Size value
  88344. */
  88345. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  88346. /**
  88347. * Interpolates a Color3 linearly
  88348. * @param startValue Start value of the animation curve
  88349. * @param endValue End value of the animation curve
  88350. * @param gradient Scalar amount to interpolate
  88351. * @returns Interpolated Color3 value
  88352. */
  88353. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  88354. /**
  88355. * @hidden Internal use only
  88356. */
  88357. _getKeyValue(value: any): any;
  88358. /**
  88359. * @hidden Internal use only
  88360. */
  88361. _interpolate(currentFrame: number, state: _IAnimationState): any;
  88362. /**
  88363. * Defines the function to use to interpolate matrices
  88364. * @param startValue defines the start matrix
  88365. * @param endValue defines the end matrix
  88366. * @param gradient defines the gradient between both matrices
  88367. * @param result defines an optional target matrix where to store the interpolation
  88368. * @returns the interpolated matrix
  88369. */
  88370. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  88371. /**
  88372. * Makes a copy of the animation
  88373. * @returns Cloned animation
  88374. */
  88375. clone(): Animation;
  88376. /**
  88377. * Sets the key frames of the animation
  88378. * @param values The animation key frames to set
  88379. */
  88380. setKeys(values: Array<IAnimationKey>): void;
  88381. /**
  88382. * Serializes the animation to an object
  88383. * @returns Serialized object
  88384. */
  88385. serialize(): any;
  88386. /**
  88387. * Float animation type
  88388. */
  88389. private static _ANIMATIONTYPE_FLOAT;
  88390. /**
  88391. * Vector3 animation type
  88392. */
  88393. private static _ANIMATIONTYPE_VECTOR3;
  88394. /**
  88395. * Quaternion animation type
  88396. */
  88397. private static _ANIMATIONTYPE_QUATERNION;
  88398. /**
  88399. * Matrix animation type
  88400. */
  88401. private static _ANIMATIONTYPE_MATRIX;
  88402. /**
  88403. * Color3 animation type
  88404. */
  88405. private static _ANIMATIONTYPE_COLOR3;
  88406. /**
  88407. * Vector2 animation type
  88408. */
  88409. private static _ANIMATIONTYPE_VECTOR2;
  88410. /**
  88411. * Size animation type
  88412. */
  88413. private static _ANIMATIONTYPE_SIZE;
  88414. /**
  88415. * Relative Loop Mode
  88416. */
  88417. private static _ANIMATIONLOOPMODE_RELATIVE;
  88418. /**
  88419. * Cycle Loop Mode
  88420. */
  88421. private static _ANIMATIONLOOPMODE_CYCLE;
  88422. /**
  88423. * Constant Loop Mode
  88424. */
  88425. private static _ANIMATIONLOOPMODE_CONSTANT;
  88426. /**
  88427. * Get the float animation type
  88428. */
  88429. static readonly ANIMATIONTYPE_FLOAT: number;
  88430. /**
  88431. * Get the Vector3 animation type
  88432. */
  88433. static readonly ANIMATIONTYPE_VECTOR3: number;
  88434. /**
  88435. * Get the Vector2 animation type
  88436. */
  88437. static readonly ANIMATIONTYPE_VECTOR2: number;
  88438. /**
  88439. * Get the Size animation type
  88440. */
  88441. static readonly ANIMATIONTYPE_SIZE: number;
  88442. /**
  88443. * Get the Quaternion animation type
  88444. */
  88445. static readonly ANIMATIONTYPE_QUATERNION: number;
  88446. /**
  88447. * Get the Matrix animation type
  88448. */
  88449. static readonly ANIMATIONTYPE_MATRIX: number;
  88450. /**
  88451. * Get the Color3 animation type
  88452. */
  88453. static readonly ANIMATIONTYPE_COLOR3: number;
  88454. /**
  88455. * Get the Relative Loop Mode
  88456. */
  88457. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  88458. /**
  88459. * Get the Cycle Loop Mode
  88460. */
  88461. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  88462. /**
  88463. * Get the Constant Loop Mode
  88464. */
  88465. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  88466. /** @hidden */
  88467. static _UniversalLerp(left: any, right: any, amount: number): any;
  88468. /**
  88469. * Parses an animation object and creates an animation
  88470. * @param parsedAnimation Parsed animation object
  88471. * @returns Animation object
  88472. */
  88473. static Parse(parsedAnimation: any): Animation;
  88474. /**
  88475. * Appends the serialized animations from the source animations
  88476. * @param source Source containing the animations
  88477. * @param destination Target to store the animations
  88478. */
  88479. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88480. }
  88481. }
  88482. declare module BABYLON {
  88483. /**
  88484. * Base class of all the textures in babylon.
  88485. * It groups all the common properties the materials, post process, lights... might need
  88486. * in order to make a correct use of the texture.
  88487. */
  88488. export class BaseTexture implements IAnimatable {
  88489. /**
  88490. * Default anisotropic filtering level for the application.
  88491. * It is set to 4 as a good tradeoff between perf and quality.
  88492. */
  88493. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  88494. /**
  88495. * Gets or sets the unique id of the texture
  88496. */
  88497. uniqueId: number;
  88498. /**
  88499. * Define the name of the texture.
  88500. */
  88501. name: string;
  88502. /**
  88503. * Gets or sets an object used to store user defined information.
  88504. */
  88505. metadata: any;
  88506. /**
  88507. * For internal use only. Please do not use.
  88508. */
  88509. reservedDataStore: any;
  88510. private _hasAlpha;
  88511. /**
  88512. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  88513. */
  88514. hasAlpha: boolean;
  88515. /**
  88516. * Defines if the alpha value should be determined via the rgb values.
  88517. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  88518. */
  88519. getAlphaFromRGB: boolean;
  88520. /**
  88521. * Intensity or strength of the texture.
  88522. * It is commonly used by materials to fine tune the intensity of the texture
  88523. */
  88524. level: number;
  88525. /**
  88526. * Define the UV chanel to use starting from 0 and defaulting to 0.
  88527. * This is part of the texture as textures usually maps to one uv set.
  88528. */
  88529. coordinatesIndex: number;
  88530. private _coordinatesMode;
  88531. /**
  88532. * How a texture is mapped.
  88533. *
  88534. * | Value | Type | Description |
  88535. * | ----- | ----------------------------------- | ----------- |
  88536. * | 0 | EXPLICIT_MODE | |
  88537. * | 1 | SPHERICAL_MODE | |
  88538. * | 2 | PLANAR_MODE | |
  88539. * | 3 | CUBIC_MODE | |
  88540. * | 4 | PROJECTION_MODE | |
  88541. * | 5 | SKYBOX_MODE | |
  88542. * | 6 | INVCUBIC_MODE | |
  88543. * | 7 | EQUIRECTANGULAR_MODE | |
  88544. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  88545. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  88546. */
  88547. coordinatesMode: number;
  88548. /**
  88549. * | Value | Type | Description |
  88550. * | ----- | ------------------ | ----------- |
  88551. * | 0 | CLAMP_ADDRESSMODE | |
  88552. * | 1 | WRAP_ADDRESSMODE | |
  88553. * | 2 | MIRROR_ADDRESSMODE | |
  88554. */
  88555. wrapU: number;
  88556. /**
  88557. * | Value | Type | Description |
  88558. * | ----- | ------------------ | ----------- |
  88559. * | 0 | CLAMP_ADDRESSMODE | |
  88560. * | 1 | WRAP_ADDRESSMODE | |
  88561. * | 2 | MIRROR_ADDRESSMODE | |
  88562. */
  88563. wrapV: number;
  88564. /**
  88565. * | Value | Type | Description |
  88566. * | ----- | ------------------ | ----------- |
  88567. * | 0 | CLAMP_ADDRESSMODE | |
  88568. * | 1 | WRAP_ADDRESSMODE | |
  88569. * | 2 | MIRROR_ADDRESSMODE | |
  88570. */
  88571. wrapR: number;
  88572. /**
  88573. * With compliant hardware and browser (supporting anisotropic filtering)
  88574. * this defines the level of anisotropic filtering in the texture.
  88575. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  88576. */
  88577. anisotropicFilteringLevel: number;
  88578. /**
  88579. * Define if the texture is a cube texture or if false a 2d texture.
  88580. */
  88581. isCube: boolean;
  88582. /**
  88583. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  88584. */
  88585. is3D: boolean;
  88586. /**
  88587. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  88588. * HDR texture are usually stored in linear space.
  88589. * This only impacts the PBR and Background materials
  88590. */
  88591. gammaSpace: boolean;
  88592. /**
  88593. * Gets whether or not the texture contains RGBD data.
  88594. */
  88595. readonly isRGBD: boolean;
  88596. /**
  88597. * Is Z inverted in the texture (useful in a cube texture).
  88598. */
  88599. invertZ: boolean;
  88600. /**
  88601. * Are mip maps generated for this texture or not.
  88602. */
  88603. readonly noMipmap: boolean;
  88604. /**
  88605. * @hidden
  88606. */
  88607. lodLevelInAlpha: boolean;
  88608. /**
  88609. * With prefiltered texture, defined the offset used during the prefiltering steps.
  88610. */
  88611. lodGenerationOffset: number;
  88612. /**
  88613. * With prefiltered texture, defined the scale used during the prefiltering steps.
  88614. */
  88615. lodGenerationScale: number;
  88616. /**
  88617. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  88618. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  88619. * average roughness values.
  88620. */
  88621. linearSpecularLOD: boolean;
  88622. /**
  88623. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  88624. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  88625. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  88626. */
  88627. irradianceTexture: Nullable<BaseTexture>;
  88628. /**
  88629. * Define if the texture is a render target.
  88630. */
  88631. isRenderTarget: boolean;
  88632. /**
  88633. * Define the unique id of the texture in the scene.
  88634. */
  88635. readonly uid: string;
  88636. /**
  88637. * Return a string representation of the texture.
  88638. * @returns the texture as a string
  88639. */
  88640. toString(): string;
  88641. /**
  88642. * Get the class name of the texture.
  88643. * @returns "BaseTexture"
  88644. */
  88645. getClassName(): string;
  88646. /**
  88647. * Define the list of animation attached to the texture.
  88648. */
  88649. animations: Animation[];
  88650. /**
  88651. * An event triggered when the texture is disposed.
  88652. */
  88653. onDisposeObservable: Observable<BaseTexture>;
  88654. private _onDisposeObserver;
  88655. /**
  88656. * Callback triggered when the texture has been disposed.
  88657. * Kept for back compatibility, you can use the onDisposeObservable instead.
  88658. */
  88659. onDispose: () => void;
  88660. /**
  88661. * Define the current state of the loading sequence when in delayed load mode.
  88662. */
  88663. delayLoadState: number;
  88664. private _scene;
  88665. /** @hidden */
  88666. _texture: Nullable<InternalTexture>;
  88667. private _uid;
  88668. /**
  88669. * Define if the texture is preventinga material to render or not.
  88670. * If not and the texture is not ready, the engine will use a default black texture instead.
  88671. */
  88672. readonly isBlocking: boolean;
  88673. /**
  88674. * Instantiates a new BaseTexture.
  88675. * Base class of all the textures in babylon.
  88676. * It groups all the common properties the materials, post process, lights... might need
  88677. * in order to make a correct use of the texture.
  88678. * @param scene Define the scene the texture blongs to
  88679. */
  88680. constructor(scene: Nullable<Scene>);
  88681. /**
  88682. * Get the scene the texture belongs to.
  88683. * @returns the scene or null if undefined
  88684. */
  88685. getScene(): Nullable<Scene>;
  88686. /**
  88687. * Get the texture transform matrix used to offset tile the texture for istance.
  88688. * @returns the transformation matrix
  88689. */
  88690. getTextureMatrix(): Matrix;
  88691. /**
  88692. * Get the texture reflection matrix used to rotate/transform the reflection.
  88693. * @returns the reflection matrix
  88694. */
  88695. getReflectionTextureMatrix(): Matrix;
  88696. /**
  88697. * Get the underlying lower level texture from Babylon.
  88698. * @returns the insternal texture
  88699. */
  88700. getInternalTexture(): Nullable<InternalTexture>;
  88701. /**
  88702. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  88703. * @returns true if ready or not blocking
  88704. */
  88705. isReadyOrNotBlocking(): boolean;
  88706. /**
  88707. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  88708. * @returns true if fully ready
  88709. */
  88710. isReady(): boolean;
  88711. private _cachedSize;
  88712. /**
  88713. * Get the size of the texture.
  88714. * @returns the texture size.
  88715. */
  88716. getSize(): ISize;
  88717. /**
  88718. * Get the base size of the texture.
  88719. * It can be different from the size if the texture has been resized for POT for instance
  88720. * @returns the base size
  88721. */
  88722. getBaseSize(): ISize;
  88723. /**
  88724. * Update the sampling mode of the texture.
  88725. * Default is Trilinear mode.
  88726. *
  88727. * | Value | Type | Description |
  88728. * | ----- | ------------------ | ----------- |
  88729. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  88730. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  88731. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  88732. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  88733. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  88734. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  88735. * | 7 | NEAREST_LINEAR | |
  88736. * | 8 | NEAREST_NEAREST | |
  88737. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  88738. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  88739. * | 11 | LINEAR_LINEAR | |
  88740. * | 12 | LINEAR_NEAREST | |
  88741. *
  88742. * > _mag_: magnification filter (close to the viewer)
  88743. * > _min_: minification filter (far from the viewer)
  88744. * > _mip_: filter used between mip map levels
  88745. *@param samplingMode Define the new sampling mode of the texture
  88746. */
  88747. updateSamplingMode(samplingMode: number): void;
  88748. /**
  88749. * Scales the texture if is `canRescale()`
  88750. * @param ratio the resize factor we want to use to rescale
  88751. */
  88752. scale(ratio: number): void;
  88753. /**
  88754. * Get if the texture can rescale.
  88755. */
  88756. readonly canRescale: boolean;
  88757. /** @hidden */
  88758. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  88759. /** @hidden */
  88760. _rebuild(): void;
  88761. /**
  88762. * Triggers the load sequence in delayed load mode.
  88763. */
  88764. delayLoad(): void;
  88765. /**
  88766. * Clones the texture.
  88767. * @returns the cloned texture
  88768. */
  88769. clone(): Nullable<BaseTexture>;
  88770. /**
  88771. * Get the texture underlying type (INT, FLOAT...)
  88772. */
  88773. readonly textureType: number;
  88774. /**
  88775. * Get the texture underlying format (RGB, RGBA...)
  88776. */
  88777. readonly textureFormat: number;
  88778. /**
  88779. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  88780. * This will returns an RGBA array buffer containing either in values (0-255) or
  88781. * float values (0-1) depending of the underlying buffer type.
  88782. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  88783. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  88784. * @param buffer defines a user defined buffer to fill with data (can be null)
  88785. * @returns The Array buffer containing the pixels data.
  88786. */
  88787. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  88788. /**
  88789. * Release and destroy the underlying lower level texture aka internalTexture.
  88790. */
  88791. releaseInternalTexture(): void;
  88792. /**
  88793. * Get the polynomial representation of the texture data.
  88794. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  88795. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  88796. */
  88797. sphericalPolynomial: Nullable<SphericalPolynomial>;
  88798. /** @hidden */
  88799. readonly _lodTextureHigh: Nullable<BaseTexture>;
  88800. /** @hidden */
  88801. readonly _lodTextureMid: Nullable<BaseTexture>;
  88802. /** @hidden */
  88803. readonly _lodTextureLow: Nullable<BaseTexture>;
  88804. /**
  88805. * Dispose the texture and release its associated resources.
  88806. */
  88807. dispose(): void;
  88808. /**
  88809. * Serialize the texture into a JSON representation that can be parsed later on.
  88810. * @returns the JSON representation of the texture
  88811. */
  88812. serialize(): any;
  88813. /**
  88814. * Helper function to be called back once a list of texture contains only ready textures.
  88815. * @param textures Define the list of textures to wait for
  88816. * @param callback Define the callback triggered once the entire list will be ready
  88817. */
  88818. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  88819. }
  88820. }
  88821. declare module BABYLON {
  88822. /**
  88823. * Uniform buffer objects.
  88824. *
  88825. * Handles blocks of uniform on the GPU.
  88826. *
  88827. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88828. *
  88829. * For more information, please refer to :
  88830. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88831. */
  88832. export class UniformBuffer {
  88833. private _engine;
  88834. private _buffer;
  88835. private _data;
  88836. private _bufferData;
  88837. private _dynamic?;
  88838. private _uniformLocations;
  88839. private _uniformSizes;
  88840. private _uniformLocationPointer;
  88841. private _needSync;
  88842. private _noUBO;
  88843. private _currentEffect;
  88844. private static _MAX_UNIFORM_SIZE;
  88845. private static _tempBuffer;
  88846. /**
  88847. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  88848. * This is dynamic to allow compat with webgl 1 and 2.
  88849. * You will need to pass the name of the uniform as well as the value.
  88850. */
  88851. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  88852. /**
  88853. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  88854. * This is dynamic to allow compat with webgl 1 and 2.
  88855. * You will need to pass the name of the uniform as well as the value.
  88856. */
  88857. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  88858. /**
  88859. * Lambda to Update a single float in a uniform buffer.
  88860. * This is dynamic to allow compat with webgl 1 and 2.
  88861. * You will need to pass the name of the uniform as well as the value.
  88862. */
  88863. updateFloat: (name: string, x: number) => void;
  88864. /**
  88865. * Lambda to Update a vec2 of float in a uniform buffer.
  88866. * This is dynamic to allow compat with webgl 1 and 2.
  88867. * You will need to pass the name of the uniform as well as the value.
  88868. */
  88869. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  88870. /**
  88871. * Lambda to Update a vec3 of float in a uniform buffer.
  88872. * This is dynamic to allow compat with webgl 1 and 2.
  88873. * You will need to pass the name of the uniform as well as the value.
  88874. */
  88875. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  88876. /**
  88877. * Lambda to Update a vec4 of float in a uniform buffer.
  88878. * This is dynamic to allow compat with webgl 1 and 2.
  88879. * You will need to pass the name of the uniform as well as the value.
  88880. */
  88881. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  88882. /**
  88883. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  88884. * This is dynamic to allow compat with webgl 1 and 2.
  88885. * You will need to pass the name of the uniform as well as the value.
  88886. */
  88887. updateMatrix: (name: string, mat: Matrix) => void;
  88888. /**
  88889. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  88890. * This is dynamic to allow compat with webgl 1 and 2.
  88891. * You will need to pass the name of the uniform as well as the value.
  88892. */
  88893. updateVector3: (name: string, vector: Vector3) => void;
  88894. /**
  88895. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  88896. * This is dynamic to allow compat with webgl 1 and 2.
  88897. * You will need to pass the name of the uniform as well as the value.
  88898. */
  88899. updateVector4: (name: string, vector: Vector4) => void;
  88900. /**
  88901. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  88902. * This is dynamic to allow compat with webgl 1 and 2.
  88903. * You will need to pass the name of the uniform as well as the value.
  88904. */
  88905. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88906. /**
  88907. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88908. * This is dynamic to allow compat with webgl 1 and 2.
  88909. * You will need to pass the name of the uniform as well as the value.
  88910. */
  88911. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88912. /**
  88913. * Instantiates a new Uniform buffer objects.
  88914. *
  88915. * Handles blocks of uniform on the GPU.
  88916. *
  88917. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88918. *
  88919. * For more information, please refer to :
  88920. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88921. * @param engine Define the engine the buffer is associated with
  88922. * @param data Define the data contained in the buffer
  88923. * @param dynamic Define if the buffer is updatable
  88924. */
  88925. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88926. /**
  88927. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88928. * or just falling back on setUniformXXX calls.
  88929. */
  88930. readonly useUbo: boolean;
  88931. /**
  88932. * Indicates if the WebGL underlying uniform buffer is in sync
  88933. * with the javascript cache data.
  88934. */
  88935. readonly isSync: boolean;
  88936. /**
  88937. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88938. * Also, a dynamic UniformBuffer will disable cache verification and always
  88939. * update the underlying WebGL uniform buffer to the GPU.
  88940. * @returns if Dynamic, otherwise false
  88941. */
  88942. isDynamic(): boolean;
  88943. /**
  88944. * The data cache on JS side.
  88945. * @returns the underlying data as a float array
  88946. */
  88947. getData(): Float32Array;
  88948. /**
  88949. * The underlying WebGL Uniform buffer.
  88950. * @returns the webgl buffer
  88951. */
  88952. getBuffer(): Nullable<DataBuffer>;
  88953. /**
  88954. * std140 layout specifies how to align data within an UBO structure.
  88955. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88956. * for specs.
  88957. */
  88958. private _fillAlignment;
  88959. /**
  88960. * Adds an uniform in the buffer.
  88961. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88962. * for the layout to be correct !
  88963. * @param name Name of the uniform, as used in the uniform block in the shader.
  88964. * @param size Data size, or data directly.
  88965. */
  88966. addUniform(name: string, size: number | number[]): void;
  88967. /**
  88968. * Adds a Matrix 4x4 to the uniform buffer.
  88969. * @param name Name of the uniform, as used in the uniform block in the shader.
  88970. * @param mat A 4x4 matrix.
  88971. */
  88972. addMatrix(name: string, mat: Matrix): void;
  88973. /**
  88974. * Adds a vec2 to the uniform buffer.
  88975. * @param name Name of the uniform, as used in the uniform block in the shader.
  88976. * @param x Define the x component value of the vec2
  88977. * @param y Define the y component value of the vec2
  88978. */
  88979. addFloat2(name: string, x: number, y: number): void;
  88980. /**
  88981. * Adds a vec3 to the uniform buffer.
  88982. * @param name Name of the uniform, as used in the uniform block in the shader.
  88983. * @param x Define the x component value of the vec3
  88984. * @param y Define the y component value of the vec3
  88985. * @param z Define the z component value of the vec3
  88986. */
  88987. addFloat3(name: string, x: number, y: number, z: number): void;
  88988. /**
  88989. * Adds a vec3 to the uniform buffer.
  88990. * @param name Name of the uniform, as used in the uniform block in the shader.
  88991. * @param color Define the vec3 from a Color
  88992. */
  88993. addColor3(name: string, color: Color3): void;
  88994. /**
  88995. * Adds a vec4 to the uniform buffer.
  88996. * @param name Name of the uniform, as used in the uniform block in the shader.
  88997. * @param color Define the rgb components from a Color
  88998. * @param alpha Define the a component of the vec4
  88999. */
  89000. addColor4(name: string, color: Color3, alpha: number): void;
  89001. /**
  89002. * Adds a vec3 to the uniform buffer.
  89003. * @param name Name of the uniform, as used in the uniform block in the shader.
  89004. * @param vector Define the vec3 components from a Vector
  89005. */
  89006. addVector3(name: string, vector: Vector3): void;
  89007. /**
  89008. * Adds a Matrix 3x3 to the uniform buffer.
  89009. * @param name Name of the uniform, as used in the uniform block in the shader.
  89010. */
  89011. addMatrix3x3(name: string): void;
  89012. /**
  89013. * Adds a Matrix 2x2 to the uniform buffer.
  89014. * @param name Name of the uniform, as used in the uniform block in the shader.
  89015. */
  89016. addMatrix2x2(name: string): void;
  89017. /**
  89018. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89019. */
  89020. create(): void;
  89021. /** @hidden */
  89022. _rebuild(): void;
  89023. /**
  89024. * Updates the WebGL Uniform Buffer on the GPU.
  89025. * If the `dynamic` flag is set to true, no cache comparison is done.
  89026. * Otherwise, the buffer will be updated only if the cache differs.
  89027. */
  89028. update(): void;
  89029. /**
  89030. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89031. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89032. * @param data Define the flattened data
  89033. * @param size Define the size of the data.
  89034. */
  89035. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89036. private _updateMatrix3x3ForUniform;
  89037. private _updateMatrix3x3ForEffect;
  89038. private _updateMatrix2x2ForEffect;
  89039. private _updateMatrix2x2ForUniform;
  89040. private _updateFloatForEffect;
  89041. private _updateFloatForUniform;
  89042. private _updateFloat2ForEffect;
  89043. private _updateFloat2ForUniform;
  89044. private _updateFloat3ForEffect;
  89045. private _updateFloat3ForUniform;
  89046. private _updateFloat4ForEffect;
  89047. private _updateFloat4ForUniform;
  89048. private _updateMatrixForEffect;
  89049. private _updateMatrixForUniform;
  89050. private _updateVector3ForEffect;
  89051. private _updateVector3ForUniform;
  89052. private _updateVector4ForEffect;
  89053. private _updateVector4ForUniform;
  89054. private _updateColor3ForEffect;
  89055. private _updateColor3ForUniform;
  89056. private _updateColor4ForEffect;
  89057. private _updateColor4ForUniform;
  89058. /**
  89059. * Sets a sampler uniform on the effect.
  89060. * @param name Define the name of the sampler.
  89061. * @param texture Define the texture to set in the sampler
  89062. */
  89063. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89064. /**
  89065. * Directly updates the value of the uniform in the cache AND on the GPU.
  89066. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89067. * @param data Define the flattened data
  89068. */
  89069. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89070. /**
  89071. * Binds this uniform buffer to an effect.
  89072. * @param effect Define the effect to bind the buffer to
  89073. * @param name Name of the uniform block in the shader.
  89074. */
  89075. bindToEffect(effect: Effect, name: string): void;
  89076. /**
  89077. * Disposes the uniform buffer.
  89078. */
  89079. dispose(): void;
  89080. }
  89081. }
  89082. declare module BABYLON {
  89083. /**
  89084. * Class used to work with sound analyzer using fast fourier transform (FFT)
  89085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89086. */
  89087. export class Analyser {
  89088. /**
  89089. * Gets or sets the smoothing
  89090. * @ignorenaming
  89091. */
  89092. SMOOTHING: number;
  89093. /**
  89094. * Gets or sets the FFT table size
  89095. * @ignorenaming
  89096. */
  89097. FFT_SIZE: number;
  89098. /**
  89099. * Gets or sets the bar graph amplitude
  89100. * @ignorenaming
  89101. */
  89102. BARGRAPHAMPLITUDE: number;
  89103. /**
  89104. * Gets or sets the position of the debug canvas
  89105. * @ignorenaming
  89106. */
  89107. DEBUGCANVASPOS: {
  89108. x: number;
  89109. y: number;
  89110. };
  89111. /**
  89112. * Gets or sets the debug canvas size
  89113. * @ignorenaming
  89114. */
  89115. DEBUGCANVASSIZE: {
  89116. width: number;
  89117. height: number;
  89118. };
  89119. private _byteFreqs;
  89120. private _byteTime;
  89121. private _floatFreqs;
  89122. private _webAudioAnalyser;
  89123. private _debugCanvas;
  89124. private _debugCanvasContext;
  89125. private _scene;
  89126. private _registerFunc;
  89127. private _audioEngine;
  89128. /**
  89129. * Creates a new analyser
  89130. * @param scene defines hosting scene
  89131. */
  89132. constructor(scene: Scene);
  89133. /**
  89134. * Get the number of data values you will have to play with for the visualization
  89135. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  89136. * @returns a number
  89137. */
  89138. getFrequencyBinCount(): number;
  89139. /**
  89140. * Gets the current frequency data as a byte array
  89141. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89142. * @returns a Uint8Array
  89143. */
  89144. getByteFrequencyData(): Uint8Array;
  89145. /**
  89146. * Gets the current waveform as a byte array
  89147. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  89148. * @returns a Uint8Array
  89149. */
  89150. getByteTimeDomainData(): Uint8Array;
  89151. /**
  89152. * Gets the current frequency data as a float array
  89153. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89154. * @returns a Float32Array
  89155. */
  89156. getFloatFrequencyData(): Float32Array;
  89157. /**
  89158. * Renders the debug canvas
  89159. */
  89160. drawDebugCanvas(): void;
  89161. /**
  89162. * Stops rendering the debug canvas and removes it
  89163. */
  89164. stopDebugCanvas(): void;
  89165. /**
  89166. * Connects two audio nodes
  89167. * @param inputAudioNode defines first node to connect
  89168. * @param outputAudioNode defines second node to connect
  89169. */
  89170. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  89171. /**
  89172. * Releases all associated resources
  89173. */
  89174. dispose(): void;
  89175. }
  89176. }
  89177. declare module BABYLON {
  89178. /**
  89179. * This represents an audio engine and it is responsible
  89180. * to play, synchronize and analyse sounds throughout the application.
  89181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89182. */
  89183. export interface IAudioEngine extends IDisposable {
  89184. /**
  89185. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89186. */
  89187. readonly canUseWebAudio: boolean;
  89188. /**
  89189. * Gets the current AudioContext if available.
  89190. */
  89191. readonly audioContext: Nullable<AudioContext>;
  89192. /**
  89193. * The master gain node defines the global audio volume of your audio engine.
  89194. */
  89195. readonly masterGain: GainNode;
  89196. /**
  89197. * Gets whether or not mp3 are supported by your browser.
  89198. */
  89199. readonly isMP3supported: boolean;
  89200. /**
  89201. * Gets whether or not ogg are supported by your browser.
  89202. */
  89203. readonly isOGGsupported: boolean;
  89204. /**
  89205. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89206. * @ignoreNaming
  89207. */
  89208. WarnedWebAudioUnsupported: boolean;
  89209. /**
  89210. * Defines if the audio engine relies on a custom unlocked button.
  89211. * In this case, the embedded button will not be displayed.
  89212. */
  89213. useCustomUnlockedButton: boolean;
  89214. /**
  89215. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  89216. */
  89217. readonly unlocked: boolean;
  89218. /**
  89219. * Event raised when audio has been unlocked on the browser.
  89220. */
  89221. onAudioUnlockedObservable: Observable<AudioEngine>;
  89222. /**
  89223. * Event raised when audio has been locked on the browser.
  89224. */
  89225. onAudioLockedObservable: Observable<AudioEngine>;
  89226. /**
  89227. * Flags the audio engine in Locked state.
  89228. * This happens due to new browser policies preventing audio to autoplay.
  89229. */
  89230. lock(): void;
  89231. /**
  89232. * Unlocks the audio engine once a user action has been done on the dom.
  89233. * This is helpful to resume play once browser policies have been satisfied.
  89234. */
  89235. unlock(): void;
  89236. }
  89237. /**
  89238. * This represents the default audio engine used in babylon.
  89239. * It is responsible to play, synchronize and analyse sounds throughout the application.
  89240. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89241. */
  89242. export class AudioEngine implements IAudioEngine {
  89243. private _audioContext;
  89244. private _audioContextInitialized;
  89245. private _muteButton;
  89246. private _hostElement;
  89247. /**
  89248. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89249. */
  89250. canUseWebAudio: boolean;
  89251. /**
  89252. * The master gain node defines the global audio volume of your audio engine.
  89253. */
  89254. masterGain: GainNode;
  89255. /**
  89256. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89257. * @ignoreNaming
  89258. */
  89259. WarnedWebAudioUnsupported: boolean;
  89260. /**
  89261. * Gets whether or not mp3 are supported by your browser.
  89262. */
  89263. isMP3supported: boolean;
  89264. /**
  89265. * Gets whether or not ogg are supported by your browser.
  89266. */
  89267. isOGGsupported: boolean;
  89268. /**
  89269. * Gets whether audio has been unlocked on the device.
  89270. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  89271. * a user interaction has happened.
  89272. */
  89273. unlocked: boolean;
  89274. /**
  89275. * Defines if the audio engine relies on a custom unlocked button.
  89276. * In this case, the embedded button will not be displayed.
  89277. */
  89278. useCustomUnlockedButton: boolean;
  89279. /**
  89280. * Event raised when audio has been unlocked on the browser.
  89281. */
  89282. onAudioUnlockedObservable: Observable<AudioEngine>;
  89283. /**
  89284. * Event raised when audio has been locked on the browser.
  89285. */
  89286. onAudioLockedObservable: Observable<AudioEngine>;
  89287. /**
  89288. * Gets the current AudioContext if available.
  89289. */
  89290. readonly audioContext: Nullable<AudioContext>;
  89291. private _connectedAnalyser;
  89292. /**
  89293. * Instantiates a new audio engine.
  89294. *
  89295. * There should be only one per page as some browsers restrict the number
  89296. * of audio contexts you can create.
  89297. * @param hostElement defines the host element where to display the mute icon if necessary
  89298. */
  89299. constructor(hostElement?: Nullable<HTMLElement>);
  89300. /**
  89301. * Flags the audio engine in Locked state.
  89302. * This happens due to new browser policies preventing audio to autoplay.
  89303. */
  89304. lock(): void;
  89305. /**
  89306. * Unlocks the audio engine once a user action has been done on the dom.
  89307. * This is helpful to resume play once browser policies have been satisfied.
  89308. */
  89309. unlock(): void;
  89310. private _resumeAudioContext;
  89311. private _initializeAudioContext;
  89312. private _tryToRun;
  89313. private _triggerRunningState;
  89314. private _triggerSuspendedState;
  89315. private _displayMuteButton;
  89316. private _moveButtonToTopLeft;
  89317. private _onResize;
  89318. private _hideMuteButton;
  89319. /**
  89320. * Destroy and release the resources associated with the audio ccontext.
  89321. */
  89322. dispose(): void;
  89323. /**
  89324. * Gets the global volume sets on the master gain.
  89325. * @returns the global volume if set or -1 otherwise
  89326. */
  89327. getGlobalVolume(): number;
  89328. /**
  89329. * Sets the global volume of your experience (sets on the master gain).
  89330. * @param newVolume Defines the new global volume of the application
  89331. */
  89332. setGlobalVolume(newVolume: number): void;
  89333. /**
  89334. * Connect the audio engine to an audio analyser allowing some amazing
  89335. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  89336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  89337. * @param analyser The analyser to connect to the engine
  89338. */
  89339. connectToAnalyser(analyser: Analyser): void;
  89340. }
  89341. }
  89342. declare module BABYLON {
  89343. /**
  89344. * Interface used to present a loading screen while loading a scene
  89345. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89346. */
  89347. export interface ILoadingScreen {
  89348. /**
  89349. * Function called to display the loading screen
  89350. */
  89351. displayLoadingUI: () => void;
  89352. /**
  89353. * Function called to hide the loading screen
  89354. */
  89355. hideLoadingUI: () => void;
  89356. /**
  89357. * Gets or sets the color to use for the background
  89358. */
  89359. loadingUIBackgroundColor: string;
  89360. /**
  89361. * Gets or sets the text to display while loading
  89362. */
  89363. loadingUIText: string;
  89364. }
  89365. /**
  89366. * Class used for the default loading screen
  89367. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89368. */
  89369. export class DefaultLoadingScreen implements ILoadingScreen {
  89370. private _renderingCanvas;
  89371. private _loadingText;
  89372. private _loadingDivBackgroundColor;
  89373. private _loadingDiv;
  89374. private _loadingTextDiv;
  89375. /** Gets or sets the logo url to use for the default loading screen */
  89376. static DefaultLogoUrl: string;
  89377. /** Gets or sets the spinner url to use for the default loading screen */
  89378. static DefaultSpinnerUrl: string;
  89379. /**
  89380. * Creates a new default loading screen
  89381. * @param _renderingCanvas defines the canvas used to render the scene
  89382. * @param _loadingText defines the default text to display
  89383. * @param _loadingDivBackgroundColor defines the default background color
  89384. */
  89385. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  89386. /**
  89387. * Function called to display the loading screen
  89388. */
  89389. displayLoadingUI(): void;
  89390. /**
  89391. * Function called to hide the loading screen
  89392. */
  89393. hideLoadingUI(): void;
  89394. /**
  89395. * Gets or sets the text to display while loading
  89396. */
  89397. loadingUIText: string;
  89398. /**
  89399. * Gets or sets the color to use for the background
  89400. */
  89401. loadingUIBackgroundColor: string;
  89402. private _resizeLoadingUI;
  89403. }
  89404. }
  89405. declare module BABYLON {
  89406. /** @hidden */
  89407. export class WebGLPipelineContext implements IPipelineContext {
  89408. engine: Engine;
  89409. program: Nullable<WebGLProgram>;
  89410. context?: WebGLRenderingContext;
  89411. vertexShader?: WebGLShader;
  89412. fragmentShader?: WebGLShader;
  89413. isParallelCompiled: boolean;
  89414. onCompiled?: () => void;
  89415. transformFeedback?: WebGLTransformFeedback | null;
  89416. readonly isAsync: boolean;
  89417. readonly isReady: boolean;
  89418. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  89419. }
  89420. }
  89421. declare module BABYLON {
  89422. /** @hidden */
  89423. export class WebGLDataBuffer extends DataBuffer {
  89424. private _buffer;
  89425. constructor(resource: WebGLBuffer);
  89426. readonly underlyingResource: any;
  89427. }
  89428. }
  89429. declare module BABYLON {
  89430. /** @hidden */
  89431. export class WebGL2ShaderProcessor implements IShaderProcessor {
  89432. attributeProcessor(attribute: string): string;
  89433. varyingProcessor(varying: string, isFragment: boolean): string;
  89434. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  89435. }
  89436. }
  89437. declare module BABYLON {
  89438. /**
  89439. * Settings for finer control over video usage
  89440. */
  89441. export interface VideoTextureSettings {
  89442. /**
  89443. * Applies `autoplay` to video, if specified
  89444. */
  89445. autoPlay?: boolean;
  89446. /**
  89447. * Applies `loop` to video, if specified
  89448. */
  89449. loop?: boolean;
  89450. /**
  89451. * Automatically updates internal texture from video at every frame in the render loop
  89452. */
  89453. autoUpdateTexture: boolean;
  89454. /**
  89455. * Image src displayed during the video loading or until the user interacts with the video.
  89456. */
  89457. poster?: string;
  89458. }
  89459. /**
  89460. * If you want to display a video in your scene, this is the special texture for that.
  89461. * This special texture works similar to other textures, with the exception of a few parameters.
  89462. * @see https://doc.babylonjs.com/how_to/video_texture
  89463. */
  89464. export class VideoTexture extends Texture {
  89465. /**
  89466. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  89467. */
  89468. readonly autoUpdateTexture: boolean;
  89469. /**
  89470. * The video instance used by the texture internally
  89471. */
  89472. readonly video: HTMLVideoElement;
  89473. private _onUserActionRequestedObservable;
  89474. /**
  89475. * Event triggerd when a dom action is required by the user to play the video.
  89476. * This happens due to recent changes in browser policies preventing video to auto start.
  89477. */
  89478. readonly onUserActionRequestedObservable: Observable<Texture>;
  89479. private _generateMipMaps;
  89480. private _engine;
  89481. private _stillImageCaptured;
  89482. private _displayingPosterTexture;
  89483. private _settings;
  89484. private _createInternalTextureOnEvent;
  89485. /**
  89486. * Creates a video texture.
  89487. * If you want to display a video in your scene, this is the special texture for that.
  89488. * This special texture works similar to other textures, with the exception of a few parameters.
  89489. * @see https://doc.babylonjs.com/how_to/video_texture
  89490. * @param name optional name, will detect from video source, if not defined
  89491. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  89492. * @param scene is obviously the current scene.
  89493. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  89494. * @param invertY is false by default but can be used to invert video on Y axis
  89495. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  89496. * @param settings allows finer control over video usage
  89497. */
  89498. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  89499. private _getName;
  89500. private _getVideo;
  89501. private _createInternalTexture;
  89502. private reset;
  89503. /**
  89504. * @hidden Internal method to initiate `update`.
  89505. */
  89506. _rebuild(): void;
  89507. /**
  89508. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  89509. */
  89510. update(): void;
  89511. /**
  89512. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  89513. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  89514. */
  89515. updateTexture(isVisible: boolean): void;
  89516. protected _updateInternalTexture: () => void;
  89517. /**
  89518. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  89519. * @param url New url.
  89520. */
  89521. updateURL(url: string): void;
  89522. /**
  89523. * Dispose the texture and release its associated resources.
  89524. */
  89525. dispose(): void;
  89526. /**
  89527. * Creates a video texture straight from a stream.
  89528. * @param scene Define the scene the texture should be created in
  89529. * @param stream Define the stream the texture should be created from
  89530. * @returns The created video texture as a promise
  89531. */
  89532. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  89533. /**
  89534. * Creates a video texture straight from your WebCam video feed.
  89535. * @param scene Define the scene the texture should be created in
  89536. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89537. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89538. * @returns The created video texture as a promise
  89539. */
  89540. static CreateFromWebCamAsync(scene: Scene, constraints: {
  89541. minWidth: number;
  89542. maxWidth: number;
  89543. minHeight: number;
  89544. maxHeight: number;
  89545. deviceId: string;
  89546. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  89547. /**
  89548. * Creates a video texture straight from your WebCam video feed.
  89549. * @param scene Define the scene the texture should be created in
  89550. * @param onReady Define a callback to triggered once the texture will be ready
  89551. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89552. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89553. */
  89554. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  89555. minWidth: number;
  89556. maxWidth: number;
  89557. minHeight: number;
  89558. maxHeight: number;
  89559. deviceId: string;
  89560. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  89561. }
  89562. }
  89563. declare module BABYLON {
  89564. /**
  89565. * Interface for attribute information associated with buffer instanciation
  89566. */
  89567. export class InstancingAttributeInfo {
  89568. /**
  89569. * Index/offset of the attribute in the vertex shader
  89570. */
  89571. index: number;
  89572. /**
  89573. * size of the attribute, 1, 2, 3 or 4
  89574. */
  89575. attributeSize: number;
  89576. /**
  89577. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  89578. * default is FLOAT
  89579. */
  89580. attribyteType: number;
  89581. /**
  89582. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  89583. */
  89584. normalized: boolean;
  89585. /**
  89586. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  89587. */
  89588. offset: number;
  89589. /**
  89590. * Name of the GLSL attribute, for debugging purpose only
  89591. */
  89592. attributeName: string;
  89593. }
  89594. /**
  89595. * Define options used to create a depth texture
  89596. */
  89597. export class DepthTextureCreationOptions {
  89598. /** Specifies whether or not a stencil should be allocated in the texture */
  89599. generateStencil?: boolean;
  89600. /** Specifies whether or not bilinear filtering is enable on the texture */
  89601. bilinearFiltering?: boolean;
  89602. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  89603. comparisonFunction?: number;
  89604. /** Specifies if the created texture is a cube texture */
  89605. isCube?: boolean;
  89606. }
  89607. /**
  89608. * Class used to describe the capabilities of the engine relatively to the current browser
  89609. */
  89610. export class EngineCapabilities {
  89611. /** Maximum textures units per fragment shader */
  89612. maxTexturesImageUnits: number;
  89613. /** Maximum texture units per vertex shader */
  89614. maxVertexTextureImageUnits: number;
  89615. /** Maximum textures units in the entire pipeline */
  89616. maxCombinedTexturesImageUnits: number;
  89617. /** Maximum texture size */
  89618. maxTextureSize: number;
  89619. /** Maximum cube texture size */
  89620. maxCubemapTextureSize: number;
  89621. /** Maximum render texture size */
  89622. maxRenderTextureSize: number;
  89623. /** Maximum number of vertex attributes */
  89624. maxVertexAttribs: number;
  89625. /** Maximum number of varyings */
  89626. maxVaryingVectors: number;
  89627. /** Maximum number of uniforms per vertex shader */
  89628. maxVertexUniformVectors: number;
  89629. /** Maximum number of uniforms per fragment shader */
  89630. maxFragmentUniformVectors: number;
  89631. /** Defines if standard derivates (dx/dy) are supported */
  89632. standardDerivatives: boolean;
  89633. /** Defines if s3tc texture compression is supported */
  89634. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  89635. /** Defines if pvrtc texture compression is supported */
  89636. pvrtc: any;
  89637. /** Defines if etc1 texture compression is supported */
  89638. etc1: any;
  89639. /** Defines if etc2 texture compression is supported */
  89640. etc2: any;
  89641. /** Defines if astc texture compression is supported */
  89642. astc: any;
  89643. /** Defines if float textures are supported */
  89644. textureFloat: boolean;
  89645. /** Defines if vertex array objects are supported */
  89646. vertexArrayObject: boolean;
  89647. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  89648. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  89649. /** Gets the maximum level of anisotropy supported */
  89650. maxAnisotropy: number;
  89651. /** Defines if instancing is supported */
  89652. instancedArrays: boolean;
  89653. /** Defines if 32 bits indices are supported */
  89654. uintIndices: boolean;
  89655. /** Defines if high precision shaders are supported */
  89656. highPrecisionShaderSupported: boolean;
  89657. /** Defines if depth reading in the fragment shader is supported */
  89658. fragmentDepthSupported: boolean;
  89659. /** Defines if float texture linear filtering is supported*/
  89660. textureFloatLinearFiltering: boolean;
  89661. /** Defines if rendering to float textures is supported */
  89662. textureFloatRender: boolean;
  89663. /** Defines if half float textures are supported*/
  89664. textureHalfFloat: boolean;
  89665. /** Defines if half float texture linear filtering is supported*/
  89666. textureHalfFloatLinearFiltering: boolean;
  89667. /** Defines if rendering to half float textures is supported */
  89668. textureHalfFloatRender: boolean;
  89669. /** Defines if textureLOD shader command is supported */
  89670. textureLOD: boolean;
  89671. /** Defines if draw buffers extension is supported */
  89672. drawBuffersExtension: boolean;
  89673. /** Defines if depth textures are supported */
  89674. depthTextureExtension: boolean;
  89675. /** Defines if float color buffer are supported */
  89676. colorBufferFloat: boolean;
  89677. /** Gets disjoint timer query extension (null if not supported) */
  89678. timerQuery: EXT_disjoint_timer_query;
  89679. /** Defines if timestamp can be used with timer query */
  89680. canUseTimestampForTimerQuery: boolean;
  89681. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  89682. multiview: any;
  89683. /** Function used to let the system compiles shaders in background */
  89684. parallelShaderCompile: {
  89685. COMPLETION_STATUS_KHR: number;
  89686. };
  89687. }
  89688. /** Interface defining initialization parameters for Engine class */
  89689. export interface EngineOptions extends WebGLContextAttributes {
  89690. /**
  89691. * Defines if the engine should no exceed a specified device ratio
  89692. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  89693. */
  89694. limitDeviceRatio?: number;
  89695. /**
  89696. * Defines if webvr should be enabled automatically
  89697. * @see http://doc.babylonjs.com/how_to/webvr_camera
  89698. */
  89699. autoEnableWebVR?: boolean;
  89700. /**
  89701. * Defines if webgl2 should be turned off even if supported
  89702. * @see http://doc.babylonjs.com/features/webgl2
  89703. */
  89704. disableWebGL2Support?: boolean;
  89705. /**
  89706. * Defines if webaudio should be initialized as well
  89707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89708. */
  89709. audioEngine?: boolean;
  89710. /**
  89711. * Defines if animations should run using a deterministic lock step
  89712. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89713. */
  89714. deterministicLockstep?: boolean;
  89715. /** Defines the maximum steps to use with deterministic lock step mode */
  89716. lockstepMaxSteps?: number;
  89717. /**
  89718. * Defines that engine should ignore context lost events
  89719. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  89720. */
  89721. doNotHandleContextLost?: boolean;
  89722. /**
  89723. * Defines that engine should ignore modifying touch action attribute and style
  89724. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  89725. */
  89726. doNotHandleTouchAction?: boolean;
  89727. /**
  89728. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  89729. */
  89730. useHighPrecisionFloats?: boolean;
  89731. }
  89732. /**
  89733. * Defines the interface used by display changed events
  89734. */
  89735. export interface IDisplayChangedEventArgs {
  89736. /** Gets the vrDisplay object (if any) */
  89737. vrDisplay: Nullable<any>;
  89738. /** Gets a boolean indicating if webVR is supported */
  89739. vrSupported: boolean;
  89740. }
  89741. /**
  89742. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  89743. */
  89744. export class Engine {
  89745. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  89746. static ExceptionList: ({
  89747. key: string;
  89748. capture: string;
  89749. captureConstraint: number;
  89750. targets: string[];
  89751. } | {
  89752. key: string;
  89753. capture: null;
  89754. captureConstraint: null;
  89755. targets: string[];
  89756. })[];
  89757. /** Gets the list of created engines */
  89758. static readonly Instances: Engine[];
  89759. /**
  89760. * Gets the latest created engine
  89761. */
  89762. static readonly LastCreatedEngine: Nullable<Engine>;
  89763. /**
  89764. * Gets the latest created scene
  89765. */
  89766. static readonly LastCreatedScene: Nullable<Scene>;
  89767. /**
  89768. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  89769. * @param flag defines which part of the materials must be marked as dirty
  89770. * @param predicate defines a predicate used to filter which materials should be affected
  89771. */
  89772. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  89773. /** @hidden */
  89774. static _TextureLoaders: IInternalTextureLoader[];
  89775. /** Defines that alpha blending is disabled */
  89776. static readonly ALPHA_DISABLE: number;
  89777. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  89778. static readonly ALPHA_ADD: number;
  89779. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  89780. static readonly ALPHA_COMBINE: number;
  89781. /** Defines that alpha blending to DEST - SRC * DEST */
  89782. static readonly ALPHA_SUBTRACT: number;
  89783. /** Defines that alpha blending to SRC * DEST */
  89784. static readonly ALPHA_MULTIPLY: number;
  89785. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  89786. static readonly ALPHA_MAXIMIZED: number;
  89787. /** Defines that alpha blending to SRC + DEST */
  89788. static readonly ALPHA_ONEONE: number;
  89789. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  89790. static readonly ALPHA_PREMULTIPLIED: number;
  89791. /**
  89792. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  89793. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  89794. */
  89795. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  89796. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  89797. static readonly ALPHA_INTERPOLATE: number;
  89798. /**
  89799. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  89800. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  89801. */
  89802. static readonly ALPHA_SCREENMODE: number;
  89803. /** Defines that the ressource is not delayed*/
  89804. static readonly DELAYLOADSTATE_NONE: number;
  89805. /** Defines that the ressource was successfully delay loaded */
  89806. static readonly DELAYLOADSTATE_LOADED: number;
  89807. /** Defines that the ressource is currently delay loading */
  89808. static readonly DELAYLOADSTATE_LOADING: number;
  89809. /** Defines that the ressource is delayed and has not started loading */
  89810. static readonly DELAYLOADSTATE_NOTLOADED: number;
  89811. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  89812. static readonly NEVER: number;
  89813. /** 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 */
  89814. static readonly ALWAYS: number;
  89815. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  89816. static readonly LESS: number;
  89817. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  89818. static readonly EQUAL: number;
  89819. /** 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 */
  89820. static readonly LEQUAL: number;
  89821. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  89822. static readonly GREATER: number;
  89823. /** 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 */
  89824. static readonly GEQUAL: number;
  89825. /** 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 */
  89826. static readonly NOTEQUAL: number;
  89827. /** Passed to stencilOperation to specify that stencil value must be kept */
  89828. static readonly KEEP: number;
  89829. /** Passed to stencilOperation to specify that stencil value must be replaced */
  89830. static readonly REPLACE: number;
  89831. /** Passed to stencilOperation to specify that stencil value must be incremented */
  89832. static readonly INCR: number;
  89833. /** Passed to stencilOperation to specify that stencil value must be decremented */
  89834. static readonly DECR: number;
  89835. /** Passed to stencilOperation to specify that stencil value must be inverted */
  89836. static readonly INVERT: number;
  89837. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  89838. static readonly INCR_WRAP: number;
  89839. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  89840. static readonly DECR_WRAP: number;
  89841. /** Texture is not repeating outside of 0..1 UVs */
  89842. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  89843. /** Texture is repeating outside of 0..1 UVs */
  89844. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  89845. /** Texture is repeating and mirrored */
  89846. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  89847. /** ALPHA */
  89848. static readonly TEXTUREFORMAT_ALPHA: number;
  89849. /** LUMINANCE */
  89850. static readonly TEXTUREFORMAT_LUMINANCE: number;
  89851. /** LUMINANCE_ALPHA */
  89852. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  89853. /** RGB */
  89854. static readonly TEXTUREFORMAT_RGB: number;
  89855. /** RGBA */
  89856. static readonly TEXTUREFORMAT_RGBA: number;
  89857. /** RED */
  89858. static readonly TEXTUREFORMAT_RED: number;
  89859. /** RED (2nd reference) */
  89860. static readonly TEXTUREFORMAT_R: number;
  89861. /** RG */
  89862. static readonly TEXTUREFORMAT_RG: number;
  89863. /** RED_INTEGER */
  89864. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  89865. /** RED_INTEGER (2nd reference) */
  89866. static readonly TEXTUREFORMAT_R_INTEGER: number;
  89867. /** RG_INTEGER */
  89868. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  89869. /** RGB_INTEGER */
  89870. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  89871. /** RGBA_INTEGER */
  89872. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  89873. /** UNSIGNED_BYTE */
  89874. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  89875. /** UNSIGNED_BYTE (2nd reference) */
  89876. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  89877. /** FLOAT */
  89878. static readonly TEXTURETYPE_FLOAT: number;
  89879. /** HALF_FLOAT */
  89880. static readonly TEXTURETYPE_HALF_FLOAT: number;
  89881. /** BYTE */
  89882. static readonly TEXTURETYPE_BYTE: number;
  89883. /** SHORT */
  89884. static readonly TEXTURETYPE_SHORT: number;
  89885. /** UNSIGNED_SHORT */
  89886. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  89887. /** INT */
  89888. static readonly TEXTURETYPE_INT: number;
  89889. /** UNSIGNED_INT */
  89890. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  89891. /** UNSIGNED_SHORT_4_4_4_4 */
  89892. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  89893. /** UNSIGNED_SHORT_5_5_5_1 */
  89894. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  89895. /** UNSIGNED_SHORT_5_6_5 */
  89896. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  89897. /** UNSIGNED_INT_2_10_10_10_REV */
  89898. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  89899. /** UNSIGNED_INT_24_8 */
  89900. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  89901. /** UNSIGNED_INT_10F_11F_11F_REV */
  89902. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  89903. /** UNSIGNED_INT_5_9_9_9_REV */
  89904. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  89905. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  89906. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  89907. /** nearest is mag = nearest and min = nearest and mip = linear */
  89908. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  89909. /** Bilinear is mag = linear and min = linear and mip = nearest */
  89910. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  89911. /** Trilinear is mag = linear and min = linear and mip = linear */
  89912. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  89913. /** nearest is mag = nearest and min = nearest and mip = linear */
  89914. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  89915. /** Bilinear is mag = linear and min = linear and mip = nearest */
  89916. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  89917. /** Trilinear is mag = linear and min = linear and mip = linear */
  89918. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  89919. /** mag = nearest and min = nearest and mip = nearest */
  89920. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  89921. /** mag = nearest and min = linear and mip = nearest */
  89922. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  89923. /** mag = nearest and min = linear and mip = linear */
  89924. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  89925. /** mag = nearest and min = linear and mip = none */
  89926. static readonly TEXTURE_NEAREST_LINEAR: number;
  89927. /** mag = nearest and min = nearest and mip = none */
  89928. static readonly TEXTURE_NEAREST_NEAREST: number;
  89929. /** mag = linear and min = nearest and mip = nearest */
  89930. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  89931. /** mag = linear and min = nearest and mip = linear */
  89932. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  89933. /** mag = linear and min = linear and mip = none */
  89934. static readonly TEXTURE_LINEAR_LINEAR: number;
  89935. /** mag = linear and min = nearest and mip = none */
  89936. static readonly TEXTURE_LINEAR_NEAREST: number;
  89937. /** Explicit coordinates mode */
  89938. static readonly TEXTURE_EXPLICIT_MODE: number;
  89939. /** Spherical coordinates mode */
  89940. static readonly TEXTURE_SPHERICAL_MODE: number;
  89941. /** Planar coordinates mode */
  89942. static readonly TEXTURE_PLANAR_MODE: number;
  89943. /** Cubic coordinates mode */
  89944. static readonly TEXTURE_CUBIC_MODE: number;
  89945. /** Projection coordinates mode */
  89946. static readonly TEXTURE_PROJECTION_MODE: number;
  89947. /** Skybox coordinates mode */
  89948. static readonly TEXTURE_SKYBOX_MODE: number;
  89949. /** Inverse Cubic coordinates mode */
  89950. static readonly TEXTURE_INVCUBIC_MODE: number;
  89951. /** Equirectangular coordinates mode */
  89952. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  89953. /** Equirectangular Fixed coordinates mode */
  89954. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  89955. /** Equirectangular Fixed Mirrored coordinates mode */
  89956. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  89957. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  89958. static readonly SCALEMODE_FLOOR: number;
  89959. /** Defines that texture rescaling will look for the nearest power of 2 size */
  89960. static readonly SCALEMODE_NEAREST: number;
  89961. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  89962. static readonly SCALEMODE_CEILING: number;
  89963. /**
  89964. * Returns the current npm package of the sdk
  89965. */
  89966. static readonly NpmPackage: string;
  89967. /**
  89968. * Returns the current version of the framework
  89969. */
  89970. static readonly Version: string;
  89971. /**
  89972. * Returns a string describing the current engine
  89973. */
  89974. readonly description: string;
  89975. /**
  89976. * Gets or sets the epsilon value used by collision engine
  89977. */
  89978. static CollisionsEpsilon: number;
  89979. /**
  89980. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  89981. */
  89982. static ShadersRepository: string;
  89983. /**
  89984. * Method called to create the default loading screen.
  89985. * This can be overriden in your own app.
  89986. * @param canvas The rendering canvas element
  89987. * @returns The loading screen
  89988. */
  89989. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  89990. /**
  89991. * Method called to create the default rescale post process on each engine.
  89992. */
  89993. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  89994. /** @hidden */
  89995. _shaderProcessor: IShaderProcessor;
  89996. /**
  89997. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  89998. */
  89999. forcePOTTextures: boolean;
  90000. /**
  90001. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  90002. */
  90003. isFullscreen: boolean;
  90004. /**
  90005. * Gets a boolean indicating if the pointer is currently locked
  90006. */
  90007. isPointerLock: boolean;
  90008. /**
  90009. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  90010. */
  90011. cullBackFaces: boolean;
  90012. /**
  90013. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  90014. */
  90015. renderEvenInBackground: boolean;
  90016. /**
  90017. * Gets or sets a boolean indicating that cache can be kept between frames
  90018. */
  90019. preventCacheWipeBetweenFrames: boolean;
  90020. /**
  90021. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  90022. **/
  90023. enableOfflineSupport: boolean;
  90024. /**
  90025. * 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)
  90026. **/
  90027. disableManifestCheck: boolean;
  90028. /**
  90029. * Gets the list of created scenes
  90030. */
  90031. scenes: Scene[];
  90032. /**
  90033. * Event raised when a new scene is created
  90034. */
  90035. onNewSceneAddedObservable: Observable<Scene>;
  90036. /**
  90037. * Gets the list of created postprocesses
  90038. */
  90039. postProcesses: PostProcess[];
  90040. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  90041. validateShaderPrograms: boolean;
  90042. /**
  90043. * Observable event triggered each time the rendering canvas is resized
  90044. */
  90045. onResizeObservable: Observable<Engine>;
  90046. /**
  90047. * Observable event triggered each time the canvas loses focus
  90048. */
  90049. onCanvasBlurObservable: Observable<Engine>;
  90050. /**
  90051. * Observable event triggered each time the canvas gains focus
  90052. */
  90053. onCanvasFocusObservable: Observable<Engine>;
  90054. /**
  90055. * Observable event triggered each time the canvas receives pointerout event
  90056. */
  90057. onCanvasPointerOutObservable: Observable<PointerEvent>;
  90058. /**
  90059. * Observable event triggered before each texture is initialized
  90060. */
  90061. onBeforeTextureInitObservable: Observable<Texture>;
  90062. /**
  90063. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  90064. */
  90065. disableUniformBuffers: boolean;
  90066. /** @hidden */
  90067. _uniformBuffers: UniformBuffer[];
  90068. /**
  90069. * Gets a boolean indicating that the engine supports uniform buffers
  90070. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90071. */
  90072. readonly supportsUniformBuffers: boolean;
  90073. /**
  90074. * Observable raised when the engine begins a new frame
  90075. */
  90076. onBeginFrameObservable: Observable<Engine>;
  90077. /**
  90078. * If set, will be used to request the next animation frame for the render loop
  90079. */
  90080. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  90081. /**
  90082. * Observable raised when the engine ends the current frame
  90083. */
  90084. onEndFrameObservable: Observable<Engine>;
  90085. /**
  90086. * Observable raised when the engine is about to compile a shader
  90087. */
  90088. onBeforeShaderCompilationObservable: Observable<Engine>;
  90089. /**
  90090. * Observable raised when the engine has jsut compiled a shader
  90091. */
  90092. onAfterShaderCompilationObservable: Observable<Engine>;
  90093. /** @hidden */
  90094. _gl: WebGLRenderingContext;
  90095. private _renderingCanvas;
  90096. private _windowIsBackground;
  90097. private _webGLVersion;
  90098. protected _highPrecisionShadersAllowed: boolean;
  90099. /** @hidden */
  90100. readonly _shouldUseHighPrecisionShader: boolean;
  90101. /**
  90102. * Gets a boolean indicating that only power of 2 textures are supported
  90103. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  90104. */
  90105. readonly needPOTTextures: boolean;
  90106. /** @hidden */
  90107. _badOS: boolean;
  90108. /** @hidden */
  90109. _badDesktopOS: boolean;
  90110. /**
  90111. * Gets the audio engine
  90112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90113. * @ignorenaming
  90114. */
  90115. static audioEngine: IAudioEngine;
  90116. /**
  90117. * Default AudioEngine factory responsible of creating the Audio Engine.
  90118. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  90119. */
  90120. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  90121. /**
  90122. * Default offline support factory responsible of creating a tool used to store data locally.
  90123. * By default, this will create a Database object if the workload has been embedded.
  90124. */
  90125. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  90126. private _onFocus;
  90127. private _onBlur;
  90128. private _onCanvasPointerOut;
  90129. private _onCanvasBlur;
  90130. private _onCanvasFocus;
  90131. private _onFullscreenChange;
  90132. private _onPointerLockChange;
  90133. private _hardwareScalingLevel;
  90134. /** @hidden */
  90135. _caps: EngineCapabilities;
  90136. private _pointerLockRequested;
  90137. private _isStencilEnable;
  90138. private _colorWrite;
  90139. private _loadingScreen;
  90140. /** @hidden */
  90141. _drawCalls: PerfCounter;
  90142. private _glVersion;
  90143. private _glRenderer;
  90144. private _glVendor;
  90145. private _videoTextureSupported;
  90146. private _renderingQueueLaunched;
  90147. private _activeRenderLoops;
  90148. private _deterministicLockstep;
  90149. private _lockstepMaxSteps;
  90150. /**
  90151. * Observable signaled when a context lost event is raised
  90152. */
  90153. onContextLostObservable: Observable<Engine>;
  90154. /**
  90155. * Observable signaled when a context restored event is raised
  90156. */
  90157. onContextRestoredObservable: Observable<Engine>;
  90158. private _onContextLost;
  90159. private _onContextRestored;
  90160. private _contextWasLost;
  90161. /** @hidden */
  90162. _doNotHandleContextLost: boolean;
  90163. /**
  90164. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  90165. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  90166. */
  90167. doNotHandleContextLost: boolean;
  90168. private _performanceMonitor;
  90169. private _fps;
  90170. private _deltaTime;
  90171. /**
  90172. * Turn this value on if you want to pause FPS computation when in background
  90173. */
  90174. disablePerformanceMonitorInBackground: boolean;
  90175. /**
  90176. * Gets the performance monitor attached to this engine
  90177. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  90178. */
  90179. readonly performanceMonitor: PerformanceMonitor;
  90180. /**
  90181. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  90182. */
  90183. disableVertexArrayObjects: boolean;
  90184. /** @hidden */
  90185. protected _depthCullingState: _DepthCullingState;
  90186. /** @hidden */
  90187. protected _stencilState: _StencilState;
  90188. /** @hidden */
  90189. protected _alphaState: _AlphaState;
  90190. /** @hidden */
  90191. protected _alphaMode: number;
  90192. /** @hidden */
  90193. _internalTexturesCache: InternalTexture[];
  90194. /** @hidden */
  90195. protected _activeChannel: number;
  90196. private _currentTextureChannel;
  90197. /** @hidden */
  90198. protected _boundTexturesCache: {
  90199. [key: string]: Nullable<InternalTexture>;
  90200. };
  90201. /** @hidden */
  90202. protected _currentEffect: Nullable<Effect>;
  90203. /** @hidden */
  90204. protected _currentProgram: Nullable<WebGLProgram>;
  90205. private _compiledEffects;
  90206. private _vertexAttribArraysEnabled;
  90207. /** @hidden */
  90208. protected _cachedViewport: Nullable<Viewport>;
  90209. private _cachedVertexArrayObject;
  90210. /** @hidden */
  90211. protected _cachedVertexBuffers: any;
  90212. /** @hidden */
  90213. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  90214. /** @hidden */
  90215. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  90216. /** @hidden */
  90217. _currentRenderTarget: Nullable<InternalTexture>;
  90218. private _uintIndicesCurrentlySet;
  90219. private _currentBoundBuffer;
  90220. /** @hidden */
  90221. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  90222. private _currentBufferPointers;
  90223. private _currentInstanceLocations;
  90224. private _currentInstanceBuffers;
  90225. private _textureUnits;
  90226. /** @hidden */
  90227. _workingCanvas: Nullable<HTMLCanvasElement>;
  90228. /** @hidden */
  90229. _workingContext: Nullable<CanvasRenderingContext2D>;
  90230. private _rescalePostProcess;
  90231. private _dummyFramebuffer;
  90232. private _externalData;
  90233. /** @hidden */
  90234. _bindedRenderFunction: any;
  90235. private _vaoRecordInProgress;
  90236. private _mustWipeVertexAttributes;
  90237. private _emptyTexture;
  90238. private _emptyCubeTexture;
  90239. private _emptyTexture3D;
  90240. /** @hidden */
  90241. _frameHandler: number;
  90242. private _nextFreeTextureSlots;
  90243. private _maxSimultaneousTextures;
  90244. private _activeRequests;
  90245. private _texturesSupported;
  90246. /** @hidden */
  90247. _textureFormatInUse: Nullable<string>;
  90248. /**
  90249. * Gets the list of texture formats supported
  90250. */
  90251. readonly texturesSupported: Array<string>;
  90252. /**
  90253. * Gets the list of texture formats in use
  90254. */
  90255. readonly textureFormatInUse: Nullable<string>;
  90256. /**
  90257. * Gets the current viewport
  90258. */
  90259. readonly currentViewport: Nullable<Viewport>;
  90260. /**
  90261. * Gets the default empty texture
  90262. */
  90263. readonly emptyTexture: InternalTexture;
  90264. /**
  90265. * Gets the default empty 3D texture
  90266. */
  90267. readonly emptyTexture3D: InternalTexture;
  90268. /**
  90269. * Gets the default empty cube texture
  90270. */
  90271. readonly emptyCubeTexture: InternalTexture;
  90272. /**
  90273. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  90274. */
  90275. readonly premultipliedAlpha: boolean;
  90276. /**
  90277. * Creates a new engine
  90278. * @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
  90279. * @param antialias defines enable antialiasing (default: false)
  90280. * @param options defines further options to be sent to the getContext() function
  90281. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  90282. */
  90283. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  90284. /**
  90285. * Initializes a webVR display and starts listening to display change events
  90286. * The onVRDisplayChangedObservable will be notified upon these changes
  90287. * @returns The onVRDisplayChangedObservable
  90288. */
  90289. initWebVR(): Observable<IDisplayChangedEventArgs>;
  90290. /** @hidden */
  90291. _prepareVRComponent(): void;
  90292. /** @hidden */
  90293. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  90294. /** @hidden */
  90295. _submitVRFrame(): void;
  90296. /**
  90297. * Call this function to leave webVR mode
  90298. * Will do nothing if webVR is not supported or if there is no webVR device
  90299. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90300. */
  90301. disableVR(): void;
  90302. /**
  90303. * Gets a boolean indicating that the system is in VR mode and is presenting
  90304. * @returns true if VR mode is engaged
  90305. */
  90306. isVRPresenting(): boolean;
  90307. /** @hidden */
  90308. _requestVRFrame(): void;
  90309. private _disableTouchAction;
  90310. private _rebuildInternalTextures;
  90311. private _rebuildEffects;
  90312. /**
  90313. * Gets a boolean indicating if all created effects are ready
  90314. * @returns true if all effects are ready
  90315. */
  90316. areAllEffectsReady(): boolean;
  90317. private _rebuildBuffers;
  90318. private _initGLContext;
  90319. /**
  90320. * Gets version of the current webGL context
  90321. */
  90322. readonly webGLVersion: number;
  90323. /**
  90324. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  90325. */
  90326. readonly isStencilEnable: boolean;
  90327. /** @hidden */
  90328. _prepareWorkingCanvas(): void;
  90329. /**
  90330. * Reset the texture cache to empty state
  90331. */
  90332. resetTextureCache(): void;
  90333. /**
  90334. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  90335. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90336. * @returns true if engine is in deterministic lock step mode
  90337. */
  90338. isDeterministicLockStep(): boolean;
  90339. /**
  90340. * Gets the max steps when engine is running in deterministic lock step
  90341. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90342. * @returns the max steps
  90343. */
  90344. getLockstepMaxSteps(): number;
  90345. /**
  90346. * Gets an object containing information about the current webGL context
  90347. * @returns an object containing the vender, the renderer and the version of the current webGL context
  90348. */
  90349. getGlInfo(): {
  90350. vendor: string;
  90351. renderer: string;
  90352. version: string;
  90353. };
  90354. /**
  90355. * Gets current aspect ratio
  90356. * @param camera defines the camera to use to get the aspect ratio
  90357. * @param useScreen defines if screen size must be used (or the current render target if any)
  90358. * @returns a number defining the aspect ratio
  90359. */
  90360. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  90361. /**
  90362. * Gets current screen aspect ratio
  90363. * @returns a number defining the aspect ratio
  90364. */
  90365. getScreenAspectRatio(): number;
  90366. /**
  90367. * Gets the current render width
  90368. * @param useScreen defines if screen size must be used (or the current render target if any)
  90369. * @returns a number defining the current render width
  90370. */
  90371. getRenderWidth(useScreen?: boolean): number;
  90372. /**
  90373. * Gets the current render height
  90374. * @param useScreen defines if screen size must be used (or the current render target if any)
  90375. * @returns a number defining the current render height
  90376. */
  90377. getRenderHeight(useScreen?: boolean): number;
  90378. /**
  90379. * Gets the HTML canvas attached with the current webGL context
  90380. * @returns a HTML canvas
  90381. */
  90382. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  90383. /**
  90384. * Gets the client rect of the HTML canvas attached with the current webGL context
  90385. * @returns a client rectanglee
  90386. */
  90387. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  90388. /**
  90389. * Defines the hardware scaling level.
  90390. * By default the hardware scaling level is computed from the window device ratio.
  90391. * 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.
  90392. * @param level defines the level to use
  90393. */
  90394. setHardwareScalingLevel(level: number): void;
  90395. /**
  90396. * Gets the current hardware scaling level.
  90397. * By default the hardware scaling level is computed from the window device ratio.
  90398. * 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.
  90399. * @returns a number indicating the current hardware scaling level
  90400. */
  90401. getHardwareScalingLevel(): number;
  90402. /**
  90403. * Gets the list of loaded textures
  90404. * @returns an array containing all loaded textures
  90405. */
  90406. getLoadedTexturesCache(): InternalTexture[];
  90407. /**
  90408. * Gets the object containing all engine capabilities
  90409. * @returns the EngineCapabilities object
  90410. */
  90411. getCaps(): EngineCapabilities;
  90412. /**
  90413. * Gets the current depth function
  90414. * @returns a number defining the depth function
  90415. */
  90416. getDepthFunction(): Nullable<number>;
  90417. /**
  90418. * Sets the current depth function
  90419. * @param depthFunc defines the function to use
  90420. */
  90421. setDepthFunction(depthFunc: number): void;
  90422. /**
  90423. * Sets the current depth function to GREATER
  90424. */
  90425. setDepthFunctionToGreater(): void;
  90426. /**
  90427. * Sets the current depth function to GEQUAL
  90428. */
  90429. setDepthFunctionToGreaterOrEqual(): void;
  90430. /**
  90431. * Sets the current depth function to LESS
  90432. */
  90433. setDepthFunctionToLess(): void;
  90434. private _cachedStencilBuffer;
  90435. private _cachedStencilFunction;
  90436. private _cachedStencilMask;
  90437. private _cachedStencilOperationPass;
  90438. private _cachedStencilOperationFail;
  90439. private _cachedStencilOperationDepthFail;
  90440. private _cachedStencilReference;
  90441. /**
  90442. * Caches the the state of the stencil buffer
  90443. */
  90444. cacheStencilState(): void;
  90445. /**
  90446. * Restores the state of the stencil buffer
  90447. */
  90448. restoreStencilState(): void;
  90449. /**
  90450. * Sets the current depth function to LEQUAL
  90451. */
  90452. setDepthFunctionToLessOrEqual(): void;
  90453. /**
  90454. * Gets a boolean indicating if stencil buffer is enabled
  90455. * @returns the current stencil buffer state
  90456. */
  90457. getStencilBuffer(): boolean;
  90458. /**
  90459. * Enable or disable the stencil buffer
  90460. * @param enable defines if the stencil buffer must be enabled or disabled
  90461. */
  90462. setStencilBuffer(enable: boolean): void;
  90463. /**
  90464. * Gets the current stencil mask
  90465. * @returns a number defining the new stencil mask to use
  90466. */
  90467. getStencilMask(): number;
  90468. /**
  90469. * Sets the current stencil mask
  90470. * @param mask defines the new stencil mask to use
  90471. */
  90472. setStencilMask(mask: number): void;
  90473. /**
  90474. * Gets the current stencil function
  90475. * @returns a number defining the stencil function to use
  90476. */
  90477. getStencilFunction(): number;
  90478. /**
  90479. * Gets the current stencil reference value
  90480. * @returns a number defining the stencil reference value to use
  90481. */
  90482. getStencilFunctionReference(): number;
  90483. /**
  90484. * Gets the current stencil mask
  90485. * @returns a number defining the stencil mask to use
  90486. */
  90487. getStencilFunctionMask(): number;
  90488. /**
  90489. * Sets the current stencil function
  90490. * @param stencilFunc defines the new stencil function to use
  90491. */
  90492. setStencilFunction(stencilFunc: number): void;
  90493. /**
  90494. * Sets the current stencil reference
  90495. * @param reference defines the new stencil reference to use
  90496. */
  90497. setStencilFunctionReference(reference: number): void;
  90498. /**
  90499. * Sets the current stencil mask
  90500. * @param mask defines the new stencil mask to use
  90501. */
  90502. setStencilFunctionMask(mask: number): void;
  90503. /**
  90504. * Gets the current stencil operation when stencil fails
  90505. * @returns a number defining stencil operation to use when stencil fails
  90506. */
  90507. getStencilOperationFail(): number;
  90508. /**
  90509. * Gets the current stencil operation when depth fails
  90510. * @returns a number defining stencil operation to use when depth fails
  90511. */
  90512. getStencilOperationDepthFail(): number;
  90513. /**
  90514. * Gets the current stencil operation when stencil passes
  90515. * @returns a number defining stencil operation to use when stencil passes
  90516. */
  90517. getStencilOperationPass(): number;
  90518. /**
  90519. * Sets the stencil operation to use when stencil fails
  90520. * @param operation defines the stencil operation to use when stencil fails
  90521. */
  90522. setStencilOperationFail(operation: number): void;
  90523. /**
  90524. * Sets the stencil operation to use when depth fails
  90525. * @param operation defines the stencil operation to use when depth fails
  90526. */
  90527. setStencilOperationDepthFail(operation: number): void;
  90528. /**
  90529. * Sets the stencil operation to use when stencil passes
  90530. * @param operation defines the stencil operation to use when stencil passes
  90531. */
  90532. setStencilOperationPass(operation: number): void;
  90533. /**
  90534. * Sets a boolean indicating if the dithering state is enabled or disabled
  90535. * @param value defines the dithering state
  90536. */
  90537. setDitheringState(value: boolean): void;
  90538. /**
  90539. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  90540. * @param value defines the rasterizer state
  90541. */
  90542. setRasterizerState(value: boolean): void;
  90543. /**
  90544. * stop executing a render loop function and remove it from the execution array
  90545. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  90546. */
  90547. stopRenderLoop(renderFunction?: () => void): void;
  90548. /** @hidden */
  90549. _renderLoop(): void;
  90550. /**
  90551. * Register and execute a render loop. The engine can have more than one render function
  90552. * @param renderFunction defines the function to continuously execute
  90553. */
  90554. runRenderLoop(renderFunction: () => void): void;
  90555. /**
  90556. * Toggle full screen mode
  90557. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90558. */
  90559. switchFullscreen(requestPointerLock: boolean): void;
  90560. /**
  90561. * Enters full screen mode
  90562. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90563. */
  90564. enterFullscreen(requestPointerLock: boolean): void;
  90565. /**
  90566. * Exits full screen mode
  90567. */
  90568. exitFullscreen(): void;
  90569. /**
  90570. * Enters Pointerlock mode
  90571. */
  90572. enterPointerlock(): void;
  90573. /**
  90574. * Exits Pointerlock mode
  90575. */
  90576. exitPointerlock(): void;
  90577. /**
  90578. * Clear the current render buffer or the current render target (if any is set up)
  90579. * @param color defines the color to use
  90580. * @param backBuffer defines if the back buffer must be cleared
  90581. * @param depth defines if the depth buffer must be cleared
  90582. * @param stencil defines if the stencil buffer must be cleared
  90583. */
  90584. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  90585. /**
  90586. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  90587. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90588. * @param y defines the y-coordinate of the corner of the clear rectangle
  90589. * @param width defines the width of the clear rectangle
  90590. * @param height defines the height of the clear rectangle
  90591. * @param clearColor defines the clear color
  90592. */
  90593. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  90594. /**
  90595. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  90596. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90597. * @param y defines the y-coordinate of the corner of the clear rectangle
  90598. * @param width defines the width of the clear rectangle
  90599. * @param height defines the height of the clear rectangle
  90600. */
  90601. enableScissor(x: number, y: number, width: number, height: number): void;
  90602. /**
  90603. * Disable previously set scissor test rectangle
  90604. */
  90605. disableScissor(): void;
  90606. private _viewportCached;
  90607. /** @hidden */
  90608. _viewport(x: number, y: number, width: number, height: number): void;
  90609. /**
  90610. * Set the WebGL's viewport
  90611. * @param viewport defines the viewport element to be used
  90612. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  90613. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  90614. */
  90615. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  90616. /**
  90617. * Directly set the WebGL Viewport
  90618. * @param x defines the x coordinate of the viewport (in screen space)
  90619. * @param y defines the y coordinate of the viewport (in screen space)
  90620. * @param width defines the width of the viewport (in screen space)
  90621. * @param height defines the height of the viewport (in screen space)
  90622. * @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
  90623. */
  90624. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  90625. /**
  90626. * Begin a new frame
  90627. */
  90628. beginFrame(): void;
  90629. /**
  90630. * Enf the current frame
  90631. */
  90632. endFrame(): void;
  90633. /**
  90634. * Resize the view according to the canvas' size
  90635. */
  90636. resize(): void;
  90637. /**
  90638. * Force a specific size of the canvas
  90639. * @param width defines the new canvas' width
  90640. * @param height defines the new canvas' height
  90641. */
  90642. setSize(width: number, height: number): void;
  90643. /**
  90644. * Binds the frame buffer to the specified texture.
  90645. * @param texture The texture to render to or null for the default canvas
  90646. * @param faceIndex The face of the texture to render to in case of cube texture
  90647. * @param requiredWidth The width of the target to render to
  90648. * @param requiredHeight The height of the target to render to
  90649. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  90650. * @param depthStencilTexture The depth stencil texture to use to render
  90651. * @param lodLevel defines le lod level to bind to the frame buffer
  90652. */
  90653. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  90654. /** @hidden */
  90655. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  90656. /**
  90657. * Unbind the current render target texture from the webGL context
  90658. * @param texture defines the render target texture to unbind
  90659. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  90660. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  90661. */
  90662. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  90663. /**
  90664. * Force the mipmap generation for the given render target texture
  90665. * @param texture defines the render target texture to use
  90666. */
  90667. generateMipMapsForCubemap(texture: InternalTexture): void;
  90668. /**
  90669. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  90670. */
  90671. flushFramebuffer(): void;
  90672. /**
  90673. * Unbind the current render target and bind the default framebuffer
  90674. */
  90675. restoreDefaultFramebuffer(): void;
  90676. /**
  90677. * Create an uniform buffer
  90678. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90679. * @param elements defines the content of the uniform buffer
  90680. * @returns the webGL uniform buffer
  90681. */
  90682. createUniformBuffer(elements: FloatArray): DataBuffer;
  90683. /**
  90684. * Create a dynamic uniform buffer
  90685. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90686. * @param elements defines the content of the uniform buffer
  90687. * @returns the webGL uniform buffer
  90688. */
  90689. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  90690. /**
  90691. * Update an existing uniform buffer
  90692. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90693. * @param uniformBuffer defines the target uniform buffer
  90694. * @param elements defines the content to update
  90695. * @param offset defines the offset in the uniform buffer where update should start
  90696. * @param count defines the size of the data to update
  90697. */
  90698. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  90699. private _resetVertexBufferBinding;
  90700. /**
  90701. * Creates a vertex buffer
  90702. * @param data the data for the vertex buffer
  90703. * @returns the new WebGL static buffer
  90704. */
  90705. createVertexBuffer(data: DataArray): DataBuffer;
  90706. /**
  90707. * Creates a dynamic vertex buffer
  90708. * @param data the data for the dynamic vertex buffer
  90709. * @returns the new WebGL dynamic buffer
  90710. */
  90711. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  90712. /**
  90713. * Update a dynamic index buffer
  90714. * @param indexBuffer defines the target index buffer
  90715. * @param indices defines the data to update
  90716. * @param offset defines the offset in the target index buffer where update should start
  90717. */
  90718. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  90719. /**
  90720. * Updates a dynamic vertex buffer.
  90721. * @param vertexBuffer the vertex buffer to update
  90722. * @param data the data used to update the vertex buffer
  90723. * @param byteOffset the byte offset of the data
  90724. * @param byteLength the byte length of the data
  90725. */
  90726. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  90727. private _resetIndexBufferBinding;
  90728. /**
  90729. * Creates a new index buffer
  90730. * @param indices defines the content of the index buffer
  90731. * @param updatable defines if the index buffer must be updatable
  90732. * @returns a new webGL buffer
  90733. */
  90734. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  90735. /**
  90736. * Bind a webGL buffer to the webGL context
  90737. * @param buffer defines the buffer to bind
  90738. */
  90739. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  90740. /**
  90741. * Bind an uniform buffer to the current webGL context
  90742. * @param buffer defines the buffer to bind
  90743. */
  90744. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  90745. /**
  90746. * Bind a buffer to the current webGL context at a given location
  90747. * @param buffer defines the buffer to bind
  90748. * @param location defines the index where to bind the buffer
  90749. */
  90750. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  90751. /**
  90752. * Bind a specific block at a given index in a specific shader program
  90753. * @param pipelineContext defines the pipeline context to use
  90754. * @param blockName defines the block name
  90755. * @param index defines the index where to bind the block
  90756. */
  90757. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  90758. private bindIndexBuffer;
  90759. private bindBuffer;
  90760. /**
  90761. * update the bound buffer with the given data
  90762. * @param data defines the data to update
  90763. */
  90764. updateArrayBuffer(data: Float32Array): void;
  90765. private _vertexAttribPointer;
  90766. private _bindIndexBufferWithCache;
  90767. private _bindVertexBuffersAttributes;
  90768. /**
  90769. * Records a vertex array object
  90770. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  90771. * @param vertexBuffers defines the list of vertex buffers to store
  90772. * @param indexBuffer defines the index buffer to store
  90773. * @param effect defines the effect to store
  90774. * @returns the new vertex array object
  90775. */
  90776. recordVertexArrayObject(vertexBuffers: {
  90777. [key: string]: VertexBuffer;
  90778. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  90779. /**
  90780. * Bind a specific vertex array object
  90781. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  90782. * @param vertexArrayObject defines the vertex array object to bind
  90783. * @param indexBuffer defines the index buffer to bind
  90784. */
  90785. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  90786. /**
  90787. * Bind webGl buffers directly to the webGL context
  90788. * @param vertexBuffer defines the vertex buffer to bind
  90789. * @param indexBuffer defines the index buffer to bind
  90790. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  90791. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  90792. * @param effect defines the effect associated with the vertex buffer
  90793. */
  90794. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  90795. private _unbindVertexArrayObject;
  90796. /**
  90797. * Bind a list of vertex buffers to the webGL context
  90798. * @param vertexBuffers defines the list of vertex buffers to bind
  90799. * @param indexBuffer defines the index buffer to bind
  90800. * @param effect defines the effect associated with the vertex buffers
  90801. */
  90802. bindBuffers(vertexBuffers: {
  90803. [key: string]: Nullable<VertexBuffer>;
  90804. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  90805. /**
  90806. * Unbind all instance attributes
  90807. */
  90808. unbindInstanceAttributes(): void;
  90809. /**
  90810. * Release and free the memory of a vertex array object
  90811. * @param vao defines the vertex array object to delete
  90812. */
  90813. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  90814. /** @hidden */
  90815. _releaseBuffer(buffer: DataBuffer): boolean;
  90816. /**
  90817. * Creates a webGL buffer to use with instanciation
  90818. * @param capacity defines the size of the buffer
  90819. * @returns the webGL buffer
  90820. */
  90821. createInstancesBuffer(capacity: number): DataBuffer;
  90822. /**
  90823. * Delete a webGL buffer used with instanciation
  90824. * @param buffer defines the webGL buffer to delete
  90825. */
  90826. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  90827. /**
  90828. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  90829. * @param instancesBuffer defines the webGL buffer to update and bind
  90830. * @param data defines the data to store in the buffer
  90831. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  90832. */
  90833. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  90834. /**
  90835. * Apply all cached states (depth, culling, stencil and alpha)
  90836. */
  90837. applyStates(): void;
  90838. /**
  90839. * Send a draw order
  90840. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  90841. * @param indexStart defines the starting index
  90842. * @param indexCount defines the number of index to draw
  90843. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90844. */
  90845. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  90846. /**
  90847. * Draw a list of points
  90848. * @param verticesStart defines the index of first vertex to draw
  90849. * @param verticesCount defines the count of vertices to draw
  90850. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90851. */
  90852. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  90853. /**
  90854. * Draw a list of unindexed primitives
  90855. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  90856. * @param verticesStart defines the index of first vertex to draw
  90857. * @param verticesCount defines the count of vertices to draw
  90858. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90859. */
  90860. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  90861. /**
  90862. * Draw a list of indexed primitives
  90863. * @param fillMode defines the primitive to use
  90864. * @param indexStart defines the starting index
  90865. * @param indexCount defines the number of index to draw
  90866. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90867. */
  90868. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  90869. /**
  90870. * Draw a list of unindexed primitives
  90871. * @param fillMode defines the primitive to use
  90872. * @param verticesStart defines the index of first vertex to draw
  90873. * @param verticesCount defines the count of vertices to draw
  90874. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90875. */
  90876. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  90877. private _drawMode;
  90878. /** @hidden */
  90879. _releaseEffect(effect: Effect): void;
  90880. /** @hidden */
  90881. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  90882. /**
  90883. * Create a new effect (used to store vertex/fragment shaders)
  90884. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  90885. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  90886. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  90887. * @param samplers defines an array of string used to represent textures
  90888. * @param defines defines the string containing the defines to use to compile the shaders
  90889. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  90890. * @param onCompiled defines a function to call when the effect creation is successful
  90891. * @param onError defines a function to call when the effect creation has failed
  90892. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  90893. * @returns the new Effect
  90894. */
  90895. 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;
  90896. private _compileShader;
  90897. private _compileRawShader;
  90898. /**
  90899. * Directly creates a webGL program
  90900. * @param pipelineContext defines the pipeline context to attach to
  90901. * @param vertexCode defines the vertex shader code to use
  90902. * @param fragmentCode defines the fragment shader code to use
  90903. * @param context defines the webGL context to use (if not set, the current one will be used)
  90904. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  90905. * @returns the new webGL program
  90906. */
  90907. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  90908. /**
  90909. * Creates a webGL program
  90910. * @param pipelineContext defines the pipeline context to attach to
  90911. * @param vertexCode defines the vertex shader code to use
  90912. * @param fragmentCode defines the fragment shader code to use
  90913. * @param defines defines the string containing the defines to use to compile the shaders
  90914. * @param context defines the webGL context to use (if not set, the current one will be used)
  90915. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  90916. * @returns the new webGL program
  90917. */
  90918. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  90919. /**
  90920. * Creates a new pipeline context
  90921. * @returns the new pipeline
  90922. */
  90923. createPipelineContext(): WebGLPipelineContext;
  90924. private _createShaderProgram;
  90925. private _finalizePipelineContext;
  90926. /** @hidden */
  90927. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  90928. /** @hidden */
  90929. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  90930. /** @hidden */
  90931. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  90932. /**
  90933. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  90934. * @param pipelineContext defines the pipeline context to use
  90935. * @param uniformsNames defines the list of uniform names
  90936. * @returns an array of webGL uniform locations
  90937. */
  90938. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  90939. /**
  90940. * Gets the lsit of active attributes for a given webGL program
  90941. * @param pipelineContext defines the pipeline context to use
  90942. * @param attributesNames defines the list of attribute names to get
  90943. * @returns an array of indices indicating the offset of each attribute
  90944. */
  90945. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  90946. /**
  90947. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  90948. * @param effect defines the effect to activate
  90949. */
  90950. enableEffect(effect: Nullable<Effect>): void;
  90951. /**
  90952. * Set the value of an uniform to an array of int32
  90953. * @param uniform defines the webGL uniform location where to store the value
  90954. * @param array defines the array of int32 to store
  90955. */
  90956. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  90957. /**
  90958. * Set the value of an uniform to an array of int32 (stored as vec2)
  90959. * @param uniform defines the webGL uniform location where to store the value
  90960. * @param array defines the array of int32 to store
  90961. */
  90962. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  90963. /**
  90964. * Set the value of an uniform to an array of int32 (stored as vec3)
  90965. * @param uniform defines the webGL uniform location where to store the value
  90966. * @param array defines the array of int32 to store
  90967. */
  90968. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  90969. /**
  90970. * Set the value of an uniform to an array of int32 (stored as vec4)
  90971. * @param uniform defines the webGL uniform location where to store the value
  90972. * @param array defines the array of int32 to store
  90973. */
  90974. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  90975. /**
  90976. * Set the value of an uniform to an array of float32
  90977. * @param uniform defines the webGL uniform location where to store the value
  90978. * @param array defines the array of float32 to store
  90979. */
  90980. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  90981. /**
  90982. * Set the value of an uniform to an array of float32 (stored as vec2)
  90983. * @param uniform defines the webGL uniform location where to store the value
  90984. * @param array defines the array of float32 to store
  90985. */
  90986. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  90987. /**
  90988. * Set the value of an uniform to an array of float32 (stored as vec3)
  90989. * @param uniform defines the webGL uniform location where to store the value
  90990. * @param array defines the array of float32 to store
  90991. */
  90992. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  90993. /**
  90994. * Set the value of an uniform to an array of float32 (stored as vec4)
  90995. * @param uniform defines the webGL uniform location where to store the value
  90996. * @param array defines the array of float32 to store
  90997. */
  90998. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  90999. /**
  91000. * Set the value of an uniform to an array of number
  91001. * @param uniform defines the webGL uniform location where to store the value
  91002. * @param array defines the array of number to store
  91003. */
  91004. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91005. /**
  91006. * Set the value of an uniform to an array of number (stored as vec2)
  91007. * @param uniform defines the webGL uniform location where to store the value
  91008. * @param array defines the array of number to store
  91009. */
  91010. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91011. /**
  91012. * Set the value of an uniform to an array of number (stored as vec3)
  91013. * @param uniform defines the webGL uniform location where to store the value
  91014. * @param array defines the array of number to store
  91015. */
  91016. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91017. /**
  91018. * Set the value of an uniform to an array of number (stored as vec4)
  91019. * @param uniform defines the webGL uniform location where to store the value
  91020. * @param array defines the array of number to store
  91021. */
  91022. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91023. /**
  91024. * Set the value of an uniform to an array of float32 (stored as matrices)
  91025. * @param uniform defines the webGL uniform location where to store the value
  91026. * @param matrices defines the array of float32 to store
  91027. */
  91028. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  91029. /**
  91030. * Set the value of an uniform to a matrix
  91031. * @param uniform defines the webGL uniform location where to store the value
  91032. * @param matrix defines the matrix to store
  91033. */
  91034. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  91035. /**
  91036. * Set the value of an uniform to a matrix (3x3)
  91037. * @param uniform defines the webGL uniform location where to store the value
  91038. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  91039. */
  91040. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91041. /**
  91042. * Set the value of an uniform to a matrix (2x2)
  91043. * @param uniform defines the webGL uniform location where to store the value
  91044. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  91045. */
  91046. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91047. /**
  91048. * Set the value of an uniform to a number (int)
  91049. * @param uniform defines the webGL uniform location where to store the value
  91050. * @param value defines the int number to store
  91051. */
  91052. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91053. /**
  91054. * Set the value of an uniform to a number (float)
  91055. * @param uniform defines the webGL uniform location where to store the value
  91056. * @param value defines the float number to store
  91057. */
  91058. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91059. /**
  91060. * Set the value of an uniform to a vec2
  91061. * @param uniform defines the webGL uniform location where to store the value
  91062. * @param x defines the 1st component of the value
  91063. * @param y defines the 2nd component of the value
  91064. */
  91065. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  91066. /**
  91067. * Set the value of an uniform to a vec3
  91068. * @param uniform defines the webGL uniform location where to store the value
  91069. * @param x defines the 1st component of the value
  91070. * @param y defines the 2nd component of the value
  91071. * @param z defines the 3rd component of the value
  91072. */
  91073. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  91074. /**
  91075. * Set the value of an uniform to a boolean
  91076. * @param uniform defines the webGL uniform location where to store the value
  91077. * @param bool defines the boolean to store
  91078. */
  91079. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  91080. /**
  91081. * Set the value of an uniform to a vec4
  91082. * @param uniform defines the webGL uniform location where to store the value
  91083. * @param x defines the 1st component of the value
  91084. * @param y defines the 2nd component of the value
  91085. * @param z defines the 3rd component of the value
  91086. * @param w defines the 4th component of the value
  91087. */
  91088. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  91089. /**
  91090. * Set the value of an uniform to a Color3
  91091. * @param uniform defines the webGL uniform location where to store the value
  91092. * @param color3 defines the color to store
  91093. */
  91094. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  91095. /**
  91096. * Set the value of an uniform to a Color3 and an alpha value
  91097. * @param uniform defines the webGL uniform location where to store the value
  91098. * @param color3 defines the color to store
  91099. * @param alpha defines the alpha component to store
  91100. */
  91101. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  91102. /**
  91103. * Sets a Color4 on a uniform variable
  91104. * @param uniform defines the uniform location
  91105. * @param color4 defines the value to be set
  91106. */
  91107. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  91108. /**
  91109. * Set various states to the webGL context
  91110. * @param culling defines backface culling state
  91111. * @param zOffset defines the value to apply to zOffset (0 by default)
  91112. * @param force defines if states must be applied even if cache is up to date
  91113. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  91114. */
  91115. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  91116. /**
  91117. * Set the z offset to apply to current rendering
  91118. * @param value defines the offset to apply
  91119. */
  91120. setZOffset(value: number): void;
  91121. /**
  91122. * Gets the current value of the zOffset
  91123. * @returns the current zOffset state
  91124. */
  91125. getZOffset(): number;
  91126. /**
  91127. * Enable or disable depth buffering
  91128. * @param enable defines the state to set
  91129. */
  91130. setDepthBuffer(enable: boolean): void;
  91131. /**
  91132. * Gets a boolean indicating if depth writing is enabled
  91133. * @returns the current depth writing state
  91134. */
  91135. getDepthWrite(): boolean;
  91136. /**
  91137. * Enable or disable depth writing
  91138. * @param enable defines the state to set
  91139. */
  91140. setDepthWrite(enable: boolean): void;
  91141. /**
  91142. * Enable or disable color writing
  91143. * @param enable defines the state to set
  91144. */
  91145. setColorWrite(enable: boolean): void;
  91146. /**
  91147. * Gets a boolean indicating if color writing is enabled
  91148. * @returns the current color writing state
  91149. */
  91150. getColorWrite(): boolean;
  91151. /**
  91152. * Sets alpha constants used by some alpha blending modes
  91153. * @param r defines the red component
  91154. * @param g defines the green component
  91155. * @param b defines the blue component
  91156. * @param a defines the alpha component
  91157. */
  91158. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91159. /**
  91160. * Sets the current alpha mode
  91161. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91162. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91163. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91164. */
  91165. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91166. /**
  91167. * Gets the current alpha mode
  91168. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91169. * @returns the current alpha mode
  91170. */
  91171. getAlphaMode(): number;
  91172. /**
  91173. * Clears the list of texture accessible through engine.
  91174. * This can help preventing texture load conflict due to name collision.
  91175. */
  91176. clearInternalTexturesCache(): void;
  91177. /**
  91178. * Force the entire cache to be cleared
  91179. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  91180. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  91181. */
  91182. wipeCaches(bruteForce?: boolean): void;
  91183. /**
  91184. * Set the compressed texture format to use, based on the formats you have, and the formats
  91185. * supported by the hardware / browser.
  91186. *
  91187. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  91188. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  91189. * to API arguments needed to compressed textures. This puts the burden on the container
  91190. * generator to house the arcane code for determining these for current & future formats.
  91191. *
  91192. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  91193. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  91194. *
  91195. * Note: The result of this call is not taken into account when a texture is base64.
  91196. *
  91197. * @param formatsAvailable defines the list of those format families you have created
  91198. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  91199. *
  91200. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  91201. * @returns The extension selected.
  91202. */
  91203. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  91204. /** @hidden */
  91205. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  91206. min: number;
  91207. mag: number;
  91208. };
  91209. /** @hidden */
  91210. _createTexture(): WebGLTexture;
  91211. /**
  91212. * Usually called from Texture.ts.
  91213. * Passed information to create a WebGLTexture
  91214. * @param urlArg defines a value which contains one of the following:
  91215. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  91216. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  91217. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  91218. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  91219. * @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)
  91220. * @param scene needed for loading to the correct scene
  91221. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  91222. * @param onLoad optional callback to be called upon successful completion
  91223. * @param onError optional callback to be called upon failure
  91224. * @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
  91225. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  91226. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  91227. * @param forcedExtension defines the extension to use to pick the right loader
  91228. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  91229. * @returns a InternalTexture for assignment back into BABYLON.Texture
  91230. */
  91231. 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;
  91232. private _rescaleTexture;
  91233. private _unpackFlipYCached;
  91234. /**
  91235. * In case you are sharing the context with other applications, it might
  91236. * be interested to not cache the unpack flip y state to ensure a consistent
  91237. * value would be set.
  91238. */
  91239. enableUnpackFlipYCached: boolean;
  91240. /** @hidden */
  91241. _unpackFlipY(value: boolean): void;
  91242. /** @hidden */
  91243. _getUnpackAlignement(): number;
  91244. /**
  91245. * Creates a dynamic texture
  91246. * @param width defines the width of the texture
  91247. * @param height defines the height of the texture
  91248. * @param generateMipMaps defines if the engine should generate the mip levels
  91249. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91250. * @returns the dynamic texture inside an InternalTexture
  91251. */
  91252. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  91253. /**
  91254. * Update the sampling mode of a given texture
  91255. * @param samplingMode defines the required sampling mode
  91256. * @param texture defines the texture to update
  91257. */
  91258. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  91259. /**
  91260. * Update the content of a dynamic texture
  91261. * @param texture defines the texture to update
  91262. * @param canvas defines the canvas containing the source
  91263. * @param invertY defines if data must be stored with Y axis inverted
  91264. * @param premulAlpha defines if alpha is stored as premultiplied
  91265. * @param format defines the format of the data
  91266. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  91267. */
  91268. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  91269. /**
  91270. * Update a video texture
  91271. * @param texture defines the texture to update
  91272. * @param video defines the video element to use
  91273. * @param invertY defines if data must be stored with Y axis inverted
  91274. */
  91275. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  91276. /**
  91277. * Updates a depth texture Comparison Mode and Function.
  91278. * If the comparison Function is equal to 0, the mode will be set to none.
  91279. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  91280. * @param texture The texture to set the comparison function for
  91281. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  91282. */
  91283. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  91284. /** @hidden */
  91285. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  91286. width: number;
  91287. height: number;
  91288. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  91289. /**
  91290. * Creates a depth stencil texture.
  91291. * This is only available in WebGL 2 or with the depth texture extension available.
  91292. * @param size The size of face edge in the texture.
  91293. * @param options The options defining the texture.
  91294. * @returns The texture
  91295. */
  91296. createDepthStencilTexture(size: number | {
  91297. width: number;
  91298. height: number;
  91299. }, options: DepthTextureCreationOptions): InternalTexture;
  91300. /**
  91301. * Creates a depth stencil texture.
  91302. * This is only available in WebGL 2 or with the depth texture extension available.
  91303. * @param size The size of face edge in the texture.
  91304. * @param options The options defining the texture.
  91305. * @returns The texture
  91306. */
  91307. private _createDepthStencilTexture;
  91308. /**
  91309. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  91310. * @param renderTarget The render target to set the frame buffer for
  91311. */
  91312. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  91313. /**
  91314. * Creates a new render target texture
  91315. * @param size defines the size of the texture
  91316. * @param options defines the options used to create the texture
  91317. * @returns a new render target texture stored in an InternalTexture
  91318. */
  91319. createRenderTargetTexture(size: number | {
  91320. width: number;
  91321. height: number;
  91322. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  91323. /** @hidden */
  91324. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  91325. /**
  91326. * Updates the sample count of a render target texture
  91327. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  91328. * @param texture defines the texture to update
  91329. * @param samples defines the sample count to set
  91330. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  91331. */
  91332. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  91333. /** @hidden */
  91334. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91335. /** @hidden */
  91336. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91337. /** @hidden */
  91338. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91339. /** @hidden */
  91340. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  91341. /**
  91342. * @hidden
  91343. */
  91344. _setCubeMapTextureParams(loadMipmap: boolean): void;
  91345. private _prepareWebGLTextureContinuation;
  91346. private _prepareWebGLTexture;
  91347. /** @hidden */
  91348. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  91349. /** @hidden */
  91350. _releaseFramebufferObjects(texture: InternalTexture): void;
  91351. /** @hidden */
  91352. _releaseTexture(texture: InternalTexture): void;
  91353. private setProgram;
  91354. private _boundUniforms;
  91355. /**
  91356. * Binds an effect to the webGL context
  91357. * @param effect defines the effect to bind
  91358. */
  91359. bindSamplers(effect: Effect): void;
  91360. private _activateCurrentTexture;
  91361. /** @hidden */
  91362. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  91363. /** @hidden */
  91364. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  91365. /**
  91366. * Sets a texture to the webGL context from a postprocess
  91367. * @param channel defines the channel to use
  91368. * @param postProcess defines the source postprocess
  91369. */
  91370. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  91371. /**
  91372. * Binds the output of the passed in post process to the texture channel specified
  91373. * @param channel The channel the texture should be bound to
  91374. * @param postProcess The post process which's output should be bound
  91375. */
  91376. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  91377. /**
  91378. * Unbind all textures from the webGL context
  91379. */
  91380. unbindAllTextures(): void;
  91381. /**
  91382. * Sets a texture to the according uniform.
  91383. * @param channel The texture channel
  91384. * @param uniform The uniform to set
  91385. * @param texture The texture to apply
  91386. */
  91387. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  91388. /**
  91389. * Sets a depth stencil texture from a render target to the according uniform.
  91390. * @param channel The texture channel
  91391. * @param uniform The uniform to set
  91392. * @param texture The render target texture containing the depth stencil texture to apply
  91393. */
  91394. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  91395. private _bindSamplerUniformToChannel;
  91396. private _getTextureWrapMode;
  91397. private _setTexture;
  91398. /**
  91399. * Sets an array of texture to the webGL context
  91400. * @param channel defines the channel where the texture array must be set
  91401. * @param uniform defines the associated uniform location
  91402. * @param textures defines the array of textures to bind
  91403. */
  91404. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  91405. /** @hidden */
  91406. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  91407. private _setTextureParameterFloat;
  91408. private _setTextureParameterInteger;
  91409. /**
  91410. * Reads pixels from the current frame buffer. Please note that this function can be slow
  91411. * @param x defines the x coordinate of the rectangle where pixels must be read
  91412. * @param y defines the y coordinate of the rectangle where pixels must be read
  91413. * @param width defines the width of the rectangle where pixels must be read
  91414. * @param height defines the height of the rectangle where pixels must be read
  91415. * @returns a Uint8Array containing RGBA colors
  91416. */
  91417. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  91418. /**
  91419. * Add an externaly attached data from its key.
  91420. * This method call will fail and return false, if such key already exists.
  91421. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91422. * @param key the unique key that identifies the data
  91423. * @param data the data object to associate to the key for this Engine instance
  91424. * @return true if no such key were already present and the data was added successfully, false otherwise
  91425. */
  91426. addExternalData<T>(key: string, data: T): boolean;
  91427. /**
  91428. * Get an externaly attached data from its key
  91429. * @param key the unique key that identifies the data
  91430. * @return the associated data, if present (can be null), or undefined if not present
  91431. */
  91432. getExternalData<T>(key: string): T;
  91433. /**
  91434. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91435. * @param key the unique key that identifies the data
  91436. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91437. * @return the associated data, can be null if the factory returned null.
  91438. */
  91439. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91440. /**
  91441. * Remove an externaly attached data from the Engine instance
  91442. * @param key the unique key that identifies the data
  91443. * @return true if the data was successfully removed, false if it doesn't exist
  91444. */
  91445. removeExternalData(key: string): boolean;
  91446. /**
  91447. * Unbind all vertex attributes from the webGL context
  91448. */
  91449. unbindAllAttributes(): void;
  91450. /**
  91451. * 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
  91452. */
  91453. releaseEffects(): void;
  91454. /**
  91455. * Dispose and release all associated resources
  91456. */
  91457. dispose(): void;
  91458. /**
  91459. * Display the loading screen
  91460. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91461. */
  91462. displayLoadingUI(): void;
  91463. /**
  91464. * Hide the loading screen
  91465. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91466. */
  91467. hideLoadingUI(): void;
  91468. /**
  91469. * Gets the current loading screen object
  91470. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91471. */
  91472. /**
  91473. * Sets the current loading screen object
  91474. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91475. */
  91476. loadingScreen: ILoadingScreen;
  91477. /**
  91478. * Sets the current loading screen text
  91479. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91480. */
  91481. loadingUIText: string;
  91482. /**
  91483. * Sets the current loading screen background color
  91484. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91485. */
  91486. loadingUIBackgroundColor: string;
  91487. /**
  91488. * Attach a new callback raised when context lost event is fired
  91489. * @param callback defines the callback to call
  91490. */
  91491. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91492. /**
  91493. * Attach a new callback raised when context restored event is fired
  91494. * @param callback defines the callback to call
  91495. */
  91496. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91497. /**
  91498. * Gets the source code of the vertex shader associated with a specific webGL program
  91499. * @param program defines the program to use
  91500. * @returns a string containing the source code of the vertex shader associated with the program
  91501. */
  91502. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  91503. /**
  91504. * Gets the source code of the fragment shader associated with a specific webGL program
  91505. * @param program defines the program to use
  91506. * @returns a string containing the source code of the fragment shader associated with the program
  91507. */
  91508. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  91509. /**
  91510. * Get the current error code of the webGL context
  91511. * @returns the error code
  91512. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  91513. */
  91514. getError(): number;
  91515. /**
  91516. * Gets the current framerate
  91517. * @returns a number representing the framerate
  91518. */
  91519. getFps(): number;
  91520. /**
  91521. * Gets the time spent between current and previous frame
  91522. * @returns a number representing the delta time in ms
  91523. */
  91524. getDeltaTime(): number;
  91525. private _measureFps;
  91526. /** @hidden */
  91527. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  91528. private _canRenderToFloatFramebuffer;
  91529. private _canRenderToHalfFloatFramebuffer;
  91530. private _canRenderToFramebuffer;
  91531. /** @hidden */
  91532. _getWebGLTextureType(type: number): number;
  91533. /** @hidden */
  91534. _getInternalFormat(format: number): number;
  91535. /** @hidden */
  91536. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  91537. /** @hidden */
  91538. _getRGBAMultiSampleBufferFormat(type: number): number;
  91539. /** @hidden */
  91540. _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;
  91541. /** @hidden */
  91542. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  91543. /**
  91544. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  91545. * @returns true if the engine can be created
  91546. * @ignorenaming
  91547. */
  91548. static isSupported(): boolean;
  91549. }
  91550. }
  91551. declare module BABYLON {
  91552. /**
  91553. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  91554. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  91555. */
  91556. export class EffectFallbacks {
  91557. private _defines;
  91558. private _currentRank;
  91559. private _maxRank;
  91560. private _mesh;
  91561. /**
  91562. * Removes the fallback from the bound mesh.
  91563. */
  91564. unBindMesh(): void;
  91565. /**
  91566. * Adds a fallback on the specified property.
  91567. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91568. * @param define The name of the define in the shader
  91569. */
  91570. addFallback(rank: number, define: string): void;
  91571. /**
  91572. * Sets the mesh to use CPU skinning when needing to fallback.
  91573. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91574. * @param mesh The mesh to use the fallbacks.
  91575. */
  91576. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  91577. /**
  91578. * Checks to see if more fallbacks are still availible.
  91579. */
  91580. readonly isMoreFallbacks: boolean;
  91581. /**
  91582. * Removes the defines that should be removed when falling back.
  91583. * @param currentDefines defines the current define statements for the shader.
  91584. * @param effect defines the current effect we try to compile
  91585. * @returns The resulting defines with defines of the current rank removed.
  91586. */
  91587. reduce(currentDefines: string, effect: Effect): string;
  91588. }
  91589. /**
  91590. * Options to be used when creating an effect.
  91591. */
  91592. export class EffectCreationOptions {
  91593. /**
  91594. * Atrributes that will be used in the shader.
  91595. */
  91596. attributes: string[];
  91597. /**
  91598. * Uniform varible names that will be set in the shader.
  91599. */
  91600. uniformsNames: string[];
  91601. /**
  91602. * Uniform buffer varible names that will be set in the shader.
  91603. */
  91604. uniformBuffersNames: string[];
  91605. /**
  91606. * Sampler texture variable names that will be set in the shader.
  91607. */
  91608. samplers: string[];
  91609. /**
  91610. * Define statements that will be set in the shader.
  91611. */
  91612. defines: any;
  91613. /**
  91614. * Possible fallbacks for this effect to improve performance when needed.
  91615. */
  91616. fallbacks: Nullable<EffectFallbacks>;
  91617. /**
  91618. * Callback that will be called when the shader is compiled.
  91619. */
  91620. onCompiled: Nullable<(effect: Effect) => void>;
  91621. /**
  91622. * Callback that will be called if an error occurs during shader compilation.
  91623. */
  91624. onError: Nullable<(effect: Effect, errors: string) => void>;
  91625. /**
  91626. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91627. */
  91628. indexParameters: any;
  91629. /**
  91630. * Max number of lights that can be used in the shader.
  91631. */
  91632. maxSimultaneousLights: number;
  91633. /**
  91634. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  91635. */
  91636. transformFeedbackVaryings: Nullable<string[]>;
  91637. }
  91638. /**
  91639. * Effect containing vertex and fragment shader that can be executed on an object.
  91640. */
  91641. export class Effect implements IDisposable {
  91642. /**
  91643. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  91644. */
  91645. static ShadersRepository: string;
  91646. /**
  91647. * Name of the effect.
  91648. */
  91649. name: any;
  91650. /**
  91651. * String container all the define statements that should be set on the shader.
  91652. */
  91653. defines: string;
  91654. /**
  91655. * Callback that will be called when the shader is compiled.
  91656. */
  91657. onCompiled: Nullable<(effect: Effect) => void>;
  91658. /**
  91659. * Callback that will be called if an error occurs during shader compilation.
  91660. */
  91661. onError: Nullable<(effect: Effect, errors: string) => void>;
  91662. /**
  91663. * Callback that will be called when effect is bound.
  91664. */
  91665. onBind: Nullable<(effect: Effect) => void>;
  91666. /**
  91667. * Unique ID of the effect.
  91668. */
  91669. uniqueId: number;
  91670. /**
  91671. * Observable that will be called when the shader is compiled.
  91672. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  91673. */
  91674. onCompileObservable: Observable<Effect>;
  91675. /**
  91676. * Observable that will be called if an error occurs during shader compilation.
  91677. */
  91678. onErrorObservable: Observable<Effect>;
  91679. /** @hidden */
  91680. _onBindObservable: Nullable<Observable<Effect>>;
  91681. /**
  91682. * Observable that will be called when effect is bound.
  91683. */
  91684. readonly onBindObservable: Observable<Effect>;
  91685. /** @hidden */
  91686. _bonesComputationForcedToCPU: boolean;
  91687. private static _uniqueIdSeed;
  91688. private _engine;
  91689. private _uniformBuffersNames;
  91690. private _uniformsNames;
  91691. private _samplerList;
  91692. private _samplers;
  91693. private _isReady;
  91694. private _compilationError;
  91695. private _attributesNames;
  91696. private _attributes;
  91697. private _uniforms;
  91698. /**
  91699. * Key for the effect.
  91700. * @hidden
  91701. */
  91702. _key: string;
  91703. private _indexParameters;
  91704. private _fallbacks;
  91705. private _vertexSourceCode;
  91706. private _fragmentSourceCode;
  91707. private _vertexSourceCodeOverride;
  91708. private _fragmentSourceCodeOverride;
  91709. private _transformFeedbackVaryings;
  91710. /**
  91711. * Compiled shader to webGL program.
  91712. * @hidden
  91713. */
  91714. _pipelineContext: Nullable<IPipelineContext>;
  91715. private _valueCache;
  91716. private static _baseCache;
  91717. /**
  91718. * Instantiates an effect.
  91719. * An effect can be used to create/manage/execute vertex and fragment shaders.
  91720. * @param baseName Name of the effect.
  91721. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  91722. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  91723. * @param samplers List of sampler variables that will be passed to the shader.
  91724. * @param engine Engine to be used to render the effect
  91725. * @param defines Define statements to be added to the shader.
  91726. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  91727. * @param onCompiled Callback that will be called when the shader is compiled.
  91728. * @param onError Callback that will be called if an error occurs during shader compilation.
  91729. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91730. */
  91731. 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);
  91732. private _useFinalCode;
  91733. /**
  91734. * Unique key for this effect
  91735. */
  91736. readonly key: string;
  91737. /**
  91738. * If the effect has been compiled and prepared.
  91739. * @returns if the effect is compiled and prepared.
  91740. */
  91741. isReady(): boolean;
  91742. /**
  91743. * The engine the effect was initialized with.
  91744. * @returns the engine.
  91745. */
  91746. getEngine(): Engine;
  91747. /**
  91748. * The pipeline context for this effect
  91749. * @returns the associated pipeline context
  91750. */
  91751. getPipelineContext(): Nullable<IPipelineContext>;
  91752. /**
  91753. * The set of names of attribute variables for the shader.
  91754. * @returns An array of attribute names.
  91755. */
  91756. getAttributesNames(): string[];
  91757. /**
  91758. * Returns the attribute at the given index.
  91759. * @param index The index of the attribute.
  91760. * @returns The location of the attribute.
  91761. */
  91762. getAttributeLocation(index: number): number;
  91763. /**
  91764. * Returns the attribute based on the name of the variable.
  91765. * @param name of the attribute to look up.
  91766. * @returns the attribute location.
  91767. */
  91768. getAttributeLocationByName(name: string): number;
  91769. /**
  91770. * The number of attributes.
  91771. * @returns the numnber of attributes.
  91772. */
  91773. getAttributesCount(): number;
  91774. /**
  91775. * Gets the index of a uniform variable.
  91776. * @param uniformName of the uniform to look up.
  91777. * @returns the index.
  91778. */
  91779. getUniformIndex(uniformName: string): number;
  91780. /**
  91781. * Returns the attribute based on the name of the variable.
  91782. * @param uniformName of the uniform to look up.
  91783. * @returns the location of the uniform.
  91784. */
  91785. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  91786. /**
  91787. * Returns an array of sampler variable names
  91788. * @returns The array of sampler variable neames.
  91789. */
  91790. getSamplers(): string[];
  91791. /**
  91792. * The error from the last compilation.
  91793. * @returns the error string.
  91794. */
  91795. getCompilationError(): string;
  91796. /**
  91797. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  91798. * @param func The callback to be used.
  91799. */
  91800. executeWhenCompiled(func: (effect: Effect) => void): void;
  91801. private _checkIsReady;
  91802. /** @hidden */
  91803. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  91804. /** @hidden */
  91805. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  91806. /** @hidden */
  91807. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  91808. /**
  91809. * Recompiles the webGL program
  91810. * @param vertexSourceCode The source code for the vertex shader.
  91811. * @param fragmentSourceCode The source code for the fragment shader.
  91812. * @param onCompiled Callback called when completed.
  91813. * @param onError Callback called on error.
  91814. * @hidden
  91815. */
  91816. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  91817. /**
  91818. * Prepares the effect
  91819. * @hidden
  91820. */
  91821. _prepareEffect(): void;
  91822. /**
  91823. * Checks if the effect is supported. (Must be called after compilation)
  91824. */
  91825. readonly isSupported: boolean;
  91826. /**
  91827. * Binds a texture to the engine to be used as output of the shader.
  91828. * @param channel Name of the output variable.
  91829. * @param texture Texture to bind.
  91830. * @hidden
  91831. */
  91832. _bindTexture(channel: string, texture: InternalTexture): void;
  91833. /**
  91834. * Sets a texture on the engine to be used in the shader.
  91835. * @param channel Name of the sampler variable.
  91836. * @param texture Texture to set.
  91837. */
  91838. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  91839. /**
  91840. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  91841. * @param channel Name of the sampler variable.
  91842. * @param texture Texture to set.
  91843. */
  91844. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  91845. /**
  91846. * Sets an array of textures on the engine to be used in the shader.
  91847. * @param channel Name of the variable.
  91848. * @param textures Textures to set.
  91849. */
  91850. setTextureArray(channel: string, textures: BaseTexture[]): void;
  91851. /**
  91852. * 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)
  91853. * @param channel Name of the sampler variable.
  91854. * @param postProcess Post process to get the input texture from.
  91855. */
  91856. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  91857. /**
  91858. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  91859. * 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)
  91860. * @param channel Name of the sampler variable.
  91861. * @param postProcess Post process to get the output texture from.
  91862. */
  91863. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  91864. /** @hidden */
  91865. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  91866. /** @hidden */
  91867. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  91868. /** @hidden */
  91869. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  91870. /** @hidden */
  91871. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  91872. /**
  91873. * Binds a buffer to a uniform.
  91874. * @param buffer Buffer to bind.
  91875. * @param name Name of the uniform variable to bind to.
  91876. */
  91877. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  91878. /**
  91879. * Binds block to a uniform.
  91880. * @param blockName Name of the block to bind.
  91881. * @param index Index to bind.
  91882. */
  91883. bindUniformBlock(blockName: string, index: number): void;
  91884. /**
  91885. * Sets an interger value on a uniform variable.
  91886. * @param uniformName Name of the variable.
  91887. * @param value Value to be set.
  91888. * @returns this effect.
  91889. */
  91890. setInt(uniformName: string, value: number): Effect;
  91891. /**
  91892. * Sets an int array on a uniform variable.
  91893. * @param uniformName Name of the variable.
  91894. * @param array array to be set.
  91895. * @returns this effect.
  91896. */
  91897. setIntArray(uniformName: string, array: Int32Array): Effect;
  91898. /**
  91899. * 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)
  91900. * @param uniformName Name of the variable.
  91901. * @param array array to be set.
  91902. * @returns this effect.
  91903. */
  91904. setIntArray2(uniformName: string, array: Int32Array): Effect;
  91905. /**
  91906. * 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)
  91907. * @param uniformName Name of the variable.
  91908. * @param array array to be set.
  91909. * @returns this effect.
  91910. */
  91911. setIntArray3(uniformName: string, array: Int32Array): Effect;
  91912. /**
  91913. * 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)
  91914. * @param uniformName Name of the variable.
  91915. * @param array array to be set.
  91916. * @returns this effect.
  91917. */
  91918. setIntArray4(uniformName: string, array: Int32Array): Effect;
  91919. /**
  91920. * Sets an float array on a uniform variable.
  91921. * @param uniformName Name of the variable.
  91922. * @param array array to be set.
  91923. * @returns this effect.
  91924. */
  91925. setFloatArray(uniformName: string, array: Float32Array): Effect;
  91926. /**
  91927. * 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)
  91928. * @param uniformName Name of the variable.
  91929. * @param array array to be set.
  91930. * @returns this effect.
  91931. */
  91932. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  91933. /**
  91934. * 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)
  91935. * @param uniformName Name of the variable.
  91936. * @param array array to be set.
  91937. * @returns this effect.
  91938. */
  91939. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  91940. /**
  91941. * 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)
  91942. * @param uniformName Name of the variable.
  91943. * @param array array to be set.
  91944. * @returns this effect.
  91945. */
  91946. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  91947. /**
  91948. * Sets an array on a uniform variable.
  91949. * @param uniformName Name of the variable.
  91950. * @param array array to be set.
  91951. * @returns this effect.
  91952. */
  91953. setArray(uniformName: string, array: number[]): Effect;
  91954. /**
  91955. * 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)
  91956. * @param uniformName Name of the variable.
  91957. * @param array array to be set.
  91958. * @returns this effect.
  91959. */
  91960. setArray2(uniformName: string, array: number[]): Effect;
  91961. /**
  91962. * 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)
  91963. * @param uniformName Name of the variable.
  91964. * @param array array to be set.
  91965. * @returns this effect.
  91966. */
  91967. setArray3(uniformName: string, array: number[]): Effect;
  91968. /**
  91969. * 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)
  91970. * @param uniformName Name of the variable.
  91971. * @param array array to be set.
  91972. * @returns this effect.
  91973. */
  91974. setArray4(uniformName: string, array: number[]): Effect;
  91975. /**
  91976. * Sets matrices on a uniform variable.
  91977. * @param uniformName Name of the variable.
  91978. * @param matrices matrices to be set.
  91979. * @returns this effect.
  91980. */
  91981. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  91982. /**
  91983. * Sets matrix on a uniform variable.
  91984. * @param uniformName Name of the variable.
  91985. * @param matrix matrix to be set.
  91986. * @returns this effect.
  91987. */
  91988. setMatrix(uniformName: string, matrix: Matrix): Effect;
  91989. /**
  91990. * 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)
  91991. * @param uniformName Name of the variable.
  91992. * @param matrix matrix to be set.
  91993. * @returns this effect.
  91994. */
  91995. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  91996. /**
  91997. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  91998. * @param uniformName Name of the variable.
  91999. * @param matrix matrix to be set.
  92000. * @returns this effect.
  92001. */
  92002. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92003. /**
  92004. * Sets a float on a uniform variable.
  92005. * @param uniformName Name of the variable.
  92006. * @param value value to be set.
  92007. * @returns this effect.
  92008. */
  92009. setFloat(uniformName: string, value: number): Effect;
  92010. /**
  92011. * Sets a boolean on a uniform variable.
  92012. * @param uniformName Name of the variable.
  92013. * @param bool value to be set.
  92014. * @returns this effect.
  92015. */
  92016. setBool(uniformName: string, bool: boolean): Effect;
  92017. /**
  92018. * Sets a Vector2 on a uniform variable.
  92019. * @param uniformName Name of the variable.
  92020. * @param vector2 vector2 to be set.
  92021. * @returns this effect.
  92022. */
  92023. setVector2(uniformName: string, vector2: Vector2): Effect;
  92024. /**
  92025. * Sets a float2 on a uniform variable.
  92026. * @param uniformName Name of the variable.
  92027. * @param x First float in float2.
  92028. * @param y Second float in float2.
  92029. * @returns this effect.
  92030. */
  92031. setFloat2(uniformName: string, x: number, y: number): Effect;
  92032. /**
  92033. * Sets a Vector3 on a uniform variable.
  92034. * @param uniformName Name of the variable.
  92035. * @param vector3 Value to be set.
  92036. * @returns this effect.
  92037. */
  92038. setVector3(uniformName: string, vector3: Vector3): Effect;
  92039. /**
  92040. * Sets a float3 on a uniform variable.
  92041. * @param uniformName Name of the variable.
  92042. * @param x First float in float3.
  92043. * @param y Second float in float3.
  92044. * @param z Third float in float3.
  92045. * @returns this effect.
  92046. */
  92047. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92048. /**
  92049. * Sets a Vector4 on a uniform variable.
  92050. * @param uniformName Name of the variable.
  92051. * @param vector4 Value to be set.
  92052. * @returns this effect.
  92053. */
  92054. setVector4(uniformName: string, vector4: Vector4): Effect;
  92055. /**
  92056. * Sets a float4 on a uniform variable.
  92057. * @param uniformName Name of the variable.
  92058. * @param x First float in float4.
  92059. * @param y Second float in float4.
  92060. * @param z Third float in float4.
  92061. * @param w Fourth float in float4.
  92062. * @returns this effect.
  92063. */
  92064. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92065. /**
  92066. * Sets a Color3 on a uniform variable.
  92067. * @param uniformName Name of the variable.
  92068. * @param color3 Value to be set.
  92069. * @returns this effect.
  92070. */
  92071. setColor3(uniformName: string, color3: Color3): Effect;
  92072. /**
  92073. * Sets a Color4 on a uniform variable.
  92074. * @param uniformName Name of the variable.
  92075. * @param color3 Value to be set.
  92076. * @param alpha Alpha value to be set.
  92077. * @returns this effect.
  92078. */
  92079. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  92080. /**
  92081. * Sets a Color4 on a uniform variable
  92082. * @param uniformName defines the name of the variable
  92083. * @param color4 defines the value to be set
  92084. * @returns this effect.
  92085. */
  92086. setDirectColor4(uniformName: string, color4: Color4): Effect;
  92087. /** Release all associated resources */
  92088. dispose(): void;
  92089. /**
  92090. * This function will add a new shader to the shader store
  92091. * @param name the name of the shader
  92092. * @param pixelShader optional pixel shader content
  92093. * @param vertexShader optional vertex shader content
  92094. */
  92095. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92096. /**
  92097. * Store of each shader (The can be looked up using effect.key)
  92098. */
  92099. static ShadersStore: {
  92100. [key: string]: string;
  92101. };
  92102. /**
  92103. * Store of each included file for a shader (The can be looked up using effect.key)
  92104. */
  92105. static IncludesShadersStore: {
  92106. [key: string]: string;
  92107. };
  92108. /**
  92109. * Resets the cache of effects.
  92110. */
  92111. static ResetCache(): void;
  92112. }
  92113. }
  92114. declare module BABYLON {
  92115. /**
  92116. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92117. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92118. * 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;
  92119. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92120. */
  92121. export class ColorCurves {
  92122. private _dirty;
  92123. private _tempColor;
  92124. private _globalCurve;
  92125. private _highlightsCurve;
  92126. private _midtonesCurve;
  92127. private _shadowsCurve;
  92128. private _positiveCurve;
  92129. private _negativeCurve;
  92130. private _globalHue;
  92131. private _globalDensity;
  92132. private _globalSaturation;
  92133. private _globalExposure;
  92134. /**
  92135. * Gets the global Hue value.
  92136. * 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).
  92137. */
  92138. /**
  92139. * Sets the global Hue value.
  92140. * 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).
  92141. */
  92142. globalHue: number;
  92143. /**
  92144. * Gets the global Density value.
  92145. * 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.
  92146. * Values less than zero provide a filter of opposite hue.
  92147. */
  92148. /**
  92149. * Sets the global Density value.
  92150. * 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.
  92151. * Values less than zero provide a filter of opposite hue.
  92152. */
  92153. globalDensity: number;
  92154. /**
  92155. * Gets the global Saturation value.
  92156. * 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.
  92157. */
  92158. /**
  92159. * Sets the global Saturation value.
  92160. * 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.
  92161. */
  92162. globalSaturation: number;
  92163. /**
  92164. * Gets the global Exposure value.
  92165. * 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.
  92166. */
  92167. /**
  92168. * Sets the global Exposure value.
  92169. * 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.
  92170. */
  92171. globalExposure: number;
  92172. private _highlightsHue;
  92173. private _highlightsDensity;
  92174. private _highlightsSaturation;
  92175. private _highlightsExposure;
  92176. /**
  92177. * Gets the highlights Hue value.
  92178. * 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).
  92179. */
  92180. /**
  92181. * Sets the highlights Hue value.
  92182. * 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).
  92183. */
  92184. highlightsHue: number;
  92185. /**
  92186. * Gets the highlights Density value.
  92187. * 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.
  92188. * Values less than zero provide a filter of opposite hue.
  92189. */
  92190. /**
  92191. * Sets the highlights Density value.
  92192. * 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.
  92193. * Values less than zero provide a filter of opposite hue.
  92194. */
  92195. highlightsDensity: number;
  92196. /**
  92197. * Gets the highlights Saturation value.
  92198. * 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.
  92199. */
  92200. /**
  92201. * Sets the highlights Saturation value.
  92202. * 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.
  92203. */
  92204. highlightsSaturation: number;
  92205. /**
  92206. * Gets the highlights Exposure value.
  92207. * 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.
  92208. */
  92209. /**
  92210. * Sets the highlights Exposure value.
  92211. * 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.
  92212. */
  92213. highlightsExposure: number;
  92214. private _midtonesHue;
  92215. private _midtonesDensity;
  92216. private _midtonesSaturation;
  92217. private _midtonesExposure;
  92218. /**
  92219. * Gets the midtones Hue value.
  92220. * 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).
  92221. */
  92222. /**
  92223. * Sets the midtones Hue value.
  92224. * 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).
  92225. */
  92226. midtonesHue: number;
  92227. /**
  92228. * Gets the midtones Density value.
  92229. * 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.
  92230. * Values less than zero provide a filter of opposite hue.
  92231. */
  92232. /**
  92233. * Sets the midtones Density value.
  92234. * 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.
  92235. * Values less than zero provide a filter of opposite hue.
  92236. */
  92237. midtonesDensity: number;
  92238. /**
  92239. * Gets the midtones Saturation value.
  92240. * 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.
  92241. */
  92242. /**
  92243. * Sets the midtones Saturation value.
  92244. * 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.
  92245. */
  92246. midtonesSaturation: number;
  92247. /**
  92248. * Gets the midtones Exposure value.
  92249. * 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.
  92250. */
  92251. /**
  92252. * Sets the midtones Exposure value.
  92253. * 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.
  92254. */
  92255. midtonesExposure: number;
  92256. private _shadowsHue;
  92257. private _shadowsDensity;
  92258. private _shadowsSaturation;
  92259. private _shadowsExposure;
  92260. /**
  92261. * Gets the shadows Hue value.
  92262. * 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).
  92263. */
  92264. /**
  92265. * Sets the shadows Hue value.
  92266. * 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).
  92267. */
  92268. shadowsHue: number;
  92269. /**
  92270. * Gets the shadows Density value.
  92271. * 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.
  92272. * Values less than zero provide a filter of opposite hue.
  92273. */
  92274. /**
  92275. * Sets the shadows Density value.
  92276. * 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.
  92277. * Values less than zero provide a filter of opposite hue.
  92278. */
  92279. shadowsDensity: number;
  92280. /**
  92281. * Gets the shadows Saturation value.
  92282. * 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.
  92283. */
  92284. /**
  92285. * Sets the shadows Saturation value.
  92286. * 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.
  92287. */
  92288. shadowsSaturation: number;
  92289. /**
  92290. * Gets the shadows Exposure value.
  92291. * 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.
  92292. */
  92293. /**
  92294. * Sets the shadows Exposure value.
  92295. * 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.
  92296. */
  92297. shadowsExposure: number;
  92298. /**
  92299. * Returns the class name
  92300. * @returns The class name
  92301. */
  92302. getClassName(): string;
  92303. /**
  92304. * Binds the color curves to the shader.
  92305. * @param colorCurves The color curve to bind
  92306. * @param effect The effect to bind to
  92307. * @param positiveUniform The positive uniform shader parameter
  92308. * @param neutralUniform The neutral uniform shader parameter
  92309. * @param negativeUniform The negative uniform shader parameter
  92310. */
  92311. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92312. /**
  92313. * Prepare the list of uniforms associated with the ColorCurves effects.
  92314. * @param uniformsList The list of uniforms used in the effect
  92315. */
  92316. static PrepareUniforms(uniformsList: string[]): void;
  92317. /**
  92318. * Returns color grading data based on a hue, density, saturation and exposure value.
  92319. * @param filterHue The hue of the color filter.
  92320. * @param filterDensity The density of the color filter.
  92321. * @param saturation The saturation.
  92322. * @param exposure The exposure.
  92323. * @param result The result data container.
  92324. */
  92325. private getColorGradingDataToRef;
  92326. /**
  92327. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  92328. * @param value The input slider value in range [-100,100].
  92329. * @returns Adjusted value.
  92330. */
  92331. private static applyColorGradingSliderNonlinear;
  92332. /**
  92333. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  92334. * @param hue The hue (H) input.
  92335. * @param saturation The saturation (S) input.
  92336. * @param brightness The brightness (B) input.
  92337. * @result An RGBA color represented as Vector4.
  92338. */
  92339. private static fromHSBToRef;
  92340. /**
  92341. * Returns a value clamped between min and max
  92342. * @param value The value to clamp
  92343. * @param min The minimum of value
  92344. * @param max The maximum of value
  92345. * @returns The clamped value.
  92346. */
  92347. private static clamp;
  92348. /**
  92349. * Clones the current color curve instance.
  92350. * @return The cloned curves
  92351. */
  92352. clone(): ColorCurves;
  92353. /**
  92354. * Serializes the current color curve instance to a json representation.
  92355. * @return a JSON representation
  92356. */
  92357. serialize(): any;
  92358. /**
  92359. * Parses the color curve from a json representation.
  92360. * @param source the JSON source to parse
  92361. * @return The parsed curves
  92362. */
  92363. static Parse(source: any): ColorCurves;
  92364. }
  92365. }
  92366. declare module BABYLON {
  92367. /**
  92368. * Interface to follow in your material defines to integrate easily the
  92369. * Image proccessing functions.
  92370. * @hidden
  92371. */
  92372. export interface IImageProcessingConfigurationDefines {
  92373. IMAGEPROCESSING: boolean;
  92374. VIGNETTE: boolean;
  92375. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92376. VIGNETTEBLENDMODEOPAQUE: boolean;
  92377. TONEMAPPING: boolean;
  92378. TONEMAPPING_ACES: boolean;
  92379. CONTRAST: boolean;
  92380. EXPOSURE: boolean;
  92381. COLORCURVES: boolean;
  92382. COLORGRADING: boolean;
  92383. COLORGRADING3D: boolean;
  92384. SAMPLER3DGREENDEPTH: boolean;
  92385. SAMPLER3DBGRMAP: boolean;
  92386. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92387. }
  92388. /**
  92389. * @hidden
  92390. */
  92391. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  92392. IMAGEPROCESSING: boolean;
  92393. VIGNETTE: boolean;
  92394. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92395. VIGNETTEBLENDMODEOPAQUE: boolean;
  92396. TONEMAPPING: boolean;
  92397. TONEMAPPING_ACES: boolean;
  92398. CONTRAST: boolean;
  92399. COLORCURVES: boolean;
  92400. COLORGRADING: boolean;
  92401. COLORGRADING3D: boolean;
  92402. SAMPLER3DGREENDEPTH: boolean;
  92403. SAMPLER3DBGRMAP: boolean;
  92404. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92405. EXPOSURE: boolean;
  92406. constructor();
  92407. }
  92408. /**
  92409. * This groups together the common properties used for image processing either in direct forward pass
  92410. * or through post processing effect depending on the use of the image processing pipeline in your scene
  92411. * or not.
  92412. */
  92413. export class ImageProcessingConfiguration {
  92414. /**
  92415. * Default tone mapping applied in BabylonJS.
  92416. */
  92417. static readonly TONEMAPPING_STANDARD: number;
  92418. /**
  92419. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  92420. * to other engines rendering to increase portability.
  92421. */
  92422. static readonly TONEMAPPING_ACES: number;
  92423. /**
  92424. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  92425. */
  92426. colorCurves: Nullable<ColorCurves>;
  92427. private _colorCurvesEnabled;
  92428. /**
  92429. * Gets wether the color curves effect is enabled.
  92430. */
  92431. /**
  92432. * Sets wether the color curves effect is enabled.
  92433. */
  92434. colorCurvesEnabled: boolean;
  92435. private _colorGradingTexture;
  92436. /**
  92437. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92438. */
  92439. /**
  92440. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92441. */
  92442. colorGradingTexture: Nullable<BaseTexture>;
  92443. private _colorGradingEnabled;
  92444. /**
  92445. * Gets wether the color grading effect is enabled.
  92446. */
  92447. /**
  92448. * Sets wether the color grading effect is enabled.
  92449. */
  92450. colorGradingEnabled: boolean;
  92451. private _colorGradingWithGreenDepth;
  92452. /**
  92453. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  92454. */
  92455. /**
  92456. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  92457. */
  92458. colorGradingWithGreenDepth: boolean;
  92459. private _colorGradingBGR;
  92460. /**
  92461. * Gets wether the color grading texture contains BGR values.
  92462. */
  92463. /**
  92464. * Sets wether the color grading texture contains BGR values.
  92465. */
  92466. colorGradingBGR: boolean;
  92467. /** @hidden */
  92468. _exposure: number;
  92469. /**
  92470. * Gets the Exposure used in the effect.
  92471. */
  92472. /**
  92473. * Sets the Exposure used in the effect.
  92474. */
  92475. exposure: number;
  92476. private _toneMappingEnabled;
  92477. /**
  92478. * Gets wether the tone mapping effect is enabled.
  92479. */
  92480. /**
  92481. * Sets wether the tone mapping effect is enabled.
  92482. */
  92483. toneMappingEnabled: boolean;
  92484. private _toneMappingType;
  92485. /**
  92486. * Gets the type of tone mapping effect.
  92487. */
  92488. /**
  92489. * Sets the type of tone mapping effect used in BabylonJS.
  92490. */
  92491. toneMappingType: number;
  92492. protected _contrast: number;
  92493. /**
  92494. * Gets the contrast used in the effect.
  92495. */
  92496. /**
  92497. * Sets the contrast used in the effect.
  92498. */
  92499. contrast: number;
  92500. /**
  92501. * Vignette stretch size.
  92502. */
  92503. vignetteStretch: number;
  92504. /**
  92505. * Vignette centre X Offset.
  92506. */
  92507. vignetteCentreX: number;
  92508. /**
  92509. * Vignette centre Y Offset.
  92510. */
  92511. vignetteCentreY: number;
  92512. /**
  92513. * Vignette weight or intensity of the vignette effect.
  92514. */
  92515. vignetteWeight: number;
  92516. /**
  92517. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  92518. * if vignetteEnabled is set to true.
  92519. */
  92520. vignetteColor: Color4;
  92521. /**
  92522. * Camera field of view used by the Vignette effect.
  92523. */
  92524. vignetteCameraFov: number;
  92525. private _vignetteBlendMode;
  92526. /**
  92527. * Gets the vignette blend mode allowing different kind of effect.
  92528. */
  92529. /**
  92530. * Sets the vignette blend mode allowing different kind of effect.
  92531. */
  92532. vignetteBlendMode: number;
  92533. private _vignetteEnabled;
  92534. /**
  92535. * Gets wether the vignette effect is enabled.
  92536. */
  92537. /**
  92538. * Sets wether the vignette effect is enabled.
  92539. */
  92540. vignetteEnabled: boolean;
  92541. private _applyByPostProcess;
  92542. /**
  92543. * Gets wether the image processing is applied through a post process or not.
  92544. */
  92545. /**
  92546. * Sets wether the image processing is applied through a post process or not.
  92547. */
  92548. applyByPostProcess: boolean;
  92549. private _isEnabled;
  92550. /**
  92551. * Gets wether the image processing is enabled or not.
  92552. */
  92553. /**
  92554. * Sets wether the image processing is enabled or not.
  92555. */
  92556. isEnabled: boolean;
  92557. /**
  92558. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  92559. */
  92560. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  92561. /**
  92562. * Method called each time the image processing information changes requires to recompile the effect.
  92563. */
  92564. protected _updateParameters(): void;
  92565. /**
  92566. * Gets the current class name.
  92567. * @return "ImageProcessingConfiguration"
  92568. */
  92569. getClassName(): string;
  92570. /**
  92571. * Prepare the list of uniforms associated with the Image Processing effects.
  92572. * @param uniforms The list of uniforms used in the effect
  92573. * @param defines the list of defines currently in use
  92574. */
  92575. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  92576. /**
  92577. * Prepare the list of samplers associated with the Image Processing effects.
  92578. * @param samplersList The list of uniforms used in the effect
  92579. * @param defines the list of defines currently in use
  92580. */
  92581. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  92582. /**
  92583. * Prepare the list of defines associated to the shader.
  92584. * @param defines the list of defines to complete
  92585. * @param forPostProcess Define if we are currently in post process mode or not
  92586. */
  92587. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  92588. /**
  92589. * Returns true if all the image processing information are ready.
  92590. * @returns True if ready, otherwise, false
  92591. */
  92592. isReady(): boolean;
  92593. /**
  92594. * Binds the image processing to the shader.
  92595. * @param effect The effect to bind to
  92596. * @param aspectRatio Define the current aspect ratio of the effect
  92597. */
  92598. bind(effect: Effect, aspectRatio?: number): void;
  92599. /**
  92600. * Clones the current image processing instance.
  92601. * @return The cloned image processing
  92602. */
  92603. clone(): ImageProcessingConfiguration;
  92604. /**
  92605. * Serializes the current image processing instance to a json representation.
  92606. * @return a JSON representation
  92607. */
  92608. serialize(): any;
  92609. /**
  92610. * Parses the image processing from a json representation.
  92611. * @param source the JSON source to parse
  92612. * @return The parsed image processing
  92613. */
  92614. static Parse(source: any): ImageProcessingConfiguration;
  92615. private static _VIGNETTEMODE_MULTIPLY;
  92616. private static _VIGNETTEMODE_OPAQUE;
  92617. /**
  92618. * Used to apply the vignette as a mix with the pixel color.
  92619. */
  92620. static readonly VIGNETTEMODE_MULTIPLY: number;
  92621. /**
  92622. * Used to apply the vignette as a replacement of the pixel color.
  92623. */
  92624. static readonly VIGNETTEMODE_OPAQUE: number;
  92625. }
  92626. }
  92627. declare module BABYLON {
  92628. /**
  92629. * This represents all the required information to add a fresnel effect on a material:
  92630. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  92631. */
  92632. export class FresnelParameters {
  92633. private _isEnabled;
  92634. /**
  92635. * Define if the fresnel effect is enable or not.
  92636. */
  92637. isEnabled: boolean;
  92638. /**
  92639. * Define the color used on edges (grazing angle)
  92640. */
  92641. leftColor: Color3;
  92642. /**
  92643. * Define the color used on center
  92644. */
  92645. rightColor: Color3;
  92646. /**
  92647. * Define bias applied to computed fresnel term
  92648. */
  92649. bias: number;
  92650. /**
  92651. * Defined the power exponent applied to fresnel term
  92652. */
  92653. power: number;
  92654. /**
  92655. * Clones the current fresnel and its valuues
  92656. * @returns a clone fresnel configuration
  92657. */
  92658. clone(): FresnelParameters;
  92659. /**
  92660. * Serializes the current fresnel parameters to a JSON representation.
  92661. * @return the JSON serialization
  92662. */
  92663. serialize(): any;
  92664. /**
  92665. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  92666. * @param parsedFresnelParameters Define the JSON representation
  92667. * @returns the parsed parameters
  92668. */
  92669. static Parse(parsedFresnelParameters: any): FresnelParameters;
  92670. }
  92671. }
  92672. declare module BABYLON {
  92673. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  92674. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92675. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92676. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92677. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92678. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92679. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92680. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92681. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92682. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92683. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92684. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92685. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92686. /**
  92687. * Decorator used to define property that can be serialized as reference to a camera
  92688. * @param sourceName defines the name of the property to decorate
  92689. */
  92690. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92691. /**
  92692. * Class used to help serialization objects
  92693. */
  92694. export class SerializationHelper {
  92695. /** @hidden */
  92696. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  92697. /** @hidden */
  92698. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  92699. /** @hidden */
  92700. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  92701. /** @hidden */
  92702. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  92703. /**
  92704. * Appends the serialized animations from the source animations
  92705. * @param source Source containing the animations
  92706. * @param destination Target to store the animations
  92707. */
  92708. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92709. /**
  92710. * Static function used to serialized a specific entity
  92711. * @param entity defines the entity to serialize
  92712. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  92713. * @returns a JSON compatible object representing the serialization of the entity
  92714. */
  92715. static Serialize<T>(entity: T, serializationObject?: any): any;
  92716. /**
  92717. * Creates a new entity from a serialization data object
  92718. * @param creationFunction defines a function used to instanciated the new entity
  92719. * @param source defines the source serialization data
  92720. * @param scene defines the hosting scene
  92721. * @param rootUrl defines the root url for resources
  92722. * @returns a new entity
  92723. */
  92724. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  92725. /**
  92726. * Clones an object
  92727. * @param creationFunction defines the function used to instanciate the new object
  92728. * @param source defines the source object
  92729. * @returns the cloned object
  92730. */
  92731. static Clone<T>(creationFunction: () => T, source: T): T;
  92732. /**
  92733. * Instanciates a new object based on a source one (some data will be shared between both object)
  92734. * @param creationFunction defines the function used to instanciate the new object
  92735. * @param source defines the source object
  92736. * @returns the new object
  92737. */
  92738. static Instanciate<T>(creationFunction: () => T, source: T): T;
  92739. }
  92740. }
  92741. declare module BABYLON {
  92742. /**
  92743. * This is the base class of all the camera used in the application.
  92744. * @see http://doc.babylonjs.com/features/cameras
  92745. */
  92746. export class Camera extends Node {
  92747. /** @hidden */
  92748. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92749. /**
  92750. * This is the default projection mode used by the cameras.
  92751. * It helps recreating a feeling of perspective and better appreciate depth.
  92752. * This is the best way to simulate real life cameras.
  92753. */
  92754. static readonly PERSPECTIVE_CAMERA: number;
  92755. /**
  92756. * This helps creating camera with an orthographic mode.
  92757. * 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.
  92758. */
  92759. static readonly ORTHOGRAPHIC_CAMERA: number;
  92760. /**
  92761. * This is the default FOV mode for perspective cameras.
  92762. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  92763. */
  92764. static readonly FOVMODE_VERTICAL_FIXED: number;
  92765. /**
  92766. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  92767. */
  92768. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  92769. /**
  92770. * This specifies ther is no need for a camera rig.
  92771. * Basically only one eye is rendered corresponding to the camera.
  92772. */
  92773. static readonly RIG_MODE_NONE: number;
  92774. /**
  92775. * Simulates a camera Rig with one blue eye and one red eye.
  92776. * This can be use with 3d blue and red glasses.
  92777. */
  92778. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  92779. /**
  92780. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  92781. */
  92782. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  92783. /**
  92784. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  92785. */
  92786. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  92787. /**
  92788. * Defines that both eyes of the camera will be rendered over under each other.
  92789. */
  92790. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  92791. /**
  92792. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  92793. */
  92794. static readonly RIG_MODE_VR: number;
  92795. /**
  92796. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  92797. */
  92798. static readonly RIG_MODE_WEBVR: number;
  92799. /**
  92800. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  92801. */
  92802. static readonly RIG_MODE_CUSTOM: number;
  92803. /**
  92804. * Defines if by default attaching controls should prevent the default javascript event to continue.
  92805. */
  92806. static ForceAttachControlToAlwaysPreventDefault: boolean;
  92807. /**
  92808. * Define the input manager associated with the camera.
  92809. */
  92810. inputs: CameraInputsManager<Camera>;
  92811. /** @hidden */
  92812. _position: Vector3;
  92813. /**
  92814. * Define the current local position of the camera in the scene
  92815. */
  92816. position: Vector3;
  92817. /**
  92818. * The vector the camera should consider as up.
  92819. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  92820. */
  92821. upVector: Vector3;
  92822. /**
  92823. * Define the current limit on the left side for an orthographic camera
  92824. * In scene unit
  92825. */
  92826. orthoLeft: Nullable<number>;
  92827. /**
  92828. * Define the current limit on the right side for an orthographic camera
  92829. * In scene unit
  92830. */
  92831. orthoRight: Nullable<number>;
  92832. /**
  92833. * Define the current limit on the bottom side for an orthographic camera
  92834. * In scene unit
  92835. */
  92836. orthoBottom: Nullable<number>;
  92837. /**
  92838. * Define the current limit on the top side for an orthographic camera
  92839. * In scene unit
  92840. */
  92841. orthoTop: Nullable<number>;
  92842. /**
  92843. * Field Of View is set in Radians. (default is 0.8)
  92844. */
  92845. fov: number;
  92846. /**
  92847. * Define the minimum distance the camera can see from.
  92848. * This is important to note that the depth buffer are not infinite and the closer it starts
  92849. * the more your scene might encounter depth fighting issue.
  92850. */
  92851. minZ: number;
  92852. /**
  92853. * Define the maximum distance the camera can see to.
  92854. * This is important to note that the depth buffer are not infinite and the further it end
  92855. * the more your scene might encounter depth fighting issue.
  92856. */
  92857. maxZ: number;
  92858. /**
  92859. * Define the default inertia of the camera.
  92860. * This helps giving a smooth feeling to the camera movement.
  92861. */
  92862. inertia: number;
  92863. /**
  92864. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  92865. */
  92866. mode: number;
  92867. /**
  92868. * Define wether the camera is intermediate.
  92869. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  92870. */
  92871. isIntermediate: boolean;
  92872. /**
  92873. * Define the viewport of the camera.
  92874. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  92875. */
  92876. viewport: Viewport;
  92877. /**
  92878. * Restricts the camera to viewing objects with the same layerMask.
  92879. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  92880. */
  92881. layerMask: number;
  92882. /**
  92883. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  92884. */
  92885. fovMode: number;
  92886. /**
  92887. * Rig mode of the camera.
  92888. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  92889. * This is normally controlled byt the camera themselves as internal use.
  92890. */
  92891. cameraRigMode: number;
  92892. /**
  92893. * Defines the distance between both "eyes" in case of a RIG
  92894. */
  92895. interaxialDistance: number;
  92896. /**
  92897. * Defines if stereoscopic rendering is done side by side or over under.
  92898. */
  92899. isStereoscopicSideBySide: boolean;
  92900. /**
  92901. * 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
  92902. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  92903. * else in the scene.
  92904. */
  92905. customRenderTargets: RenderTargetTexture[];
  92906. /**
  92907. * When set, the camera will render to this render target instead of the default canvas
  92908. */
  92909. outputRenderTarget: Nullable<RenderTargetTexture>;
  92910. /**
  92911. * Observable triggered when the camera view matrix has changed.
  92912. */
  92913. onViewMatrixChangedObservable: Observable<Camera>;
  92914. /**
  92915. * Observable triggered when the camera Projection matrix has changed.
  92916. */
  92917. onProjectionMatrixChangedObservable: Observable<Camera>;
  92918. /**
  92919. * Observable triggered when the inputs have been processed.
  92920. */
  92921. onAfterCheckInputsObservable: Observable<Camera>;
  92922. /**
  92923. * Observable triggered when reset has been called and applied to the camera.
  92924. */
  92925. onRestoreStateObservable: Observable<Camera>;
  92926. /** @hidden */
  92927. _cameraRigParams: any;
  92928. /** @hidden */
  92929. _rigCameras: Camera[];
  92930. /** @hidden */
  92931. _rigPostProcess: Nullable<PostProcess>;
  92932. protected _webvrViewMatrix: Matrix;
  92933. /** @hidden */
  92934. _skipRendering: boolean;
  92935. /** @hidden */
  92936. _projectionMatrix: Matrix;
  92937. /** @hidden */
  92938. _postProcesses: Nullable<PostProcess>[];
  92939. /** @hidden */
  92940. _activeMeshes: SmartArray<AbstractMesh>;
  92941. protected _globalPosition: Vector3;
  92942. /** @hidden */
  92943. _computedViewMatrix: Matrix;
  92944. private _doNotComputeProjectionMatrix;
  92945. private _transformMatrix;
  92946. private _frustumPlanes;
  92947. private _refreshFrustumPlanes;
  92948. private _storedFov;
  92949. private _stateStored;
  92950. /**
  92951. * Instantiates a new camera object.
  92952. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  92953. * @see http://doc.babylonjs.com/features/cameras
  92954. * @param name Defines the name of the camera in the scene
  92955. * @param position Defines the position of the camera
  92956. * @param scene Defines the scene the camera belongs too
  92957. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  92958. */
  92959. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92960. /**
  92961. * Store current camera state (fov, position, etc..)
  92962. * @returns the camera
  92963. */
  92964. storeState(): Camera;
  92965. /**
  92966. * Restores the camera state values if it has been stored. You must call storeState() first
  92967. */
  92968. protected _restoreStateValues(): boolean;
  92969. /**
  92970. * Restored camera state. You must call storeState() first.
  92971. * @returns true if restored and false otherwise
  92972. */
  92973. restoreState(): boolean;
  92974. /**
  92975. * Gets the class name of the camera.
  92976. * @returns the class name
  92977. */
  92978. getClassName(): string;
  92979. /** @hidden */
  92980. readonly _isCamera: boolean;
  92981. /**
  92982. * Gets a string representation of the camera useful for debug purpose.
  92983. * @param fullDetails Defines that a more verboe level of logging is required
  92984. * @returns the string representation
  92985. */
  92986. toString(fullDetails?: boolean): string;
  92987. /**
  92988. * Gets the current world space position of the camera.
  92989. */
  92990. readonly globalPosition: Vector3;
  92991. /**
  92992. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  92993. * @returns the active meshe list
  92994. */
  92995. getActiveMeshes(): SmartArray<AbstractMesh>;
  92996. /**
  92997. * Check wether a mesh is part of the current active mesh list of the camera
  92998. * @param mesh Defines the mesh to check
  92999. * @returns true if active, false otherwise
  93000. */
  93001. isActiveMesh(mesh: Mesh): boolean;
  93002. /**
  93003. * Is this camera ready to be used/rendered
  93004. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93005. * @return true if the camera is ready
  93006. */
  93007. isReady(completeCheck?: boolean): boolean;
  93008. /** @hidden */
  93009. _initCache(): void;
  93010. /** @hidden */
  93011. _updateCache(ignoreParentClass?: boolean): void;
  93012. /** @hidden */
  93013. _isSynchronized(): boolean;
  93014. /** @hidden */
  93015. _isSynchronizedViewMatrix(): boolean;
  93016. /** @hidden */
  93017. _isSynchronizedProjectionMatrix(): boolean;
  93018. /**
  93019. * Attach the input controls to a specific dom element to get the input from.
  93020. * @param element Defines the element the controls should be listened from
  93021. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93022. */
  93023. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93024. /**
  93025. * Detach the current controls from the specified dom element.
  93026. * @param element Defines the element to stop listening the inputs from
  93027. */
  93028. detachControl(element: HTMLElement): void;
  93029. /**
  93030. * Update the camera state according to the different inputs gathered during the frame.
  93031. */
  93032. update(): void;
  93033. /** @hidden */
  93034. _checkInputs(): void;
  93035. /** @hidden */
  93036. readonly rigCameras: Camera[];
  93037. /**
  93038. * Gets the post process used by the rig cameras
  93039. */
  93040. readonly rigPostProcess: Nullable<PostProcess>;
  93041. /**
  93042. * Internal, gets the first post proces.
  93043. * @returns the first post process to be run on this camera.
  93044. */
  93045. _getFirstPostProcess(): Nullable<PostProcess>;
  93046. private _cascadePostProcessesToRigCams;
  93047. /**
  93048. * Attach a post process to the camera.
  93049. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93050. * @param postProcess The post process to attach to the camera
  93051. * @param insertAt The position of the post process in case several of them are in use in the scene
  93052. * @returns the position the post process has been inserted at
  93053. */
  93054. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93055. /**
  93056. * Detach a post process to the camera.
  93057. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93058. * @param postProcess The post process to detach from the camera
  93059. */
  93060. detachPostProcess(postProcess: PostProcess): void;
  93061. /**
  93062. * Gets the current world matrix of the camera
  93063. */
  93064. getWorldMatrix(): Matrix;
  93065. /** @hidden */
  93066. _getViewMatrix(): Matrix;
  93067. /**
  93068. * Gets the current view matrix of the camera.
  93069. * @param force forces the camera to recompute the matrix without looking at the cached state
  93070. * @returns the view matrix
  93071. */
  93072. getViewMatrix(force?: boolean): Matrix;
  93073. /**
  93074. * Freeze the projection matrix.
  93075. * It will prevent the cache check of the camera projection compute and can speed up perf
  93076. * if no parameter of the camera are meant to change
  93077. * @param projection Defines manually a projection if necessary
  93078. */
  93079. freezeProjectionMatrix(projection?: Matrix): void;
  93080. /**
  93081. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93082. */
  93083. unfreezeProjectionMatrix(): void;
  93084. /**
  93085. * Gets the current projection matrix of the camera.
  93086. * @param force forces the camera to recompute the matrix without looking at the cached state
  93087. * @returns the projection matrix
  93088. */
  93089. getProjectionMatrix(force?: boolean): Matrix;
  93090. /**
  93091. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93092. * @returns a Matrix
  93093. */
  93094. getTransformationMatrix(): Matrix;
  93095. private _updateFrustumPlanes;
  93096. /**
  93097. * Checks if a cullable object (mesh...) is in the camera frustum
  93098. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93099. * @param target The object to check
  93100. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93101. * @returns true if the object is in frustum otherwise false
  93102. */
  93103. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93104. /**
  93105. * Checks if a cullable object (mesh...) is in the camera frustum
  93106. * Unlike isInFrustum this cheks the full bounding box
  93107. * @param target The object to check
  93108. * @returns true if the object is in frustum otherwise false
  93109. */
  93110. isCompletelyInFrustum(target: ICullable): boolean;
  93111. /**
  93112. * Gets a ray in the forward direction from the camera.
  93113. * @param length Defines the length of the ray to create
  93114. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93115. * @param origin Defines the start point of the ray which defaults to the camera position
  93116. * @returns the forward ray
  93117. */
  93118. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93119. /**
  93120. * Releases resources associated with this node.
  93121. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93122. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93123. */
  93124. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93125. /** @hidden */
  93126. _isLeftCamera: boolean;
  93127. /**
  93128. * Gets the left camera of a rig setup in case of Rigged Camera
  93129. */
  93130. readonly isLeftCamera: boolean;
  93131. /** @hidden */
  93132. _isRightCamera: boolean;
  93133. /**
  93134. * Gets the right camera of a rig setup in case of Rigged Camera
  93135. */
  93136. readonly isRightCamera: boolean;
  93137. /**
  93138. * Gets the left camera of a rig setup in case of Rigged Camera
  93139. */
  93140. readonly leftCamera: Nullable<FreeCamera>;
  93141. /**
  93142. * Gets the right camera of a rig setup in case of Rigged Camera
  93143. */
  93144. readonly rightCamera: Nullable<FreeCamera>;
  93145. /**
  93146. * Gets the left camera target of a rig setup in case of Rigged Camera
  93147. * @returns the target position
  93148. */
  93149. getLeftTarget(): Nullable<Vector3>;
  93150. /**
  93151. * Gets the right camera target of a rig setup in case of Rigged Camera
  93152. * @returns the target position
  93153. */
  93154. getRightTarget(): Nullable<Vector3>;
  93155. /**
  93156. * @hidden
  93157. */
  93158. setCameraRigMode(mode: number, rigParams: any): void;
  93159. /** @hidden */
  93160. static _setStereoscopicRigMode(camera: Camera): void;
  93161. /** @hidden */
  93162. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93163. /** @hidden */
  93164. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93165. /** @hidden */
  93166. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93167. /** @hidden */
  93168. _getVRProjectionMatrix(): Matrix;
  93169. protected _updateCameraRotationMatrix(): void;
  93170. protected _updateWebVRCameraRotationMatrix(): void;
  93171. /**
  93172. * This function MUST be overwritten by the different WebVR cameras available.
  93173. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93174. * @hidden
  93175. */
  93176. _getWebVRProjectionMatrix(): Matrix;
  93177. /**
  93178. * This function MUST be overwritten by the different WebVR cameras available.
  93179. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93180. * @hidden
  93181. */
  93182. _getWebVRViewMatrix(): Matrix;
  93183. /** @hidden */
  93184. setCameraRigParameter(name: string, value: any): void;
  93185. /**
  93186. * needs to be overridden by children so sub has required properties to be copied
  93187. * @hidden
  93188. */
  93189. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93190. /**
  93191. * May need to be overridden by children
  93192. * @hidden
  93193. */
  93194. _updateRigCameras(): void;
  93195. /** @hidden */
  93196. _setupInputs(): void;
  93197. /**
  93198. * Serialiaze the camera setup to a json represention
  93199. * @returns the JSON representation
  93200. */
  93201. serialize(): any;
  93202. /**
  93203. * Clones the current camera.
  93204. * @param name The cloned camera name
  93205. * @returns the cloned camera
  93206. */
  93207. clone(name: string): Camera;
  93208. /**
  93209. * Gets the direction of the camera relative to a given local axis.
  93210. * @param localAxis Defines the reference axis to provide a relative direction.
  93211. * @return the direction
  93212. */
  93213. getDirection(localAxis: Vector3): Vector3;
  93214. /**
  93215. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93216. * @param localAxis Defines the reference axis to provide a relative direction.
  93217. * @param result Defines the vector to store the result in
  93218. */
  93219. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93220. /**
  93221. * Gets a camera constructor for a given camera type
  93222. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93223. * @param name The name of the camera the result will be able to instantiate
  93224. * @param scene The scene the result will construct the camera in
  93225. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93226. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93227. * @returns a factory method to construc the camera
  93228. */
  93229. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93230. /**
  93231. * Compute the world matrix of the camera.
  93232. * @returns the camera workd matrix
  93233. */
  93234. computeWorldMatrix(): Matrix;
  93235. /**
  93236. * Parse a JSON and creates the camera from the parsed information
  93237. * @param parsedCamera The JSON to parse
  93238. * @param scene The scene to instantiate the camera in
  93239. * @returns the newly constructed camera
  93240. */
  93241. static Parse(parsedCamera: any, scene: Scene): Camera;
  93242. }
  93243. }
  93244. declare module BABYLON {
  93245. /**
  93246. * Interface for any object that can request an animation frame
  93247. */
  93248. export interface ICustomAnimationFrameRequester {
  93249. /**
  93250. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93251. */
  93252. renderFunction?: Function;
  93253. /**
  93254. * Called to request the next frame to render to
  93255. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93256. */
  93257. requestAnimationFrame: Function;
  93258. /**
  93259. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93260. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93261. */
  93262. requestID?: number;
  93263. }
  93264. /**
  93265. * Interface containing an array of animations
  93266. */
  93267. export interface IAnimatable {
  93268. /**
  93269. * Array of animations
  93270. */
  93271. animations: Nullable<Array<Animation>>;
  93272. }
  93273. /** Interface used by value gradients (color, factor, ...) */
  93274. export interface IValueGradient {
  93275. /**
  93276. * Gets or sets the gradient value (between 0 and 1)
  93277. */
  93278. gradient: number;
  93279. }
  93280. /** Class used to store color4 gradient */
  93281. export class ColorGradient implements IValueGradient {
  93282. /**
  93283. * Gets or sets the gradient value (between 0 and 1)
  93284. */
  93285. gradient: number;
  93286. /**
  93287. * Gets or sets first associated color
  93288. */
  93289. color1: Color4;
  93290. /**
  93291. * Gets or sets second associated color
  93292. */
  93293. color2?: Color4;
  93294. /**
  93295. * Will get a color picked randomly between color1 and color2.
  93296. * If color2 is undefined then color1 will be used
  93297. * @param result defines the target Color4 to store the result in
  93298. */
  93299. getColorToRef(result: Color4): void;
  93300. }
  93301. /** Class used to store color 3 gradient */
  93302. export class Color3Gradient implements IValueGradient {
  93303. /**
  93304. * Gets or sets the gradient value (between 0 and 1)
  93305. */
  93306. gradient: number;
  93307. /**
  93308. * Gets or sets the associated color
  93309. */
  93310. color: Color3;
  93311. }
  93312. /** Class used to store factor gradient */
  93313. export class FactorGradient implements IValueGradient {
  93314. /**
  93315. * Gets or sets the gradient value (between 0 and 1)
  93316. */
  93317. gradient: number;
  93318. /**
  93319. * Gets or sets first associated factor
  93320. */
  93321. factor1: number;
  93322. /**
  93323. * Gets or sets second associated factor
  93324. */
  93325. factor2?: number;
  93326. /**
  93327. * Will get a number picked randomly between factor1 and factor2.
  93328. * If factor2 is undefined then factor1 will be used
  93329. * @returns the picked number
  93330. */
  93331. getFactor(): number;
  93332. }
  93333. /**
  93334. * @ignore
  93335. * Application error to support additional information when loading a file
  93336. */
  93337. export class LoadFileError extends Error {
  93338. /** defines the optional web request */
  93339. request?: WebRequest | undefined;
  93340. private static _setPrototypeOf;
  93341. /**
  93342. * Creates a new LoadFileError
  93343. * @param message defines the message of the error
  93344. * @param request defines the optional web request
  93345. */
  93346. constructor(message: string,
  93347. /** defines the optional web request */
  93348. request?: WebRequest | undefined);
  93349. }
  93350. /**
  93351. * Class used to define a retry strategy when error happens while loading assets
  93352. */
  93353. export class RetryStrategy {
  93354. /**
  93355. * Function used to defines an exponential back off strategy
  93356. * @param maxRetries defines the maximum number of retries (3 by default)
  93357. * @param baseInterval defines the interval between retries
  93358. * @returns the strategy function to use
  93359. */
  93360. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  93361. }
  93362. /**
  93363. * File request interface
  93364. */
  93365. export interface IFileRequest {
  93366. /**
  93367. * Raised when the request is complete (success or error).
  93368. */
  93369. onCompleteObservable: Observable<IFileRequest>;
  93370. /**
  93371. * Aborts the request for a file.
  93372. */
  93373. abort: () => void;
  93374. }
  93375. /**
  93376. * Class containing a set of static utilities functions
  93377. */
  93378. export class Tools {
  93379. /**
  93380. * Gets or sets the base URL to use to load assets
  93381. */
  93382. static BaseUrl: string;
  93383. /**
  93384. * Enable/Disable Custom HTTP Request Headers globally.
  93385. * default = false
  93386. * @see CustomRequestHeaders
  93387. */
  93388. static UseCustomRequestHeaders: boolean;
  93389. /**
  93390. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  93391. * i.e. when loading files, where the server/service expects an Authorization header
  93392. */
  93393. static CustomRequestHeaders: {
  93394. [key: string]: string;
  93395. };
  93396. /**
  93397. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  93398. */
  93399. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  93400. /**
  93401. * Default behaviour for cors in the application.
  93402. * It can be a string if the expected behavior is identical in the entire app.
  93403. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  93404. */
  93405. static CorsBehavior: string | ((url: string | string[]) => string);
  93406. /**
  93407. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  93408. * @ignorenaming
  93409. */
  93410. static UseFallbackTexture: boolean;
  93411. /**
  93412. * Use this object to register external classes like custom textures or material
  93413. * to allow the laoders to instantiate them
  93414. */
  93415. static RegisteredExternalClasses: {
  93416. [key: string]: Object;
  93417. };
  93418. /**
  93419. * Texture content used if a texture cannot loaded
  93420. * @ignorenaming
  93421. */
  93422. static fallbackTexture: string;
  93423. /**
  93424. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  93425. * @param u defines the coordinate on X axis
  93426. * @param v defines the coordinate on Y axis
  93427. * @param width defines the width of the source data
  93428. * @param height defines the height of the source data
  93429. * @param pixels defines the source byte array
  93430. * @param color defines the output color
  93431. */
  93432. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  93433. /**
  93434. * Interpolates between a and b via alpha
  93435. * @param a The lower value (returned when alpha = 0)
  93436. * @param b The upper value (returned when alpha = 1)
  93437. * @param alpha The interpolation-factor
  93438. * @return The mixed value
  93439. */
  93440. static Mix(a: number, b: number, alpha: number): number;
  93441. /**
  93442. * Tries to instantiate a new object from a given class name
  93443. * @param className defines the class name to instantiate
  93444. * @returns the new object or null if the system was not able to do the instantiation
  93445. */
  93446. static Instantiate(className: string): any;
  93447. /**
  93448. * Provides a slice function that will work even on IE
  93449. * @param data defines the array to slice
  93450. * @param start defines the start of the data (optional)
  93451. * @param end defines the end of the data (optional)
  93452. * @returns the new sliced array
  93453. */
  93454. static Slice<T>(data: T, start?: number, end?: number): T;
  93455. /**
  93456. * Polyfill for setImmediate
  93457. * @param action defines the action to execute after the current execution block
  93458. */
  93459. static SetImmediate(action: () => void): void;
  93460. /**
  93461. * Function indicating if a number is an exponent of 2
  93462. * @param value defines the value to test
  93463. * @returns true if the value is an exponent of 2
  93464. */
  93465. static IsExponentOfTwo(value: number): boolean;
  93466. private static _tmpFloatArray;
  93467. /**
  93468. * Returns the nearest 32-bit single precision float representation of a Number
  93469. * @param value A Number. If the parameter is of a different type, it will get converted
  93470. * to a number or to NaN if it cannot be converted
  93471. * @returns number
  93472. */
  93473. static FloatRound(value: number): number;
  93474. /**
  93475. * Find the next highest power of two.
  93476. * @param x Number to start search from.
  93477. * @return Next highest power of two.
  93478. */
  93479. static CeilingPOT(x: number): number;
  93480. /**
  93481. * Find the next lowest power of two.
  93482. * @param x Number to start search from.
  93483. * @return Next lowest power of two.
  93484. */
  93485. static FloorPOT(x: number): number;
  93486. /**
  93487. * Find the nearest power of two.
  93488. * @param x Number to start search from.
  93489. * @return Next nearest power of two.
  93490. */
  93491. static NearestPOT(x: number): number;
  93492. /**
  93493. * Get the closest exponent of two
  93494. * @param value defines the value to approximate
  93495. * @param max defines the maximum value to return
  93496. * @param mode defines how to define the closest value
  93497. * @returns closest exponent of two of the given value
  93498. */
  93499. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  93500. /**
  93501. * Extracts the filename from a path
  93502. * @param path defines the path to use
  93503. * @returns the filename
  93504. */
  93505. static GetFilename(path: string): string;
  93506. /**
  93507. * Extracts the "folder" part of a path (everything before the filename).
  93508. * @param uri The URI to extract the info from
  93509. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  93510. * @returns The "folder" part of the path
  93511. */
  93512. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  93513. /**
  93514. * Extracts text content from a DOM element hierarchy
  93515. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  93516. */
  93517. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  93518. /**
  93519. * Convert an angle in radians to degrees
  93520. * @param angle defines the angle to convert
  93521. * @returns the angle in degrees
  93522. */
  93523. static ToDegrees(angle: number): number;
  93524. /**
  93525. * Convert an angle in degrees to radians
  93526. * @param angle defines the angle to convert
  93527. * @returns the angle in radians
  93528. */
  93529. static ToRadians(angle: number): number;
  93530. /**
  93531. * Encode a buffer to a base64 string
  93532. * @param buffer defines the buffer to encode
  93533. * @returns the encoded string
  93534. */
  93535. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  93536. /**
  93537. * Extracts minimum and maximum values from a list of indexed positions
  93538. * @param positions defines the positions to use
  93539. * @param indices defines the indices to the positions
  93540. * @param indexStart defines the start index
  93541. * @param indexCount defines the end index
  93542. * @param bias defines bias value to add to the result
  93543. * @return minimum and maximum values
  93544. */
  93545. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  93546. minimum: Vector3;
  93547. maximum: Vector3;
  93548. };
  93549. /**
  93550. * Extracts minimum and maximum values from a list of positions
  93551. * @param positions defines the positions to use
  93552. * @param start defines the start index in the positions array
  93553. * @param count defines the number of positions to handle
  93554. * @param bias defines bias value to add to the result
  93555. * @param stride defines the stride size to use (distance between two positions in the positions array)
  93556. * @return minimum and maximum values
  93557. */
  93558. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  93559. minimum: Vector3;
  93560. maximum: Vector3;
  93561. };
  93562. /**
  93563. * Returns an array if obj is not an array
  93564. * @param obj defines the object to evaluate as an array
  93565. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  93566. * @returns either obj directly if obj is an array or a new array containing obj
  93567. */
  93568. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  93569. /**
  93570. * Gets the pointer prefix to use
  93571. * @returns "pointer" if touch is enabled. Else returns "mouse"
  93572. */
  93573. static GetPointerPrefix(): string;
  93574. /**
  93575. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  93576. * @param func - the function to be called
  93577. * @param requester - the object that will request the next frame. Falls back to window.
  93578. * @returns frame number
  93579. */
  93580. static QueueNewFrame(func: () => void, requester?: any): number;
  93581. /**
  93582. * Ask the browser to promote the current element to fullscreen rendering mode
  93583. * @param element defines the DOM element to promote
  93584. */
  93585. static RequestFullscreen(element: HTMLElement): void;
  93586. /**
  93587. * Asks the browser to exit fullscreen mode
  93588. */
  93589. static ExitFullscreen(): void;
  93590. /**
  93591. * Ask the browser to promote the current element to pointerlock mode
  93592. * @param element defines the DOM element to promote
  93593. */
  93594. static RequestPointerlock(element: HTMLElement): void;
  93595. /**
  93596. * Asks the browser to exit pointerlock mode
  93597. */
  93598. static ExitPointerlock(): void;
  93599. /**
  93600. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  93601. * @param url define the url we are trying
  93602. * @param element define the dom element where to configure the cors policy
  93603. */
  93604. static SetCorsBehavior(url: string | string[], element: {
  93605. crossOrigin: string | null;
  93606. }): void;
  93607. /**
  93608. * Removes unwanted characters from an url
  93609. * @param url defines the url to clean
  93610. * @returns the cleaned url
  93611. */
  93612. static CleanUrl(url: string): string;
  93613. /**
  93614. * Gets or sets a function used to pre-process url before using them to load assets
  93615. */
  93616. static PreprocessUrl: (url: string) => string;
  93617. /**
  93618. * Loads an image as an HTMLImageElement.
  93619. * @param input url string, ArrayBuffer, or Blob to load
  93620. * @param onLoad callback called when the image successfully loads
  93621. * @param onError callback called when the image fails to load
  93622. * @param offlineProvider offline provider for caching
  93623. * @returns the HTMLImageElement of the loaded image
  93624. */
  93625. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  93626. /**
  93627. * Loads a file
  93628. * @param url url string, ArrayBuffer, or Blob to load
  93629. * @param onSuccess callback called when the file successfully loads
  93630. * @param onProgress callback called while file is loading (if the server supports this mode)
  93631. * @param offlineProvider defines the offline provider for caching
  93632. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  93633. * @param onError callback called when the file fails to load
  93634. * @returns a file request object
  93635. */
  93636. 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;
  93637. /**
  93638. * Load a script (identified by an url). When the url returns, the
  93639. * content of this file is added into a new script element, attached to the DOM (body element)
  93640. * @param scriptUrl defines the url of the script to laod
  93641. * @param onSuccess defines the callback called when the script is loaded
  93642. * @param onError defines the callback to call if an error occurs
  93643. * @param scriptId defines the id of the script element
  93644. */
  93645. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  93646. /**
  93647. * Load an asynchronous script (identified by an url). When the url returns, the
  93648. * content of this file is added into a new script element, attached to the DOM (body element)
  93649. * @param scriptUrl defines the url of the script to laod
  93650. * @param scriptId defines the id of the script element
  93651. * @returns a promise request object
  93652. */
  93653. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  93654. /**
  93655. * Loads a file from a blob
  93656. * @param fileToLoad defines the blob to use
  93657. * @param callback defines the callback to call when data is loaded
  93658. * @param progressCallback defines the callback to call during loading process
  93659. * @returns a file request object
  93660. */
  93661. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  93662. /**
  93663. * Loads a file
  93664. * @param fileToLoad defines the file to load
  93665. * @param callback defines the callback to call when data is loaded
  93666. * @param progressCallBack defines the callback to call during loading process
  93667. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  93668. * @returns a file request object
  93669. */
  93670. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  93671. /**
  93672. * Creates a data url from a given string content
  93673. * @param content defines the content to convert
  93674. * @returns the new data url link
  93675. */
  93676. static FileAsURL(content: string): string;
  93677. /**
  93678. * Format the given number to a specific decimal format
  93679. * @param value defines the number to format
  93680. * @param decimals defines the number of decimals to use
  93681. * @returns the formatted string
  93682. */
  93683. static Format(value: number, decimals?: number): string;
  93684. /**
  93685. * Checks if a given vector is inside a specific range
  93686. * @param v defines the vector to test
  93687. * @param min defines the minimum range
  93688. * @param max defines the maximum range
  93689. */
  93690. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  93691. /**
  93692. * Tries to copy an object by duplicating every property
  93693. * @param source defines the source object
  93694. * @param destination defines the target object
  93695. * @param doNotCopyList defines a list of properties to avoid
  93696. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  93697. */
  93698. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  93699. /**
  93700. * Gets a boolean indicating if the given object has no own property
  93701. * @param obj defines the object to test
  93702. * @returns true if object has no own property
  93703. */
  93704. static IsEmpty(obj: any): boolean;
  93705. /**
  93706. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  93707. * @param str Source string
  93708. * @param suffix Suffix to search for in the source string
  93709. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  93710. */
  93711. static EndsWith(str: string, suffix: string): boolean;
  93712. /**
  93713. * Function used to register events at window level
  93714. * @param events defines the events to register
  93715. */
  93716. static RegisterTopRootEvents(events: {
  93717. name: string;
  93718. handler: Nullable<(e: FocusEvent) => any>;
  93719. }[]): void;
  93720. /**
  93721. * Function used to unregister events from window level
  93722. * @param events defines the events to unregister
  93723. */
  93724. static UnregisterTopRootEvents(events: {
  93725. name: string;
  93726. handler: Nullable<(e: FocusEvent) => any>;
  93727. }[]): void;
  93728. /**
  93729. * @ignore
  93730. */
  93731. static _ScreenshotCanvas: HTMLCanvasElement;
  93732. /**
  93733. * Dumps the current bound framebuffer
  93734. * @param width defines the rendering width
  93735. * @param height defines the rendering height
  93736. * @param engine defines the hosting engine
  93737. * @param successCallback defines the callback triggered once the data are available
  93738. * @param mimeType defines the mime type of the result
  93739. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  93740. */
  93741. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  93742. /**
  93743. * Converts the canvas data to blob.
  93744. * This acts as a polyfill for browsers not supporting the to blob function.
  93745. * @param canvas Defines the canvas to extract the data from
  93746. * @param successCallback Defines the callback triggered once the data are available
  93747. * @param mimeType Defines the mime type of the result
  93748. */
  93749. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  93750. /**
  93751. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  93752. * @param successCallback defines the callback triggered once the data are available
  93753. * @param mimeType defines the mime type of the result
  93754. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  93755. */
  93756. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  93757. /**
  93758. * Downloads a blob in the browser
  93759. * @param blob defines the blob to download
  93760. * @param fileName defines the name of the downloaded file
  93761. */
  93762. static Download(blob: Blob, fileName: string): void;
  93763. /**
  93764. * Captures a screenshot of the current rendering
  93765. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  93766. * @param engine defines the rendering engine
  93767. * @param camera defines the source camera
  93768. * @param size This parameter can be set to a single number or to an object with the
  93769. * following (optional) properties: precision, width, height. If a single number is passed,
  93770. * it will be used for both width and height. If an object is passed, the screenshot size
  93771. * will be derived from the parameters. The precision property is a multiplier allowing
  93772. * rendering at a higher or lower resolution
  93773. * @param successCallback defines the callback receives a single parameter which contains the
  93774. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  93775. * src parameter of an <img> to display it
  93776. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  93777. * Check your browser for supported MIME types
  93778. */
  93779. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  93780. /**
  93781. * Generates an image screenshot from the specified camera.
  93782. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  93783. * @param engine The engine to use for rendering
  93784. * @param camera The camera to use for rendering
  93785. * @param size This parameter can be set to a single number or to an object with the
  93786. * following (optional) properties: precision, width, height. If a single number is passed,
  93787. * it will be used for both width and height. If an object is passed, the screenshot size
  93788. * will be derived from the parameters. The precision property is a multiplier allowing
  93789. * rendering at a higher or lower resolution
  93790. * @param successCallback The callback receives a single parameter which contains the
  93791. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  93792. * src parameter of an <img> to display it
  93793. * @param mimeType The MIME type of the screenshot image (default: image/png).
  93794. * Check your browser for supported MIME types
  93795. * @param samples Texture samples (default: 1)
  93796. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  93797. * @param fileName A name for for the downloaded file.
  93798. */
  93799. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  93800. /**
  93801. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93802. * Be aware Math.random() could cause collisions, but:
  93803. * "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"
  93804. * @returns a pseudo random id
  93805. */
  93806. static RandomId(): string;
  93807. /**
  93808. * Test if the given uri is a base64 string
  93809. * @param uri The uri to test
  93810. * @return True if the uri is a base64 string or false otherwise
  93811. */
  93812. static IsBase64(uri: string): boolean;
  93813. /**
  93814. * Decode the given base64 uri.
  93815. * @param uri The uri to decode
  93816. * @return The decoded base64 data.
  93817. */
  93818. static DecodeBase64(uri: string): ArrayBuffer;
  93819. /**
  93820. * Gets the absolute url.
  93821. * @param url the input url
  93822. * @return the absolute url
  93823. */
  93824. static GetAbsoluteUrl(url: string): string;
  93825. /**
  93826. * No log
  93827. */
  93828. static readonly NoneLogLevel: number;
  93829. /**
  93830. * Only message logs
  93831. */
  93832. static readonly MessageLogLevel: number;
  93833. /**
  93834. * Only warning logs
  93835. */
  93836. static readonly WarningLogLevel: number;
  93837. /**
  93838. * Only error logs
  93839. */
  93840. static readonly ErrorLogLevel: number;
  93841. /**
  93842. * All logs
  93843. */
  93844. static readonly AllLogLevel: number;
  93845. /**
  93846. * Gets a value indicating the number of loading errors
  93847. * @ignorenaming
  93848. */
  93849. static readonly errorsCount: number;
  93850. /**
  93851. * Callback called when a new log is added
  93852. */
  93853. static OnNewCacheEntry: (entry: string) => void;
  93854. /**
  93855. * Log a message to the console
  93856. * @param message defines the message to log
  93857. */
  93858. static Log(message: string): void;
  93859. /**
  93860. * Write a warning message to the console
  93861. * @param message defines the message to log
  93862. */
  93863. static Warn(message: string): void;
  93864. /**
  93865. * Write an error message to the console
  93866. * @param message defines the message to log
  93867. */
  93868. static Error(message: string): void;
  93869. /**
  93870. * Gets current log cache (list of logs)
  93871. */
  93872. static readonly LogCache: string;
  93873. /**
  93874. * Clears the log cache
  93875. */
  93876. static ClearLogCache(): void;
  93877. /**
  93878. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  93879. */
  93880. static LogLevels: number;
  93881. /**
  93882. * Checks if the loaded document was accessed via `file:`-Protocol.
  93883. * @returns boolean
  93884. */
  93885. static IsFileURL(): boolean;
  93886. /**
  93887. * Checks if the window object exists
  93888. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  93889. */
  93890. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  93891. /**
  93892. * No performance log
  93893. */
  93894. static readonly PerformanceNoneLogLevel: number;
  93895. /**
  93896. * Use user marks to log performance
  93897. */
  93898. static readonly PerformanceUserMarkLogLevel: number;
  93899. /**
  93900. * Log performance to the console
  93901. */
  93902. static readonly PerformanceConsoleLogLevel: number;
  93903. private static _performance;
  93904. /**
  93905. * Sets the current performance log level
  93906. */
  93907. static PerformanceLogLevel: number;
  93908. private static _StartPerformanceCounterDisabled;
  93909. private static _EndPerformanceCounterDisabled;
  93910. private static _StartUserMark;
  93911. private static _EndUserMark;
  93912. private static _StartPerformanceConsole;
  93913. private static _EndPerformanceConsole;
  93914. /**
  93915. * Starts a performance counter
  93916. */
  93917. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  93918. /**
  93919. * Ends a specific performance coutner
  93920. */
  93921. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  93922. /**
  93923. * Gets either window.performance.now() if supported or Date.now() else
  93924. */
  93925. static readonly Now: number;
  93926. /**
  93927. * This method will return the name of the class used to create the instance of the given object.
  93928. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  93929. * @param object the object to get the class name from
  93930. * @param isType defines if the object is actually a type
  93931. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  93932. */
  93933. static GetClassName(object: any, isType?: boolean): string;
  93934. /**
  93935. * Gets the first element of an array satisfying a given predicate
  93936. * @param array defines the array to browse
  93937. * @param predicate defines the predicate to use
  93938. * @returns null if not found or the element
  93939. */
  93940. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  93941. /**
  93942. * This method will return the name of the full name of the class, including its owning module (if any).
  93943. * 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).
  93944. * @param object the object to get the class name from
  93945. * @param isType defines if the object is actually a type
  93946. * @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.
  93947. * @ignorenaming
  93948. */
  93949. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  93950. /**
  93951. * Returns a promise that resolves after the given amount of time.
  93952. * @param delay Number of milliseconds to delay
  93953. * @returns Promise that resolves after the given amount of time
  93954. */
  93955. static DelayAsync(delay: number): Promise<void>;
  93956. /**
  93957. * Gets the current gradient from an array of IValueGradient
  93958. * @param ratio defines the current ratio to get
  93959. * @param gradients defines the array of IValueGradient
  93960. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  93961. */
  93962. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  93963. }
  93964. /**
  93965. * This class is used to track a performance counter which is number based.
  93966. * The user has access to many properties which give statistics of different nature.
  93967. *
  93968. * The implementer can track two kinds of Performance Counter: time and count.
  93969. * 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.
  93970. * 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.
  93971. */
  93972. export class PerfCounter {
  93973. /**
  93974. * Gets or sets a global boolean to turn on and off all the counters
  93975. */
  93976. static Enabled: boolean;
  93977. /**
  93978. * Returns the smallest value ever
  93979. */
  93980. readonly min: number;
  93981. /**
  93982. * Returns the biggest value ever
  93983. */
  93984. readonly max: number;
  93985. /**
  93986. * Returns the average value since the performance counter is running
  93987. */
  93988. readonly average: number;
  93989. /**
  93990. * Returns the average value of the last second the counter was monitored
  93991. */
  93992. readonly lastSecAverage: number;
  93993. /**
  93994. * Returns the current value
  93995. */
  93996. readonly current: number;
  93997. /**
  93998. * Gets the accumulated total
  93999. */
  94000. readonly total: number;
  94001. /**
  94002. * Gets the total value count
  94003. */
  94004. readonly count: number;
  94005. /**
  94006. * Creates a new counter
  94007. */
  94008. constructor();
  94009. /**
  94010. * Call this method to start monitoring a new frame.
  94011. * 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.
  94012. */
  94013. fetchNewFrame(): void;
  94014. /**
  94015. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94016. * @param newCount the count value to add to the monitored count
  94017. * @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.
  94018. */
  94019. addCount(newCount: number, fetchResult: boolean): void;
  94020. /**
  94021. * Start monitoring this performance counter
  94022. */
  94023. beginMonitoring(): void;
  94024. /**
  94025. * Compute the time lapsed since the previous beginMonitoring() call.
  94026. * @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
  94027. */
  94028. endMonitoring(newFrame?: boolean): void;
  94029. private _fetchResult;
  94030. private _startMonitoringTime;
  94031. private _min;
  94032. private _max;
  94033. private _average;
  94034. private _current;
  94035. private _totalValueCount;
  94036. private _totalAccumulated;
  94037. private _lastSecAverage;
  94038. private _lastSecAccumulated;
  94039. private _lastSecTime;
  94040. private _lastSecValueCount;
  94041. }
  94042. /**
  94043. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  94044. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  94045. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  94046. * @param name The name of the class, case should be preserved
  94047. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  94048. */
  94049. export function className(name: string, module?: string): (target: Object) => void;
  94050. /**
  94051. * An implementation of a loop for asynchronous functions.
  94052. */
  94053. export class AsyncLoop {
  94054. /**
  94055. * Defines the number of iterations for the loop
  94056. */
  94057. iterations: number;
  94058. /**
  94059. * Defines the current index of the loop.
  94060. */
  94061. index: number;
  94062. private _done;
  94063. private _fn;
  94064. private _successCallback;
  94065. /**
  94066. * Constructor.
  94067. * @param iterations the number of iterations.
  94068. * @param func the function to run each iteration
  94069. * @param successCallback the callback that will be called upon succesful execution
  94070. * @param offset starting offset.
  94071. */
  94072. constructor(
  94073. /**
  94074. * Defines the number of iterations for the loop
  94075. */
  94076. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  94077. /**
  94078. * Execute the next iteration. Must be called after the last iteration was finished.
  94079. */
  94080. executeNext(): void;
  94081. /**
  94082. * Break the loop and run the success callback.
  94083. */
  94084. breakLoop(): void;
  94085. /**
  94086. * Create and run an async loop.
  94087. * @param iterations the number of iterations.
  94088. * @param fn the function to run each iteration
  94089. * @param successCallback the callback that will be called upon succesful execution
  94090. * @param offset starting offset.
  94091. * @returns the created async loop object
  94092. */
  94093. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  94094. /**
  94095. * A for-loop that will run a given number of iterations synchronous and the rest async.
  94096. * @param iterations total number of iterations
  94097. * @param syncedIterations number of synchronous iterations in each async iteration.
  94098. * @param fn the function to call each iteration.
  94099. * @param callback a success call back that will be called when iterating stops.
  94100. * @param breakFunction a break condition (optional)
  94101. * @param timeout timeout settings for the setTimeout function. default - 0.
  94102. * @returns the created async loop object
  94103. */
  94104. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  94105. }
  94106. }
  94107. declare module BABYLON {
  94108. /** @hidden */
  94109. export interface ICollisionCoordinator {
  94110. createCollider(): Collider;
  94111. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94112. init(scene: Scene): void;
  94113. }
  94114. /** @hidden */
  94115. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  94116. private _scene;
  94117. private _scaledPosition;
  94118. private _scaledVelocity;
  94119. private _finalPosition;
  94120. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94121. createCollider(): Collider;
  94122. init(scene: Scene): void;
  94123. private _collideWithWorld;
  94124. }
  94125. }
  94126. declare module BABYLON {
  94127. /**
  94128. * Class used to manage all inputs for the scene.
  94129. */
  94130. export class InputManager {
  94131. /** The distance in pixel that you have to move to prevent some events */
  94132. static DragMovementThreshold: number;
  94133. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  94134. static LongPressDelay: number;
  94135. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  94136. static DoubleClickDelay: number;
  94137. /** If you need to check double click without raising a single click at first click, enable this flag */
  94138. static ExclusiveDoubleClickMode: boolean;
  94139. private _wheelEventName;
  94140. private _onPointerMove;
  94141. private _onPointerDown;
  94142. private _onPointerUp;
  94143. private _initClickEvent;
  94144. private _initActionManager;
  94145. private _delayedSimpleClick;
  94146. private _delayedSimpleClickTimeout;
  94147. private _previousDelayedSimpleClickTimeout;
  94148. private _meshPickProceed;
  94149. private _previousButtonPressed;
  94150. private _currentPickResult;
  94151. private _previousPickResult;
  94152. private _totalPointersPressed;
  94153. private _doubleClickOccured;
  94154. private _pointerOverMesh;
  94155. private _pickedDownMesh;
  94156. private _pickedUpMesh;
  94157. private _pointerX;
  94158. private _pointerY;
  94159. private _unTranslatedPointerX;
  94160. private _unTranslatedPointerY;
  94161. private _startingPointerPosition;
  94162. private _previousStartingPointerPosition;
  94163. private _startingPointerTime;
  94164. private _previousStartingPointerTime;
  94165. private _pointerCaptures;
  94166. private _onKeyDown;
  94167. private _onKeyUp;
  94168. private _onCanvasFocusObserver;
  94169. private _onCanvasBlurObserver;
  94170. private _scene;
  94171. /**
  94172. * Creates a new InputManager
  94173. * @param scene defines the hosting scene
  94174. */
  94175. constructor(scene: Scene);
  94176. /**
  94177. * Gets the mesh that is currently under the pointer
  94178. */
  94179. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94180. /**
  94181. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  94182. */
  94183. readonly unTranslatedPointer: Vector2;
  94184. /**
  94185. * Gets or sets the current on-screen X position of the pointer
  94186. */
  94187. pointerX: number;
  94188. /**
  94189. * Gets or sets the current on-screen Y position of the pointer
  94190. */
  94191. pointerY: number;
  94192. private _updatePointerPosition;
  94193. private _processPointerMove;
  94194. private _setRayOnPointerInfo;
  94195. private _checkPrePointerObservable;
  94196. /**
  94197. * Use this method to simulate a pointer move on a mesh
  94198. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94199. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94200. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94201. */
  94202. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94203. /**
  94204. * Use this method to simulate a pointer down on a mesh
  94205. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94206. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94207. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94208. */
  94209. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94210. private _processPointerDown;
  94211. /** @hidden */
  94212. _isPointerSwiping(): boolean;
  94213. /**
  94214. * Use this method to simulate a pointer up on a mesh
  94215. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94216. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94217. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94218. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  94219. */
  94220. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  94221. private _processPointerUp;
  94222. /**
  94223. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  94224. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  94225. * @returns true if the pointer was captured
  94226. */
  94227. isPointerCaptured(pointerId?: number): boolean;
  94228. /**
  94229. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  94230. * @param attachUp defines if you want to attach events to pointerup
  94231. * @param attachDown defines if you want to attach events to pointerdown
  94232. * @param attachMove defines if you want to attach events to pointermove
  94233. */
  94234. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  94235. /**
  94236. * Detaches all event handlers
  94237. */
  94238. detachControl(): void;
  94239. /**
  94240. * Force the value of meshUnderPointer
  94241. * @param mesh defines the mesh to use
  94242. */
  94243. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  94244. /**
  94245. * Gets the mesh under the pointer
  94246. * @returns a Mesh or null if no mesh is under the pointer
  94247. */
  94248. getPointerOverMesh(): Nullable<AbstractMesh>;
  94249. }
  94250. }
  94251. declare module BABYLON {
  94252. /**
  94253. * This class defines the direct association between an animation and a target
  94254. */
  94255. export class TargetedAnimation {
  94256. /**
  94257. * Animation to perform
  94258. */
  94259. animation: Animation;
  94260. /**
  94261. * Target to animate
  94262. */
  94263. target: any;
  94264. /**
  94265. * Serialize the object
  94266. * @returns the JSON object representing the current entity
  94267. */
  94268. serialize(): any;
  94269. }
  94270. /**
  94271. * Use this class to create coordinated animations on multiple targets
  94272. */
  94273. export class AnimationGroup implements IDisposable {
  94274. /** The name of the animation group */
  94275. name: string;
  94276. private _scene;
  94277. private _targetedAnimations;
  94278. private _animatables;
  94279. private _from;
  94280. private _to;
  94281. private _isStarted;
  94282. private _isPaused;
  94283. private _speedRatio;
  94284. private _loopAnimation;
  94285. /**
  94286. * Gets or sets the unique id of the node
  94287. */
  94288. uniqueId: number;
  94289. /**
  94290. * This observable will notify when one animation have ended
  94291. */
  94292. onAnimationEndObservable: Observable<TargetedAnimation>;
  94293. /**
  94294. * Observer raised when one animation loops
  94295. */
  94296. onAnimationLoopObservable: Observable<TargetedAnimation>;
  94297. /**
  94298. * This observable will notify when all animations have ended.
  94299. */
  94300. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  94301. /**
  94302. * This observable will notify when all animations have paused.
  94303. */
  94304. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  94305. /**
  94306. * This observable will notify when all animations are playing.
  94307. */
  94308. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  94309. /**
  94310. * Gets the first frame
  94311. */
  94312. readonly from: number;
  94313. /**
  94314. * Gets the last frame
  94315. */
  94316. readonly to: number;
  94317. /**
  94318. * Define if the animations are started
  94319. */
  94320. readonly isStarted: boolean;
  94321. /**
  94322. * Gets a value indicating that the current group is playing
  94323. */
  94324. readonly isPlaying: boolean;
  94325. /**
  94326. * Gets or sets the speed ratio to use for all animations
  94327. */
  94328. /**
  94329. * Gets or sets the speed ratio to use for all animations
  94330. */
  94331. speedRatio: number;
  94332. /**
  94333. * Gets or sets if all animations should loop or not
  94334. */
  94335. loopAnimation: boolean;
  94336. /**
  94337. * Gets the targeted animations for this animation group
  94338. */
  94339. readonly targetedAnimations: Array<TargetedAnimation>;
  94340. /**
  94341. * returning the list of animatables controlled by this animation group.
  94342. */
  94343. readonly animatables: Array<Animatable>;
  94344. /**
  94345. * Instantiates a new Animation Group.
  94346. * This helps managing several animations at once.
  94347. * @see http://doc.babylonjs.com/how_to/group
  94348. * @param name Defines the name of the group
  94349. * @param scene Defines the scene the group belongs to
  94350. */
  94351. constructor(
  94352. /** The name of the animation group */
  94353. name: string, scene?: Nullable<Scene>);
  94354. /**
  94355. * Add an animation (with its target) in the group
  94356. * @param animation defines the animation we want to add
  94357. * @param target defines the target of the animation
  94358. * @returns the TargetedAnimation object
  94359. */
  94360. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  94361. /**
  94362. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  94363. * It can add constant keys at begin or end
  94364. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  94365. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  94366. * @returns the animation group
  94367. */
  94368. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  94369. /**
  94370. * Start all animations on given targets
  94371. * @param loop defines if animations must loop
  94372. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  94373. * @param from defines the from key (optional)
  94374. * @param to defines the to key (optional)
  94375. * @returns the current animation group
  94376. */
  94377. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  94378. /**
  94379. * Pause all animations
  94380. * @returns the animation group
  94381. */
  94382. pause(): AnimationGroup;
  94383. /**
  94384. * Play all animations to initial state
  94385. * This function will start() the animations if they were not started or will restart() them if they were paused
  94386. * @param loop defines if animations must loop
  94387. * @returns the animation group
  94388. */
  94389. play(loop?: boolean): AnimationGroup;
  94390. /**
  94391. * Reset all animations to initial state
  94392. * @returns the animation group
  94393. */
  94394. reset(): AnimationGroup;
  94395. /**
  94396. * Restart animations from key 0
  94397. * @returns the animation group
  94398. */
  94399. restart(): AnimationGroup;
  94400. /**
  94401. * Stop all animations
  94402. * @returns the animation group
  94403. */
  94404. stop(): AnimationGroup;
  94405. /**
  94406. * Set animation weight for all animatables
  94407. * @param weight defines the weight to use
  94408. * @return the animationGroup
  94409. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94410. */
  94411. setWeightForAllAnimatables(weight: number): AnimationGroup;
  94412. /**
  94413. * Synchronize and normalize all animatables with a source animatable
  94414. * @param root defines the root animatable to synchronize with
  94415. * @return the animationGroup
  94416. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94417. */
  94418. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  94419. /**
  94420. * Goes to a specific frame in this animation group
  94421. * @param frame the frame number to go to
  94422. * @return the animationGroup
  94423. */
  94424. goToFrame(frame: number): AnimationGroup;
  94425. /**
  94426. * Dispose all associated resources
  94427. */
  94428. dispose(): void;
  94429. private _checkAnimationGroupEnded;
  94430. /**
  94431. * Clone the current animation group and returns a copy
  94432. * @param newName defines the name of the new group
  94433. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  94434. * @returns the new aniamtion group
  94435. */
  94436. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  94437. /**
  94438. * Serializes the animationGroup to an object
  94439. * @returns Serialized object
  94440. */
  94441. serialize(): any;
  94442. /**
  94443. * Returns a new AnimationGroup object parsed from the source provided.
  94444. * @param parsedAnimationGroup defines the source
  94445. * @param scene defines the scene that will receive the animationGroup
  94446. * @returns a new AnimationGroup
  94447. */
  94448. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  94449. /**
  94450. * Returns the string "AnimationGroup"
  94451. * @returns "AnimationGroup"
  94452. */
  94453. getClassName(): string;
  94454. /**
  94455. * Creates a detailled string about the object
  94456. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  94457. * @returns a string representing the object
  94458. */
  94459. toString(fullDetails?: boolean): string;
  94460. }
  94461. }
  94462. declare module BABYLON {
  94463. /**
  94464. * Define an interface for all classes that will hold resources
  94465. */
  94466. export interface IDisposable {
  94467. /**
  94468. * Releases all held resources
  94469. */
  94470. dispose(): void;
  94471. }
  94472. /** Interface defining initialization parameters for Scene class */
  94473. export interface SceneOptions {
  94474. /**
  94475. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  94476. * It will improve performance when the number of geometries becomes important.
  94477. */
  94478. useGeometryUniqueIdsMap?: boolean;
  94479. /**
  94480. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  94481. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94482. */
  94483. useMaterialMeshMap?: boolean;
  94484. /**
  94485. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  94486. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94487. */
  94488. useClonedMeshhMap?: boolean;
  94489. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  94490. virtual?: boolean;
  94491. }
  94492. /**
  94493. * Represents a scene to be rendered by the engine.
  94494. * @see http://doc.babylonjs.com/features/scene
  94495. */
  94496. export class Scene extends AbstractScene implements IAnimatable {
  94497. private static _uniqueIdCounter;
  94498. /** The fog is deactivated */
  94499. static readonly FOGMODE_NONE: number;
  94500. /** The fog density is following an exponential function */
  94501. static readonly FOGMODE_EXP: number;
  94502. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  94503. static readonly FOGMODE_EXP2: number;
  94504. /** The fog density is following a linear function. */
  94505. static readonly FOGMODE_LINEAR: number;
  94506. /**
  94507. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  94508. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94509. */
  94510. static MinDeltaTime: number;
  94511. /**
  94512. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  94513. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94514. */
  94515. static MaxDeltaTime: number;
  94516. /**
  94517. * Factory used to create the default material.
  94518. * @param name The name of the material to create
  94519. * @param scene The scene to create the material for
  94520. * @returns The default material
  94521. */
  94522. static DefaultMaterialFactory(scene: Scene): Material;
  94523. /**
  94524. * Factory used to create the a collision coordinator.
  94525. * @returns The collision coordinator
  94526. */
  94527. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  94528. /** @hidden */
  94529. _inputManager: InputManager;
  94530. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  94531. cameraToUseForPointers: Nullable<Camera>;
  94532. /** @hidden */
  94533. readonly _isScene: boolean;
  94534. /**
  94535. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  94536. */
  94537. autoClear: boolean;
  94538. /**
  94539. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  94540. */
  94541. autoClearDepthAndStencil: boolean;
  94542. /**
  94543. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  94544. */
  94545. clearColor: Color4;
  94546. /**
  94547. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  94548. */
  94549. ambientColor: Color3;
  94550. /**
  94551. * This is use to store the default BRDF lookup for PBR materials in your scene.
  94552. * It should only be one of the following (if not the default embedded one):
  94553. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  94554. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  94555. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  94556. * The material properties need to be setup according to the type of texture in use.
  94557. */
  94558. environmentBRDFTexture: BaseTexture;
  94559. /** @hidden */
  94560. protected _environmentTexture: Nullable<BaseTexture>;
  94561. /**
  94562. * Texture used in all pbr material as the reflection texture.
  94563. * As in the majority of the scene they are the same (exception for multi room and so on),
  94564. * this is easier to reference from here than from all the materials.
  94565. */
  94566. /**
  94567. * Texture used in all pbr material as the reflection texture.
  94568. * As in the majority of the scene they are the same (exception for multi room and so on),
  94569. * this is easier to set here than in all the materials.
  94570. */
  94571. environmentTexture: Nullable<BaseTexture>;
  94572. /** @hidden */
  94573. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94574. /**
  94575. * Default image processing configuration used either in the rendering
  94576. * Forward main pass or through the imageProcessingPostProcess if present.
  94577. * As in the majority of the scene they are the same (exception for multi camera),
  94578. * this is easier to reference from here than from all the materials and post process.
  94579. *
  94580. * No setter as we it is a shared configuration, you can set the values instead.
  94581. */
  94582. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  94583. private _forceWireframe;
  94584. /**
  94585. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  94586. */
  94587. forceWireframe: boolean;
  94588. private _forcePointsCloud;
  94589. /**
  94590. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  94591. */
  94592. forcePointsCloud: boolean;
  94593. /**
  94594. * Gets or sets the active clipplane 1
  94595. */
  94596. clipPlane: Nullable<Plane>;
  94597. /**
  94598. * Gets or sets the active clipplane 2
  94599. */
  94600. clipPlane2: Nullable<Plane>;
  94601. /**
  94602. * Gets or sets the active clipplane 3
  94603. */
  94604. clipPlane3: Nullable<Plane>;
  94605. /**
  94606. * Gets or sets the active clipplane 4
  94607. */
  94608. clipPlane4: Nullable<Plane>;
  94609. /**
  94610. * Gets or sets a boolean indicating if animations are enabled
  94611. */
  94612. animationsEnabled: boolean;
  94613. private _animationPropertiesOverride;
  94614. /**
  94615. * Gets or sets the animation properties override
  94616. */
  94617. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94618. /**
  94619. * Gets or sets a boolean indicating if a constant deltatime has to be used
  94620. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  94621. */
  94622. useConstantAnimationDeltaTime: boolean;
  94623. /**
  94624. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  94625. * Please note that it requires to run a ray cast through the scene on every frame
  94626. */
  94627. constantlyUpdateMeshUnderPointer: boolean;
  94628. /**
  94629. * Defines the HTML cursor to use when hovering over interactive elements
  94630. */
  94631. hoverCursor: string;
  94632. /**
  94633. * Defines the HTML default cursor to use (empty by default)
  94634. */
  94635. defaultCursor: string;
  94636. /**
  94637. * This is used to call preventDefault() on pointer down
  94638. * in order to block unwanted artifacts like system double clicks
  94639. */
  94640. preventDefaultOnPointerDown: boolean;
  94641. /**
  94642. * This is used to call preventDefault() on pointer up
  94643. * in order to block unwanted artifacts like system double clicks
  94644. */
  94645. preventDefaultOnPointerUp: boolean;
  94646. /**
  94647. * Gets or sets user defined metadata
  94648. */
  94649. metadata: any;
  94650. /**
  94651. * For internal use only. Please do not use.
  94652. */
  94653. reservedDataStore: any;
  94654. /**
  94655. * Gets the name of the plugin used to load this scene (null by default)
  94656. */
  94657. loadingPluginName: string;
  94658. /**
  94659. * Use this array to add regular expressions used to disable offline support for specific urls
  94660. */
  94661. disableOfflineSupportExceptionRules: RegExp[];
  94662. /**
  94663. * An event triggered when the scene is disposed.
  94664. */
  94665. onDisposeObservable: Observable<Scene>;
  94666. private _onDisposeObserver;
  94667. /** Sets a function to be executed when this scene is disposed. */
  94668. onDispose: () => void;
  94669. /**
  94670. * An event triggered before rendering the scene (right after animations and physics)
  94671. */
  94672. onBeforeRenderObservable: Observable<Scene>;
  94673. private _onBeforeRenderObserver;
  94674. /** Sets a function to be executed before rendering this scene */
  94675. beforeRender: Nullable<() => void>;
  94676. /**
  94677. * An event triggered after rendering the scene
  94678. */
  94679. onAfterRenderObservable: Observable<Scene>;
  94680. private _onAfterRenderObserver;
  94681. /** Sets a function to be executed after rendering this scene */
  94682. afterRender: Nullable<() => void>;
  94683. /**
  94684. * An event triggered before animating the scene
  94685. */
  94686. onBeforeAnimationsObservable: Observable<Scene>;
  94687. /**
  94688. * An event triggered after animations processing
  94689. */
  94690. onAfterAnimationsObservable: Observable<Scene>;
  94691. /**
  94692. * An event triggered before draw calls are ready to be sent
  94693. */
  94694. onBeforeDrawPhaseObservable: Observable<Scene>;
  94695. /**
  94696. * An event triggered after draw calls have been sent
  94697. */
  94698. onAfterDrawPhaseObservable: Observable<Scene>;
  94699. /**
  94700. * An event triggered when the scene is ready
  94701. */
  94702. onReadyObservable: Observable<Scene>;
  94703. /**
  94704. * An event triggered before rendering a camera
  94705. */
  94706. onBeforeCameraRenderObservable: Observable<Camera>;
  94707. private _onBeforeCameraRenderObserver;
  94708. /** Sets a function to be executed before rendering a camera*/
  94709. beforeCameraRender: () => void;
  94710. /**
  94711. * An event triggered after rendering a camera
  94712. */
  94713. onAfterCameraRenderObservable: Observable<Camera>;
  94714. private _onAfterCameraRenderObserver;
  94715. /** Sets a function to be executed after rendering a camera*/
  94716. afterCameraRender: () => void;
  94717. /**
  94718. * An event triggered when active meshes evaluation is about to start
  94719. */
  94720. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  94721. /**
  94722. * An event triggered when active meshes evaluation is done
  94723. */
  94724. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  94725. /**
  94726. * An event triggered when particles rendering is about to start
  94727. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  94728. */
  94729. onBeforeParticlesRenderingObservable: Observable<Scene>;
  94730. /**
  94731. * An event triggered when particles rendering is done
  94732. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  94733. */
  94734. onAfterParticlesRenderingObservable: Observable<Scene>;
  94735. /**
  94736. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  94737. */
  94738. onDataLoadedObservable: Observable<Scene>;
  94739. /**
  94740. * An event triggered when a camera is created
  94741. */
  94742. onNewCameraAddedObservable: Observable<Camera>;
  94743. /**
  94744. * An event triggered when a camera is removed
  94745. */
  94746. onCameraRemovedObservable: Observable<Camera>;
  94747. /**
  94748. * An event triggered when a light is created
  94749. */
  94750. onNewLightAddedObservable: Observable<Light>;
  94751. /**
  94752. * An event triggered when a light is removed
  94753. */
  94754. onLightRemovedObservable: Observable<Light>;
  94755. /**
  94756. * An event triggered when a geometry is created
  94757. */
  94758. onNewGeometryAddedObservable: Observable<Geometry>;
  94759. /**
  94760. * An event triggered when a geometry is removed
  94761. */
  94762. onGeometryRemovedObservable: Observable<Geometry>;
  94763. /**
  94764. * An event triggered when a transform node is created
  94765. */
  94766. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  94767. /**
  94768. * An event triggered when a transform node is removed
  94769. */
  94770. onTransformNodeRemovedObservable: Observable<TransformNode>;
  94771. /**
  94772. * An event triggered when a mesh is created
  94773. */
  94774. onNewMeshAddedObservable: Observable<AbstractMesh>;
  94775. /**
  94776. * An event triggered when a mesh is removed
  94777. */
  94778. onMeshRemovedObservable: Observable<AbstractMesh>;
  94779. /**
  94780. * An event triggered when a skeleton is created
  94781. */
  94782. onNewSkeletonAddedObservable: Observable<Skeleton>;
  94783. /**
  94784. * An event triggered when a skeleton is removed
  94785. */
  94786. onSkeletonRemovedObservable: Observable<Skeleton>;
  94787. /**
  94788. * An event triggered when a material is created
  94789. */
  94790. onNewMaterialAddedObservable: Observable<Material>;
  94791. /**
  94792. * An event triggered when a material is removed
  94793. */
  94794. onMaterialRemovedObservable: Observable<Material>;
  94795. /**
  94796. * An event triggered when a texture is created
  94797. */
  94798. onNewTextureAddedObservable: Observable<BaseTexture>;
  94799. /**
  94800. * An event triggered when a texture is removed
  94801. */
  94802. onTextureRemovedObservable: Observable<BaseTexture>;
  94803. /**
  94804. * An event triggered when render targets are about to be rendered
  94805. * Can happen multiple times per frame.
  94806. */
  94807. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  94808. /**
  94809. * An event triggered when render targets were rendered.
  94810. * Can happen multiple times per frame.
  94811. */
  94812. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  94813. /**
  94814. * An event triggered before calculating deterministic simulation step
  94815. */
  94816. onBeforeStepObservable: Observable<Scene>;
  94817. /**
  94818. * An event triggered after calculating deterministic simulation step
  94819. */
  94820. onAfterStepObservable: Observable<Scene>;
  94821. /**
  94822. * An event triggered when the activeCamera property is updated
  94823. */
  94824. onActiveCameraChanged: Observable<Scene>;
  94825. /**
  94826. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  94827. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  94828. * 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)
  94829. */
  94830. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  94831. /**
  94832. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  94833. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  94834. * 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)
  94835. */
  94836. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  94837. /**
  94838. * This Observable will when a mesh has been imported into the scene.
  94839. */
  94840. onMeshImportedObservable: Observable<AbstractMesh>;
  94841. /**
  94842. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  94843. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  94844. */
  94845. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  94846. /** @hidden */
  94847. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  94848. /**
  94849. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  94850. */
  94851. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  94852. /**
  94853. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  94854. */
  94855. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  94856. /**
  94857. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  94858. */
  94859. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  94860. /** Callback called when a pointer move is detected */
  94861. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  94862. /** Callback called when a pointer down is detected */
  94863. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  94864. /** Callback called when a pointer up is detected */
  94865. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  94866. /** Callback called when a pointer pick is detected */
  94867. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  94868. /**
  94869. * 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).
  94870. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  94871. */
  94872. onPrePointerObservable: Observable<PointerInfoPre>;
  94873. /**
  94874. * Observable event triggered each time an input event is received from the rendering canvas
  94875. */
  94876. onPointerObservable: Observable<PointerInfo>;
  94877. /**
  94878. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  94879. */
  94880. readonly unTranslatedPointer: Vector2;
  94881. /**
  94882. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  94883. */
  94884. static DragMovementThreshold: number;
  94885. /**
  94886. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  94887. */
  94888. static LongPressDelay: number;
  94889. /**
  94890. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  94891. */
  94892. static DoubleClickDelay: number;
  94893. /** If you need to check double click without raising a single click at first click, enable this flag */
  94894. static ExclusiveDoubleClickMode: boolean;
  94895. /** @hidden */
  94896. _mirroredCameraPosition: Nullable<Vector3>;
  94897. /**
  94898. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  94899. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  94900. */
  94901. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  94902. /**
  94903. * Observable event triggered each time an keyboard event is received from the hosting window
  94904. */
  94905. onKeyboardObservable: Observable<KeyboardInfo>;
  94906. private _useRightHandedSystem;
  94907. /**
  94908. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  94909. */
  94910. useRightHandedSystem: boolean;
  94911. private _timeAccumulator;
  94912. private _currentStepId;
  94913. private _currentInternalStep;
  94914. /**
  94915. * Sets the step Id used by deterministic lock step
  94916. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94917. * @param newStepId defines the step Id
  94918. */
  94919. setStepId(newStepId: number): void;
  94920. /**
  94921. * Gets the step Id used by deterministic lock step
  94922. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94923. * @returns the step Id
  94924. */
  94925. getStepId(): number;
  94926. /**
  94927. * Gets the internal step used by deterministic lock step
  94928. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94929. * @returns the internal step
  94930. */
  94931. getInternalStep(): number;
  94932. private _fogEnabled;
  94933. /**
  94934. * Gets or sets a boolean indicating if fog is enabled on this scene
  94935. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94936. * (Default is true)
  94937. */
  94938. fogEnabled: boolean;
  94939. private _fogMode;
  94940. /**
  94941. * Gets or sets the fog mode to use
  94942. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94943. * | mode | value |
  94944. * | --- | --- |
  94945. * | FOGMODE_NONE | 0 |
  94946. * | FOGMODE_EXP | 1 |
  94947. * | FOGMODE_EXP2 | 2 |
  94948. * | FOGMODE_LINEAR | 3 |
  94949. */
  94950. fogMode: number;
  94951. /**
  94952. * Gets or sets the fog color to use
  94953. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94954. * (Default is Color3(0.2, 0.2, 0.3))
  94955. */
  94956. fogColor: Color3;
  94957. /**
  94958. * Gets or sets the fog density to use
  94959. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94960. * (Default is 0.1)
  94961. */
  94962. fogDensity: number;
  94963. /**
  94964. * Gets or sets the fog start distance to use
  94965. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94966. * (Default is 0)
  94967. */
  94968. fogStart: number;
  94969. /**
  94970. * Gets or sets the fog end distance to use
  94971. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94972. * (Default is 1000)
  94973. */
  94974. fogEnd: number;
  94975. private _shadowsEnabled;
  94976. /**
  94977. * Gets or sets a boolean indicating if shadows are enabled on this scene
  94978. */
  94979. shadowsEnabled: boolean;
  94980. private _lightsEnabled;
  94981. /**
  94982. * Gets or sets a boolean indicating if lights are enabled on this scene
  94983. */
  94984. lightsEnabled: boolean;
  94985. /** All of the active cameras added to this scene. */
  94986. activeCameras: Camera[];
  94987. /** @hidden */
  94988. _activeCamera: Nullable<Camera>;
  94989. /** Gets or sets the current active camera */
  94990. activeCamera: Nullable<Camera>;
  94991. private _defaultMaterial;
  94992. /** The default material used on meshes when no material is affected */
  94993. /** The default material used on meshes when no material is affected */
  94994. defaultMaterial: Material;
  94995. private _texturesEnabled;
  94996. /**
  94997. * Gets or sets a boolean indicating if textures are enabled on this scene
  94998. */
  94999. texturesEnabled: boolean;
  95000. /**
  95001. * Gets or sets a boolean indicating if particles are enabled on this scene
  95002. */
  95003. particlesEnabled: boolean;
  95004. /**
  95005. * Gets or sets a boolean indicating if sprites are enabled on this scene
  95006. */
  95007. spritesEnabled: boolean;
  95008. private _skeletonsEnabled;
  95009. /**
  95010. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  95011. */
  95012. skeletonsEnabled: boolean;
  95013. /**
  95014. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  95015. */
  95016. lensFlaresEnabled: boolean;
  95017. /**
  95018. * Gets or sets a boolean indicating if collisions are enabled on this scene
  95019. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95020. */
  95021. collisionsEnabled: boolean;
  95022. private _collisionCoordinator;
  95023. /** @hidden */
  95024. readonly collisionCoordinator: ICollisionCoordinator;
  95025. /**
  95026. * Defines the gravity applied to this scene (used only for collisions)
  95027. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95028. */
  95029. gravity: Vector3;
  95030. /**
  95031. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  95032. */
  95033. postProcessesEnabled: boolean;
  95034. /**
  95035. * The list of postprocesses added to the scene
  95036. */
  95037. postProcesses: PostProcess[];
  95038. /**
  95039. * Gets the current postprocess manager
  95040. */
  95041. postProcessManager: PostProcessManager;
  95042. /**
  95043. * Gets or sets a boolean indicating if render targets are enabled on this scene
  95044. */
  95045. renderTargetsEnabled: boolean;
  95046. /**
  95047. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  95048. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  95049. */
  95050. dumpNextRenderTargets: boolean;
  95051. /**
  95052. * The list of user defined render targets added to the scene
  95053. */
  95054. customRenderTargets: RenderTargetTexture[];
  95055. /**
  95056. * Defines if texture loading must be delayed
  95057. * If true, textures will only be loaded when they need to be rendered
  95058. */
  95059. useDelayedTextureLoading: boolean;
  95060. /**
  95061. * Gets the list of meshes imported to the scene through SceneLoader
  95062. */
  95063. importedMeshesFiles: String[];
  95064. /**
  95065. * Gets or sets a boolean indicating if probes are enabled on this scene
  95066. */
  95067. probesEnabled: boolean;
  95068. /**
  95069. * Gets or sets the current offline provider to use to store scene data
  95070. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  95071. */
  95072. offlineProvider: IOfflineProvider;
  95073. /**
  95074. * Gets or sets the action manager associated with the scene
  95075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95076. */
  95077. actionManager: AbstractActionManager;
  95078. private _meshesForIntersections;
  95079. /**
  95080. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  95081. */
  95082. proceduralTexturesEnabled: boolean;
  95083. private _engine;
  95084. private _totalVertices;
  95085. /** @hidden */
  95086. _activeIndices: PerfCounter;
  95087. /** @hidden */
  95088. _activeParticles: PerfCounter;
  95089. /** @hidden */
  95090. _activeBones: PerfCounter;
  95091. private _animationRatio;
  95092. /** @hidden */
  95093. _animationTimeLast: number;
  95094. /** @hidden */
  95095. _animationTime: number;
  95096. /**
  95097. * Gets or sets a general scale for animation speed
  95098. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  95099. */
  95100. animationTimeScale: number;
  95101. /** @hidden */
  95102. _cachedMaterial: Nullable<Material>;
  95103. /** @hidden */
  95104. _cachedEffect: Nullable<Effect>;
  95105. /** @hidden */
  95106. _cachedVisibility: Nullable<number>;
  95107. private _renderId;
  95108. private _frameId;
  95109. private _executeWhenReadyTimeoutId;
  95110. private _intermediateRendering;
  95111. private _viewUpdateFlag;
  95112. private _projectionUpdateFlag;
  95113. /** @hidden */
  95114. _toBeDisposed: Nullable<IDisposable>[];
  95115. private _activeRequests;
  95116. /** @hidden */
  95117. _pendingData: any[];
  95118. private _isDisposed;
  95119. /**
  95120. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  95121. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  95122. */
  95123. dispatchAllSubMeshesOfActiveMeshes: boolean;
  95124. private _activeMeshes;
  95125. private _processedMaterials;
  95126. private _renderTargets;
  95127. /** @hidden */
  95128. _activeParticleSystems: SmartArray<IParticleSystem>;
  95129. private _activeSkeletons;
  95130. private _softwareSkinnedMeshes;
  95131. private _renderingManager;
  95132. /** @hidden */
  95133. _activeAnimatables: Animatable[];
  95134. private _transformMatrix;
  95135. private _sceneUbo;
  95136. /** @hidden */
  95137. _viewMatrix: Matrix;
  95138. private _projectionMatrix;
  95139. /** @hidden */
  95140. _forcedViewPosition: Nullable<Vector3>;
  95141. /** @hidden */
  95142. _frustumPlanes: Plane[];
  95143. /**
  95144. * Gets the list of frustum planes (built from the active camera)
  95145. */
  95146. readonly frustumPlanes: Plane[];
  95147. /**
  95148. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  95149. * This is useful if there are more lights that the maximum simulteanous authorized
  95150. */
  95151. requireLightSorting: boolean;
  95152. /** @hidden */
  95153. readonly useMaterialMeshMap: boolean;
  95154. /** @hidden */
  95155. readonly useClonedMeshhMap: boolean;
  95156. private _externalData;
  95157. private _uid;
  95158. /**
  95159. * @hidden
  95160. * Backing store of defined scene components.
  95161. */
  95162. _components: ISceneComponent[];
  95163. /**
  95164. * @hidden
  95165. * Backing store of defined scene components.
  95166. */
  95167. _serializableComponents: ISceneSerializableComponent[];
  95168. /**
  95169. * List of components to register on the next registration step.
  95170. */
  95171. private _transientComponents;
  95172. /**
  95173. * Registers the transient components if needed.
  95174. */
  95175. private _registerTransientComponents;
  95176. /**
  95177. * @hidden
  95178. * Add a component to the scene.
  95179. * Note that the ccomponent could be registered on th next frame if this is called after
  95180. * the register component stage.
  95181. * @param component Defines the component to add to the scene
  95182. */
  95183. _addComponent(component: ISceneComponent): void;
  95184. /**
  95185. * @hidden
  95186. * Gets a component from the scene.
  95187. * @param name defines the name of the component to retrieve
  95188. * @returns the component or null if not present
  95189. */
  95190. _getComponent(name: string): Nullable<ISceneComponent>;
  95191. /**
  95192. * @hidden
  95193. * Defines the actions happening before camera updates.
  95194. */
  95195. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  95196. /**
  95197. * @hidden
  95198. * Defines the actions happening before clear the canvas.
  95199. */
  95200. _beforeClearStage: Stage<SimpleStageAction>;
  95201. /**
  95202. * @hidden
  95203. * Defines the actions when collecting render targets for the frame.
  95204. */
  95205. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95206. /**
  95207. * @hidden
  95208. * Defines the actions happening for one camera in the frame.
  95209. */
  95210. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95211. /**
  95212. * @hidden
  95213. * Defines the actions happening during the per mesh ready checks.
  95214. */
  95215. _isReadyForMeshStage: Stage<MeshStageAction>;
  95216. /**
  95217. * @hidden
  95218. * Defines the actions happening before evaluate active mesh checks.
  95219. */
  95220. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  95221. /**
  95222. * @hidden
  95223. * Defines the actions happening during the evaluate sub mesh checks.
  95224. */
  95225. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  95226. /**
  95227. * @hidden
  95228. * Defines the actions happening during the active mesh stage.
  95229. */
  95230. _activeMeshStage: Stage<ActiveMeshStageAction>;
  95231. /**
  95232. * @hidden
  95233. * Defines the actions happening during the per camera render target step.
  95234. */
  95235. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  95236. /**
  95237. * @hidden
  95238. * Defines the actions happening just before the active camera is drawing.
  95239. */
  95240. _beforeCameraDrawStage: Stage<CameraStageAction>;
  95241. /**
  95242. * @hidden
  95243. * Defines the actions happening just before a render target is drawing.
  95244. */
  95245. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95246. /**
  95247. * @hidden
  95248. * Defines the actions happening just before a rendering group is drawing.
  95249. */
  95250. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95251. /**
  95252. * @hidden
  95253. * Defines the actions happening just before a mesh is drawing.
  95254. */
  95255. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95256. /**
  95257. * @hidden
  95258. * Defines the actions happening just after a mesh has been drawn.
  95259. */
  95260. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95261. /**
  95262. * @hidden
  95263. * Defines the actions happening just after a rendering group has been drawn.
  95264. */
  95265. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95266. /**
  95267. * @hidden
  95268. * Defines the actions happening just after the active camera has been drawn.
  95269. */
  95270. _afterCameraDrawStage: Stage<CameraStageAction>;
  95271. /**
  95272. * @hidden
  95273. * Defines the actions happening just after a render target has been drawn.
  95274. */
  95275. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95276. /**
  95277. * @hidden
  95278. * Defines the actions happening just after rendering all cameras and computing intersections.
  95279. */
  95280. _afterRenderStage: Stage<SimpleStageAction>;
  95281. /**
  95282. * @hidden
  95283. * Defines the actions happening when a pointer move event happens.
  95284. */
  95285. _pointerMoveStage: Stage<PointerMoveStageAction>;
  95286. /**
  95287. * @hidden
  95288. * Defines the actions happening when a pointer down event happens.
  95289. */
  95290. _pointerDownStage: Stage<PointerUpDownStageAction>;
  95291. /**
  95292. * @hidden
  95293. * Defines the actions happening when a pointer up event happens.
  95294. */
  95295. _pointerUpStage: Stage<PointerUpDownStageAction>;
  95296. /**
  95297. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  95298. */
  95299. private geometriesByUniqueId;
  95300. /**
  95301. * Creates a new Scene
  95302. * @param engine defines the engine to use to render this scene
  95303. * @param options defines the scene options
  95304. */
  95305. constructor(engine: Engine, options?: SceneOptions);
  95306. /**
  95307. * Gets a string idenfifying the name of the class
  95308. * @returns "Scene" string
  95309. */
  95310. getClassName(): string;
  95311. private _defaultMeshCandidates;
  95312. /**
  95313. * @hidden
  95314. */
  95315. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95316. private _defaultSubMeshCandidates;
  95317. /**
  95318. * @hidden
  95319. */
  95320. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95321. /**
  95322. * Sets the default candidate providers for the scene.
  95323. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  95324. * and getCollidingSubMeshCandidates to their default function
  95325. */
  95326. setDefaultCandidateProviders(): void;
  95327. /**
  95328. * Gets the mesh that is currently under the pointer
  95329. */
  95330. readonly meshUnderPointer: Nullable<AbstractMesh>;
  95331. /**
  95332. * Gets or sets the current on-screen X position of the pointer
  95333. */
  95334. pointerX: number;
  95335. /**
  95336. * Gets or sets the current on-screen Y position of the pointer
  95337. */
  95338. pointerY: number;
  95339. /**
  95340. * Gets the cached material (ie. the latest rendered one)
  95341. * @returns the cached material
  95342. */
  95343. getCachedMaterial(): Nullable<Material>;
  95344. /**
  95345. * Gets the cached effect (ie. the latest rendered one)
  95346. * @returns the cached effect
  95347. */
  95348. getCachedEffect(): Nullable<Effect>;
  95349. /**
  95350. * Gets the cached visibility state (ie. the latest rendered one)
  95351. * @returns the cached visibility state
  95352. */
  95353. getCachedVisibility(): Nullable<number>;
  95354. /**
  95355. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  95356. * @param material defines the current material
  95357. * @param effect defines the current effect
  95358. * @param visibility defines the current visibility state
  95359. * @returns true if one parameter is not cached
  95360. */
  95361. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  95362. /**
  95363. * Gets the engine associated with the scene
  95364. * @returns an Engine
  95365. */
  95366. getEngine(): Engine;
  95367. /**
  95368. * Gets the total number of vertices rendered per frame
  95369. * @returns the total number of vertices rendered per frame
  95370. */
  95371. getTotalVertices(): number;
  95372. /**
  95373. * Gets the performance counter for total vertices
  95374. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95375. */
  95376. readonly totalVerticesPerfCounter: PerfCounter;
  95377. /**
  95378. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  95379. * @returns the total number of active indices rendered per frame
  95380. */
  95381. getActiveIndices(): number;
  95382. /**
  95383. * Gets the performance counter for active indices
  95384. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95385. */
  95386. readonly totalActiveIndicesPerfCounter: PerfCounter;
  95387. /**
  95388. * Gets the total number of active particles rendered per frame
  95389. * @returns the total number of active particles rendered per frame
  95390. */
  95391. getActiveParticles(): number;
  95392. /**
  95393. * Gets the performance counter for active particles
  95394. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95395. */
  95396. readonly activeParticlesPerfCounter: PerfCounter;
  95397. /**
  95398. * Gets the total number of active bones rendered per frame
  95399. * @returns the total number of active bones rendered per frame
  95400. */
  95401. getActiveBones(): number;
  95402. /**
  95403. * Gets the performance counter for active bones
  95404. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95405. */
  95406. readonly activeBonesPerfCounter: PerfCounter;
  95407. /**
  95408. * Gets the array of active meshes
  95409. * @returns an array of AbstractMesh
  95410. */
  95411. getActiveMeshes(): SmartArray<AbstractMesh>;
  95412. /**
  95413. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  95414. * @returns a number
  95415. */
  95416. getAnimationRatio(): number;
  95417. /**
  95418. * Gets an unique Id for the current render phase
  95419. * @returns a number
  95420. */
  95421. getRenderId(): number;
  95422. /**
  95423. * Gets an unique Id for the current frame
  95424. * @returns a number
  95425. */
  95426. getFrameId(): number;
  95427. /** Call this function if you want to manually increment the render Id*/
  95428. incrementRenderId(): void;
  95429. private _createUbo;
  95430. /**
  95431. * Use this method to simulate a pointer move on a mesh
  95432. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95433. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95434. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95435. * @returns the current scene
  95436. */
  95437. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95438. /**
  95439. * Use this method to simulate a pointer down on a mesh
  95440. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95441. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95442. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95443. * @returns the current scene
  95444. */
  95445. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95446. /**
  95447. * Use this method to simulate a pointer up on a mesh
  95448. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95449. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95450. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95451. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  95452. * @returns the current scene
  95453. */
  95454. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  95455. /**
  95456. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  95457. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  95458. * @returns true if the pointer was captured
  95459. */
  95460. isPointerCaptured(pointerId?: number): boolean;
  95461. /**
  95462. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  95463. * @param attachUp defines if you want to attach events to pointerup
  95464. * @param attachDown defines if you want to attach events to pointerdown
  95465. * @param attachMove defines if you want to attach events to pointermove
  95466. */
  95467. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  95468. /** Detaches all event handlers*/
  95469. detachControl(): void;
  95470. /**
  95471. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  95472. * Delay loaded resources are not taking in account
  95473. * @return true if all required resources are ready
  95474. */
  95475. isReady(): boolean;
  95476. /** Resets all cached information relative to material (including effect and visibility) */
  95477. resetCachedMaterial(): void;
  95478. /**
  95479. * Registers a function to be called before every frame render
  95480. * @param func defines the function to register
  95481. */
  95482. registerBeforeRender(func: () => void): void;
  95483. /**
  95484. * Unregisters a function called before every frame render
  95485. * @param func defines the function to unregister
  95486. */
  95487. unregisterBeforeRender(func: () => void): void;
  95488. /**
  95489. * Registers a function to be called after every frame render
  95490. * @param func defines the function to register
  95491. */
  95492. registerAfterRender(func: () => void): void;
  95493. /**
  95494. * Unregisters a function called after every frame render
  95495. * @param func defines the function to unregister
  95496. */
  95497. unregisterAfterRender(func: () => void): void;
  95498. private _executeOnceBeforeRender;
  95499. /**
  95500. * The provided function will run before render once and will be disposed afterwards.
  95501. * A timeout delay can be provided so that the function will be executed in N ms.
  95502. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  95503. * @param func The function to be executed.
  95504. * @param timeout optional delay in ms
  95505. */
  95506. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  95507. /** @hidden */
  95508. _addPendingData(data: any): void;
  95509. /** @hidden */
  95510. _removePendingData(data: any): void;
  95511. /**
  95512. * Returns the number of items waiting to be loaded
  95513. * @returns the number of items waiting to be loaded
  95514. */
  95515. getWaitingItemsCount(): number;
  95516. /**
  95517. * Returns a boolean indicating if the scene is still loading data
  95518. */
  95519. readonly isLoading: boolean;
  95520. /**
  95521. * Registers a function to be executed when the scene is ready
  95522. * @param {Function} func - the function to be executed
  95523. */
  95524. executeWhenReady(func: () => void): void;
  95525. /**
  95526. * Returns a promise that resolves when the scene is ready
  95527. * @returns A promise that resolves when the scene is ready
  95528. */
  95529. whenReadyAsync(): Promise<void>;
  95530. /** @hidden */
  95531. _checkIsReady(): void;
  95532. /**
  95533. * Gets all animatable attached to the scene
  95534. */
  95535. readonly animatables: Animatable[];
  95536. /**
  95537. * Resets the last animation time frame.
  95538. * Useful to override when animations start running when loading a scene for the first time.
  95539. */
  95540. resetLastAnimationTimeFrame(): void;
  95541. /**
  95542. * Gets the current view matrix
  95543. * @returns a Matrix
  95544. */
  95545. getViewMatrix(): Matrix;
  95546. /**
  95547. * Gets the current projection matrix
  95548. * @returns a Matrix
  95549. */
  95550. getProjectionMatrix(): Matrix;
  95551. /**
  95552. * Gets the current transform matrix
  95553. * @returns a Matrix made of View * Projection
  95554. */
  95555. getTransformMatrix(): Matrix;
  95556. /**
  95557. * Sets the current transform matrix
  95558. * @param viewL defines the View matrix to use
  95559. * @param projectionL defines the Projection matrix to use
  95560. * @param viewR defines the right View matrix to use (if provided)
  95561. * @param projectionR defines the right Projection matrix to use (if provided)
  95562. */
  95563. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  95564. /**
  95565. * Gets the uniform buffer used to store scene data
  95566. * @returns a UniformBuffer
  95567. */
  95568. getSceneUniformBuffer(): UniformBuffer;
  95569. /**
  95570. * Gets an unique (relatively to the current scene) Id
  95571. * @returns an unique number for the scene
  95572. */
  95573. getUniqueId(): number;
  95574. /**
  95575. * Add a mesh to the list of scene's meshes
  95576. * @param newMesh defines the mesh to add
  95577. * @param recursive if all child meshes should also be added to the scene
  95578. */
  95579. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  95580. /**
  95581. * Remove a mesh for the list of scene's meshes
  95582. * @param toRemove defines the mesh to remove
  95583. * @param recursive if all child meshes should also be removed from the scene
  95584. * @returns the index where the mesh was in the mesh list
  95585. */
  95586. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  95587. /**
  95588. * Add a transform node to the list of scene's transform nodes
  95589. * @param newTransformNode defines the transform node to add
  95590. */
  95591. addTransformNode(newTransformNode: TransformNode): void;
  95592. /**
  95593. * Remove a transform node for the list of scene's transform nodes
  95594. * @param toRemove defines the transform node to remove
  95595. * @returns the index where the transform node was in the transform node list
  95596. */
  95597. removeTransformNode(toRemove: TransformNode): number;
  95598. /**
  95599. * Remove a skeleton for the list of scene's skeletons
  95600. * @param toRemove defines the skeleton to remove
  95601. * @returns the index where the skeleton was in the skeleton list
  95602. */
  95603. removeSkeleton(toRemove: Skeleton): number;
  95604. /**
  95605. * Remove a morph target for the list of scene's morph targets
  95606. * @param toRemove defines the morph target to remove
  95607. * @returns the index where the morph target was in the morph target list
  95608. */
  95609. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  95610. /**
  95611. * Remove a light for the list of scene's lights
  95612. * @param toRemove defines the light to remove
  95613. * @returns the index where the light was in the light list
  95614. */
  95615. removeLight(toRemove: Light): number;
  95616. /**
  95617. * Remove a camera for the list of scene's cameras
  95618. * @param toRemove defines the camera to remove
  95619. * @returns the index where the camera was in the camera list
  95620. */
  95621. removeCamera(toRemove: Camera): number;
  95622. /**
  95623. * Remove a particle system for the list of scene's particle systems
  95624. * @param toRemove defines the particle system to remove
  95625. * @returns the index where the particle system was in the particle system list
  95626. */
  95627. removeParticleSystem(toRemove: IParticleSystem): number;
  95628. /**
  95629. * Remove a animation for the list of scene's animations
  95630. * @param toRemove defines the animation to remove
  95631. * @returns the index where the animation was in the animation list
  95632. */
  95633. removeAnimation(toRemove: Animation): number;
  95634. /**
  95635. * Will stop the animation of the given target
  95636. * @param target - the target
  95637. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  95638. * @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)
  95639. */
  95640. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  95641. /**
  95642. * Removes the given animation group from this scene.
  95643. * @param toRemove The animation group to remove
  95644. * @returns The index of the removed animation group
  95645. */
  95646. removeAnimationGroup(toRemove: AnimationGroup): number;
  95647. /**
  95648. * Removes the given multi-material from this scene.
  95649. * @param toRemove The multi-material to remove
  95650. * @returns The index of the removed multi-material
  95651. */
  95652. removeMultiMaterial(toRemove: MultiMaterial): number;
  95653. /**
  95654. * Removes the given material from this scene.
  95655. * @param toRemove The material to remove
  95656. * @returns The index of the removed material
  95657. */
  95658. removeMaterial(toRemove: Material): number;
  95659. /**
  95660. * Removes the given action manager from this scene.
  95661. * @param toRemove The action manager to remove
  95662. * @returns The index of the removed action manager
  95663. */
  95664. removeActionManager(toRemove: AbstractActionManager): number;
  95665. /**
  95666. * Removes the given texture from this scene.
  95667. * @param toRemove The texture to remove
  95668. * @returns The index of the removed texture
  95669. */
  95670. removeTexture(toRemove: BaseTexture): number;
  95671. /**
  95672. * Adds the given light to this scene
  95673. * @param newLight The light to add
  95674. */
  95675. addLight(newLight: Light): void;
  95676. /**
  95677. * Sorts the list list based on light priorities
  95678. */
  95679. sortLightsByPriority(): void;
  95680. /**
  95681. * Adds the given camera to this scene
  95682. * @param newCamera The camera to add
  95683. */
  95684. addCamera(newCamera: Camera): void;
  95685. /**
  95686. * Adds the given skeleton to this scene
  95687. * @param newSkeleton The skeleton to add
  95688. */
  95689. addSkeleton(newSkeleton: Skeleton): void;
  95690. /**
  95691. * Adds the given particle system to this scene
  95692. * @param newParticleSystem The particle system to add
  95693. */
  95694. addParticleSystem(newParticleSystem: IParticleSystem): void;
  95695. /**
  95696. * Adds the given animation to this scene
  95697. * @param newAnimation The animation to add
  95698. */
  95699. addAnimation(newAnimation: Animation): void;
  95700. /**
  95701. * Adds the given animation group to this scene.
  95702. * @param newAnimationGroup The animation group to add
  95703. */
  95704. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  95705. /**
  95706. * Adds the given multi-material to this scene
  95707. * @param newMultiMaterial The multi-material to add
  95708. */
  95709. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  95710. /**
  95711. * Adds the given material to this scene
  95712. * @param newMaterial The material to add
  95713. */
  95714. addMaterial(newMaterial: Material): void;
  95715. /**
  95716. * Adds the given morph target to this scene
  95717. * @param newMorphTargetManager The morph target to add
  95718. */
  95719. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  95720. /**
  95721. * Adds the given geometry to this scene
  95722. * @param newGeometry The geometry to add
  95723. */
  95724. addGeometry(newGeometry: Geometry): void;
  95725. /**
  95726. * Adds the given action manager to this scene
  95727. * @param newActionManager The action manager to add
  95728. */
  95729. addActionManager(newActionManager: AbstractActionManager): void;
  95730. /**
  95731. * Adds the given texture to this scene.
  95732. * @param newTexture The texture to add
  95733. */
  95734. addTexture(newTexture: BaseTexture): void;
  95735. /**
  95736. * Switch active camera
  95737. * @param newCamera defines the new active camera
  95738. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  95739. */
  95740. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  95741. /**
  95742. * sets the active camera of the scene using its ID
  95743. * @param id defines the camera's ID
  95744. * @return the new active camera or null if none found.
  95745. */
  95746. setActiveCameraByID(id: string): Nullable<Camera>;
  95747. /**
  95748. * sets the active camera of the scene using its name
  95749. * @param name defines the camera's name
  95750. * @returns the new active camera or null if none found.
  95751. */
  95752. setActiveCameraByName(name: string): Nullable<Camera>;
  95753. /**
  95754. * get an animation group using its name
  95755. * @param name defines the material's name
  95756. * @return the animation group or null if none found.
  95757. */
  95758. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  95759. /**
  95760. * Get a material using its unique id
  95761. * @param uniqueId defines the material's unique id
  95762. * @return the material or null if none found.
  95763. */
  95764. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  95765. /**
  95766. * get a material using its id
  95767. * @param id defines the material's ID
  95768. * @return the material or null if none found.
  95769. */
  95770. getMaterialByID(id: string): Nullable<Material>;
  95771. /**
  95772. * Gets a material using its name
  95773. * @param name defines the material's name
  95774. * @return the material or null if none found.
  95775. */
  95776. getMaterialByName(name: string): Nullable<Material>;
  95777. /**
  95778. * Gets a camera using its id
  95779. * @param id defines the id to look for
  95780. * @returns the camera or null if not found
  95781. */
  95782. getCameraByID(id: string): Nullable<Camera>;
  95783. /**
  95784. * Gets a camera using its unique id
  95785. * @param uniqueId defines the unique id to look for
  95786. * @returns the camera or null if not found
  95787. */
  95788. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  95789. /**
  95790. * Gets a camera using its name
  95791. * @param name defines the camera's name
  95792. * @return the camera or null if none found.
  95793. */
  95794. getCameraByName(name: string): Nullable<Camera>;
  95795. /**
  95796. * Gets a bone using its id
  95797. * @param id defines the bone's id
  95798. * @return the bone or null if not found
  95799. */
  95800. getBoneByID(id: string): Nullable<Bone>;
  95801. /**
  95802. * Gets a bone using its id
  95803. * @param name defines the bone's name
  95804. * @return the bone or null if not found
  95805. */
  95806. getBoneByName(name: string): Nullable<Bone>;
  95807. /**
  95808. * Gets a light node using its name
  95809. * @param name defines the the light's name
  95810. * @return the light or null if none found.
  95811. */
  95812. getLightByName(name: string): Nullable<Light>;
  95813. /**
  95814. * Gets a light node using its id
  95815. * @param id defines the light's id
  95816. * @return the light or null if none found.
  95817. */
  95818. getLightByID(id: string): Nullable<Light>;
  95819. /**
  95820. * Gets a light node using its scene-generated unique ID
  95821. * @param uniqueId defines the light's unique id
  95822. * @return the light or null if none found.
  95823. */
  95824. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  95825. /**
  95826. * Gets a particle system by id
  95827. * @param id defines the particle system id
  95828. * @return the corresponding system or null if none found
  95829. */
  95830. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  95831. /**
  95832. * Gets a geometry using its ID
  95833. * @param id defines the geometry's id
  95834. * @return the geometry or null if none found.
  95835. */
  95836. getGeometryByID(id: string): Nullable<Geometry>;
  95837. private _getGeometryByUniqueID;
  95838. /**
  95839. * Add a new geometry to this scene
  95840. * @param geometry defines the geometry to be added to the scene.
  95841. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  95842. * @return a boolean defining if the geometry was added or not
  95843. */
  95844. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  95845. /**
  95846. * Removes an existing geometry
  95847. * @param geometry defines the geometry to be removed from the scene
  95848. * @return a boolean defining if the geometry was removed or not
  95849. */
  95850. removeGeometry(geometry: Geometry): boolean;
  95851. /**
  95852. * Gets the list of geometries attached to the scene
  95853. * @returns an array of Geometry
  95854. */
  95855. getGeometries(): Geometry[];
  95856. /**
  95857. * Gets the first added mesh found of a given ID
  95858. * @param id defines the id to search for
  95859. * @return the mesh found or null if not found at all
  95860. */
  95861. getMeshByID(id: string): Nullable<AbstractMesh>;
  95862. /**
  95863. * Gets a list of meshes using their id
  95864. * @param id defines the id to search for
  95865. * @returns a list of meshes
  95866. */
  95867. getMeshesByID(id: string): Array<AbstractMesh>;
  95868. /**
  95869. * Gets the first added transform node found of a given ID
  95870. * @param id defines the id to search for
  95871. * @return the found transform node or null if not found at all.
  95872. */
  95873. getTransformNodeByID(id: string): Nullable<TransformNode>;
  95874. /**
  95875. * Gets a transform node with its auto-generated unique id
  95876. * @param uniqueId efines the unique id to search for
  95877. * @return the found transform node or null if not found at all.
  95878. */
  95879. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  95880. /**
  95881. * Gets a list of transform nodes using their id
  95882. * @param id defines the id to search for
  95883. * @returns a list of transform nodes
  95884. */
  95885. getTransformNodesByID(id: string): Array<TransformNode>;
  95886. /**
  95887. * Gets a mesh with its auto-generated unique id
  95888. * @param uniqueId defines the unique id to search for
  95889. * @return the found mesh or null if not found at all.
  95890. */
  95891. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  95892. /**
  95893. * Gets a the last added mesh using a given id
  95894. * @param id defines the id to search for
  95895. * @return the found mesh or null if not found at all.
  95896. */
  95897. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  95898. /**
  95899. * Gets a the last added node (Mesh, Camera, Light) using a given id
  95900. * @param id defines the id to search for
  95901. * @return the found node or null if not found at all
  95902. */
  95903. getLastEntryByID(id: string): Nullable<Node>;
  95904. /**
  95905. * Gets a node (Mesh, Camera, Light) using a given id
  95906. * @param id defines the id to search for
  95907. * @return the found node or null if not found at all
  95908. */
  95909. getNodeByID(id: string): Nullable<Node>;
  95910. /**
  95911. * Gets a node (Mesh, Camera, Light) using a given name
  95912. * @param name defines the name to search for
  95913. * @return the found node or null if not found at all.
  95914. */
  95915. getNodeByName(name: string): Nullable<Node>;
  95916. /**
  95917. * Gets a mesh using a given name
  95918. * @param name defines the name to search for
  95919. * @return the found mesh or null if not found at all.
  95920. */
  95921. getMeshByName(name: string): Nullable<AbstractMesh>;
  95922. /**
  95923. * Gets a transform node using a given name
  95924. * @param name defines the name to search for
  95925. * @return the found transform node or null if not found at all.
  95926. */
  95927. getTransformNodeByName(name: string): Nullable<TransformNode>;
  95928. /**
  95929. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  95930. * @param id defines the id to search for
  95931. * @return the found skeleton or null if not found at all.
  95932. */
  95933. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  95934. /**
  95935. * Gets a skeleton using a given auto generated unique id
  95936. * @param uniqueId defines the unique id to search for
  95937. * @return the found skeleton or null if not found at all.
  95938. */
  95939. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  95940. /**
  95941. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  95942. * @param id defines the id to search for
  95943. * @return the found skeleton or null if not found at all.
  95944. */
  95945. getSkeletonById(id: string): Nullable<Skeleton>;
  95946. /**
  95947. * Gets a skeleton using a given name
  95948. * @param name defines the name to search for
  95949. * @return the found skeleton or null if not found at all.
  95950. */
  95951. getSkeletonByName(name: string): Nullable<Skeleton>;
  95952. /**
  95953. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  95954. * @param id defines the id to search for
  95955. * @return the found morph target manager or null if not found at all.
  95956. */
  95957. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  95958. /**
  95959. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  95960. * @param id defines the id to search for
  95961. * @return the found morph target or null if not found at all.
  95962. */
  95963. getMorphTargetById(id: string): Nullable<MorphTarget>;
  95964. /**
  95965. * Gets a boolean indicating if the given mesh is active
  95966. * @param mesh defines the mesh to look for
  95967. * @returns true if the mesh is in the active list
  95968. */
  95969. isActiveMesh(mesh: AbstractMesh): boolean;
  95970. /**
  95971. * Return a unique id as a string which can serve as an identifier for the scene
  95972. */
  95973. readonly uid: string;
  95974. /**
  95975. * Add an externaly attached data from its key.
  95976. * This method call will fail and return false, if such key already exists.
  95977. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  95978. * @param key the unique key that identifies the data
  95979. * @param data the data object to associate to the key for this Engine instance
  95980. * @return true if no such key were already present and the data was added successfully, false otherwise
  95981. */
  95982. addExternalData<T>(key: string, data: T): boolean;
  95983. /**
  95984. * Get an externaly attached data from its key
  95985. * @param key the unique key that identifies the data
  95986. * @return the associated data, if present (can be null), or undefined if not present
  95987. */
  95988. getExternalData<T>(key: string): Nullable<T>;
  95989. /**
  95990. * Get an externaly attached data from its key, create it using a factory if it's not already present
  95991. * @param key the unique key that identifies the data
  95992. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  95993. * @return the associated data, can be null if the factory returned null.
  95994. */
  95995. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  95996. /**
  95997. * Remove an externaly attached data from the Engine instance
  95998. * @param key the unique key that identifies the data
  95999. * @return true if the data was successfully removed, false if it doesn't exist
  96000. */
  96001. removeExternalData(key: string): boolean;
  96002. private _evaluateSubMesh;
  96003. /**
  96004. * Clear the processed materials smart array preventing retention point in material dispose.
  96005. */
  96006. freeProcessedMaterials(): void;
  96007. private _preventFreeActiveMeshesAndRenderingGroups;
  96008. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  96009. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  96010. * when disposing several meshes in a row or a hierarchy of meshes.
  96011. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  96012. */
  96013. blockfreeActiveMeshesAndRenderingGroups: boolean;
  96014. /**
  96015. * Clear the active meshes smart array preventing retention point in mesh dispose.
  96016. */
  96017. freeActiveMeshes(): void;
  96018. /**
  96019. * Clear the info related to rendering groups preventing retention points during dispose.
  96020. */
  96021. freeRenderingGroups(): void;
  96022. /** @hidden */
  96023. _isInIntermediateRendering(): boolean;
  96024. /**
  96025. * Lambda returning the list of potentially active meshes.
  96026. */
  96027. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  96028. /**
  96029. * Lambda returning the list of potentially active sub meshes.
  96030. */
  96031. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  96032. /**
  96033. * Lambda returning the list of potentially intersecting sub meshes.
  96034. */
  96035. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  96036. /**
  96037. * Lambda returning the list of potentially colliding sub meshes.
  96038. */
  96039. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  96040. private _activeMeshesFrozen;
  96041. /**
  96042. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  96043. * @returns the current scene
  96044. */
  96045. freezeActiveMeshes(): Scene;
  96046. /**
  96047. * Use this function to restart evaluating active meshes on every frame
  96048. * @returns the current scene
  96049. */
  96050. unfreezeActiveMeshes(): Scene;
  96051. private _evaluateActiveMeshes;
  96052. private _activeMesh;
  96053. /**
  96054. * Update the transform matrix to update from the current active camera
  96055. * @param force defines a boolean used to force the update even if cache is up to date
  96056. */
  96057. updateTransformMatrix(force?: boolean): void;
  96058. private _bindFrameBuffer;
  96059. /** @hidden */
  96060. _allowPostProcessClearColor: boolean;
  96061. /** @hidden */
  96062. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  96063. private _processSubCameras;
  96064. private _checkIntersections;
  96065. /** @hidden */
  96066. _advancePhysicsEngineStep(step: number): void;
  96067. /**
  96068. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  96069. */
  96070. getDeterministicFrameTime: () => number;
  96071. /** @hidden */
  96072. _animate(): void;
  96073. /** Execute all animations (for a frame) */
  96074. animate(): void;
  96075. /**
  96076. * Render the scene
  96077. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  96078. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  96079. */
  96080. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  96081. /**
  96082. * Freeze all materials
  96083. * A frozen material will not be updatable but should be faster to render
  96084. */
  96085. freezeMaterials(): void;
  96086. /**
  96087. * Unfreeze all materials
  96088. * A frozen material will not be updatable but should be faster to render
  96089. */
  96090. unfreezeMaterials(): void;
  96091. /**
  96092. * Releases all held ressources
  96093. */
  96094. dispose(): void;
  96095. /**
  96096. * Gets if the scene is already disposed
  96097. */
  96098. readonly isDisposed: boolean;
  96099. /**
  96100. * Call this function to reduce memory footprint of the scene.
  96101. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  96102. */
  96103. clearCachedVertexData(): void;
  96104. /**
  96105. * This function will remove the local cached buffer data from texture.
  96106. * It will save memory but will prevent the texture from being rebuilt
  96107. */
  96108. cleanCachedTextureBuffer(): void;
  96109. /**
  96110. * Get the world extend vectors with an optional filter
  96111. *
  96112. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  96113. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  96114. */
  96115. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  96116. min: Vector3;
  96117. max: Vector3;
  96118. };
  96119. /**
  96120. * Creates a ray that can be used to pick in the scene
  96121. * @param x defines the x coordinate of the origin (on-screen)
  96122. * @param y defines the y coordinate of the origin (on-screen)
  96123. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96124. * @param camera defines the camera to use for the picking
  96125. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96126. * @returns a Ray
  96127. */
  96128. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  96129. /**
  96130. * Creates a ray that can be used to pick in the scene
  96131. * @param x defines the x coordinate of the origin (on-screen)
  96132. * @param y defines the y coordinate of the origin (on-screen)
  96133. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96134. * @param result defines the ray where to store the picking ray
  96135. * @param camera defines the camera to use for the picking
  96136. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96137. * @returns the current scene
  96138. */
  96139. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  96140. /**
  96141. * Creates a ray that can be used to pick in the scene
  96142. * @param x defines the x coordinate of the origin (on-screen)
  96143. * @param y defines the y coordinate of the origin (on-screen)
  96144. * @param camera defines the camera to use for the picking
  96145. * @returns a Ray
  96146. */
  96147. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  96148. /**
  96149. * Creates a ray that can be used to pick in the scene
  96150. * @param x defines the x coordinate of the origin (on-screen)
  96151. * @param y defines the y coordinate of the origin (on-screen)
  96152. * @param result defines the ray where to store the picking ray
  96153. * @param camera defines the camera to use for the picking
  96154. * @returns the current scene
  96155. */
  96156. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  96157. /** Launch a ray to try to pick a mesh in the scene
  96158. * @param x position on screen
  96159. * @param y position on screen
  96160. * @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
  96161. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  96162. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96163. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96164. * @returns a PickingInfo
  96165. */
  96166. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  96167. /** Use the given ray to pick a mesh in the scene
  96168. * @param ray The ray to use to pick meshes
  96169. * @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
  96170. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  96171. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96172. * @returns a PickingInfo
  96173. */
  96174. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96175. /**
  96176. * Launch a ray to try to pick a mesh in the scene
  96177. * @param x X position on screen
  96178. * @param y Y position on screen
  96179. * @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
  96180. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96181. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96182. * @returns an array of PickingInfo
  96183. */
  96184. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96185. /**
  96186. * Launch a ray to try to pick a mesh in the scene
  96187. * @param ray Ray to use
  96188. * @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
  96189. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96190. * @returns an array of PickingInfo
  96191. */
  96192. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96193. /**
  96194. * Force the value of meshUnderPointer
  96195. * @param mesh defines the mesh to use
  96196. */
  96197. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96198. /**
  96199. * Gets the mesh under the pointer
  96200. * @returns a Mesh or null if no mesh is under the pointer
  96201. */
  96202. getPointerOverMesh(): Nullable<AbstractMesh>;
  96203. /** @hidden */
  96204. _rebuildGeometries(): void;
  96205. /** @hidden */
  96206. _rebuildTextures(): void;
  96207. private _getByTags;
  96208. /**
  96209. * Get a list of meshes by tags
  96210. * @param tagsQuery defines the tags query to use
  96211. * @param forEach defines a predicate used to filter results
  96212. * @returns an array of Mesh
  96213. */
  96214. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  96215. /**
  96216. * Get a list of cameras by tags
  96217. * @param tagsQuery defines the tags query to use
  96218. * @param forEach defines a predicate used to filter results
  96219. * @returns an array of Camera
  96220. */
  96221. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  96222. /**
  96223. * Get a list of lights by tags
  96224. * @param tagsQuery defines the tags query to use
  96225. * @param forEach defines a predicate used to filter results
  96226. * @returns an array of Light
  96227. */
  96228. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  96229. /**
  96230. * Get a list of materials by tags
  96231. * @param tagsQuery defines the tags query to use
  96232. * @param forEach defines a predicate used to filter results
  96233. * @returns an array of Material
  96234. */
  96235. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  96236. /**
  96237. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96238. * This allowed control for front to back rendering or reversly depending of the special needs.
  96239. *
  96240. * @param renderingGroupId The rendering group id corresponding to its index
  96241. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96242. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96243. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96244. */
  96245. 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;
  96246. /**
  96247. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96248. *
  96249. * @param renderingGroupId The rendering group id corresponding to its index
  96250. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96251. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96252. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96253. */
  96254. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96255. /**
  96256. * Gets the current auto clear configuration for one rendering group of the rendering
  96257. * manager.
  96258. * @param index the rendering group index to get the information for
  96259. * @returns The auto clear setup for the requested rendering group
  96260. */
  96261. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96262. private _blockMaterialDirtyMechanism;
  96263. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  96264. blockMaterialDirtyMechanism: boolean;
  96265. /**
  96266. * Will flag all materials as dirty to trigger new shader compilation
  96267. * @param flag defines the flag used to specify which material part must be marked as dirty
  96268. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  96269. */
  96270. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  96271. /** @hidden */
  96272. _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;
  96273. /** @hidden */
  96274. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96275. }
  96276. }
  96277. declare module BABYLON {
  96278. /**
  96279. * Set of assets to keep when moving a scene into an asset container.
  96280. */
  96281. export class KeepAssets extends AbstractScene {
  96282. }
  96283. /**
  96284. * Container with a set of assets that can be added or removed from a scene.
  96285. */
  96286. export class AssetContainer extends AbstractScene {
  96287. /**
  96288. * The scene the AssetContainer belongs to.
  96289. */
  96290. scene: Scene;
  96291. /**
  96292. * Instantiates an AssetContainer.
  96293. * @param scene The scene the AssetContainer belongs to.
  96294. */
  96295. constructor(scene: Scene);
  96296. /**
  96297. * Adds all the assets from the container to the scene.
  96298. */
  96299. addAllToScene(): void;
  96300. /**
  96301. * Removes all the assets in the container from the scene
  96302. */
  96303. removeAllFromScene(): void;
  96304. /**
  96305. * Disposes all the assets in the container
  96306. */
  96307. dispose(): void;
  96308. private _moveAssets;
  96309. /**
  96310. * Removes all the assets contained in the scene and adds them to the container.
  96311. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  96312. */
  96313. moveAllFromScene(keepAssets?: KeepAssets): void;
  96314. /**
  96315. * 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.
  96316. * @returns the root mesh
  96317. */
  96318. createRootMesh(): Mesh;
  96319. }
  96320. }
  96321. declare module BABYLON {
  96322. /**
  96323. * Defines how the parser contract is defined.
  96324. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  96325. */
  96326. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  96327. /**
  96328. * Defines how the individual parser contract is defined.
  96329. * These parser can parse an individual asset
  96330. */
  96331. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  96332. /**
  96333. * Base class of the scene acting as a container for the different elements composing a scene.
  96334. * This class is dynamically extended by the different components of the scene increasing
  96335. * flexibility and reducing coupling
  96336. */
  96337. export abstract class AbstractScene {
  96338. /**
  96339. * Stores the list of available parsers in the application.
  96340. */
  96341. private static _BabylonFileParsers;
  96342. /**
  96343. * Stores the list of available individual parsers in the application.
  96344. */
  96345. private static _IndividualBabylonFileParsers;
  96346. /**
  96347. * Adds a parser in the list of available ones
  96348. * @param name Defines the name of the parser
  96349. * @param parser Defines the parser to add
  96350. */
  96351. static AddParser(name: string, parser: BabylonFileParser): void;
  96352. /**
  96353. * Gets a general parser from the list of avaialble ones
  96354. * @param name Defines the name of the parser
  96355. * @returns the requested parser or null
  96356. */
  96357. static GetParser(name: string): Nullable<BabylonFileParser>;
  96358. /**
  96359. * Adds n individual parser in the list of available ones
  96360. * @param name Defines the name of the parser
  96361. * @param parser Defines the parser to add
  96362. */
  96363. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  96364. /**
  96365. * Gets an individual parser from the list of avaialble ones
  96366. * @param name Defines the name of the parser
  96367. * @returns the requested parser or null
  96368. */
  96369. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  96370. /**
  96371. * Parser json data and populate both a scene and its associated container object
  96372. * @param jsonData Defines the data to parse
  96373. * @param scene Defines the scene to parse the data for
  96374. * @param container Defines the container attached to the parsing sequence
  96375. * @param rootUrl Defines the root url of the data
  96376. */
  96377. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  96378. /**
  96379. * Gets the list of root nodes (ie. nodes with no parent)
  96380. */
  96381. rootNodes: Node[];
  96382. /** All of the cameras added to this scene
  96383. * @see http://doc.babylonjs.com/babylon101/cameras
  96384. */
  96385. cameras: Camera[];
  96386. /**
  96387. * All of the lights added to this scene
  96388. * @see http://doc.babylonjs.com/babylon101/lights
  96389. */
  96390. lights: Light[];
  96391. /**
  96392. * All of the (abstract) meshes added to this scene
  96393. */
  96394. meshes: AbstractMesh[];
  96395. /**
  96396. * The list of skeletons added to the scene
  96397. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96398. */
  96399. skeletons: Skeleton[];
  96400. /**
  96401. * All of the particle systems added to this scene
  96402. * @see http://doc.babylonjs.com/babylon101/particles
  96403. */
  96404. particleSystems: IParticleSystem[];
  96405. /**
  96406. * Gets a list of Animations associated with the scene
  96407. */
  96408. animations: Animation[];
  96409. /**
  96410. * All of the animation groups added to this scene
  96411. * @see http://doc.babylonjs.com/how_to/group
  96412. */
  96413. animationGroups: AnimationGroup[];
  96414. /**
  96415. * All of the multi-materials added to this scene
  96416. * @see http://doc.babylonjs.com/how_to/multi_materials
  96417. */
  96418. multiMaterials: MultiMaterial[];
  96419. /**
  96420. * All of the materials added to this scene
  96421. * In the context of a Scene, it is not supposed to be modified manually.
  96422. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  96423. * Note also that the order of the Material wihin the array is not significant and might change.
  96424. * @see http://doc.babylonjs.com/babylon101/materials
  96425. */
  96426. materials: Material[];
  96427. /**
  96428. * The list of morph target managers added to the scene
  96429. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  96430. */
  96431. morphTargetManagers: MorphTargetManager[];
  96432. /**
  96433. * The list of geometries used in the scene.
  96434. */
  96435. geometries: Geometry[];
  96436. /**
  96437. * All of the tranform nodes added to this scene
  96438. * In the context of a Scene, it is not supposed to be modified manually.
  96439. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  96440. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  96441. * @see http://doc.babylonjs.com/how_to/transformnode
  96442. */
  96443. transformNodes: TransformNode[];
  96444. /**
  96445. * ActionManagers available on the scene.
  96446. */
  96447. actionManagers: AbstractActionManager[];
  96448. /**
  96449. * Textures to keep.
  96450. */
  96451. textures: BaseTexture[];
  96452. /**
  96453. * Environment texture for the scene
  96454. */
  96455. environmentTexture: Nullable<BaseTexture>;
  96456. }
  96457. }
  96458. declare module BABYLON {
  96459. /**
  96460. * Defines a sound that can be played in the application.
  96461. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  96462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96463. */
  96464. export class Sound {
  96465. /**
  96466. * The name of the sound in the scene.
  96467. */
  96468. name: string;
  96469. /**
  96470. * Does the sound autoplay once loaded.
  96471. */
  96472. autoplay: boolean;
  96473. /**
  96474. * Does the sound loop after it finishes playing once.
  96475. */
  96476. loop: boolean;
  96477. /**
  96478. * Does the sound use a custom attenuation curve to simulate the falloff
  96479. * happening when the source gets further away from the camera.
  96480. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96481. */
  96482. useCustomAttenuation: boolean;
  96483. /**
  96484. * The sound track id this sound belongs to.
  96485. */
  96486. soundTrackId: number;
  96487. /**
  96488. * Is this sound currently played.
  96489. */
  96490. isPlaying: boolean;
  96491. /**
  96492. * Is this sound currently paused.
  96493. */
  96494. isPaused: boolean;
  96495. /**
  96496. * Does this sound enables spatial sound.
  96497. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96498. */
  96499. spatialSound: boolean;
  96500. /**
  96501. * Define the reference distance the sound should be heard perfectly.
  96502. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96503. */
  96504. refDistance: number;
  96505. /**
  96506. * Define the roll off factor of spatial sounds.
  96507. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96508. */
  96509. rolloffFactor: number;
  96510. /**
  96511. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  96512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96513. */
  96514. maxDistance: number;
  96515. /**
  96516. * Define the distance attenuation model the sound will follow.
  96517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96518. */
  96519. distanceModel: string;
  96520. /**
  96521. * @hidden
  96522. * Back Compat
  96523. **/
  96524. onended: () => any;
  96525. /**
  96526. * Observable event when the current playing sound finishes.
  96527. */
  96528. onEndedObservable: Observable<Sound>;
  96529. private _panningModel;
  96530. private _playbackRate;
  96531. private _streaming;
  96532. private _startTime;
  96533. private _startOffset;
  96534. private _position;
  96535. /** @hidden */
  96536. _positionInEmitterSpace: boolean;
  96537. private _localDirection;
  96538. private _volume;
  96539. private _isReadyToPlay;
  96540. private _isDirectional;
  96541. private _readyToPlayCallback;
  96542. private _audioBuffer;
  96543. private _soundSource;
  96544. private _streamingSource;
  96545. private _soundPanner;
  96546. private _soundGain;
  96547. private _inputAudioNode;
  96548. private _outputAudioNode;
  96549. private _coneInnerAngle;
  96550. private _coneOuterAngle;
  96551. private _coneOuterGain;
  96552. private _scene;
  96553. private _connectedTransformNode;
  96554. private _customAttenuationFunction;
  96555. private _registerFunc;
  96556. private _isOutputConnected;
  96557. private _htmlAudioElement;
  96558. private _urlType;
  96559. /** @hidden */
  96560. static _SceneComponentInitialization: (scene: Scene) => void;
  96561. /**
  96562. * Create a sound and attach it to a scene
  96563. * @param name Name of your sound
  96564. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  96565. * @param scene defines the scene the sound belongs to
  96566. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  96567. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  96568. */
  96569. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  96570. /**
  96571. * Release the sound and its associated resources
  96572. */
  96573. dispose(): void;
  96574. /**
  96575. * Gets if the sounds is ready to be played or not.
  96576. * @returns true if ready, otherwise false
  96577. */
  96578. isReady(): boolean;
  96579. private _soundLoaded;
  96580. /**
  96581. * Sets the data of the sound from an audiobuffer
  96582. * @param audioBuffer The audioBuffer containing the data
  96583. */
  96584. setAudioBuffer(audioBuffer: AudioBuffer): void;
  96585. /**
  96586. * Updates the current sounds options such as maxdistance, loop...
  96587. * @param options A JSON object containing values named as the object properties
  96588. */
  96589. updateOptions(options: any): void;
  96590. private _createSpatialParameters;
  96591. private _updateSpatialParameters;
  96592. /**
  96593. * Switch the panning model to HRTF:
  96594. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  96595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96596. */
  96597. switchPanningModelToHRTF(): void;
  96598. /**
  96599. * Switch the panning model to Equal Power:
  96600. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  96601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96602. */
  96603. switchPanningModelToEqualPower(): void;
  96604. private _switchPanningModel;
  96605. /**
  96606. * Connect this sound to a sound track audio node like gain...
  96607. * @param soundTrackAudioNode the sound track audio node to connect to
  96608. */
  96609. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  96610. /**
  96611. * Transform this sound into a directional source
  96612. * @param coneInnerAngle Size of the inner cone in degree
  96613. * @param coneOuterAngle Size of the outer cone in degree
  96614. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  96615. */
  96616. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  96617. /**
  96618. * Gets or sets the inner angle for the directional cone.
  96619. */
  96620. /**
  96621. * Gets or sets the inner angle for the directional cone.
  96622. */
  96623. directionalConeInnerAngle: number;
  96624. /**
  96625. * Gets or sets the outer angle for the directional cone.
  96626. */
  96627. /**
  96628. * Gets or sets the outer angle for the directional cone.
  96629. */
  96630. directionalConeOuterAngle: number;
  96631. /**
  96632. * Sets the position of the emitter if spatial sound is enabled
  96633. * @param newPosition Defines the new posisiton
  96634. */
  96635. setPosition(newPosition: Vector3): void;
  96636. /**
  96637. * Sets the local direction of the emitter if spatial sound is enabled
  96638. * @param newLocalDirection Defines the new local direction
  96639. */
  96640. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  96641. private _updateDirection;
  96642. /** @hidden */
  96643. updateDistanceFromListener(): void;
  96644. /**
  96645. * Sets a new custom attenuation function for the sound.
  96646. * @param callback Defines the function used for the attenuation
  96647. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96648. */
  96649. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  96650. /**
  96651. * Play the sound
  96652. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  96653. * @param offset (optional) Start the sound setting it at a specific time
  96654. */
  96655. play(time?: number, offset?: number): void;
  96656. private _onended;
  96657. /**
  96658. * Stop the sound
  96659. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  96660. */
  96661. stop(time?: number): void;
  96662. /**
  96663. * Put the sound in pause
  96664. */
  96665. pause(): void;
  96666. /**
  96667. * Sets a dedicated volume for this sounds
  96668. * @param newVolume Define the new volume of the sound
  96669. * @param time Define in how long the sound should be at this value
  96670. */
  96671. setVolume(newVolume: number, time?: number): void;
  96672. /**
  96673. * Set the sound play back rate
  96674. * @param newPlaybackRate Define the playback rate the sound should be played at
  96675. */
  96676. setPlaybackRate(newPlaybackRate: number): void;
  96677. /**
  96678. * Gets the volume of the sound.
  96679. * @returns the volume of the sound
  96680. */
  96681. getVolume(): number;
  96682. /**
  96683. * Attach the sound to a dedicated mesh
  96684. * @param transformNode The transform node to connect the sound with
  96685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  96686. */
  96687. attachToMesh(transformNode: TransformNode): void;
  96688. /**
  96689. * Detach the sound from the previously attached mesh
  96690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  96691. */
  96692. detachFromMesh(): void;
  96693. private _onRegisterAfterWorldMatrixUpdate;
  96694. /**
  96695. * Clone the current sound in the scene.
  96696. * @returns the new sound clone
  96697. */
  96698. clone(): Nullable<Sound>;
  96699. /**
  96700. * Gets the current underlying audio buffer containing the data
  96701. * @returns the audio buffer
  96702. */
  96703. getAudioBuffer(): Nullable<AudioBuffer>;
  96704. /**
  96705. * Serializes the Sound in a JSON representation
  96706. * @returns the JSON representation of the sound
  96707. */
  96708. serialize(): any;
  96709. /**
  96710. * Parse a JSON representation of a sound to innstantiate in a given scene
  96711. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  96712. * @param scene Define the scene the new parsed sound should be created in
  96713. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  96714. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  96715. * @returns the newly parsed sound
  96716. */
  96717. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  96718. }
  96719. }
  96720. declare module BABYLON {
  96721. /**
  96722. * This defines an action helpful to play a defined sound on a triggered action.
  96723. */
  96724. export class PlaySoundAction extends Action {
  96725. private _sound;
  96726. /**
  96727. * Instantiate the action
  96728. * @param triggerOptions defines the trigger options
  96729. * @param sound defines the sound to play
  96730. * @param condition defines the trigger related conditions
  96731. */
  96732. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  96733. /** @hidden */
  96734. _prepare(): void;
  96735. /**
  96736. * Execute the action and play the sound.
  96737. */
  96738. execute(): void;
  96739. /**
  96740. * Serializes the actions and its related information.
  96741. * @param parent defines the object to serialize in
  96742. * @returns the serialized object
  96743. */
  96744. serialize(parent: any): any;
  96745. }
  96746. /**
  96747. * This defines an action helpful to stop a defined sound on a triggered action.
  96748. */
  96749. export class StopSoundAction extends Action {
  96750. private _sound;
  96751. /**
  96752. * Instantiate the action
  96753. * @param triggerOptions defines the trigger options
  96754. * @param sound defines the sound to stop
  96755. * @param condition defines the trigger related conditions
  96756. */
  96757. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  96758. /** @hidden */
  96759. _prepare(): void;
  96760. /**
  96761. * Execute the action and stop the sound.
  96762. */
  96763. execute(): void;
  96764. /**
  96765. * Serializes the actions and its related information.
  96766. * @param parent defines the object to serialize in
  96767. * @returns the serialized object
  96768. */
  96769. serialize(parent: any): any;
  96770. }
  96771. }
  96772. declare module BABYLON {
  96773. /**
  96774. * This defines an action responsible to change the value of a property
  96775. * by interpolating between its current value and the newly set one once triggered.
  96776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  96777. */
  96778. export class InterpolateValueAction extends Action {
  96779. /**
  96780. * Defines the path of the property where the value should be interpolated
  96781. */
  96782. propertyPath: string;
  96783. /**
  96784. * Defines the target value at the end of the interpolation.
  96785. */
  96786. value: any;
  96787. /**
  96788. * Defines the time it will take for the property to interpolate to the value.
  96789. */
  96790. duration: number;
  96791. /**
  96792. * Defines if the other scene animations should be stopped when the action has been triggered
  96793. */
  96794. stopOtherAnimations?: boolean;
  96795. /**
  96796. * Defines a callback raised once the interpolation animation has been done.
  96797. */
  96798. onInterpolationDone?: () => void;
  96799. /**
  96800. * Observable triggered once the interpolation animation has been done.
  96801. */
  96802. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  96803. private _target;
  96804. private _effectiveTarget;
  96805. private _property;
  96806. /**
  96807. * Instantiate the action
  96808. * @param triggerOptions defines the trigger options
  96809. * @param target defines the object containing the value to interpolate
  96810. * @param propertyPath defines the path to the property in the target object
  96811. * @param value defines the target value at the end of the interpolation
  96812. * @param duration deines the time it will take for the property to interpolate to the value.
  96813. * @param condition defines the trigger related conditions
  96814. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  96815. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  96816. */
  96817. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  96818. /** @hidden */
  96819. _prepare(): void;
  96820. /**
  96821. * Execute the action starts the value interpolation.
  96822. */
  96823. execute(): void;
  96824. /**
  96825. * Serializes the actions and its related information.
  96826. * @param parent defines the object to serialize in
  96827. * @returns the serialized object
  96828. */
  96829. serialize(parent: any): any;
  96830. }
  96831. }
  96832. declare module BABYLON {
  96833. /**
  96834. * Options allowed during the creation of a sound track.
  96835. */
  96836. export interface ISoundTrackOptions {
  96837. /**
  96838. * The volume the sound track should take during creation
  96839. */
  96840. volume?: number;
  96841. /**
  96842. * Define if the sound track is the main sound track of the scene
  96843. */
  96844. mainTrack?: boolean;
  96845. }
  96846. /**
  96847. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  96848. * It will be also used in a future release to apply effects on a specific track.
  96849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  96850. */
  96851. export class SoundTrack {
  96852. /**
  96853. * The unique identifier of the sound track in the scene.
  96854. */
  96855. id: number;
  96856. /**
  96857. * The list of sounds included in the sound track.
  96858. */
  96859. soundCollection: Array<Sound>;
  96860. private _outputAudioNode;
  96861. private _scene;
  96862. private _isMainTrack;
  96863. private _connectedAnalyser;
  96864. private _options;
  96865. private _isInitialized;
  96866. /**
  96867. * Creates a new sound track.
  96868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  96869. * @param scene Define the scene the sound track belongs to
  96870. * @param options
  96871. */
  96872. constructor(scene: Scene, options?: ISoundTrackOptions);
  96873. private _initializeSoundTrackAudioGraph;
  96874. /**
  96875. * Release the sound track and its associated resources
  96876. */
  96877. dispose(): void;
  96878. /**
  96879. * Adds a sound to this sound track
  96880. * @param sound define the cound to add
  96881. * @ignoreNaming
  96882. */
  96883. AddSound(sound: Sound): void;
  96884. /**
  96885. * Removes a sound to this sound track
  96886. * @param sound define the cound to remove
  96887. * @ignoreNaming
  96888. */
  96889. RemoveSound(sound: Sound): void;
  96890. /**
  96891. * Set a global volume for the full sound track.
  96892. * @param newVolume Define the new volume of the sound track
  96893. */
  96894. setVolume(newVolume: number): void;
  96895. /**
  96896. * Switch the panning model to HRTF:
  96897. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  96898. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96899. */
  96900. switchPanningModelToHRTF(): void;
  96901. /**
  96902. * Switch the panning model to Equal Power:
  96903. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  96904. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96905. */
  96906. switchPanningModelToEqualPower(): void;
  96907. /**
  96908. * Connect the sound track to an audio analyser allowing some amazing
  96909. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  96910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  96911. * @param analyser The analyser to connect to the engine
  96912. */
  96913. connectToAnalyser(analyser: Analyser): void;
  96914. }
  96915. }
  96916. declare module BABYLON {
  96917. interface AbstractScene {
  96918. /**
  96919. * The list of sounds used in the scene.
  96920. */
  96921. sounds: Nullable<Array<Sound>>;
  96922. }
  96923. interface Scene {
  96924. /**
  96925. * @hidden
  96926. * Backing field
  96927. */
  96928. _mainSoundTrack: SoundTrack;
  96929. /**
  96930. * The main sound track played by the scene.
  96931. * It cotains your primary collection of sounds.
  96932. */
  96933. mainSoundTrack: SoundTrack;
  96934. /**
  96935. * The list of sound tracks added to the scene
  96936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96937. */
  96938. soundTracks: Nullable<Array<SoundTrack>>;
  96939. /**
  96940. * Gets a sound using a given name
  96941. * @param name defines the name to search for
  96942. * @return the found sound or null if not found at all.
  96943. */
  96944. getSoundByName(name: string): Nullable<Sound>;
  96945. /**
  96946. * Gets or sets if audio support is enabled
  96947. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96948. */
  96949. audioEnabled: boolean;
  96950. /**
  96951. * Gets or sets if audio will be output to headphones
  96952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96953. */
  96954. headphone: boolean;
  96955. }
  96956. /**
  96957. * Defines the sound scene component responsible to manage any sounds
  96958. * in a given scene.
  96959. */
  96960. export class AudioSceneComponent implements ISceneSerializableComponent {
  96961. /**
  96962. * The component name helpfull to identify the component in the list of scene components.
  96963. */
  96964. readonly name: string;
  96965. /**
  96966. * The scene the component belongs to.
  96967. */
  96968. scene: Scene;
  96969. private _audioEnabled;
  96970. /**
  96971. * Gets whether audio is enabled or not.
  96972. * Please use related enable/disable method to switch state.
  96973. */
  96974. readonly audioEnabled: boolean;
  96975. private _headphone;
  96976. /**
  96977. * Gets whether audio is outputing to headphone or not.
  96978. * Please use the according Switch methods to change output.
  96979. */
  96980. readonly headphone: boolean;
  96981. /**
  96982. * Creates a new instance of the component for the given scene
  96983. * @param scene Defines the scene to register the component in
  96984. */
  96985. constructor(scene: Scene);
  96986. /**
  96987. * Registers the component in a given scene
  96988. */
  96989. register(): void;
  96990. /**
  96991. * Rebuilds the elements related to this component in case of
  96992. * context lost for instance.
  96993. */
  96994. rebuild(): void;
  96995. /**
  96996. * Serializes the component data to the specified json object
  96997. * @param serializationObject The object to serialize to
  96998. */
  96999. serialize(serializationObject: any): void;
  97000. /**
  97001. * Adds all the elements from the container to the scene
  97002. * @param container the container holding the elements
  97003. */
  97004. addFromContainer(container: AbstractScene): void;
  97005. /**
  97006. * Removes all the elements in the container from the scene
  97007. * @param container contains the elements to remove
  97008. * @param dispose if the removed element should be disposed (default: false)
  97009. */
  97010. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  97011. /**
  97012. * Disposes the component and the associated ressources.
  97013. */
  97014. dispose(): void;
  97015. /**
  97016. * Disables audio in the associated scene.
  97017. */
  97018. disableAudio(): void;
  97019. /**
  97020. * Enables audio in the associated scene.
  97021. */
  97022. enableAudio(): void;
  97023. /**
  97024. * Switch audio to headphone output.
  97025. */
  97026. switchAudioModeForHeadphones(): void;
  97027. /**
  97028. * Switch audio to normal speakers.
  97029. */
  97030. switchAudioModeForNormalSpeakers(): void;
  97031. private _afterRender;
  97032. }
  97033. }
  97034. declare module BABYLON {
  97035. /**
  97036. * Wraps one or more Sound objects and selects one with random weight for playback.
  97037. */
  97038. export class WeightedSound {
  97039. /** When true a Sound will be selected and played when the current playing Sound completes. */
  97040. loop: boolean;
  97041. private _coneInnerAngle;
  97042. private _coneOuterAngle;
  97043. private _volume;
  97044. /** A Sound is currently playing. */
  97045. isPlaying: boolean;
  97046. /** A Sound is currently paused. */
  97047. isPaused: boolean;
  97048. private _sounds;
  97049. private _weights;
  97050. private _currentIndex?;
  97051. /**
  97052. * Creates a new WeightedSound from the list of sounds given.
  97053. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  97054. * @param sounds Array of Sounds that will be selected from.
  97055. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  97056. */
  97057. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  97058. /**
  97059. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  97060. */
  97061. /**
  97062. * The size of cone in degress for a directional sound in which there will be no attenuation.
  97063. */
  97064. directionalConeInnerAngle: number;
  97065. /**
  97066. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97067. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97068. */
  97069. /**
  97070. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97071. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97072. */
  97073. directionalConeOuterAngle: number;
  97074. /**
  97075. * Playback volume.
  97076. */
  97077. /**
  97078. * Playback volume.
  97079. */
  97080. volume: number;
  97081. private _onended;
  97082. /**
  97083. * Suspend playback
  97084. */
  97085. pause(): void;
  97086. /**
  97087. * Stop playback
  97088. */
  97089. stop(): void;
  97090. /**
  97091. * Start playback.
  97092. * @param startOffset Position the clip head at a specific time in seconds.
  97093. */
  97094. play(startOffset?: number): void;
  97095. }
  97096. }
  97097. declare module BABYLON {
  97098. /**
  97099. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  97100. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97101. */
  97102. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  97103. /**
  97104. * Gets the name of the behavior.
  97105. */
  97106. readonly name: string;
  97107. /**
  97108. * The easing function used by animations
  97109. */
  97110. static EasingFunction: BackEase;
  97111. /**
  97112. * The easing mode used by animations
  97113. */
  97114. static EasingMode: number;
  97115. /**
  97116. * The duration of the animation, in milliseconds
  97117. */
  97118. transitionDuration: number;
  97119. /**
  97120. * Length of the distance animated by the transition when lower radius is reached
  97121. */
  97122. lowerRadiusTransitionRange: number;
  97123. /**
  97124. * Length of the distance animated by the transition when upper radius is reached
  97125. */
  97126. upperRadiusTransitionRange: number;
  97127. private _autoTransitionRange;
  97128. /**
  97129. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97130. */
  97131. /**
  97132. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97133. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  97134. */
  97135. autoTransitionRange: boolean;
  97136. private _attachedCamera;
  97137. private _onAfterCheckInputsObserver;
  97138. private _onMeshTargetChangedObserver;
  97139. /**
  97140. * Initializes the behavior.
  97141. */
  97142. init(): void;
  97143. /**
  97144. * Attaches the behavior to its arc rotate camera.
  97145. * @param camera Defines the camera to attach the behavior to
  97146. */
  97147. attach(camera: ArcRotateCamera): void;
  97148. /**
  97149. * Detaches the behavior from its current arc rotate camera.
  97150. */
  97151. detach(): void;
  97152. private _radiusIsAnimating;
  97153. private _radiusBounceTransition;
  97154. private _animatables;
  97155. private _cachedWheelPrecision;
  97156. /**
  97157. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  97158. * @param radiusLimit The limit to check against.
  97159. * @return Bool to indicate if at limit.
  97160. */
  97161. private _isRadiusAtLimit;
  97162. /**
  97163. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  97164. * @param radiusDelta The delta by which to animate to. Can be negative.
  97165. */
  97166. private _applyBoundRadiusAnimation;
  97167. /**
  97168. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  97169. */
  97170. protected _clearAnimationLocks(): void;
  97171. /**
  97172. * Stops and removes all animations that have been applied to the camera
  97173. */
  97174. stopAllAnimations(): void;
  97175. }
  97176. }
  97177. declare module BABYLON {
  97178. /**
  97179. * 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.
  97180. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97181. */
  97182. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  97183. /**
  97184. * Gets the name of the behavior.
  97185. */
  97186. readonly name: string;
  97187. private _mode;
  97188. private _radiusScale;
  97189. private _positionScale;
  97190. private _defaultElevation;
  97191. private _elevationReturnTime;
  97192. private _elevationReturnWaitTime;
  97193. private _zoomStopsAnimation;
  97194. private _framingTime;
  97195. /**
  97196. * The easing function used by animations
  97197. */
  97198. static EasingFunction: ExponentialEase;
  97199. /**
  97200. * The easing mode used by animations
  97201. */
  97202. static EasingMode: number;
  97203. /**
  97204. * Sets the current mode used by the behavior
  97205. */
  97206. /**
  97207. * Gets current mode used by the behavior.
  97208. */
  97209. mode: number;
  97210. /**
  97211. * Sets the scale applied to the radius (1 by default)
  97212. */
  97213. /**
  97214. * Gets the scale applied to the radius
  97215. */
  97216. radiusScale: number;
  97217. /**
  97218. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97219. */
  97220. /**
  97221. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97222. */
  97223. positionScale: number;
  97224. /**
  97225. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97226. * behaviour is triggered, in radians.
  97227. */
  97228. /**
  97229. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97230. * behaviour is triggered, in radians.
  97231. */
  97232. defaultElevation: number;
  97233. /**
  97234. * Sets the time (in milliseconds) taken to return to the default beta position.
  97235. * Negative value indicates camera should not return to default.
  97236. */
  97237. /**
  97238. * Gets the time (in milliseconds) taken to return to the default beta position.
  97239. * Negative value indicates camera should not return to default.
  97240. */
  97241. elevationReturnTime: number;
  97242. /**
  97243. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97244. */
  97245. /**
  97246. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97247. */
  97248. elevationReturnWaitTime: number;
  97249. /**
  97250. * Sets the flag that indicates if user zooming should stop animation.
  97251. */
  97252. /**
  97253. * Gets the flag that indicates if user zooming should stop animation.
  97254. */
  97255. zoomStopsAnimation: boolean;
  97256. /**
  97257. * Sets the transition time when framing the mesh, in milliseconds
  97258. */
  97259. /**
  97260. * Gets the transition time when framing the mesh, in milliseconds
  97261. */
  97262. framingTime: number;
  97263. /**
  97264. * Define if the behavior should automatically change the configured
  97265. * camera limits and sensibilities.
  97266. */
  97267. autoCorrectCameraLimitsAndSensibility: boolean;
  97268. private _onPrePointerObservableObserver;
  97269. private _onAfterCheckInputsObserver;
  97270. private _onMeshTargetChangedObserver;
  97271. private _attachedCamera;
  97272. private _isPointerDown;
  97273. private _lastInteractionTime;
  97274. /**
  97275. * Initializes the behavior.
  97276. */
  97277. init(): void;
  97278. /**
  97279. * Attaches the behavior to its arc rotate camera.
  97280. * @param camera Defines the camera to attach the behavior to
  97281. */
  97282. attach(camera: ArcRotateCamera): void;
  97283. /**
  97284. * Detaches the behavior from its current arc rotate camera.
  97285. */
  97286. detach(): void;
  97287. private _animatables;
  97288. private _betaIsAnimating;
  97289. private _betaTransition;
  97290. private _radiusTransition;
  97291. private _vectorTransition;
  97292. /**
  97293. * Targets the given mesh and updates zoom level accordingly.
  97294. * @param mesh The mesh to target.
  97295. * @param radius Optional. If a cached radius position already exists, overrides default.
  97296. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97297. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97298. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97299. */
  97300. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97301. /**
  97302. * Targets the given mesh with its children and updates zoom level accordingly.
  97303. * @param mesh The mesh to target.
  97304. * @param radius Optional. If a cached radius position already exists, overrides default.
  97305. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97306. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97307. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97308. */
  97309. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97310. /**
  97311. * Targets the given meshes with their children and updates zoom level accordingly.
  97312. * @param meshes The mesh to target.
  97313. * @param radius Optional. If a cached radius position already exists, overrides default.
  97314. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97315. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97316. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97317. */
  97318. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97319. /**
  97320. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  97321. * @param minimumWorld Determines the smaller position of the bounding box extend
  97322. * @param maximumWorld Determines the bigger position of the bounding box extend
  97323. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97324. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97325. */
  97326. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97327. /**
  97328. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  97329. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  97330. * frustum width.
  97331. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  97332. * to fully enclose the mesh in the viewing frustum.
  97333. */
  97334. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  97335. /**
  97336. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  97337. * is automatically returned to its default position (expected to be above ground plane).
  97338. */
  97339. private _maintainCameraAboveGround;
  97340. /**
  97341. * Returns the frustum slope based on the canvas ratio and camera FOV
  97342. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  97343. */
  97344. private _getFrustumSlope;
  97345. /**
  97346. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  97347. */
  97348. private _clearAnimationLocks;
  97349. /**
  97350. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  97351. */
  97352. private _applyUserInteraction;
  97353. /**
  97354. * Stops and removes all animations that have been applied to the camera
  97355. */
  97356. stopAllAnimations(): void;
  97357. /**
  97358. * Gets a value indicating if the user is moving the camera
  97359. */
  97360. readonly isUserIsMoving: boolean;
  97361. /**
  97362. * The camera can move all the way towards the mesh.
  97363. */
  97364. static IgnoreBoundsSizeMode: number;
  97365. /**
  97366. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  97367. */
  97368. static FitFrustumSidesMode: number;
  97369. }
  97370. }
  97371. declare module BABYLON {
  97372. /**
  97373. * Base class for Camera Pointer Inputs.
  97374. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  97375. * for example usage.
  97376. */
  97377. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  97378. /**
  97379. * Defines the camera the input is attached to.
  97380. */
  97381. abstract camera: Camera;
  97382. /**
  97383. * Whether keyboard modifier keys are pressed at time of last mouse event.
  97384. */
  97385. protected _altKey: boolean;
  97386. protected _ctrlKey: boolean;
  97387. protected _metaKey: boolean;
  97388. protected _shiftKey: boolean;
  97389. /**
  97390. * Which mouse buttons were pressed at time of last mouse event.
  97391. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  97392. */
  97393. protected _buttonsPressed: number;
  97394. /**
  97395. * Defines the buttons associated with the input to handle camera move.
  97396. */
  97397. buttons: number[];
  97398. /**
  97399. * Attach the input controls to a specific dom element to get the input from.
  97400. * @param element Defines the element the controls should be listened from
  97401. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97402. */
  97403. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97404. /**
  97405. * Detach the current controls from the specified dom element.
  97406. * @param element Defines the element to stop listening the inputs from
  97407. */
  97408. detachControl(element: Nullable<HTMLElement>): void;
  97409. /**
  97410. * Gets the class name of the current input.
  97411. * @returns the class name
  97412. */
  97413. getClassName(): string;
  97414. /**
  97415. * Get the friendly name associated with the input class.
  97416. * @returns the input friendly name
  97417. */
  97418. getSimpleName(): string;
  97419. /**
  97420. * Called on pointer POINTERDOUBLETAP event.
  97421. * Override this method to provide functionality on POINTERDOUBLETAP event.
  97422. */
  97423. protected onDoubleTap(type: string): void;
  97424. /**
  97425. * Called on pointer POINTERMOVE event if only a single touch is active.
  97426. * Override this method to provide functionality.
  97427. */
  97428. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97429. /**
  97430. * Called on pointer POINTERMOVE event if multiple touches are active.
  97431. * Override this method to provide functionality.
  97432. */
  97433. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97434. /**
  97435. * Called on JS contextmenu event.
  97436. * Override this method to provide functionality.
  97437. */
  97438. protected onContextMenu(evt: PointerEvent): void;
  97439. /**
  97440. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97441. * press.
  97442. * Override this method to provide functionality.
  97443. */
  97444. protected onButtonDown(evt: PointerEvent): void;
  97445. /**
  97446. * Called each time a new POINTERUP event occurs. Ie, for each button
  97447. * release.
  97448. * Override this method to provide functionality.
  97449. */
  97450. protected onButtonUp(evt: PointerEvent): void;
  97451. /**
  97452. * Called when window becomes inactive.
  97453. * Override this method to provide functionality.
  97454. */
  97455. protected onLostFocus(): void;
  97456. private _pointerInput;
  97457. private _observer;
  97458. private _onLostFocus;
  97459. private pointA;
  97460. private pointB;
  97461. }
  97462. }
  97463. declare module BABYLON {
  97464. /**
  97465. * Manage the pointers inputs to control an arc rotate camera.
  97466. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97467. */
  97468. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  97469. /**
  97470. * Defines the camera the input is attached to.
  97471. */
  97472. camera: ArcRotateCamera;
  97473. /**
  97474. * Gets the class name of the current input.
  97475. * @returns the class name
  97476. */
  97477. getClassName(): string;
  97478. /**
  97479. * Defines the buttons associated with the input to handle camera move.
  97480. */
  97481. buttons: number[];
  97482. /**
  97483. * Defines the pointer angular sensibility along the X axis or how fast is
  97484. * the camera rotating.
  97485. */
  97486. angularSensibilityX: number;
  97487. /**
  97488. * Defines the pointer angular sensibility along the Y axis or how fast is
  97489. * the camera rotating.
  97490. */
  97491. angularSensibilityY: number;
  97492. /**
  97493. * Defines the pointer pinch precision or how fast is the camera zooming.
  97494. */
  97495. pinchPrecision: number;
  97496. /**
  97497. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  97498. * from 0.
  97499. * It defines the percentage of current camera.radius to use as delta when
  97500. * pinch zoom is used.
  97501. */
  97502. pinchDeltaPercentage: number;
  97503. /**
  97504. * Defines the pointer panning sensibility or how fast is the camera moving.
  97505. */
  97506. panningSensibility: number;
  97507. /**
  97508. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  97509. */
  97510. multiTouchPanning: boolean;
  97511. /**
  97512. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  97513. * zoom (pinch) through multitouch.
  97514. */
  97515. multiTouchPanAndZoom: boolean;
  97516. /**
  97517. * Revers pinch action direction.
  97518. */
  97519. pinchInwards: boolean;
  97520. private _isPanClick;
  97521. private _twoFingerActivityCount;
  97522. private _isPinching;
  97523. /**
  97524. * Called on pointer POINTERMOVE event if only a single touch is active.
  97525. */
  97526. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97527. /**
  97528. * Called on pointer POINTERDOUBLETAP event.
  97529. */
  97530. protected onDoubleTap(type: string): void;
  97531. /**
  97532. * Called on pointer POINTERMOVE event if multiple touches are active.
  97533. */
  97534. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97535. /**
  97536. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97537. * press.
  97538. */
  97539. protected onButtonDown(evt: PointerEvent): void;
  97540. /**
  97541. * Called each time a new POINTERUP event occurs. Ie, for each button
  97542. * release.
  97543. */
  97544. protected onButtonUp(evt: PointerEvent): void;
  97545. /**
  97546. * Called when window becomes inactive.
  97547. */
  97548. protected onLostFocus(): void;
  97549. }
  97550. }
  97551. declare module BABYLON {
  97552. /**
  97553. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  97554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97555. */
  97556. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  97557. /**
  97558. * Defines the camera the input is attached to.
  97559. */
  97560. camera: ArcRotateCamera;
  97561. /**
  97562. * Defines the list of key codes associated with the up action (increase alpha)
  97563. */
  97564. keysUp: number[];
  97565. /**
  97566. * Defines the list of key codes associated with the down action (decrease alpha)
  97567. */
  97568. keysDown: number[];
  97569. /**
  97570. * Defines the list of key codes associated with the left action (increase beta)
  97571. */
  97572. keysLeft: number[];
  97573. /**
  97574. * Defines the list of key codes associated with the right action (decrease beta)
  97575. */
  97576. keysRight: number[];
  97577. /**
  97578. * Defines the list of key codes associated with the reset action.
  97579. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  97580. */
  97581. keysReset: number[];
  97582. /**
  97583. * Defines the panning sensibility of the inputs.
  97584. * (How fast is the camera paning)
  97585. */
  97586. panningSensibility: number;
  97587. /**
  97588. * Defines the zooming sensibility of the inputs.
  97589. * (How fast is the camera zooming)
  97590. */
  97591. zoomingSensibility: number;
  97592. /**
  97593. * Defines wether maintaining the alt key down switch the movement mode from
  97594. * orientation to zoom.
  97595. */
  97596. useAltToZoom: boolean;
  97597. /**
  97598. * Rotation speed of the camera
  97599. */
  97600. angularSpeed: number;
  97601. private _keys;
  97602. private _ctrlPressed;
  97603. private _altPressed;
  97604. private _onCanvasBlurObserver;
  97605. private _onKeyboardObserver;
  97606. private _engine;
  97607. private _scene;
  97608. /**
  97609. * Attach the input controls to a specific dom element to get the input from.
  97610. * @param element Defines the element the controls should be listened from
  97611. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97612. */
  97613. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97614. /**
  97615. * Detach the current controls from the specified dom element.
  97616. * @param element Defines the element to stop listening the inputs from
  97617. */
  97618. detachControl(element: Nullable<HTMLElement>): void;
  97619. /**
  97620. * Update the current camera state depending on the inputs that have been used this frame.
  97621. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97622. */
  97623. checkInputs(): void;
  97624. /**
  97625. * Gets the class name of the current intput.
  97626. * @returns the class name
  97627. */
  97628. getClassName(): string;
  97629. /**
  97630. * Get the friendly name associated with the input class.
  97631. * @returns the input friendly name
  97632. */
  97633. getSimpleName(): string;
  97634. }
  97635. }
  97636. declare module BABYLON {
  97637. /**
  97638. * Manage the mouse wheel inputs to control an arc rotate camera.
  97639. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97640. */
  97641. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  97642. /**
  97643. * Defines the camera the input is attached to.
  97644. */
  97645. camera: ArcRotateCamera;
  97646. /**
  97647. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  97648. */
  97649. wheelPrecision: number;
  97650. /**
  97651. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  97652. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  97653. */
  97654. wheelDeltaPercentage: number;
  97655. private _wheel;
  97656. private _observer;
  97657. private computeDeltaFromMouseWheelLegacyEvent;
  97658. /**
  97659. * Attach the input controls to a specific dom element to get the input from.
  97660. * @param element Defines the element the controls should be listened from
  97661. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97662. */
  97663. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97664. /**
  97665. * Detach the current controls from the specified dom element.
  97666. * @param element Defines the element to stop listening the inputs from
  97667. */
  97668. detachControl(element: Nullable<HTMLElement>): void;
  97669. /**
  97670. * Gets the class name of the current intput.
  97671. * @returns the class name
  97672. */
  97673. getClassName(): string;
  97674. /**
  97675. * Get the friendly name associated with the input class.
  97676. * @returns the input friendly name
  97677. */
  97678. getSimpleName(): string;
  97679. }
  97680. }
  97681. declare module BABYLON {
  97682. /**
  97683. * Default Inputs manager for the ArcRotateCamera.
  97684. * It groups all the default supported inputs for ease of use.
  97685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97686. */
  97687. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  97688. /**
  97689. * Instantiates a new ArcRotateCameraInputsManager.
  97690. * @param camera Defines the camera the inputs belong to
  97691. */
  97692. constructor(camera: ArcRotateCamera);
  97693. /**
  97694. * Add mouse wheel input support to the input manager.
  97695. * @returns the current input manager
  97696. */
  97697. addMouseWheel(): ArcRotateCameraInputsManager;
  97698. /**
  97699. * Add pointers input support to the input manager.
  97700. * @returns the current input manager
  97701. */
  97702. addPointers(): ArcRotateCameraInputsManager;
  97703. /**
  97704. * Add keyboard input support to the input manager.
  97705. * @returns the current input manager
  97706. */
  97707. addKeyboard(): ArcRotateCameraInputsManager;
  97708. }
  97709. }
  97710. declare module BABYLON {
  97711. /**
  97712. * This represents an orbital type of camera.
  97713. *
  97714. * 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.
  97715. * 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.
  97716. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  97717. */
  97718. export class ArcRotateCamera extends TargetCamera {
  97719. /**
  97720. * Defines the rotation angle of the camera along the longitudinal axis.
  97721. */
  97722. alpha: number;
  97723. /**
  97724. * Defines the rotation angle of the camera along the latitudinal axis.
  97725. */
  97726. beta: number;
  97727. /**
  97728. * Defines the radius of the camera from it s target point.
  97729. */
  97730. radius: number;
  97731. protected _target: Vector3;
  97732. protected _targetHost: Nullable<AbstractMesh>;
  97733. /**
  97734. * Defines the target point of the camera.
  97735. * The camera looks towards it form the radius distance.
  97736. */
  97737. target: Vector3;
  97738. /**
  97739. * Define the current local position of the camera in the scene
  97740. */
  97741. position: Vector3;
  97742. protected _upVector: Vector3;
  97743. protected _upToYMatrix: Matrix;
  97744. protected _YToUpMatrix: Matrix;
  97745. /**
  97746. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  97747. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  97748. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  97749. */
  97750. upVector: Vector3;
  97751. /**
  97752. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  97753. */
  97754. setMatUp(): void;
  97755. /**
  97756. * Current inertia value on the longitudinal axis.
  97757. * The bigger this number the longer it will take for the camera to stop.
  97758. */
  97759. inertialAlphaOffset: number;
  97760. /**
  97761. * Current inertia value on the latitudinal axis.
  97762. * The bigger this number the longer it will take for the camera to stop.
  97763. */
  97764. inertialBetaOffset: number;
  97765. /**
  97766. * Current inertia value on the radius axis.
  97767. * The bigger this number the longer it will take for the camera to stop.
  97768. */
  97769. inertialRadiusOffset: number;
  97770. /**
  97771. * Minimum allowed angle on the longitudinal axis.
  97772. * This can help limiting how the Camera is able to move in the scene.
  97773. */
  97774. lowerAlphaLimit: Nullable<number>;
  97775. /**
  97776. * Maximum allowed angle on the longitudinal axis.
  97777. * This can help limiting how the Camera is able to move in the scene.
  97778. */
  97779. upperAlphaLimit: Nullable<number>;
  97780. /**
  97781. * Minimum allowed angle on the latitudinal axis.
  97782. * This can help limiting how the Camera is able to move in the scene.
  97783. */
  97784. lowerBetaLimit: number;
  97785. /**
  97786. * Maximum allowed angle on the latitudinal axis.
  97787. * This can help limiting how the Camera is able to move in the scene.
  97788. */
  97789. upperBetaLimit: number;
  97790. /**
  97791. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  97792. * This can help limiting how the Camera is able to move in the scene.
  97793. */
  97794. lowerRadiusLimit: Nullable<number>;
  97795. /**
  97796. * Maximum allowed distance of the camera to the target (The camera can not get further).
  97797. * This can help limiting how the Camera is able to move in the scene.
  97798. */
  97799. upperRadiusLimit: Nullable<number>;
  97800. /**
  97801. * Defines the current inertia value used during panning of the camera along the X axis.
  97802. */
  97803. inertialPanningX: number;
  97804. /**
  97805. * Defines the current inertia value used during panning of the camera along the Y axis.
  97806. */
  97807. inertialPanningY: number;
  97808. /**
  97809. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  97810. * Basically if your fingers moves away from more than this distance you will be considered
  97811. * in pinch mode.
  97812. */
  97813. pinchToPanMaxDistance: number;
  97814. /**
  97815. * Defines the maximum distance the camera can pan.
  97816. * This could help keeping the cammera always in your scene.
  97817. */
  97818. panningDistanceLimit: Nullable<number>;
  97819. /**
  97820. * Defines the target of the camera before paning.
  97821. */
  97822. panningOriginTarget: Vector3;
  97823. /**
  97824. * Defines the value of the inertia used during panning.
  97825. * 0 would mean stop inertia and one would mean no decelleration at all.
  97826. */
  97827. panningInertia: number;
  97828. /**
  97829. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  97830. */
  97831. angularSensibilityX: number;
  97832. /**
  97833. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  97834. */
  97835. angularSensibilityY: number;
  97836. /**
  97837. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  97838. */
  97839. pinchPrecision: number;
  97840. /**
  97841. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  97842. * It will be used instead of pinchDeltaPrecision if different from 0.
  97843. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  97844. */
  97845. pinchDeltaPercentage: number;
  97846. /**
  97847. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  97848. */
  97849. panningSensibility: number;
  97850. /**
  97851. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  97852. */
  97853. keysUp: number[];
  97854. /**
  97855. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  97856. */
  97857. keysDown: number[];
  97858. /**
  97859. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  97860. */
  97861. keysLeft: number[];
  97862. /**
  97863. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  97864. */
  97865. keysRight: number[];
  97866. /**
  97867. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  97868. */
  97869. wheelPrecision: number;
  97870. /**
  97871. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  97872. * It will be used instead of pinchDeltaPrecision if different from 0.
  97873. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  97874. */
  97875. wheelDeltaPercentage: number;
  97876. /**
  97877. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  97878. */
  97879. zoomOnFactor: number;
  97880. /**
  97881. * Defines a screen offset for the camera position.
  97882. */
  97883. targetScreenOffset: Vector2;
  97884. /**
  97885. * Allows the camera to be completely reversed.
  97886. * If false the camera can not arrive upside down.
  97887. */
  97888. allowUpsideDown: boolean;
  97889. /**
  97890. * Define if double tap/click is used to restore the previously saved state of the camera.
  97891. */
  97892. useInputToRestoreState: boolean;
  97893. /** @hidden */
  97894. _viewMatrix: Matrix;
  97895. /** @hidden */
  97896. _useCtrlForPanning: boolean;
  97897. /** @hidden */
  97898. _panningMouseButton: number;
  97899. /**
  97900. * Defines the input associated to the camera.
  97901. */
  97902. inputs: ArcRotateCameraInputsManager;
  97903. /** @hidden */
  97904. _reset: () => void;
  97905. /**
  97906. * Defines the allowed panning axis.
  97907. */
  97908. panningAxis: Vector3;
  97909. protected _localDirection: Vector3;
  97910. protected _transformedDirection: Vector3;
  97911. private _bouncingBehavior;
  97912. /**
  97913. * Gets the bouncing behavior of the camera if it has been enabled.
  97914. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97915. */
  97916. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  97917. /**
  97918. * Defines if the bouncing behavior of the camera is enabled on the camera.
  97919. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97920. */
  97921. useBouncingBehavior: boolean;
  97922. private _framingBehavior;
  97923. /**
  97924. * Gets the framing behavior of the camera if it has been enabled.
  97925. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97926. */
  97927. readonly framingBehavior: Nullable<FramingBehavior>;
  97928. /**
  97929. * Defines if the framing behavior of the camera is enabled on the camera.
  97930. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97931. */
  97932. useFramingBehavior: boolean;
  97933. private _autoRotationBehavior;
  97934. /**
  97935. * Gets the auto rotation behavior of the camera if it has been enabled.
  97936. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  97937. */
  97938. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  97939. /**
  97940. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  97941. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  97942. */
  97943. useAutoRotationBehavior: boolean;
  97944. /**
  97945. * Observable triggered when the mesh target has been changed on the camera.
  97946. */
  97947. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  97948. /**
  97949. * Event raised when the camera is colliding with a mesh.
  97950. */
  97951. onCollide: (collidedMesh: AbstractMesh) => void;
  97952. /**
  97953. * Defines whether the camera should check collision with the objects oh the scene.
  97954. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  97955. */
  97956. checkCollisions: boolean;
  97957. /**
  97958. * Defines the collision radius of the camera.
  97959. * This simulates a sphere around the camera.
  97960. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  97961. */
  97962. collisionRadius: Vector3;
  97963. protected _collider: Collider;
  97964. protected _previousPosition: Vector3;
  97965. protected _collisionVelocity: Vector3;
  97966. protected _newPosition: Vector3;
  97967. protected _previousAlpha: number;
  97968. protected _previousBeta: number;
  97969. protected _previousRadius: number;
  97970. protected _collisionTriggered: boolean;
  97971. protected _targetBoundingCenter: Nullable<Vector3>;
  97972. private _computationVector;
  97973. /**
  97974. * Instantiates a new ArcRotateCamera in a given scene
  97975. * @param name Defines the name of the camera
  97976. * @param alpha Defines the camera rotation along the logitudinal axis
  97977. * @param beta Defines the camera rotation along the latitudinal axis
  97978. * @param radius Defines the camera distance from its target
  97979. * @param target Defines the camera target
  97980. * @param scene Defines the scene the camera belongs to
  97981. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97982. */
  97983. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97984. /** @hidden */
  97985. _initCache(): void;
  97986. /** @hidden */
  97987. _updateCache(ignoreParentClass?: boolean): void;
  97988. protected _getTargetPosition(): Vector3;
  97989. private _storedAlpha;
  97990. private _storedBeta;
  97991. private _storedRadius;
  97992. private _storedTarget;
  97993. /**
  97994. * Stores the current state of the camera (alpha, beta, radius and target)
  97995. * @returns the camera itself
  97996. */
  97997. storeState(): Camera;
  97998. /**
  97999. * @hidden
  98000. * Restored camera state. You must call storeState() first
  98001. */
  98002. _restoreStateValues(): boolean;
  98003. /** @hidden */
  98004. _isSynchronizedViewMatrix(): boolean;
  98005. /**
  98006. * Attached controls to the current camera.
  98007. * @param element Defines the element the controls should be listened from
  98008. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98009. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  98010. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  98011. */
  98012. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  98013. /**
  98014. * Detach the current controls from the camera.
  98015. * The camera will stop reacting to inputs.
  98016. * @param element Defines the element to stop listening the inputs from
  98017. */
  98018. detachControl(element: HTMLElement): void;
  98019. /** @hidden */
  98020. _checkInputs(): void;
  98021. protected _checkLimits(): void;
  98022. /**
  98023. * Rebuilds angles (alpha, beta) and radius from the give position and target
  98024. */
  98025. rebuildAnglesAndRadius(): void;
  98026. /**
  98027. * Use a position to define the current camera related information like aplha, beta and radius
  98028. * @param position Defines the position to set the camera at
  98029. */
  98030. setPosition(position: Vector3): void;
  98031. /**
  98032. * Defines the target the camera should look at.
  98033. * This will automatically adapt alpha beta and radius to fit within the new target.
  98034. * @param target Defines the new target as a Vector or a mesh
  98035. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  98036. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  98037. */
  98038. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  98039. /** @hidden */
  98040. _getViewMatrix(): Matrix;
  98041. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  98042. /**
  98043. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  98044. * @param meshes Defines the mesh to zoom on
  98045. * @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)
  98046. */
  98047. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  98048. /**
  98049. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  98050. * The target will be changed but the radius
  98051. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  98052. * @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)
  98053. */
  98054. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  98055. min: Vector3;
  98056. max: Vector3;
  98057. distance: number;
  98058. }, doNotUpdateMaxZ?: boolean): void;
  98059. /**
  98060. * @override
  98061. * Override Camera.createRigCamera
  98062. */
  98063. createRigCamera(name: string, cameraIndex: number): Camera;
  98064. /**
  98065. * @hidden
  98066. * @override
  98067. * Override Camera._updateRigCameras
  98068. */
  98069. _updateRigCameras(): void;
  98070. /**
  98071. * Destroy the camera and release the current resources hold by it.
  98072. */
  98073. dispose(): void;
  98074. /**
  98075. * Gets the current object class name.
  98076. * @return the class name
  98077. */
  98078. getClassName(): string;
  98079. }
  98080. }
  98081. declare module BABYLON {
  98082. /**
  98083. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  98084. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98085. */
  98086. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  98087. /**
  98088. * Gets the name of the behavior.
  98089. */
  98090. readonly name: string;
  98091. private _zoomStopsAnimation;
  98092. private _idleRotationSpeed;
  98093. private _idleRotationWaitTime;
  98094. private _idleRotationSpinupTime;
  98095. /**
  98096. * Sets the flag that indicates if user zooming should stop animation.
  98097. */
  98098. /**
  98099. * Gets the flag that indicates if user zooming should stop animation.
  98100. */
  98101. zoomStopsAnimation: boolean;
  98102. /**
  98103. * Sets the default speed at which the camera rotates around the model.
  98104. */
  98105. /**
  98106. * Gets the default speed at which the camera rotates around the model.
  98107. */
  98108. idleRotationSpeed: number;
  98109. /**
  98110. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  98111. */
  98112. /**
  98113. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  98114. */
  98115. idleRotationWaitTime: number;
  98116. /**
  98117. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98118. */
  98119. /**
  98120. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98121. */
  98122. idleRotationSpinupTime: number;
  98123. /**
  98124. * Gets a value indicating if the camera is currently rotating because of this behavior
  98125. */
  98126. readonly rotationInProgress: boolean;
  98127. private _onPrePointerObservableObserver;
  98128. private _onAfterCheckInputsObserver;
  98129. private _attachedCamera;
  98130. private _isPointerDown;
  98131. private _lastFrameTime;
  98132. private _lastInteractionTime;
  98133. private _cameraRotationSpeed;
  98134. /**
  98135. * Initializes the behavior.
  98136. */
  98137. init(): void;
  98138. /**
  98139. * Attaches the behavior to its arc rotate camera.
  98140. * @param camera Defines the camera to attach the behavior to
  98141. */
  98142. attach(camera: ArcRotateCamera): void;
  98143. /**
  98144. * Detaches the behavior from its current arc rotate camera.
  98145. */
  98146. detach(): void;
  98147. /**
  98148. * Returns true if user is scrolling.
  98149. * @return true if user is scrolling.
  98150. */
  98151. private _userIsZooming;
  98152. private _lastFrameRadius;
  98153. private _shouldAnimationStopForInteraction;
  98154. /**
  98155. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98156. */
  98157. private _applyUserInteraction;
  98158. private _userIsMoving;
  98159. }
  98160. }
  98161. declare module BABYLON {
  98162. /**
  98163. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  98164. */
  98165. export class AttachToBoxBehavior implements Behavior<Mesh> {
  98166. private ui;
  98167. /**
  98168. * The name of the behavior
  98169. */
  98170. name: string;
  98171. /**
  98172. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  98173. */
  98174. distanceAwayFromFace: number;
  98175. /**
  98176. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  98177. */
  98178. distanceAwayFromBottomOfFace: number;
  98179. private _faceVectors;
  98180. private _target;
  98181. private _scene;
  98182. private _onRenderObserver;
  98183. private _tmpMatrix;
  98184. private _tmpVector;
  98185. /**
  98186. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  98187. * @param ui The transform node that should be attched to the mesh
  98188. */
  98189. constructor(ui: TransformNode);
  98190. /**
  98191. * Initializes the behavior
  98192. */
  98193. init(): void;
  98194. private _closestFace;
  98195. private _zeroVector;
  98196. private _lookAtTmpMatrix;
  98197. private _lookAtToRef;
  98198. /**
  98199. * Attaches the AttachToBoxBehavior to the passed in mesh
  98200. * @param target The mesh that the specified node will be attached to
  98201. */
  98202. attach(target: Mesh): void;
  98203. /**
  98204. * Detaches the behavior from the mesh
  98205. */
  98206. detach(): void;
  98207. }
  98208. }
  98209. declare module BABYLON {
  98210. /**
  98211. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  98212. */
  98213. export class FadeInOutBehavior implements Behavior<Mesh> {
  98214. /**
  98215. * Time in milliseconds to delay before fading in (Default: 0)
  98216. */
  98217. delay: number;
  98218. /**
  98219. * Time in milliseconds for the mesh to fade in (Default: 300)
  98220. */
  98221. fadeInTime: number;
  98222. private _millisecondsPerFrame;
  98223. private _hovered;
  98224. private _hoverValue;
  98225. private _ownerNode;
  98226. /**
  98227. * Instatiates the FadeInOutBehavior
  98228. */
  98229. constructor();
  98230. /**
  98231. * The name of the behavior
  98232. */
  98233. readonly name: string;
  98234. /**
  98235. * Initializes the behavior
  98236. */
  98237. init(): void;
  98238. /**
  98239. * Attaches the fade behavior on the passed in mesh
  98240. * @param ownerNode The mesh that will be faded in/out once attached
  98241. */
  98242. attach(ownerNode: Mesh): void;
  98243. /**
  98244. * Detaches the behavior from the mesh
  98245. */
  98246. detach(): void;
  98247. /**
  98248. * Triggers the mesh to begin fading in or out
  98249. * @param value if the object should fade in or out (true to fade in)
  98250. */
  98251. fadeIn(value: boolean): void;
  98252. private _update;
  98253. private _setAllVisibility;
  98254. }
  98255. }
  98256. declare module BABYLON {
  98257. /**
  98258. * Class containing a set of static utilities functions for managing Pivots
  98259. * @hidden
  98260. */
  98261. export class PivotTools {
  98262. private static _PivotCached;
  98263. private static _OldPivotPoint;
  98264. private static _PivotTranslation;
  98265. private static _PivotTmpVector;
  98266. /** @hidden */
  98267. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  98268. /** @hidden */
  98269. static _RestorePivotPoint(mesh: AbstractMesh): void;
  98270. }
  98271. }
  98272. declare module BABYLON {
  98273. /**
  98274. * Class containing static functions to help procedurally build meshes
  98275. */
  98276. export class PlaneBuilder {
  98277. /**
  98278. * Creates a plane mesh
  98279. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  98280. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  98281. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  98282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98283. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98285. * @param name defines the name of the mesh
  98286. * @param options defines the options used to create the mesh
  98287. * @param scene defines the hosting scene
  98288. * @returns the plane mesh
  98289. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  98290. */
  98291. static CreatePlane(name: string, options: {
  98292. size?: number;
  98293. width?: number;
  98294. height?: number;
  98295. sideOrientation?: number;
  98296. frontUVs?: Vector4;
  98297. backUVs?: Vector4;
  98298. updatable?: boolean;
  98299. sourcePlane?: Plane;
  98300. }, scene?: Nullable<Scene>): Mesh;
  98301. }
  98302. }
  98303. declare module BABYLON {
  98304. /**
  98305. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  98306. */
  98307. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  98308. private static _AnyMouseID;
  98309. /**
  98310. * Abstract mesh the behavior is set on
  98311. */
  98312. attachedNode: AbstractMesh;
  98313. private _dragPlane;
  98314. private _scene;
  98315. private _pointerObserver;
  98316. private _beforeRenderObserver;
  98317. private static _planeScene;
  98318. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  98319. /**
  98320. * 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)
  98321. */
  98322. maxDragAngle: number;
  98323. /**
  98324. * @hidden
  98325. */
  98326. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  98327. /**
  98328. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98329. */
  98330. currentDraggingPointerID: number;
  98331. /**
  98332. * The last position where the pointer hit the drag plane in world space
  98333. */
  98334. lastDragPosition: Vector3;
  98335. /**
  98336. * If the behavior is currently in a dragging state
  98337. */
  98338. dragging: boolean;
  98339. /**
  98340. * 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)
  98341. */
  98342. dragDeltaRatio: number;
  98343. /**
  98344. * If the drag plane orientation should be updated during the dragging (Default: true)
  98345. */
  98346. updateDragPlane: boolean;
  98347. private _debugMode;
  98348. private _moving;
  98349. /**
  98350. * Fires each time the attached mesh is dragged with the pointer
  98351. * * delta between last drag position and current drag position in world space
  98352. * * dragDistance along the drag axis
  98353. * * dragPlaneNormal normal of the current drag plane used during the drag
  98354. * * dragPlanePoint in world space where the drag intersects the drag plane
  98355. */
  98356. onDragObservable: Observable<{
  98357. delta: Vector3;
  98358. dragPlanePoint: Vector3;
  98359. dragPlaneNormal: Vector3;
  98360. dragDistance: number;
  98361. pointerId: number;
  98362. }>;
  98363. /**
  98364. * Fires each time a drag begins (eg. mouse down on mesh)
  98365. */
  98366. onDragStartObservable: Observable<{
  98367. dragPlanePoint: Vector3;
  98368. pointerId: number;
  98369. }>;
  98370. /**
  98371. * Fires each time a drag ends (eg. mouse release after drag)
  98372. */
  98373. onDragEndObservable: Observable<{
  98374. dragPlanePoint: Vector3;
  98375. pointerId: number;
  98376. }>;
  98377. /**
  98378. * If the attached mesh should be moved when dragged
  98379. */
  98380. moveAttached: boolean;
  98381. /**
  98382. * If the drag behavior will react to drag events (Default: true)
  98383. */
  98384. enabled: boolean;
  98385. /**
  98386. * If camera controls should be detached during the drag
  98387. */
  98388. detachCameraControls: boolean;
  98389. /**
  98390. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  98391. */
  98392. useObjectOrienationForDragging: boolean;
  98393. private _options;
  98394. /**
  98395. * Creates a pointer drag behavior that can be attached to a mesh
  98396. * @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)
  98397. */
  98398. constructor(options?: {
  98399. dragAxis?: Vector3;
  98400. dragPlaneNormal?: Vector3;
  98401. });
  98402. /**
  98403. * Predicate to determine if it is valid to move the object to a new position when it is moved
  98404. */
  98405. validateDrag: (targetPosition: Vector3) => boolean;
  98406. /**
  98407. * The name of the behavior
  98408. */
  98409. readonly name: string;
  98410. /**
  98411. * Initializes the behavior
  98412. */
  98413. init(): void;
  98414. private _tmpVector;
  98415. private _alternatePickedPoint;
  98416. private _worldDragAxis;
  98417. private _targetPosition;
  98418. private _attachedElement;
  98419. /**
  98420. * Attaches the drag behavior the passed in mesh
  98421. * @param ownerNode The mesh that will be dragged around once attached
  98422. */
  98423. attach(ownerNode: AbstractMesh): void;
  98424. /**
  98425. * Force relase the drag action by code.
  98426. */
  98427. releaseDrag(): void;
  98428. private _startDragRay;
  98429. private _lastPointerRay;
  98430. /**
  98431. * Simulates the start of a pointer drag event on the behavior
  98432. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  98433. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  98434. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  98435. */
  98436. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  98437. private _startDrag;
  98438. private _dragDelta;
  98439. private _moveDrag;
  98440. private _pickWithRayOnDragPlane;
  98441. private _pointA;
  98442. private _pointB;
  98443. private _pointC;
  98444. private _lineA;
  98445. private _lineB;
  98446. private _localAxis;
  98447. private _lookAt;
  98448. private _updateDragPlanePosition;
  98449. /**
  98450. * Detaches the behavior from the mesh
  98451. */
  98452. detach(): void;
  98453. }
  98454. }
  98455. declare module BABYLON {
  98456. /**
  98457. * A behavior that when attached to a mesh will allow the mesh to be scaled
  98458. */
  98459. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  98460. private _dragBehaviorA;
  98461. private _dragBehaviorB;
  98462. private _startDistance;
  98463. private _initialScale;
  98464. private _targetScale;
  98465. private _ownerNode;
  98466. private _sceneRenderObserver;
  98467. /**
  98468. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  98469. */
  98470. constructor();
  98471. /**
  98472. * The name of the behavior
  98473. */
  98474. readonly name: string;
  98475. /**
  98476. * Initializes the behavior
  98477. */
  98478. init(): void;
  98479. private _getCurrentDistance;
  98480. /**
  98481. * Attaches the scale behavior the passed in mesh
  98482. * @param ownerNode The mesh that will be scaled around once attached
  98483. */
  98484. attach(ownerNode: Mesh): void;
  98485. /**
  98486. * Detaches the behavior from the mesh
  98487. */
  98488. detach(): void;
  98489. }
  98490. }
  98491. declare module BABYLON {
  98492. /**
  98493. * 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
  98494. */
  98495. export class SixDofDragBehavior implements Behavior<Mesh> {
  98496. private static _virtualScene;
  98497. private _ownerNode;
  98498. private _sceneRenderObserver;
  98499. private _scene;
  98500. private _targetPosition;
  98501. private _virtualOriginMesh;
  98502. private _virtualDragMesh;
  98503. private _pointerObserver;
  98504. private _moving;
  98505. private _startingOrientation;
  98506. /**
  98507. * 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)
  98508. */
  98509. private zDragFactor;
  98510. /**
  98511. * If the object should rotate to face the drag origin
  98512. */
  98513. rotateDraggedObject: boolean;
  98514. /**
  98515. * If the behavior is currently in a dragging state
  98516. */
  98517. dragging: boolean;
  98518. /**
  98519. * 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)
  98520. */
  98521. dragDeltaRatio: number;
  98522. /**
  98523. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98524. */
  98525. currentDraggingPointerID: number;
  98526. /**
  98527. * If camera controls should be detached during the drag
  98528. */
  98529. detachCameraControls: boolean;
  98530. /**
  98531. * Fires each time a drag starts
  98532. */
  98533. onDragStartObservable: Observable<{}>;
  98534. /**
  98535. * Fires each time a drag ends (eg. mouse release after drag)
  98536. */
  98537. onDragEndObservable: Observable<{}>;
  98538. /**
  98539. * 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
  98540. */
  98541. constructor();
  98542. /**
  98543. * The name of the behavior
  98544. */
  98545. readonly name: string;
  98546. /**
  98547. * Initializes the behavior
  98548. */
  98549. init(): void;
  98550. /**
  98551. * Attaches the scale behavior the passed in mesh
  98552. * @param ownerNode The mesh that will be scaled around once attached
  98553. */
  98554. attach(ownerNode: Mesh): void;
  98555. /**
  98556. * Detaches the behavior from the mesh
  98557. */
  98558. detach(): void;
  98559. }
  98560. }
  98561. declare module BABYLON {
  98562. /**
  98563. * Class used to apply inverse kinematics to bones
  98564. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  98565. */
  98566. export class BoneIKController {
  98567. private static _tmpVecs;
  98568. private static _tmpQuat;
  98569. private static _tmpMats;
  98570. /**
  98571. * Gets or sets the target mesh
  98572. */
  98573. targetMesh: AbstractMesh;
  98574. /** Gets or sets the mesh used as pole */
  98575. poleTargetMesh: AbstractMesh;
  98576. /**
  98577. * Gets or sets the bone used as pole
  98578. */
  98579. poleTargetBone: Nullable<Bone>;
  98580. /**
  98581. * Gets or sets the target position
  98582. */
  98583. targetPosition: Vector3;
  98584. /**
  98585. * Gets or sets the pole target position
  98586. */
  98587. poleTargetPosition: Vector3;
  98588. /**
  98589. * Gets or sets the pole target local offset
  98590. */
  98591. poleTargetLocalOffset: Vector3;
  98592. /**
  98593. * Gets or sets the pole angle
  98594. */
  98595. poleAngle: number;
  98596. /**
  98597. * Gets or sets the mesh associated with the controller
  98598. */
  98599. mesh: AbstractMesh;
  98600. /**
  98601. * 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)
  98602. */
  98603. slerpAmount: number;
  98604. private _bone1Quat;
  98605. private _bone1Mat;
  98606. private _bone2Ang;
  98607. private _bone1;
  98608. private _bone2;
  98609. private _bone1Length;
  98610. private _bone2Length;
  98611. private _maxAngle;
  98612. private _maxReach;
  98613. private _rightHandedSystem;
  98614. private _bendAxis;
  98615. private _slerping;
  98616. private _adjustRoll;
  98617. /**
  98618. * Gets or sets maximum allowed angle
  98619. */
  98620. maxAngle: number;
  98621. /**
  98622. * Creates a new BoneIKController
  98623. * @param mesh defines the mesh to control
  98624. * @param bone defines the bone to control
  98625. * @param options defines options to set up the controller
  98626. */
  98627. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  98628. targetMesh?: AbstractMesh;
  98629. poleTargetMesh?: AbstractMesh;
  98630. poleTargetBone?: Bone;
  98631. poleTargetLocalOffset?: Vector3;
  98632. poleAngle?: number;
  98633. bendAxis?: Vector3;
  98634. maxAngle?: number;
  98635. slerpAmount?: number;
  98636. });
  98637. private _setMaxAngle;
  98638. /**
  98639. * Force the controller to update the bones
  98640. */
  98641. update(): void;
  98642. }
  98643. }
  98644. declare module BABYLON {
  98645. /**
  98646. * Class used to make a bone look toward a point in space
  98647. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  98648. */
  98649. export class BoneLookController {
  98650. private static _tmpVecs;
  98651. private static _tmpQuat;
  98652. private static _tmpMats;
  98653. /**
  98654. * The target Vector3 that the bone will look at
  98655. */
  98656. target: Vector3;
  98657. /**
  98658. * The mesh that the bone is attached to
  98659. */
  98660. mesh: AbstractMesh;
  98661. /**
  98662. * The bone that will be looking to the target
  98663. */
  98664. bone: Bone;
  98665. /**
  98666. * The up axis of the coordinate system that is used when the bone is rotated
  98667. */
  98668. upAxis: Vector3;
  98669. /**
  98670. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  98671. */
  98672. upAxisSpace: Space;
  98673. /**
  98674. * Used to make an adjustment to the yaw of the bone
  98675. */
  98676. adjustYaw: number;
  98677. /**
  98678. * Used to make an adjustment to the pitch of the bone
  98679. */
  98680. adjustPitch: number;
  98681. /**
  98682. * Used to make an adjustment to the roll of the bone
  98683. */
  98684. adjustRoll: number;
  98685. /**
  98686. * 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)
  98687. */
  98688. slerpAmount: number;
  98689. private _minYaw;
  98690. private _maxYaw;
  98691. private _minPitch;
  98692. private _maxPitch;
  98693. private _minYawSin;
  98694. private _minYawCos;
  98695. private _maxYawSin;
  98696. private _maxYawCos;
  98697. private _midYawConstraint;
  98698. private _minPitchTan;
  98699. private _maxPitchTan;
  98700. private _boneQuat;
  98701. private _slerping;
  98702. private _transformYawPitch;
  98703. private _transformYawPitchInv;
  98704. private _firstFrameSkipped;
  98705. private _yawRange;
  98706. private _fowardAxis;
  98707. /**
  98708. * Gets or sets the minimum yaw angle that the bone can look to
  98709. */
  98710. minYaw: number;
  98711. /**
  98712. * Gets or sets the maximum yaw angle that the bone can look to
  98713. */
  98714. maxYaw: number;
  98715. /**
  98716. * Gets or sets the minimum pitch angle that the bone can look to
  98717. */
  98718. minPitch: number;
  98719. /**
  98720. * Gets or sets the maximum pitch angle that the bone can look to
  98721. */
  98722. maxPitch: number;
  98723. /**
  98724. * Create a BoneLookController
  98725. * @param mesh the mesh that the bone belongs to
  98726. * @param bone the bone that will be looking to the target
  98727. * @param target the target Vector3 to look at
  98728. * @param options optional settings:
  98729. * * maxYaw: the maximum angle the bone will yaw to
  98730. * * minYaw: the minimum angle the bone will yaw to
  98731. * * maxPitch: the maximum angle the bone will pitch to
  98732. * * minPitch: the minimum angle the bone will yaw to
  98733. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  98734. * * upAxis: the up axis of the coordinate system
  98735. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  98736. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  98737. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  98738. * * adjustYaw: used to make an adjustment to the yaw of the bone
  98739. * * adjustPitch: used to make an adjustment to the pitch of the bone
  98740. * * adjustRoll: used to make an adjustment to the roll of the bone
  98741. **/
  98742. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  98743. maxYaw?: number;
  98744. minYaw?: number;
  98745. maxPitch?: number;
  98746. minPitch?: number;
  98747. slerpAmount?: number;
  98748. upAxis?: Vector3;
  98749. upAxisSpace?: Space;
  98750. yawAxis?: Vector3;
  98751. pitchAxis?: Vector3;
  98752. adjustYaw?: number;
  98753. adjustPitch?: number;
  98754. adjustRoll?: number;
  98755. });
  98756. /**
  98757. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  98758. */
  98759. update(): void;
  98760. private _getAngleDiff;
  98761. private _getAngleBetween;
  98762. private _isAngleBetween;
  98763. }
  98764. }
  98765. declare module BABYLON {
  98766. /**
  98767. * Manage the gamepad inputs to control an arc rotate camera.
  98768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98769. */
  98770. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  98771. /**
  98772. * Defines the camera the input is attached to.
  98773. */
  98774. camera: ArcRotateCamera;
  98775. /**
  98776. * Defines the gamepad the input is gathering event from.
  98777. */
  98778. gamepad: Nullable<Gamepad>;
  98779. /**
  98780. * Defines the gamepad rotation sensiblity.
  98781. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  98782. */
  98783. gamepadRotationSensibility: number;
  98784. /**
  98785. * Defines the gamepad move sensiblity.
  98786. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  98787. */
  98788. gamepadMoveSensibility: number;
  98789. private _onGamepadConnectedObserver;
  98790. private _onGamepadDisconnectedObserver;
  98791. /**
  98792. * Attach the input controls to a specific dom element to get the input from.
  98793. * @param element Defines the element the controls should be listened from
  98794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98795. */
  98796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98797. /**
  98798. * Detach the current controls from the specified dom element.
  98799. * @param element Defines the element to stop listening the inputs from
  98800. */
  98801. detachControl(element: Nullable<HTMLElement>): void;
  98802. /**
  98803. * Update the current camera state depending on the inputs that have been used this frame.
  98804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98805. */
  98806. checkInputs(): void;
  98807. /**
  98808. * Gets the class name of the current intput.
  98809. * @returns the class name
  98810. */
  98811. getClassName(): string;
  98812. /**
  98813. * Get the friendly name associated with the input class.
  98814. * @returns the input friendly name
  98815. */
  98816. getSimpleName(): string;
  98817. }
  98818. }
  98819. declare module BABYLON {
  98820. interface ArcRotateCameraInputsManager {
  98821. /**
  98822. * Add orientation input support to the input manager.
  98823. * @returns the current input manager
  98824. */
  98825. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  98826. }
  98827. /**
  98828. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  98829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98830. */
  98831. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  98832. /**
  98833. * Defines the camera the input is attached to.
  98834. */
  98835. camera: ArcRotateCamera;
  98836. /**
  98837. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  98838. */
  98839. alphaCorrection: number;
  98840. /**
  98841. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  98842. */
  98843. gammaCorrection: number;
  98844. private _alpha;
  98845. private _gamma;
  98846. private _dirty;
  98847. private _deviceOrientationHandler;
  98848. /**
  98849. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  98850. */
  98851. constructor();
  98852. /**
  98853. * Attach the input controls to a specific dom element to get the input from.
  98854. * @param element Defines the element the controls should be listened from
  98855. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98856. */
  98857. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98858. /** @hidden */
  98859. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  98860. /**
  98861. * Update the current camera state depending on the inputs that have been used this frame.
  98862. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98863. */
  98864. checkInputs(): void;
  98865. /**
  98866. * Detach the current controls from the specified dom element.
  98867. * @param element Defines the element to stop listening the inputs from
  98868. */
  98869. detachControl(element: Nullable<HTMLElement>): void;
  98870. /**
  98871. * Gets the class name of the current intput.
  98872. * @returns the class name
  98873. */
  98874. getClassName(): string;
  98875. /**
  98876. * Get the friendly name associated with the input class.
  98877. * @returns the input friendly name
  98878. */
  98879. getSimpleName(): string;
  98880. }
  98881. }
  98882. declare module BABYLON {
  98883. /**
  98884. * Listen to mouse events to control the camera.
  98885. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98886. */
  98887. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  98888. /**
  98889. * Defines the camera the input is attached to.
  98890. */
  98891. camera: FlyCamera;
  98892. /**
  98893. * Defines if touch is enabled. (Default is true.)
  98894. */
  98895. touchEnabled: boolean;
  98896. /**
  98897. * Defines the buttons associated with the input to handle camera rotation.
  98898. */
  98899. buttons: number[];
  98900. /**
  98901. * Assign buttons for Yaw control.
  98902. */
  98903. buttonsYaw: number[];
  98904. /**
  98905. * Assign buttons for Pitch control.
  98906. */
  98907. buttonsPitch: number[];
  98908. /**
  98909. * Assign buttons for Roll control.
  98910. */
  98911. buttonsRoll: number[];
  98912. /**
  98913. * Detect if any button is being pressed while mouse is moved.
  98914. * -1 = Mouse locked.
  98915. * 0 = Left button.
  98916. * 1 = Middle Button.
  98917. * 2 = Right Button.
  98918. */
  98919. activeButton: number;
  98920. /**
  98921. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  98922. * Higher values reduce its sensitivity.
  98923. */
  98924. angularSensibility: number;
  98925. private _mousemoveCallback;
  98926. private _observer;
  98927. private _rollObserver;
  98928. private previousPosition;
  98929. private noPreventDefault;
  98930. private element;
  98931. /**
  98932. * Listen to mouse events to control the camera.
  98933. * @param touchEnabled Define if touch is enabled. (Default is true.)
  98934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98935. */
  98936. constructor(touchEnabled?: boolean);
  98937. /**
  98938. * Attach the mouse control to the HTML DOM element.
  98939. * @param element Defines the element that listens to the input events.
  98940. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  98941. */
  98942. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98943. /**
  98944. * Detach the current controls from the specified dom element.
  98945. * @param element Defines the element to stop listening the inputs from
  98946. */
  98947. detachControl(element: Nullable<HTMLElement>): void;
  98948. /**
  98949. * Gets the class name of the current input.
  98950. * @returns the class name.
  98951. */
  98952. getClassName(): string;
  98953. /**
  98954. * Get the friendly name associated with the input class.
  98955. * @returns the input's friendly name.
  98956. */
  98957. getSimpleName(): string;
  98958. private _pointerInput;
  98959. private _onMouseMove;
  98960. /**
  98961. * Rotate camera by mouse offset.
  98962. */
  98963. private rotateCamera;
  98964. }
  98965. }
  98966. declare module BABYLON {
  98967. /**
  98968. * Default Inputs manager for the FlyCamera.
  98969. * It groups all the default supported inputs for ease of use.
  98970. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98971. */
  98972. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  98973. /**
  98974. * Instantiates a new FlyCameraInputsManager.
  98975. * @param camera Defines the camera the inputs belong to.
  98976. */
  98977. constructor(camera: FlyCamera);
  98978. /**
  98979. * Add keyboard input support to the input manager.
  98980. * @returns the new FlyCameraKeyboardMoveInput().
  98981. */
  98982. addKeyboard(): FlyCameraInputsManager;
  98983. /**
  98984. * Add mouse input support to the input manager.
  98985. * @param touchEnabled Enable touch screen support.
  98986. * @returns the new FlyCameraMouseInput().
  98987. */
  98988. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  98989. }
  98990. }
  98991. declare module BABYLON {
  98992. /**
  98993. * This is a flying camera, designed for 3D movement and rotation in all directions,
  98994. * such as in a 3D Space Shooter or a Flight Simulator.
  98995. */
  98996. export class FlyCamera extends TargetCamera {
  98997. /**
  98998. * Define the collision ellipsoid of the camera.
  98999. * This is helpful for simulating a camera body, like a player's body.
  99000. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99001. */
  99002. ellipsoid: Vector3;
  99003. /**
  99004. * Define an offset for the position of the ellipsoid around the camera.
  99005. * This can be helpful if the camera is attached away from the player's body center,
  99006. * such as at its head.
  99007. */
  99008. ellipsoidOffset: Vector3;
  99009. /**
  99010. * Enable or disable collisions of the camera with the rest of the scene objects.
  99011. */
  99012. checkCollisions: boolean;
  99013. /**
  99014. * Enable or disable gravity on the camera.
  99015. */
  99016. applyGravity: boolean;
  99017. /**
  99018. * Define the current direction the camera is moving to.
  99019. */
  99020. cameraDirection: Vector3;
  99021. /**
  99022. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  99023. * This overrides and empties cameraRotation.
  99024. */
  99025. rotationQuaternion: Quaternion;
  99026. /**
  99027. * Track Roll to maintain the wanted Rolling when looking around.
  99028. */
  99029. _trackRoll: number;
  99030. /**
  99031. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  99032. */
  99033. rollCorrect: number;
  99034. /**
  99035. * Mimic a banked turn, Rolling the camera when Yawing.
  99036. * It's recommended to use rollCorrect = 10 for faster banking correction.
  99037. */
  99038. bankedTurn: boolean;
  99039. /**
  99040. * Limit in radians for how much Roll banking will add. (Default: 90°)
  99041. */
  99042. bankedTurnLimit: number;
  99043. /**
  99044. * Value of 0 disables the banked Roll.
  99045. * Value of 1 is equal to the Yaw angle in radians.
  99046. */
  99047. bankedTurnMultiplier: number;
  99048. /**
  99049. * The inputs manager loads all the input sources, such as keyboard and mouse.
  99050. */
  99051. inputs: FlyCameraInputsManager;
  99052. /**
  99053. * Gets the input sensibility for mouse input.
  99054. * Higher values reduce sensitivity.
  99055. */
  99056. /**
  99057. * Sets the input sensibility for a mouse input.
  99058. * Higher values reduce sensitivity.
  99059. */
  99060. angularSensibility: number;
  99061. /**
  99062. * Get the keys for camera movement forward.
  99063. */
  99064. /**
  99065. * Set the keys for camera movement forward.
  99066. */
  99067. keysForward: number[];
  99068. /**
  99069. * Get the keys for camera movement backward.
  99070. */
  99071. keysBackward: number[];
  99072. /**
  99073. * Get the keys for camera movement up.
  99074. */
  99075. /**
  99076. * Set the keys for camera movement up.
  99077. */
  99078. keysUp: number[];
  99079. /**
  99080. * Get the keys for camera movement down.
  99081. */
  99082. /**
  99083. * Set the keys for camera movement down.
  99084. */
  99085. keysDown: number[];
  99086. /**
  99087. * Get the keys for camera movement left.
  99088. */
  99089. /**
  99090. * Set the keys for camera movement left.
  99091. */
  99092. keysLeft: number[];
  99093. /**
  99094. * Set the keys for camera movement right.
  99095. */
  99096. /**
  99097. * Set the keys for camera movement right.
  99098. */
  99099. keysRight: number[];
  99100. /**
  99101. * Event raised when the camera collides with a mesh in the scene.
  99102. */
  99103. onCollide: (collidedMesh: AbstractMesh) => void;
  99104. private _collider;
  99105. private _needMoveForGravity;
  99106. private _oldPosition;
  99107. private _diffPosition;
  99108. private _newPosition;
  99109. /** @hidden */
  99110. _localDirection: Vector3;
  99111. /** @hidden */
  99112. _transformedDirection: Vector3;
  99113. /**
  99114. * Instantiates a FlyCamera.
  99115. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99116. * such as in a 3D Space Shooter or a Flight Simulator.
  99117. * @param name Define the name of the camera in the scene.
  99118. * @param position Define the starting position of the camera in the scene.
  99119. * @param scene Define the scene the camera belongs to.
  99120. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  99121. */
  99122. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99123. /**
  99124. * Attach a control to the HTML DOM element.
  99125. * @param element Defines the element that listens to the input events.
  99126. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  99127. */
  99128. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99129. /**
  99130. * Detach a control from the HTML DOM element.
  99131. * The camera will stop reacting to that input.
  99132. * @param element Defines the element that listens to the input events.
  99133. */
  99134. detachControl(element: HTMLElement): void;
  99135. private _collisionMask;
  99136. /**
  99137. * Get the mask that the camera ignores in collision events.
  99138. */
  99139. /**
  99140. * Set the mask that the camera ignores in collision events.
  99141. */
  99142. collisionMask: number;
  99143. /** @hidden */
  99144. _collideWithWorld(displacement: Vector3): void;
  99145. /** @hidden */
  99146. private _onCollisionPositionChange;
  99147. /** @hidden */
  99148. _checkInputs(): void;
  99149. /** @hidden */
  99150. _decideIfNeedsToMove(): boolean;
  99151. /** @hidden */
  99152. _updatePosition(): void;
  99153. /**
  99154. * Restore the Roll to its target value at the rate specified.
  99155. * @param rate - Higher means slower restoring.
  99156. * @hidden
  99157. */
  99158. restoreRoll(rate: number): void;
  99159. /**
  99160. * Destroy the camera and release the current resources held by it.
  99161. */
  99162. dispose(): void;
  99163. /**
  99164. * Get the current object class name.
  99165. * @returns the class name.
  99166. */
  99167. getClassName(): string;
  99168. }
  99169. }
  99170. declare module BABYLON {
  99171. /**
  99172. * Listen to keyboard events to control the camera.
  99173. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99174. */
  99175. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  99176. /**
  99177. * Defines the camera the input is attached to.
  99178. */
  99179. camera: FlyCamera;
  99180. /**
  99181. * The list of keyboard keys used to control the forward move of the camera.
  99182. */
  99183. keysForward: number[];
  99184. /**
  99185. * The list of keyboard keys used to control the backward move of the camera.
  99186. */
  99187. keysBackward: number[];
  99188. /**
  99189. * The list of keyboard keys used to control the forward move of the camera.
  99190. */
  99191. keysUp: number[];
  99192. /**
  99193. * The list of keyboard keys used to control the backward move of the camera.
  99194. */
  99195. keysDown: number[];
  99196. /**
  99197. * The list of keyboard keys used to control the right strafe move of the camera.
  99198. */
  99199. keysRight: number[];
  99200. /**
  99201. * The list of keyboard keys used to control the left strafe move of the camera.
  99202. */
  99203. keysLeft: number[];
  99204. private _keys;
  99205. private _onCanvasBlurObserver;
  99206. private _onKeyboardObserver;
  99207. private _engine;
  99208. private _scene;
  99209. /**
  99210. * Attach the input controls to a specific dom element to get the input from.
  99211. * @param element Defines the element the controls should be listened from
  99212. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99213. */
  99214. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99215. /**
  99216. * Detach the current controls from the specified dom element.
  99217. * @param element Defines the element to stop listening the inputs from
  99218. */
  99219. detachControl(element: Nullable<HTMLElement>): void;
  99220. /**
  99221. * Gets the class name of the current intput.
  99222. * @returns the class name
  99223. */
  99224. getClassName(): string;
  99225. /** @hidden */
  99226. _onLostFocus(e: FocusEvent): void;
  99227. /**
  99228. * Get the friendly name associated with the input class.
  99229. * @returns the input friendly name
  99230. */
  99231. getSimpleName(): string;
  99232. /**
  99233. * Update the current camera state depending on the inputs that have been used this frame.
  99234. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99235. */
  99236. checkInputs(): void;
  99237. }
  99238. }
  99239. declare module BABYLON {
  99240. /**
  99241. * Manage the mouse wheel inputs to control a follow camera.
  99242. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99243. */
  99244. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  99245. /**
  99246. * Defines the camera the input is attached to.
  99247. */
  99248. camera: FollowCamera;
  99249. /**
  99250. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  99251. */
  99252. axisControlRadius: boolean;
  99253. /**
  99254. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  99255. */
  99256. axisControlHeight: boolean;
  99257. /**
  99258. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  99259. */
  99260. axisControlRotation: boolean;
  99261. /**
  99262. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  99263. * relation to mouseWheel events.
  99264. */
  99265. wheelPrecision: number;
  99266. /**
  99267. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  99268. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  99269. */
  99270. wheelDeltaPercentage: number;
  99271. private _wheel;
  99272. private _observer;
  99273. /**
  99274. * Attach the input controls to a specific dom element to get the input from.
  99275. * @param element Defines the element the controls should be listened from
  99276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99277. */
  99278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99279. /**
  99280. * Detach the current controls from the specified dom element.
  99281. * @param element Defines the element to stop listening the inputs from
  99282. */
  99283. detachControl(element: Nullable<HTMLElement>): void;
  99284. /**
  99285. * Gets the class name of the current intput.
  99286. * @returns the class name
  99287. */
  99288. getClassName(): string;
  99289. /**
  99290. * Get the friendly name associated with the input class.
  99291. * @returns the input friendly name
  99292. */
  99293. getSimpleName(): string;
  99294. }
  99295. }
  99296. declare module BABYLON {
  99297. /**
  99298. * Manage the pointers inputs to control an follow camera.
  99299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99300. */
  99301. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  99302. /**
  99303. * Defines the camera the input is attached to.
  99304. */
  99305. camera: FollowCamera;
  99306. /**
  99307. * Gets the class name of the current input.
  99308. * @returns the class name
  99309. */
  99310. getClassName(): string;
  99311. /**
  99312. * Defines the pointer angular sensibility along the X axis or how fast is
  99313. * the camera rotating.
  99314. * A negative number will reverse the axis direction.
  99315. */
  99316. angularSensibilityX: number;
  99317. /**
  99318. * Defines the pointer angular sensibility along the Y axis or how fast is
  99319. * the camera rotating.
  99320. * A negative number will reverse the axis direction.
  99321. */
  99322. angularSensibilityY: number;
  99323. /**
  99324. * Defines the pointer pinch precision or how fast is the camera zooming.
  99325. * A negative number will reverse the axis direction.
  99326. */
  99327. pinchPrecision: number;
  99328. /**
  99329. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99330. * from 0.
  99331. * It defines the percentage of current camera.radius to use as delta when
  99332. * pinch zoom is used.
  99333. */
  99334. pinchDeltaPercentage: number;
  99335. /**
  99336. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  99337. */
  99338. axisXControlRadius: boolean;
  99339. /**
  99340. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  99341. */
  99342. axisXControlHeight: boolean;
  99343. /**
  99344. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  99345. */
  99346. axisXControlRotation: boolean;
  99347. /**
  99348. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  99349. */
  99350. axisYControlRadius: boolean;
  99351. /**
  99352. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  99353. */
  99354. axisYControlHeight: boolean;
  99355. /**
  99356. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  99357. */
  99358. axisYControlRotation: boolean;
  99359. /**
  99360. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  99361. */
  99362. axisPinchControlRadius: boolean;
  99363. /**
  99364. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  99365. */
  99366. axisPinchControlHeight: boolean;
  99367. /**
  99368. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  99369. */
  99370. axisPinchControlRotation: boolean;
  99371. /**
  99372. * Log error messages if basic misconfiguration has occurred.
  99373. */
  99374. warningEnable: boolean;
  99375. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99376. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99377. private _warningCounter;
  99378. private _warning;
  99379. }
  99380. }
  99381. declare module BABYLON {
  99382. /**
  99383. * Default Inputs manager for the FollowCamera.
  99384. * It groups all the default supported inputs for ease of use.
  99385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99386. */
  99387. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  99388. /**
  99389. * Instantiates a new FollowCameraInputsManager.
  99390. * @param camera Defines the camera the inputs belong to
  99391. */
  99392. constructor(camera: FollowCamera);
  99393. /**
  99394. * Add keyboard input support to the input manager.
  99395. * @returns the current input manager
  99396. */
  99397. addKeyboard(): FollowCameraInputsManager;
  99398. /**
  99399. * Add mouse wheel input support to the input manager.
  99400. * @returns the current input manager
  99401. */
  99402. addMouseWheel(): FollowCameraInputsManager;
  99403. /**
  99404. * Add pointers input support to the input manager.
  99405. * @returns the current input manager
  99406. */
  99407. addPointers(): FollowCameraInputsManager;
  99408. /**
  99409. * Add orientation input support to the input manager.
  99410. * @returns the current input manager
  99411. */
  99412. addVRDeviceOrientation(): FollowCameraInputsManager;
  99413. }
  99414. }
  99415. declare module BABYLON {
  99416. /**
  99417. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  99418. * an arc rotate version arcFollowCamera are available.
  99419. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99420. */
  99421. export class FollowCamera extends TargetCamera {
  99422. /**
  99423. * Distance the follow camera should follow an object at
  99424. */
  99425. radius: number;
  99426. /**
  99427. * Minimum allowed distance of the camera to the axis of rotation
  99428. * (The camera can not get closer).
  99429. * This can help limiting how the Camera is able to move in the scene.
  99430. */
  99431. lowerRadiusLimit: Nullable<number>;
  99432. /**
  99433. * Maximum allowed distance of the camera to the axis of rotation
  99434. * (The camera can not get further).
  99435. * This can help limiting how the Camera is able to move in the scene.
  99436. */
  99437. upperRadiusLimit: Nullable<number>;
  99438. /**
  99439. * Define a rotation offset between the camera and the object it follows
  99440. */
  99441. rotationOffset: number;
  99442. /**
  99443. * Minimum allowed angle to camera position relative to target object.
  99444. * This can help limiting how the Camera is able to move in the scene.
  99445. */
  99446. lowerRotationOffsetLimit: Nullable<number>;
  99447. /**
  99448. * Maximum allowed angle to camera position relative to target object.
  99449. * This can help limiting how the Camera is able to move in the scene.
  99450. */
  99451. upperRotationOffsetLimit: Nullable<number>;
  99452. /**
  99453. * Define a height offset between the camera and the object it follows.
  99454. * It can help following an object from the top (like a car chaing a plane)
  99455. */
  99456. heightOffset: number;
  99457. /**
  99458. * Minimum allowed height of camera position relative to target object.
  99459. * This can help limiting how the Camera is able to move in the scene.
  99460. */
  99461. lowerHeightOffsetLimit: Nullable<number>;
  99462. /**
  99463. * Maximum allowed height of camera position relative to target object.
  99464. * This can help limiting how the Camera is able to move in the scene.
  99465. */
  99466. upperHeightOffsetLimit: Nullable<number>;
  99467. /**
  99468. * Define how fast the camera can accelerate to follow it s target.
  99469. */
  99470. cameraAcceleration: number;
  99471. /**
  99472. * Define the speed limit of the camera following an object.
  99473. */
  99474. maxCameraSpeed: number;
  99475. /**
  99476. * Define the target of the camera.
  99477. */
  99478. lockedTarget: Nullable<AbstractMesh>;
  99479. /**
  99480. * Defines the input associated with the camera.
  99481. */
  99482. inputs: FollowCameraInputsManager;
  99483. /**
  99484. * Instantiates the follow camera.
  99485. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99486. * @param name Define the name of the camera in the scene
  99487. * @param position Define the position of the camera
  99488. * @param scene Define the scene the camera belong to
  99489. * @param lockedTarget Define the target of the camera
  99490. */
  99491. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  99492. private _follow;
  99493. /**
  99494. * Attached controls to the current camera.
  99495. * @param element Defines the element the controls should be listened from
  99496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99497. */
  99498. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99499. /**
  99500. * Detach the current controls from the camera.
  99501. * The camera will stop reacting to inputs.
  99502. * @param element Defines the element to stop listening the inputs from
  99503. */
  99504. detachControl(element: HTMLElement): void;
  99505. /** @hidden */
  99506. _checkInputs(): void;
  99507. private _checkLimits;
  99508. /**
  99509. * Gets the camera class name.
  99510. * @returns the class name
  99511. */
  99512. getClassName(): string;
  99513. }
  99514. /**
  99515. * Arc Rotate version of the follow camera.
  99516. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  99517. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99518. */
  99519. export class ArcFollowCamera extends TargetCamera {
  99520. /** The longitudinal angle of the camera */
  99521. alpha: number;
  99522. /** The latitudinal angle of the camera */
  99523. beta: number;
  99524. /** The radius of the camera from its target */
  99525. radius: number;
  99526. /** Define the camera target (the messh it should follow) */
  99527. target: Nullable<AbstractMesh>;
  99528. private _cartesianCoordinates;
  99529. /**
  99530. * Instantiates a new ArcFollowCamera
  99531. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99532. * @param name Define the name of the camera
  99533. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  99534. * @param beta Define the rotation angle of the camera around the elevation axis
  99535. * @param radius Define the radius of the camera from its target point
  99536. * @param target Define the target of the camera
  99537. * @param scene Define the scene the camera belongs to
  99538. */
  99539. constructor(name: string,
  99540. /** The longitudinal angle of the camera */
  99541. alpha: number,
  99542. /** The latitudinal angle of the camera */
  99543. beta: number,
  99544. /** The radius of the camera from its target */
  99545. radius: number,
  99546. /** Define the camera target (the messh it should follow) */
  99547. target: Nullable<AbstractMesh>, scene: Scene);
  99548. private _follow;
  99549. /** @hidden */
  99550. _checkInputs(): void;
  99551. /**
  99552. * Returns the class name of the object.
  99553. * It is mostly used internally for serialization purposes.
  99554. */
  99555. getClassName(): string;
  99556. }
  99557. }
  99558. declare module BABYLON {
  99559. /**
  99560. * Manage the keyboard inputs to control the movement of a follow camera.
  99561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99562. */
  99563. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  99564. /**
  99565. * Defines the camera the input is attached to.
  99566. */
  99567. camera: FollowCamera;
  99568. /**
  99569. * Defines the list of key codes associated with the up action (increase heightOffset)
  99570. */
  99571. keysHeightOffsetIncr: number[];
  99572. /**
  99573. * Defines the list of key codes associated with the down action (decrease heightOffset)
  99574. */
  99575. keysHeightOffsetDecr: number[];
  99576. /**
  99577. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  99578. */
  99579. keysHeightOffsetModifierAlt: boolean;
  99580. /**
  99581. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  99582. */
  99583. keysHeightOffsetModifierCtrl: boolean;
  99584. /**
  99585. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  99586. */
  99587. keysHeightOffsetModifierShift: boolean;
  99588. /**
  99589. * Defines the list of key codes associated with the left action (increase rotationOffset)
  99590. */
  99591. keysRotationOffsetIncr: number[];
  99592. /**
  99593. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  99594. */
  99595. keysRotationOffsetDecr: number[];
  99596. /**
  99597. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  99598. */
  99599. keysRotationOffsetModifierAlt: boolean;
  99600. /**
  99601. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  99602. */
  99603. keysRotationOffsetModifierCtrl: boolean;
  99604. /**
  99605. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  99606. */
  99607. keysRotationOffsetModifierShift: boolean;
  99608. /**
  99609. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  99610. */
  99611. keysRadiusIncr: number[];
  99612. /**
  99613. * Defines the list of key codes associated with the zoom-out action (increase radius)
  99614. */
  99615. keysRadiusDecr: number[];
  99616. /**
  99617. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  99618. */
  99619. keysRadiusModifierAlt: boolean;
  99620. /**
  99621. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  99622. */
  99623. keysRadiusModifierCtrl: boolean;
  99624. /**
  99625. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  99626. */
  99627. keysRadiusModifierShift: boolean;
  99628. /**
  99629. * Defines the rate of change of heightOffset.
  99630. */
  99631. heightSensibility: number;
  99632. /**
  99633. * Defines the rate of change of rotationOffset.
  99634. */
  99635. rotationSensibility: number;
  99636. /**
  99637. * Defines the rate of change of radius.
  99638. */
  99639. radiusSensibility: number;
  99640. private _keys;
  99641. private _ctrlPressed;
  99642. private _altPressed;
  99643. private _shiftPressed;
  99644. private _onCanvasBlurObserver;
  99645. private _onKeyboardObserver;
  99646. private _engine;
  99647. private _scene;
  99648. /**
  99649. * Attach the input controls to a specific dom element to get the input from.
  99650. * @param element Defines the element the controls should be listened from
  99651. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99652. */
  99653. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99654. /**
  99655. * Detach the current controls from the specified dom element.
  99656. * @param element Defines the element to stop listening the inputs from
  99657. */
  99658. detachControl(element: Nullable<HTMLElement>): void;
  99659. /**
  99660. * Update the current camera state depending on the inputs that have been used this frame.
  99661. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99662. */
  99663. checkInputs(): void;
  99664. /**
  99665. * Gets the class name of the current input.
  99666. * @returns the class name
  99667. */
  99668. getClassName(): string;
  99669. /**
  99670. * Get the friendly name associated with the input class.
  99671. * @returns the input friendly name
  99672. */
  99673. getSimpleName(): string;
  99674. /**
  99675. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99676. * allow modification of the heightOffset value.
  99677. */
  99678. private _modifierHeightOffset;
  99679. /**
  99680. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99681. * allow modification of the rotationOffset value.
  99682. */
  99683. private _modifierRotationOffset;
  99684. /**
  99685. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99686. * allow modification of the radius value.
  99687. */
  99688. private _modifierRadius;
  99689. }
  99690. }
  99691. declare module BABYLON {
  99692. interface FreeCameraInputsManager {
  99693. /**
  99694. * @hidden
  99695. */
  99696. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  99697. /**
  99698. * Add orientation input support to the input manager.
  99699. * @returns the current input manager
  99700. */
  99701. addDeviceOrientation(): FreeCameraInputsManager;
  99702. }
  99703. /**
  99704. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  99705. * Screen rotation is taken into account.
  99706. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99707. */
  99708. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  99709. private _camera;
  99710. private _screenOrientationAngle;
  99711. private _constantTranform;
  99712. private _screenQuaternion;
  99713. private _alpha;
  99714. private _beta;
  99715. private _gamma;
  99716. /**
  99717. * @hidden
  99718. */
  99719. _onDeviceOrientationChangedObservable: Observable<void>;
  99720. /**
  99721. * Instantiates a new input
  99722. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99723. */
  99724. constructor();
  99725. /**
  99726. * Define the camera controlled by the input.
  99727. */
  99728. camera: FreeCamera;
  99729. /**
  99730. * Attach the input controls to a specific dom element to get the input from.
  99731. * @param element Defines the element the controls should be listened from
  99732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99733. */
  99734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99735. private _orientationChanged;
  99736. private _deviceOrientation;
  99737. /**
  99738. * Detach the current controls from the specified dom element.
  99739. * @param element Defines the element to stop listening the inputs from
  99740. */
  99741. detachControl(element: Nullable<HTMLElement>): void;
  99742. /**
  99743. * Update the current camera state depending on the inputs that have been used this frame.
  99744. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99745. */
  99746. checkInputs(): void;
  99747. /**
  99748. * Gets the class name of the current intput.
  99749. * @returns the class name
  99750. */
  99751. getClassName(): string;
  99752. /**
  99753. * Get the friendly name associated with the input class.
  99754. * @returns the input friendly name
  99755. */
  99756. getSimpleName(): string;
  99757. }
  99758. }
  99759. declare module BABYLON {
  99760. /**
  99761. * Manage the gamepad inputs to control a free camera.
  99762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99763. */
  99764. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  99765. /**
  99766. * Define the camera the input is attached to.
  99767. */
  99768. camera: FreeCamera;
  99769. /**
  99770. * Define the Gamepad controlling the input
  99771. */
  99772. gamepad: Nullable<Gamepad>;
  99773. /**
  99774. * Defines the gamepad rotation sensiblity.
  99775. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99776. */
  99777. gamepadAngularSensibility: number;
  99778. /**
  99779. * Defines the gamepad move sensiblity.
  99780. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99781. */
  99782. gamepadMoveSensibility: number;
  99783. private _onGamepadConnectedObserver;
  99784. private _onGamepadDisconnectedObserver;
  99785. private _cameraTransform;
  99786. private _deltaTransform;
  99787. private _vector3;
  99788. private _vector2;
  99789. /**
  99790. * Attach the input controls to a specific dom element to get the input from.
  99791. * @param element Defines the element the controls should be listened from
  99792. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99793. */
  99794. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99795. /**
  99796. * Detach the current controls from the specified dom element.
  99797. * @param element Defines the element to stop listening the inputs from
  99798. */
  99799. detachControl(element: Nullable<HTMLElement>): void;
  99800. /**
  99801. * Update the current camera state depending on the inputs that have been used this frame.
  99802. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99803. */
  99804. checkInputs(): void;
  99805. /**
  99806. * Gets the class name of the current intput.
  99807. * @returns the class name
  99808. */
  99809. getClassName(): string;
  99810. /**
  99811. * Get the friendly name associated with the input class.
  99812. * @returns the input friendly name
  99813. */
  99814. getSimpleName(): string;
  99815. }
  99816. }
  99817. declare module BABYLON {
  99818. /**
  99819. * Defines the potential axis of a Joystick
  99820. */
  99821. export enum JoystickAxis {
  99822. /** X axis */
  99823. X = 0,
  99824. /** Y axis */
  99825. Y = 1,
  99826. /** Z axis */
  99827. Z = 2
  99828. }
  99829. /**
  99830. * Class used to define virtual joystick (used in touch mode)
  99831. */
  99832. export class VirtualJoystick {
  99833. /**
  99834. * Gets or sets a boolean indicating that left and right values must be inverted
  99835. */
  99836. reverseLeftRight: boolean;
  99837. /**
  99838. * Gets or sets a boolean indicating that up and down values must be inverted
  99839. */
  99840. reverseUpDown: boolean;
  99841. /**
  99842. * Gets the offset value for the position (ie. the change of the position value)
  99843. */
  99844. deltaPosition: Vector3;
  99845. /**
  99846. * Gets a boolean indicating if the virtual joystick was pressed
  99847. */
  99848. pressed: boolean;
  99849. /**
  99850. * Canvas the virtual joystick will render onto, default z-index of this is 5
  99851. */
  99852. static Canvas: Nullable<HTMLCanvasElement>;
  99853. private static _globalJoystickIndex;
  99854. private static vjCanvasContext;
  99855. private static vjCanvasWidth;
  99856. private static vjCanvasHeight;
  99857. private static halfWidth;
  99858. private _action;
  99859. private _axisTargetedByLeftAndRight;
  99860. private _axisTargetedByUpAndDown;
  99861. private _joystickSensibility;
  99862. private _inversedSensibility;
  99863. private _joystickPointerID;
  99864. private _joystickColor;
  99865. private _joystickPointerPos;
  99866. private _joystickPreviousPointerPos;
  99867. private _joystickPointerStartPos;
  99868. private _deltaJoystickVector;
  99869. private _leftJoystick;
  99870. private _touches;
  99871. private _onPointerDownHandlerRef;
  99872. private _onPointerMoveHandlerRef;
  99873. private _onPointerUpHandlerRef;
  99874. private _onResize;
  99875. /**
  99876. * Creates a new virtual joystick
  99877. * @param leftJoystick defines that the joystick is for left hand (false by default)
  99878. */
  99879. constructor(leftJoystick?: boolean);
  99880. /**
  99881. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  99882. * @param newJoystickSensibility defines the new sensibility
  99883. */
  99884. setJoystickSensibility(newJoystickSensibility: number): void;
  99885. private _onPointerDown;
  99886. private _onPointerMove;
  99887. private _onPointerUp;
  99888. /**
  99889. * Change the color of the virtual joystick
  99890. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  99891. */
  99892. setJoystickColor(newColor: string): void;
  99893. /**
  99894. * Defines a callback to call when the joystick is touched
  99895. * @param action defines the callback
  99896. */
  99897. setActionOnTouch(action: () => any): void;
  99898. /**
  99899. * Defines which axis you'd like to control for left & right
  99900. * @param axis defines the axis to use
  99901. */
  99902. setAxisForLeftRight(axis: JoystickAxis): void;
  99903. /**
  99904. * Defines which axis you'd like to control for up & down
  99905. * @param axis defines the axis to use
  99906. */
  99907. setAxisForUpDown(axis: JoystickAxis): void;
  99908. private _drawVirtualJoystick;
  99909. /**
  99910. * Release internal HTML canvas
  99911. */
  99912. releaseCanvas(): void;
  99913. }
  99914. }
  99915. declare module BABYLON {
  99916. interface FreeCameraInputsManager {
  99917. /**
  99918. * Add virtual joystick input support to the input manager.
  99919. * @returns the current input manager
  99920. */
  99921. addVirtualJoystick(): FreeCameraInputsManager;
  99922. }
  99923. /**
  99924. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  99925. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99926. */
  99927. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  99928. /**
  99929. * Defines the camera the input is attached to.
  99930. */
  99931. camera: FreeCamera;
  99932. private _leftjoystick;
  99933. private _rightjoystick;
  99934. /**
  99935. * Gets the left stick of the virtual joystick.
  99936. * @returns The virtual Joystick
  99937. */
  99938. getLeftJoystick(): VirtualJoystick;
  99939. /**
  99940. * Gets the right stick of the virtual joystick.
  99941. * @returns The virtual Joystick
  99942. */
  99943. getRightJoystick(): VirtualJoystick;
  99944. /**
  99945. * Update the current camera state depending on the inputs that have been used this frame.
  99946. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99947. */
  99948. checkInputs(): void;
  99949. /**
  99950. * Attach the input controls to a specific dom element to get the input from.
  99951. * @param element Defines the element the controls should be listened from
  99952. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99953. */
  99954. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99955. /**
  99956. * Detach the current controls from the specified dom element.
  99957. * @param element Defines the element to stop listening the inputs from
  99958. */
  99959. detachControl(element: Nullable<HTMLElement>): void;
  99960. /**
  99961. * Gets the class name of the current intput.
  99962. * @returns the class name
  99963. */
  99964. getClassName(): string;
  99965. /**
  99966. * Get the friendly name associated with the input class.
  99967. * @returns the input friendly name
  99968. */
  99969. getSimpleName(): string;
  99970. }
  99971. }
  99972. declare module BABYLON {
  99973. /**
  99974. * This represents a FPS type of camera controlled by touch.
  99975. * This is like a universal camera minus the Gamepad controls.
  99976. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  99977. */
  99978. export class TouchCamera extends FreeCamera {
  99979. /**
  99980. * Defines the touch sensibility for rotation.
  99981. * The higher the faster.
  99982. */
  99983. touchAngularSensibility: number;
  99984. /**
  99985. * Defines the touch sensibility for move.
  99986. * The higher the faster.
  99987. */
  99988. touchMoveSensibility: number;
  99989. /**
  99990. * Instantiates a new touch camera.
  99991. * This represents a FPS type of camera controlled by touch.
  99992. * This is like a universal camera minus the Gamepad controls.
  99993. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  99994. * @param name Define the name of the camera in the scene
  99995. * @param position Define the start position of the camera in the scene
  99996. * @param scene Define the scene the camera belongs to
  99997. */
  99998. constructor(name: string, position: Vector3, scene: Scene);
  99999. /**
  100000. * Gets the current object class name.
  100001. * @return the class name
  100002. */
  100003. getClassName(): string;
  100004. /** @hidden */
  100005. _setupInputs(): void;
  100006. }
  100007. }
  100008. declare module BABYLON {
  100009. /**
  100010. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  100011. * being tilted forward or back and left or right.
  100012. */
  100013. export class DeviceOrientationCamera extends FreeCamera {
  100014. private _initialQuaternion;
  100015. private _quaternionCache;
  100016. private _tmpDragQuaternion;
  100017. /**
  100018. * Creates a new device orientation camera
  100019. * @param name The name of the camera
  100020. * @param position The start position camera
  100021. * @param scene The scene the camera belongs to
  100022. */
  100023. constructor(name: string, position: Vector3, scene: Scene);
  100024. /**
  100025. * @hidden
  100026. * Disabled pointer input on first orientation sensor update (Default: true)
  100027. */
  100028. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  100029. private _dragFactor;
  100030. /**
  100031. * Enabled turning on the y axis when the orientation sensor is active
  100032. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  100033. */
  100034. enableHorizontalDragging(dragFactor?: number): void;
  100035. /**
  100036. * Gets the current instance class name ("DeviceOrientationCamera").
  100037. * This helps avoiding instanceof at run time.
  100038. * @returns the class name
  100039. */
  100040. getClassName(): string;
  100041. /**
  100042. * @hidden
  100043. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  100044. */
  100045. _checkInputs(): void;
  100046. /**
  100047. * Reset the camera to its default orientation on the specified axis only.
  100048. * @param axis The axis to reset
  100049. */
  100050. resetToCurrentRotation(axis?: Axis): void;
  100051. }
  100052. }
  100053. declare module BABYLON {
  100054. /**
  100055. * Defines supported buttons for XBox360 compatible gamepads
  100056. */
  100057. export enum Xbox360Button {
  100058. /** A */
  100059. A = 0,
  100060. /** B */
  100061. B = 1,
  100062. /** X */
  100063. X = 2,
  100064. /** Y */
  100065. Y = 3,
  100066. /** Start */
  100067. Start = 4,
  100068. /** Back */
  100069. Back = 5,
  100070. /** Left button */
  100071. LB = 6,
  100072. /** Right button */
  100073. RB = 7,
  100074. /** Left stick */
  100075. LeftStick = 8,
  100076. /** Right stick */
  100077. RightStick = 9
  100078. }
  100079. /** Defines values for XBox360 DPad */
  100080. export enum Xbox360Dpad {
  100081. /** Up */
  100082. Up = 0,
  100083. /** Down */
  100084. Down = 1,
  100085. /** Left */
  100086. Left = 2,
  100087. /** Right */
  100088. Right = 3
  100089. }
  100090. /**
  100091. * Defines a XBox360 gamepad
  100092. */
  100093. export class Xbox360Pad extends Gamepad {
  100094. private _leftTrigger;
  100095. private _rightTrigger;
  100096. private _onlefttriggerchanged;
  100097. private _onrighttriggerchanged;
  100098. private _onbuttondown;
  100099. private _onbuttonup;
  100100. private _ondpaddown;
  100101. private _ondpadup;
  100102. /** Observable raised when a button is pressed */
  100103. onButtonDownObservable: Observable<Xbox360Button>;
  100104. /** Observable raised when a button is released */
  100105. onButtonUpObservable: Observable<Xbox360Button>;
  100106. /** Observable raised when a pad is pressed */
  100107. onPadDownObservable: Observable<Xbox360Dpad>;
  100108. /** Observable raised when a pad is released */
  100109. onPadUpObservable: Observable<Xbox360Dpad>;
  100110. private _buttonA;
  100111. private _buttonB;
  100112. private _buttonX;
  100113. private _buttonY;
  100114. private _buttonBack;
  100115. private _buttonStart;
  100116. private _buttonLB;
  100117. private _buttonRB;
  100118. private _buttonLeftStick;
  100119. private _buttonRightStick;
  100120. private _dPadUp;
  100121. private _dPadDown;
  100122. private _dPadLeft;
  100123. private _dPadRight;
  100124. private _isXboxOnePad;
  100125. /**
  100126. * Creates a new XBox360 gamepad object
  100127. * @param id defines the id of this gamepad
  100128. * @param index defines its index
  100129. * @param gamepad defines the internal HTML gamepad object
  100130. * @param xboxOne defines if it is a XBox One gamepad
  100131. */
  100132. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  100133. /**
  100134. * Defines the callback to call when left trigger is pressed
  100135. * @param callback defines the callback to use
  100136. */
  100137. onlefttriggerchanged(callback: (value: number) => void): void;
  100138. /**
  100139. * Defines the callback to call when right trigger is pressed
  100140. * @param callback defines the callback to use
  100141. */
  100142. onrighttriggerchanged(callback: (value: number) => void): void;
  100143. /**
  100144. * Gets the left trigger value
  100145. */
  100146. /**
  100147. * Sets the left trigger value
  100148. */
  100149. leftTrigger: number;
  100150. /**
  100151. * Gets the right trigger value
  100152. */
  100153. /**
  100154. * Sets the right trigger value
  100155. */
  100156. rightTrigger: number;
  100157. /**
  100158. * Defines the callback to call when a button is pressed
  100159. * @param callback defines the callback to use
  100160. */
  100161. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  100162. /**
  100163. * Defines the callback to call when a button is released
  100164. * @param callback defines the callback to use
  100165. */
  100166. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  100167. /**
  100168. * Defines the callback to call when a pad is pressed
  100169. * @param callback defines the callback to use
  100170. */
  100171. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  100172. /**
  100173. * Defines the callback to call when a pad is released
  100174. * @param callback defines the callback to use
  100175. */
  100176. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  100177. private _setButtonValue;
  100178. private _setDPadValue;
  100179. /**
  100180. * Gets the value of the `A` button
  100181. */
  100182. /**
  100183. * Sets the value of the `A` button
  100184. */
  100185. buttonA: number;
  100186. /**
  100187. * Gets the value of the `B` button
  100188. */
  100189. /**
  100190. * Sets the value of the `B` button
  100191. */
  100192. buttonB: number;
  100193. /**
  100194. * Gets the value of the `X` button
  100195. */
  100196. /**
  100197. * Sets the value of the `X` button
  100198. */
  100199. buttonX: number;
  100200. /**
  100201. * Gets the value of the `Y` button
  100202. */
  100203. /**
  100204. * Sets the value of the `Y` button
  100205. */
  100206. buttonY: number;
  100207. /**
  100208. * Gets the value of the `Start` button
  100209. */
  100210. /**
  100211. * Sets the value of the `Start` button
  100212. */
  100213. buttonStart: number;
  100214. /**
  100215. * Gets the value of the `Back` button
  100216. */
  100217. /**
  100218. * Sets the value of the `Back` button
  100219. */
  100220. buttonBack: number;
  100221. /**
  100222. * Gets the value of the `Left` button
  100223. */
  100224. /**
  100225. * Sets the value of the `Left` button
  100226. */
  100227. buttonLB: number;
  100228. /**
  100229. * Gets the value of the `Right` button
  100230. */
  100231. /**
  100232. * Sets the value of the `Right` button
  100233. */
  100234. buttonRB: number;
  100235. /**
  100236. * Gets the value of the Left joystick
  100237. */
  100238. /**
  100239. * Sets the value of the Left joystick
  100240. */
  100241. buttonLeftStick: number;
  100242. /**
  100243. * Gets the value of the Right joystick
  100244. */
  100245. /**
  100246. * Sets the value of the Right joystick
  100247. */
  100248. buttonRightStick: number;
  100249. /**
  100250. * Gets the value of D-pad up
  100251. */
  100252. /**
  100253. * Sets the value of D-pad up
  100254. */
  100255. dPadUp: number;
  100256. /**
  100257. * Gets the value of D-pad down
  100258. */
  100259. /**
  100260. * Sets the value of D-pad down
  100261. */
  100262. dPadDown: number;
  100263. /**
  100264. * Gets the value of D-pad left
  100265. */
  100266. /**
  100267. * Sets the value of D-pad left
  100268. */
  100269. dPadLeft: number;
  100270. /**
  100271. * Gets the value of D-pad right
  100272. */
  100273. /**
  100274. * Sets the value of D-pad right
  100275. */
  100276. dPadRight: number;
  100277. /**
  100278. * Force the gamepad to synchronize with device values
  100279. */
  100280. update(): void;
  100281. /**
  100282. * Disposes the gamepad
  100283. */
  100284. dispose(): void;
  100285. }
  100286. }
  100287. declare module BABYLON {
  100288. /**
  100289. * Manager for handling gamepads
  100290. */
  100291. export class GamepadManager {
  100292. private _scene?;
  100293. private _babylonGamepads;
  100294. private _oneGamepadConnected;
  100295. /** @hidden */
  100296. _isMonitoring: boolean;
  100297. private _gamepadEventSupported;
  100298. private _gamepadSupport;
  100299. /**
  100300. * observable to be triggered when the gamepad controller has been connected
  100301. */
  100302. onGamepadConnectedObservable: Observable<Gamepad>;
  100303. /**
  100304. * observable to be triggered when the gamepad controller has been disconnected
  100305. */
  100306. onGamepadDisconnectedObservable: Observable<Gamepad>;
  100307. private _onGamepadConnectedEvent;
  100308. private _onGamepadDisconnectedEvent;
  100309. /**
  100310. * Initializes the gamepad manager
  100311. * @param _scene BabylonJS scene
  100312. */
  100313. constructor(_scene?: Scene | undefined);
  100314. /**
  100315. * The gamepads in the game pad manager
  100316. */
  100317. readonly gamepads: Gamepad[];
  100318. /**
  100319. * Get the gamepad controllers based on type
  100320. * @param type The type of gamepad controller
  100321. * @returns Nullable gamepad
  100322. */
  100323. getGamepadByType(type?: number): Nullable<Gamepad>;
  100324. /**
  100325. * Disposes the gamepad manager
  100326. */
  100327. dispose(): void;
  100328. private _addNewGamepad;
  100329. private _startMonitoringGamepads;
  100330. private _stopMonitoringGamepads;
  100331. /** @hidden */
  100332. _checkGamepadsStatus(): void;
  100333. private _updateGamepadObjects;
  100334. }
  100335. }
  100336. declare module BABYLON {
  100337. interface Scene {
  100338. /** @hidden */
  100339. _gamepadManager: Nullable<GamepadManager>;
  100340. /**
  100341. * Gets the gamepad manager associated with the scene
  100342. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  100343. */
  100344. gamepadManager: GamepadManager;
  100345. }
  100346. /**
  100347. * Interface representing a free camera inputs manager
  100348. */
  100349. interface FreeCameraInputsManager {
  100350. /**
  100351. * Adds gamepad input support to the FreeCameraInputsManager.
  100352. * @returns the FreeCameraInputsManager
  100353. */
  100354. addGamepad(): FreeCameraInputsManager;
  100355. }
  100356. /**
  100357. * Interface representing an arc rotate camera inputs manager
  100358. */
  100359. interface ArcRotateCameraInputsManager {
  100360. /**
  100361. * Adds gamepad input support to the ArcRotateCamera InputManager.
  100362. * @returns the camera inputs manager
  100363. */
  100364. addGamepad(): ArcRotateCameraInputsManager;
  100365. }
  100366. /**
  100367. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  100368. */
  100369. export class GamepadSystemSceneComponent implements ISceneComponent {
  100370. /**
  100371. * The component name helpfull to identify the component in the list of scene components.
  100372. */
  100373. readonly name: string;
  100374. /**
  100375. * The scene the component belongs to.
  100376. */
  100377. scene: Scene;
  100378. /**
  100379. * Creates a new instance of the component for the given scene
  100380. * @param scene Defines the scene to register the component in
  100381. */
  100382. constructor(scene: Scene);
  100383. /**
  100384. * Registers the component in a given scene
  100385. */
  100386. register(): void;
  100387. /**
  100388. * Rebuilds the elements related to this component in case of
  100389. * context lost for instance.
  100390. */
  100391. rebuild(): void;
  100392. /**
  100393. * Disposes the component and the associated ressources
  100394. */
  100395. dispose(): void;
  100396. private _beforeCameraUpdate;
  100397. }
  100398. }
  100399. declare module BABYLON {
  100400. /**
  100401. * 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,
  100402. * which still works and will still be found in many Playgrounds.
  100403. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100404. */
  100405. export class UniversalCamera extends TouchCamera {
  100406. /**
  100407. * Defines the gamepad rotation sensiblity.
  100408. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100409. */
  100410. gamepadAngularSensibility: number;
  100411. /**
  100412. * Defines the gamepad move sensiblity.
  100413. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100414. */
  100415. gamepadMoveSensibility: number;
  100416. /**
  100417. * 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,
  100418. * which still works and will still be found in many Playgrounds.
  100419. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100420. * @param name Define the name of the camera in the scene
  100421. * @param position Define the start position of the camera in the scene
  100422. * @param scene Define the scene the camera belongs to
  100423. */
  100424. constructor(name: string, position: Vector3, scene: Scene);
  100425. /**
  100426. * Gets the current object class name.
  100427. * @return the class name
  100428. */
  100429. getClassName(): string;
  100430. }
  100431. }
  100432. declare module BABYLON {
  100433. /**
  100434. * This represents a FPS type of camera. This is only here for back compat purpose.
  100435. * Please use the UniversalCamera instead as both are identical.
  100436. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100437. */
  100438. export class GamepadCamera extends UniversalCamera {
  100439. /**
  100440. * Instantiates a new Gamepad Camera
  100441. * This represents a FPS type of camera. This is only here for back compat purpose.
  100442. * Please use the UniversalCamera instead as both are identical.
  100443. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100444. * @param name Define the name of the camera in the scene
  100445. * @param position Define the start position of the camera in the scene
  100446. * @param scene Define the scene the camera belongs to
  100447. */
  100448. constructor(name: string, position: Vector3, scene: Scene);
  100449. /**
  100450. * Gets the current object class name.
  100451. * @return the class name
  100452. */
  100453. getClassName(): string;
  100454. }
  100455. }
  100456. declare module BABYLON {
  100457. /** @hidden */
  100458. export var passPixelShader: {
  100459. name: string;
  100460. shader: string;
  100461. };
  100462. }
  100463. declare module BABYLON {
  100464. /** @hidden */
  100465. export var passCubePixelShader: {
  100466. name: string;
  100467. shader: string;
  100468. };
  100469. }
  100470. declare module BABYLON {
  100471. /**
  100472. * PassPostProcess which produces an output the same as it's input
  100473. */
  100474. export class PassPostProcess extends PostProcess {
  100475. /**
  100476. * Creates the PassPostProcess
  100477. * @param name The name of the effect.
  100478. * @param options The required width/height ratio to downsize to before computing the render pass.
  100479. * @param camera The camera to apply the render pass to.
  100480. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100481. * @param engine The engine which the post process will be applied. (default: current engine)
  100482. * @param reusable If the post process can be reused on the same frame. (default: false)
  100483. * @param textureType The type of texture to be used when performing the post processing.
  100484. * @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)
  100485. */
  100486. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100487. }
  100488. /**
  100489. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  100490. */
  100491. export class PassCubePostProcess extends PostProcess {
  100492. private _face;
  100493. /**
  100494. * Gets or sets the cube face to display.
  100495. * * 0 is +X
  100496. * * 1 is -X
  100497. * * 2 is +Y
  100498. * * 3 is -Y
  100499. * * 4 is +Z
  100500. * * 5 is -Z
  100501. */
  100502. face: number;
  100503. /**
  100504. * Creates the PassCubePostProcess
  100505. * @param name The name of the effect.
  100506. * @param options The required width/height ratio to downsize to before computing the render pass.
  100507. * @param camera The camera to apply the render pass to.
  100508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100509. * @param engine The engine which the post process will be applied. (default: current engine)
  100510. * @param reusable If the post process can be reused on the same frame. (default: false)
  100511. * @param textureType The type of texture to be used when performing the post processing.
  100512. * @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)
  100513. */
  100514. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100515. }
  100516. }
  100517. declare module BABYLON {
  100518. /** @hidden */
  100519. export var anaglyphPixelShader: {
  100520. name: string;
  100521. shader: string;
  100522. };
  100523. }
  100524. declare module BABYLON {
  100525. /**
  100526. * Postprocess used to generate anaglyphic rendering
  100527. */
  100528. export class AnaglyphPostProcess extends PostProcess {
  100529. private _passedProcess;
  100530. /**
  100531. * Creates a new AnaglyphPostProcess
  100532. * @param name defines postprocess name
  100533. * @param options defines creation options or target ratio scale
  100534. * @param rigCameras defines cameras using this postprocess
  100535. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  100536. * @param engine defines hosting engine
  100537. * @param reusable defines if the postprocess will be reused multiple times per frame
  100538. */
  100539. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  100540. }
  100541. }
  100542. declare module BABYLON {
  100543. /**
  100544. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  100545. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100546. */
  100547. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  100548. /**
  100549. * Creates a new AnaglyphArcRotateCamera
  100550. * @param name defines camera name
  100551. * @param alpha defines alpha angle (in radians)
  100552. * @param beta defines beta angle (in radians)
  100553. * @param radius defines radius
  100554. * @param target defines camera target
  100555. * @param interaxialDistance defines distance between each color axis
  100556. * @param scene defines the hosting scene
  100557. */
  100558. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  100559. /**
  100560. * Gets camera class name
  100561. * @returns AnaglyphArcRotateCamera
  100562. */
  100563. getClassName(): string;
  100564. }
  100565. }
  100566. declare module BABYLON {
  100567. /**
  100568. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  100569. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100570. */
  100571. export class AnaglyphFreeCamera extends FreeCamera {
  100572. /**
  100573. * Creates a new AnaglyphFreeCamera
  100574. * @param name defines camera name
  100575. * @param position defines initial position
  100576. * @param interaxialDistance defines distance between each color axis
  100577. * @param scene defines the hosting scene
  100578. */
  100579. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100580. /**
  100581. * Gets camera class name
  100582. * @returns AnaglyphFreeCamera
  100583. */
  100584. getClassName(): string;
  100585. }
  100586. }
  100587. declare module BABYLON {
  100588. /**
  100589. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  100590. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100591. */
  100592. export class AnaglyphGamepadCamera extends GamepadCamera {
  100593. /**
  100594. * Creates a new AnaglyphGamepadCamera
  100595. * @param name defines camera name
  100596. * @param position defines initial position
  100597. * @param interaxialDistance defines distance between each color axis
  100598. * @param scene defines the hosting scene
  100599. */
  100600. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100601. /**
  100602. * Gets camera class name
  100603. * @returns AnaglyphGamepadCamera
  100604. */
  100605. getClassName(): string;
  100606. }
  100607. }
  100608. declare module BABYLON {
  100609. /**
  100610. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  100611. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100612. */
  100613. export class AnaglyphUniversalCamera extends UniversalCamera {
  100614. /**
  100615. * Creates a new AnaglyphUniversalCamera
  100616. * @param name defines camera name
  100617. * @param position defines initial position
  100618. * @param interaxialDistance defines distance between each color axis
  100619. * @param scene defines the hosting scene
  100620. */
  100621. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100622. /**
  100623. * Gets camera class name
  100624. * @returns AnaglyphUniversalCamera
  100625. */
  100626. getClassName(): string;
  100627. }
  100628. }
  100629. declare module BABYLON {
  100630. /** @hidden */
  100631. export var stereoscopicInterlacePixelShader: {
  100632. name: string;
  100633. shader: string;
  100634. };
  100635. }
  100636. declare module BABYLON {
  100637. /**
  100638. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  100639. */
  100640. export class StereoscopicInterlacePostProcess extends PostProcess {
  100641. private _stepSize;
  100642. private _passedProcess;
  100643. /**
  100644. * Initializes a StereoscopicInterlacePostProcess
  100645. * @param name The name of the effect.
  100646. * @param rigCameras The rig cameras to be appled to the post process
  100647. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  100648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100649. * @param engine The engine which the post process will be applied. (default: current engine)
  100650. * @param reusable If the post process can be reused on the same frame. (default: false)
  100651. */
  100652. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  100653. }
  100654. }
  100655. declare module BABYLON {
  100656. /**
  100657. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  100658. * @see http://doc.babylonjs.com/features/cameras
  100659. */
  100660. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  100661. /**
  100662. * Creates a new StereoscopicArcRotateCamera
  100663. * @param name defines camera name
  100664. * @param alpha defines alpha angle (in radians)
  100665. * @param beta defines beta angle (in radians)
  100666. * @param radius defines radius
  100667. * @param target defines camera target
  100668. * @param interaxialDistance defines distance between each color axis
  100669. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100670. * @param scene defines the hosting scene
  100671. */
  100672. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100673. /**
  100674. * Gets camera class name
  100675. * @returns StereoscopicArcRotateCamera
  100676. */
  100677. getClassName(): string;
  100678. }
  100679. }
  100680. declare module BABYLON {
  100681. /**
  100682. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  100683. * @see http://doc.babylonjs.com/features/cameras
  100684. */
  100685. export class StereoscopicFreeCamera extends FreeCamera {
  100686. /**
  100687. * Creates a new StereoscopicFreeCamera
  100688. * @param name defines camera name
  100689. * @param position defines initial position
  100690. * @param interaxialDistance defines distance between each color axis
  100691. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100692. * @param scene defines the hosting scene
  100693. */
  100694. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100695. /**
  100696. * Gets camera class name
  100697. * @returns StereoscopicFreeCamera
  100698. */
  100699. getClassName(): string;
  100700. }
  100701. }
  100702. declare module BABYLON {
  100703. /**
  100704. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  100705. * @see http://doc.babylonjs.com/features/cameras
  100706. */
  100707. export class StereoscopicGamepadCamera extends GamepadCamera {
  100708. /**
  100709. * Creates a new StereoscopicGamepadCamera
  100710. * @param name defines camera name
  100711. * @param position defines initial position
  100712. * @param interaxialDistance defines distance between each color axis
  100713. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100714. * @param scene defines the hosting scene
  100715. */
  100716. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100717. /**
  100718. * Gets camera class name
  100719. * @returns StereoscopicGamepadCamera
  100720. */
  100721. getClassName(): string;
  100722. }
  100723. }
  100724. declare module BABYLON {
  100725. /**
  100726. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  100727. * @see http://doc.babylonjs.com/features/cameras
  100728. */
  100729. export class StereoscopicUniversalCamera extends UniversalCamera {
  100730. /**
  100731. * Creates a new StereoscopicUniversalCamera
  100732. * @param name defines camera name
  100733. * @param position defines initial position
  100734. * @param interaxialDistance defines distance between each color axis
  100735. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100736. * @param scene defines the hosting scene
  100737. */
  100738. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100739. /**
  100740. * Gets camera class name
  100741. * @returns StereoscopicUniversalCamera
  100742. */
  100743. getClassName(): string;
  100744. }
  100745. }
  100746. declare module BABYLON {
  100747. /**
  100748. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  100749. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  100750. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  100751. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  100752. */
  100753. export class VirtualJoysticksCamera extends FreeCamera {
  100754. /**
  100755. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  100756. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  100757. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  100758. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  100759. * @param name Define the name of the camera in the scene
  100760. * @param position Define the start position of the camera in the scene
  100761. * @param scene Define the scene the camera belongs to
  100762. */
  100763. constructor(name: string, position: Vector3, scene: Scene);
  100764. /**
  100765. * Gets the current object class name.
  100766. * @return the class name
  100767. */
  100768. getClassName(): string;
  100769. }
  100770. }
  100771. declare module BABYLON {
  100772. /**
  100773. * This represents all the required metrics to create a VR camera.
  100774. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  100775. */
  100776. export class VRCameraMetrics {
  100777. /**
  100778. * Define the horizontal resolution off the screen.
  100779. */
  100780. hResolution: number;
  100781. /**
  100782. * Define the vertical resolution off the screen.
  100783. */
  100784. vResolution: number;
  100785. /**
  100786. * Define the horizontal screen size.
  100787. */
  100788. hScreenSize: number;
  100789. /**
  100790. * Define the vertical screen size.
  100791. */
  100792. vScreenSize: number;
  100793. /**
  100794. * Define the vertical screen center position.
  100795. */
  100796. vScreenCenter: number;
  100797. /**
  100798. * Define the distance of the eyes to the screen.
  100799. */
  100800. eyeToScreenDistance: number;
  100801. /**
  100802. * Define the distance between both lenses
  100803. */
  100804. lensSeparationDistance: number;
  100805. /**
  100806. * Define the distance between both viewer's eyes.
  100807. */
  100808. interpupillaryDistance: number;
  100809. /**
  100810. * Define the distortion factor of the VR postprocess.
  100811. * Please, touch with care.
  100812. */
  100813. distortionK: number[];
  100814. /**
  100815. * Define the chromatic aberration correction factors for the VR post process.
  100816. */
  100817. chromaAbCorrection: number[];
  100818. /**
  100819. * Define the scale factor of the post process.
  100820. * The smaller the better but the slower.
  100821. */
  100822. postProcessScaleFactor: number;
  100823. /**
  100824. * Define an offset for the lens center.
  100825. */
  100826. lensCenterOffset: number;
  100827. /**
  100828. * Define if the current vr camera should compensate the distortion of the lense or not.
  100829. */
  100830. compensateDistortion: boolean;
  100831. /**
  100832. * Defines if multiview should be enabled when rendering (Default: false)
  100833. */
  100834. multiviewEnabled: boolean;
  100835. /**
  100836. * Gets the rendering aspect ratio based on the provided resolutions.
  100837. */
  100838. readonly aspectRatio: number;
  100839. /**
  100840. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  100841. */
  100842. readonly aspectRatioFov: number;
  100843. /**
  100844. * @hidden
  100845. */
  100846. readonly leftHMatrix: Matrix;
  100847. /**
  100848. * @hidden
  100849. */
  100850. readonly rightHMatrix: Matrix;
  100851. /**
  100852. * @hidden
  100853. */
  100854. readonly leftPreViewMatrix: Matrix;
  100855. /**
  100856. * @hidden
  100857. */
  100858. readonly rightPreViewMatrix: Matrix;
  100859. /**
  100860. * Get the default VRMetrics based on the most generic setup.
  100861. * @returns the default vr metrics
  100862. */
  100863. static GetDefault(): VRCameraMetrics;
  100864. }
  100865. }
  100866. declare module BABYLON {
  100867. /** @hidden */
  100868. export var vrDistortionCorrectionPixelShader: {
  100869. name: string;
  100870. shader: string;
  100871. };
  100872. }
  100873. declare module BABYLON {
  100874. /**
  100875. * VRDistortionCorrectionPostProcess used for mobile VR
  100876. */
  100877. export class VRDistortionCorrectionPostProcess extends PostProcess {
  100878. private _isRightEye;
  100879. private _distortionFactors;
  100880. private _postProcessScaleFactor;
  100881. private _lensCenterOffset;
  100882. private _scaleIn;
  100883. private _scaleFactor;
  100884. private _lensCenter;
  100885. /**
  100886. * Initializes the VRDistortionCorrectionPostProcess
  100887. * @param name The name of the effect.
  100888. * @param camera The camera to apply the render pass to.
  100889. * @param isRightEye If this is for the right eye distortion
  100890. * @param vrMetrics All the required metrics for the VR camera
  100891. */
  100892. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  100893. }
  100894. }
  100895. declare module BABYLON {
  100896. /**
  100897. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  100898. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  100899. */
  100900. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  100901. /**
  100902. * Creates a new VRDeviceOrientationArcRotateCamera
  100903. * @param name defines camera name
  100904. * @param alpha defines the camera rotation along the logitudinal axis
  100905. * @param beta defines the camera rotation along the latitudinal axis
  100906. * @param radius defines the camera distance from its target
  100907. * @param target defines the camera target
  100908. * @param scene defines the scene the camera belongs to
  100909. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  100910. * @param vrCameraMetrics defines the vr metrics associated to the camera
  100911. */
  100912. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  100913. /**
  100914. * Gets camera class name
  100915. * @returns VRDeviceOrientationArcRotateCamera
  100916. */
  100917. getClassName(): string;
  100918. }
  100919. }
  100920. declare module BABYLON {
  100921. /**
  100922. * Camera used to simulate VR rendering (based on FreeCamera)
  100923. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  100924. */
  100925. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  100926. /**
  100927. * Creates a new VRDeviceOrientationFreeCamera
  100928. * @param name defines camera name
  100929. * @param position defines the start position of the camera
  100930. * @param scene defines the scene the camera belongs to
  100931. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  100932. * @param vrCameraMetrics defines the vr metrics associated to the camera
  100933. */
  100934. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  100935. /**
  100936. * Gets camera class name
  100937. * @returns VRDeviceOrientationFreeCamera
  100938. */
  100939. getClassName(): string;
  100940. }
  100941. }
  100942. declare module BABYLON {
  100943. /**
  100944. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  100945. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  100946. */
  100947. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  100948. /**
  100949. * Creates a new VRDeviceOrientationGamepadCamera
  100950. * @param name defines camera name
  100951. * @param position defines the start position of the camera
  100952. * @param scene defines the scene the camera belongs to
  100953. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  100954. * @param vrCameraMetrics defines the vr metrics associated to the camera
  100955. */
  100956. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  100957. /**
  100958. * Gets camera class name
  100959. * @returns VRDeviceOrientationGamepadCamera
  100960. */
  100961. getClassName(): string;
  100962. }
  100963. }
  100964. declare module BABYLON {
  100965. /**
  100966. * Base class of materials working in push mode in babylon JS
  100967. * @hidden
  100968. */
  100969. export class PushMaterial extends Material {
  100970. protected _activeEffect: Effect;
  100971. protected _normalMatrix: Matrix;
  100972. /**
  100973. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  100974. * This means that the material can keep using a previous shader while a new one is being compiled.
  100975. * This is mostly used when shader parallel compilation is supported (true by default)
  100976. */
  100977. allowShaderHotSwapping: boolean;
  100978. constructor(name: string, scene: Scene);
  100979. getEffect(): Effect;
  100980. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100981. /**
  100982. * Binds the given world matrix to the active effect
  100983. *
  100984. * @param world the matrix to bind
  100985. */
  100986. bindOnlyWorldMatrix(world: Matrix): void;
  100987. /**
  100988. * Binds the given normal matrix to the active effect
  100989. *
  100990. * @param normalMatrix the matrix to bind
  100991. */
  100992. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100993. bind(world: Matrix, mesh?: Mesh): void;
  100994. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100995. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100996. }
  100997. }
  100998. declare module BABYLON {
  100999. /**
  101000. * This groups all the flags used to control the materials channel.
  101001. */
  101002. export class MaterialFlags {
  101003. private static _DiffuseTextureEnabled;
  101004. /**
  101005. * Are diffuse textures enabled in the application.
  101006. */
  101007. static DiffuseTextureEnabled: boolean;
  101008. private static _AmbientTextureEnabled;
  101009. /**
  101010. * Are ambient textures enabled in the application.
  101011. */
  101012. static AmbientTextureEnabled: boolean;
  101013. private static _OpacityTextureEnabled;
  101014. /**
  101015. * Are opacity textures enabled in the application.
  101016. */
  101017. static OpacityTextureEnabled: boolean;
  101018. private static _ReflectionTextureEnabled;
  101019. /**
  101020. * Are reflection textures enabled in the application.
  101021. */
  101022. static ReflectionTextureEnabled: boolean;
  101023. private static _EmissiveTextureEnabled;
  101024. /**
  101025. * Are emissive textures enabled in the application.
  101026. */
  101027. static EmissiveTextureEnabled: boolean;
  101028. private static _SpecularTextureEnabled;
  101029. /**
  101030. * Are specular textures enabled in the application.
  101031. */
  101032. static SpecularTextureEnabled: boolean;
  101033. private static _BumpTextureEnabled;
  101034. /**
  101035. * Are bump textures enabled in the application.
  101036. */
  101037. static BumpTextureEnabled: boolean;
  101038. private static _LightmapTextureEnabled;
  101039. /**
  101040. * Are lightmap textures enabled in the application.
  101041. */
  101042. static LightmapTextureEnabled: boolean;
  101043. private static _RefractionTextureEnabled;
  101044. /**
  101045. * Are refraction textures enabled in the application.
  101046. */
  101047. static RefractionTextureEnabled: boolean;
  101048. private static _ColorGradingTextureEnabled;
  101049. /**
  101050. * Are color grading textures enabled in the application.
  101051. */
  101052. static ColorGradingTextureEnabled: boolean;
  101053. private static _FresnelEnabled;
  101054. /**
  101055. * Are fresnels enabled in the application.
  101056. */
  101057. static FresnelEnabled: boolean;
  101058. private static _ClearCoatTextureEnabled;
  101059. /**
  101060. * Are clear coat textures enabled in the application.
  101061. */
  101062. static ClearCoatTextureEnabled: boolean;
  101063. private static _ClearCoatBumpTextureEnabled;
  101064. /**
  101065. * Are clear coat bump textures enabled in the application.
  101066. */
  101067. static ClearCoatBumpTextureEnabled: boolean;
  101068. private static _ClearCoatTintTextureEnabled;
  101069. /**
  101070. * Are clear coat tint textures enabled in the application.
  101071. */
  101072. static ClearCoatTintTextureEnabled: boolean;
  101073. private static _SheenTextureEnabled;
  101074. /**
  101075. * Are sheen textures enabled in the application.
  101076. */
  101077. static SheenTextureEnabled: boolean;
  101078. private static _AnisotropicTextureEnabled;
  101079. /**
  101080. * Are anisotropic textures enabled in the application.
  101081. */
  101082. static AnisotropicTextureEnabled: boolean;
  101083. private static _ThicknessTextureEnabled;
  101084. /**
  101085. * Are thickness textures enabled in the application.
  101086. */
  101087. static ThicknessTextureEnabled: boolean;
  101088. }
  101089. }
  101090. declare module BABYLON {
  101091. /** @hidden */
  101092. export var defaultFragmentDeclaration: {
  101093. name: string;
  101094. shader: string;
  101095. };
  101096. }
  101097. declare module BABYLON {
  101098. /** @hidden */
  101099. export var defaultUboDeclaration: {
  101100. name: string;
  101101. shader: string;
  101102. };
  101103. }
  101104. declare module BABYLON {
  101105. /** @hidden */
  101106. export var lightFragmentDeclaration: {
  101107. name: string;
  101108. shader: string;
  101109. };
  101110. }
  101111. declare module BABYLON {
  101112. /** @hidden */
  101113. export var lightUboDeclaration: {
  101114. name: string;
  101115. shader: string;
  101116. };
  101117. }
  101118. declare module BABYLON {
  101119. /** @hidden */
  101120. export var lightsFragmentFunctions: {
  101121. name: string;
  101122. shader: string;
  101123. };
  101124. }
  101125. declare module BABYLON {
  101126. /** @hidden */
  101127. export var shadowsFragmentFunctions: {
  101128. name: string;
  101129. shader: string;
  101130. };
  101131. }
  101132. declare module BABYLON {
  101133. /** @hidden */
  101134. export var fresnelFunction: {
  101135. name: string;
  101136. shader: string;
  101137. };
  101138. }
  101139. declare module BABYLON {
  101140. /** @hidden */
  101141. export var reflectionFunction: {
  101142. name: string;
  101143. shader: string;
  101144. };
  101145. }
  101146. declare module BABYLON {
  101147. /** @hidden */
  101148. export var bumpFragmentFunctions: {
  101149. name: string;
  101150. shader: string;
  101151. };
  101152. }
  101153. declare module BABYLON {
  101154. /** @hidden */
  101155. export var logDepthDeclaration: {
  101156. name: string;
  101157. shader: string;
  101158. };
  101159. }
  101160. declare module BABYLON {
  101161. /** @hidden */
  101162. export var bumpFragment: {
  101163. name: string;
  101164. shader: string;
  101165. };
  101166. }
  101167. declare module BABYLON {
  101168. /** @hidden */
  101169. export var depthPrePass: {
  101170. name: string;
  101171. shader: string;
  101172. };
  101173. }
  101174. declare module BABYLON {
  101175. /** @hidden */
  101176. export var lightFragment: {
  101177. name: string;
  101178. shader: string;
  101179. };
  101180. }
  101181. declare module BABYLON {
  101182. /** @hidden */
  101183. export var logDepthFragment: {
  101184. name: string;
  101185. shader: string;
  101186. };
  101187. }
  101188. declare module BABYLON {
  101189. /** @hidden */
  101190. export var defaultPixelShader: {
  101191. name: string;
  101192. shader: string;
  101193. };
  101194. }
  101195. declare module BABYLON {
  101196. /** @hidden */
  101197. export var defaultVertexDeclaration: {
  101198. name: string;
  101199. shader: string;
  101200. };
  101201. }
  101202. declare module BABYLON {
  101203. /** @hidden */
  101204. export var bumpVertexDeclaration: {
  101205. name: string;
  101206. shader: string;
  101207. };
  101208. }
  101209. declare module BABYLON {
  101210. /** @hidden */
  101211. export var bumpVertex: {
  101212. name: string;
  101213. shader: string;
  101214. };
  101215. }
  101216. declare module BABYLON {
  101217. /** @hidden */
  101218. export var fogVertex: {
  101219. name: string;
  101220. shader: string;
  101221. };
  101222. }
  101223. declare module BABYLON {
  101224. /** @hidden */
  101225. export var shadowsVertex: {
  101226. name: string;
  101227. shader: string;
  101228. };
  101229. }
  101230. declare module BABYLON {
  101231. /** @hidden */
  101232. export var pointCloudVertex: {
  101233. name: string;
  101234. shader: string;
  101235. };
  101236. }
  101237. declare module BABYLON {
  101238. /** @hidden */
  101239. export var logDepthVertex: {
  101240. name: string;
  101241. shader: string;
  101242. };
  101243. }
  101244. declare module BABYLON {
  101245. /** @hidden */
  101246. export var defaultVertexShader: {
  101247. name: string;
  101248. shader: string;
  101249. };
  101250. }
  101251. declare module BABYLON {
  101252. /** @hidden */
  101253. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101254. MAINUV1: boolean;
  101255. MAINUV2: boolean;
  101256. DIFFUSE: boolean;
  101257. DIFFUSEDIRECTUV: number;
  101258. AMBIENT: boolean;
  101259. AMBIENTDIRECTUV: number;
  101260. OPACITY: boolean;
  101261. OPACITYDIRECTUV: number;
  101262. OPACITYRGB: boolean;
  101263. REFLECTION: boolean;
  101264. EMISSIVE: boolean;
  101265. EMISSIVEDIRECTUV: number;
  101266. SPECULAR: boolean;
  101267. SPECULARDIRECTUV: number;
  101268. BUMP: boolean;
  101269. BUMPDIRECTUV: number;
  101270. PARALLAX: boolean;
  101271. PARALLAXOCCLUSION: boolean;
  101272. SPECULAROVERALPHA: boolean;
  101273. CLIPPLANE: boolean;
  101274. CLIPPLANE2: boolean;
  101275. CLIPPLANE3: boolean;
  101276. CLIPPLANE4: boolean;
  101277. ALPHATEST: boolean;
  101278. DEPTHPREPASS: boolean;
  101279. ALPHAFROMDIFFUSE: boolean;
  101280. POINTSIZE: boolean;
  101281. FOG: boolean;
  101282. SPECULARTERM: boolean;
  101283. DIFFUSEFRESNEL: boolean;
  101284. OPACITYFRESNEL: boolean;
  101285. REFLECTIONFRESNEL: boolean;
  101286. REFRACTIONFRESNEL: boolean;
  101287. EMISSIVEFRESNEL: boolean;
  101288. FRESNEL: boolean;
  101289. NORMAL: boolean;
  101290. UV1: boolean;
  101291. UV2: boolean;
  101292. VERTEXCOLOR: boolean;
  101293. VERTEXALPHA: boolean;
  101294. NUM_BONE_INFLUENCERS: number;
  101295. BonesPerMesh: number;
  101296. BONETEXTURE: boolean;
  101297. INSTANCES: boolean;
  101298. GLOSSINESS: boolean;
  101299. ROUGHNESS: boolean;
  101300. EMISSIVEASILLUMINATION: boolean;
  101301. LINKEMISSIVEWITHDIFFUSE: boolean;
  101302. REFLECTIONFRESNELFROMSPECULAR: boolean;
  101303. LIGHTMAP: boolean;
  101304. LIGHTMAPDIRECTUV: number;
  101305. OBJECTSPACE_NORMALMAP: boolean;
  101306. USELIGHTMAPASSHADOWMAP: boolean;
  101307. REFLECTIONMAP_3D: boolean;
  101308. REFLECTIONMAP_SPHERICAL: boolean;
  101309. REFLECTIONMAP_PLANAR: boolean;
  101310. REFLECTIONMAP_CUBIC: boolean;
  101311. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  101312. REFLECTIONMAP_PROJECTION: boolean;
  101313. REFLECTIONMAP_SKYBOX: boolean;
  101314. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  101315. REFLECTIONMAP_EXPLICIT: boolean;
  101316. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  101317. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  101318. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  101319. INVERTCUBICMAP: boolean;
  101320. LOGARITHMICDEPTH: boolean;
  101321. REFRACTION: boolean;
  101322. REFRACTIONMAP_3D: boolean;
  101323. REFLECTIONOVERALPHA: boolean;
  101324. TWOSIDEDLIGHTING: boolean;
  101325. SHADOWFLOAT: boolean;
  101326. MORPHTARGETS: boolean;
  101327. MORPHTARGETS_NORMAL: boolean;
  101328. MORPHTARGETS_TANGENT: boolean;
  101329. NUM_MORPH_INFLUENCERS: number;
  101330. NONUNIFORMSCALING: boolean;
  101331. PREMULTIPLYALPHA: boolean;
  101332. IMAGEPROCESSING: boolean;
  101333. VIGNETTE: boolean;
  101334. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101335. VIGNETTEBLENDMODEOPAQUE: boolean;
  101336. TONEMAPPING: boolean;
  101337. TONEMAPPING_ACES: boolean;
  101338. CONTRAST: boolean;
  101339. COLORCURVES: boolean;
  101340. COLORGRADING: boolean;
  101341. COLORGRADING3D: boolean;
  101342. SAMPLER3DGREENDEPTH: boolean;
  101343. SAMPLER3DBGRMAP: boolean;
  101344. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101345. MULTIVIEW: boolean;
  101346. /**
  101347. * If the reflection texture on this material is in linear color space
  101348. * @hidden
  101349. */
  101350. IS_REFLECTION_LINEAR: boolean;
  101351. /**
  101352. * If the refraction texture on this material is in linear color space
  101353. * @hidden
  101354. */
  101355. IS_REFRACTION_LINEAR: boolean;
  101356. EXPOSURE: boolean;
  101357. constructor();
  101358. setReflectionMode(modeToEnable: string): void;
  101359. }
  101360. /**
  101361. * This is the default material used in Babylon. It is the best trade off between quality
  101362. * and performances.
  101363. * @see http://doc.babylonjs.com/babylon101/materials
  101364. */
  101365. export class StandardMaterial extends PushMaterial {
  101366. private _diffuseTexture;
  101367. /**
  101368. * The basic texture of the material as viewed under a light.
  101369. */
  101370. diffuseTexture: Nullable<BaseTexture>;
  101371. private _ambientTexture;
  101372. /**
  101373. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  101374. */
  101375. ambientTexture: Nullable<BaseTexture>;
  101376. private _opacityTexture;
  101377. /**
  101378. * Define the transparency of the material from a texture.
  101379. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  101380. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  101381. */
  101382. opacityTexture: Nullable<BaseTexture>;
  101383. private _reflectionTexture;
  101384. /**
  101385. * Define the texture used to display the reflection.
  101386. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101387. */
  101388. reflectionTexture: Nullable<BaseTexture>;
  101389. private _emissiveTexture;
  101390. /**
  101391. * Define texture of the material as if self lit.
  101392. * This will be mixed in the final result even in the absence of light.
  101393. */
  101394. emissiveTexture: Nullable<BaseTexture>;
  101395. private _specularTexture;
  101396. /**
  101397. * Define how the color and intensity of the highlight given by the light in the material.
  101398. */
  101399. specularTexture: Nullable<BaseTexture>;
  101400. private _bumpTexture;
  101401. /**
  101402. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  101403. * 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.
  101404. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  101405. */
  101406. bumpTexture: Nullable<BaseTexture>;
  101407. private _lightmapTexture;
  101408. /**
  101409. * Complex lighting can be computationally expensive to compute at runtime.
  101410. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  101411. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  101412. */
  101413. lightmapTexture: Nullable<BaseTexture>;
  101414. private _refractionTexture;
  101415. /**
  101416. * Define the texture used to display the refraction.
  101417. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101418. */
  101419. refractionTexture: Nullable<BaseTexture>;
  101420. /**
  101421. * The color of the material lit by the environmental background lighting.
  101422. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  101423. */
  101424. ambientColor: Color3;
  101425. /**
  101426. * The basic color of the material as viewed under a light.
  101427. */
  101428. diffuseColor: Color3;
  101429. /**
  101430. * Define how the color and intensity of the highlight given by the light in the material.
  101431. */
  101432. specularColor: Color3;
  101433. /**
  101434. * Define the color of the material as if self lit.
  101435. * This will be mixed in the final result even in the absence of light.
  101436. */
  101437. emissiveColor: Color3;
  101438. /**
  101439. * Defines how sharp are the highlights in the material.
  101440. * The bigger the value the sharper giving a more glossy feeling to the result.
  101441. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  101442. */
  101443. specularPower: number;
  101444. private _useAlphaFromDiffuseTexture;
  101445. /**
  101446. * Does the transparency come from the diffuse texture alpha channel.
  101447. */
  101448. useAlphaFromDiffuseTexture: boolean;
  101449. private _useEmissiveAsIllumination;
  101450. /**
  101451. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  101452. */
  101453. useEmissiveAsIllumination: boolean;
  101454. private _linkEmissiveWithDiffuse;
  101455. /**
  101456. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  101457. * the emissive level when the final color is close to one.
  101458. */
  101459. linkEmissiveWithDiffuse: boolean;
  101460. private _useSpecularOverAlpha;
  101461. /**
  101462. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101463. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101464. */
  101465. useSpecularOverAlpha: boolean;
  101466. private _useReflectionOverAlpha;
  101467. /**
  101468. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101469. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101470. */
  101471. useReflectionOverAlpha: boolean;
  101472. private _disableLighting;
  101473. /**
  101474. * Does lights from the scene impacts this material.
  101475. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  101476. */
  101477. disableLighting: boolean;
  101478. private _useObjectSpaceNormalMap;
  101479. /**
  101480. * Allows using an object space normal map (instead of tangent space).
  101481. */
  101482. useObjectSpaceNormalMap: boolean;
  101483. private _useParallax;
  101484. /**
  101485. * Is parallax enabled or not.
  101486. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101487. */
  101488. useParallax: boolean;
  101489. private _useParallaxOcclusion;
  101490. /**
  101491. * Is parallax occlusion enabled or not.
  101492. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  101493. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101494. */
  101495. useParallaxOcclusion: boolean;
  101496. /**
  101497. * 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.
  101498. */
  101499. parallaxScaleBias: number;
  101500. private _roughness;
  101501. /**
  101502. * Helps to define how blurry the reflections should appears in the material.
  101503. */
  101504. roughness: number;
  101505. /**
  101506. * In case of refraction, define the value of the indice of refraction.
  101507. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101508. */
  101509. indexOfRefraction: number;
  101510. /**
  101511. * Invert the refraction texture alongside the y axis.
  101512. * It can be useful with procedural textures or probe for instance.
  101513. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101514. */
  101515. invertRefractionY: boolean;
  101516. /**
  101517. * Defines the alpha limits in alpha test mode.
  101518. */
  101519. alphaCutOff: number;
  101520. private _useLightmapAsShadowmap;
  101521. /**
  101522. * In case of light mapping, define whether the map contains light or shadow informations.
  101523. */
  101524. useLightmapAsShadowmap: boolean;
  101525. private _diffuseFresnelParameters;
  101526. /**
  101527. * Define the diffuse fresnel parameters of the material.
  101528. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101529. */
  101530. diffuseFresnelParameters: FresnelParameters;
  101531. private _opacityFresnelParameters;
  101532. /**
  101533. * Define the opacity fresnel parameters of the material.
  101534. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101535. */
  101536. opacityFresnelParameters: FresnelParameters;
  101537. private _reflectionFresnelParameters;
  101538. /**
  101539. * Define the reflection fresnel parameters of the material.
  101540. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101541. */
  101542. reflectionFresnelParameters: FresnelParameters;
  101543. private _refractionFresnelParameters;
  101544. /**
  101545. * Define the refraction fresnel parameters of the material.
  101546. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101547. */
  101548. refractionFresnelParameters: FresnelParameters;
  101549. private _emissiveFresnelParameters;
  101550. /**
  101551. * Define the emissive fresnel parameters of the material.
  101552. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101553. */
  101554. emissiveFresnelParameters: FresnelParameters;
  101555. private _useReflectionFresnelFromSpecular;
  101556. /**
  101557. * If true automatically deducts the fresnels values from the material specularity.
  101558. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101559. */
  101560. useReflectionFresnelFromSpecular: boolean;
  101561. private _useGlossinessFromSpecularMapAlpha;
  101562. /**
  101563. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  101564. */
  101565. useGlossinessFromSpecularMapAlpha: boolean;
  101566. private _maxSimultaneousLights;
  101567. /**
  101568. * Defines the maximum number of lights that can be used in the material
  101569. */
  101570. maxSimultaneousLights: number;
  101571. private _invertNormalMapX;
  101572. /**
  101573. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101574. */
  101575. invertNormalMapX: boolean;
  101576. private _invertNormalMapY;
  101577. /**
  101578. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101579. */
  101580. invertNormalMapY: boolean;
  101581. private _twoSidedLighting;
  101582. /**
  101583. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101584. */
  101585. twoSidedLighting: boolean;
  101586. /**
  101587. * Default configuration related to image processing available in the standard Material.
  101588. */
  101589. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101590. /**
  101591. * Gets the image processing configuration used either in this material.
  101592. */
  101593. /**
  101594. * Sets the Default image processing configuration used either in the this material.
  101595. *
  101596. * If sets to null, the scene one is in use.
  101597. */
  101598. imageProcessingConfiguration: ImageProcessingConfiguration;
  101599. /**
  101600. * Keep track of the image processing observer to allow dispose and replace.
  101601. */
  101602. private _imageProcessingObserver;
  101603. /**
  101604. * Attaches a new image processing configuration to the Standard Material.
  101605. * @param configuration
  101606. */
  101607. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101608. /**
  101609. * Gets wether the color curves effect is enabled.
  101610. */
  101611. /**
  101612. * Sets wether the color curves effect is enabled.
  101613. */
  101614. cameraColorCurvesEnabled: boolean;
  101615. /**
  101616. * Gets wether the color grading effect is enabled.
  101617. */
  101618. /**
  101619. * Gets wether the color grading effect is enabled.
  101620. */
  101621. cameraColorGradingEnabled: boolean;
  101622. /**
  101623. * Gets wether tonemapping is enabled or not.
  101624. */
  101625. /**
  101626. * Sets wether tonemapping is enabled or not
  101627. */
  101628. cameraToneMappingEnabled: boolean;
  101629. /**
  101630. * The camera exposure used on this material.
  101631. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101632. * This corresponds to a photographic exposure.
  101633. */
  101634. /**
  101635. * The camera exposure used on this material.
  101636. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101637. * This corresponds to a photographic exposure.
  101638. */
  101639. cameraExposure: number;
  101640. /**
  101641. * Gets The camera contrast used on this material.
  101642. */
  101643. /**
  101644. * Sets The camera contrast used on this material.
  101645. */
  101646. cameraContrast: number;
  101647. /**
  101648. * Gets the Color Grading 2D Lookup Texture.
  101649. */
  101650. /**
  101651. * Sets the Color Grading 2D Lookup Texture.
  101652. */
  101653. cameraColorGradingTexture: Nullable<BaseTexture>;
  101654. /**
  101655. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101656. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101657. * 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;
  101658. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101659. */
  101660. /**
  101661. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101662. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101663. * 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;
  101664. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101665. */
  101666. cameraColorCurves: Nullable<ColorCurves>;
  101667. /**
  101668. * Custom callback helping to override the default shader used in the material.
  101669. */
  101670. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  101671. protected _renderTargets: SmartArray<RenderTargetTexture>;
  101672. protected _worldViewProjectionMatrix: Matrix;
  101673. protected _globalAmbientColor: Color3;
  101674. protected _useLogarithmicDepth: boolean;
  101675. /**
  101676. * Instantiates a new standard material.
  101677. * This is the default material used in Babylon. It is the best trade off between quality
  101678. * and performances.
  101679. * @see http://doc.babylonjs.com/babylon101/materials
  101680. * @param name Define the name of the material in the scene
  101681. * @param scene Define the scene the material belong to
  101682. */
  101683. constructor(name: string, scene: Scene);
  101684. /**
  101685. * Gets a boolean indicating that current material needs to register RTT
  101686. */
  101687. readonly hasRenderTargetTextures: boolean;
  101688. /**
  101689. * Gets the current class name of the material e.g. "StandardMaterial"
  101690. * Mainly use in serialization.
  101691. * @returns the class name
  101692. */
  101693. getClassName(): string;
  101694. /**
  101695. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  101696. * You can try switching to logarithmic depth.
  101697. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  101698. */
  101699. useLogarithmicDepth: boolean;
  101700. /**
  101701. * Specifies if the material will require alpha blending
  101702. * @returns a boolean specifying if alpha blending is needed
  101703. */
  101704. needAlphaBlending(): boolean;
  101705. /**
  101706. * Specifies if this material should be rendered in alpha test mode
  101707. * @returns a boolean specifying if an alpha test is needed.
  101708. */
  101709. needAlphaTesting(): boolean;
  101710. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  101711. /**
  101712. * Get the texture used for alpha test purpose.
  101713. * @returns the diffuse texture in case of the standard material.
  101714. */
  101715. getAlphaTestTexture(): Nullable<BaseTexture>;
  101716. /**
  101717. * Get if the submesh is ready to be used and all its information available.
  101718. * Child classes can use it to update shaders
  101719. * @param mesh defines the mesh to check
  101720. * @param subMesh defines which submesh to check
  101721. * @param useInstances specifies that instances should be used
  101722. * @returns a boolean indicating that the submesh is ready or not
  101723. */
  101724. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101725. /**
  101726. * Builds the material UBO layouts.
  101727. * Used internally during the effect preparation.
  101728. */
  101729. buildUniformLayout(): void;
  101730. /**
  101731. * Unbinds the material from the mesh
  101732. */
  101733. unbind(): void;
  101734. /**
  101735. * Binds the submesh to this material by preparing the effect and shader to draw
  101736. * @param world defines the world transformation matrix
  101737. * @param mesh defines the mesh containing the submesh
  101738. * @param subMesh defines the submesh to bind the material to
  101739. */
  101740. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101741. /**
  101742. * Get the list of animatables in the material.
  101743. * @returns the list of animatables object used in the material
  101744. */
  101745. getAnimatables(): IAnimatable[];
  101746. /**
  101747. * Gets the active textures from the material
  101748. * @returns an array of textures
  101749. */
  101750. getActiveTextures(): BaseTexture[];
  101751. /**
  101752. * Specifies if the material uses a texture
  101753. * @param texture defines the texture to check against the material
  101754. * @returns a boolean specifying if the material uses the texture
  101755. */
  101756. hasTexture(texture: BaseTexture): boolean;
  101757. /**
  101758. * Disposes the material
  101759. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101760. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101761. */
  101762. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101763. /**
  101764. * Makes a duplicate of the material, and gives it a new name
  101765. * @param name defines the new name for the duplicated material
  101766. * @returns the cloned material
  101767. */
  101768. clone(name: string): StandardMaterial;
  101769. /**
  101770. * Serializes this material in a JSON representation
  101771. * @returns the serialized material object
  101772. */
  101773. serialize(): any;
  101774. /**
  101775. * Creates a standard material from parsed material data
  101776. * @param source defines the JSON representation of the material
  101777. * @param scene defines the hosting scene
  101778. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101779. * @returns a new standard material
  101780. */
  101781. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  101782. /**
  101783. * Are diffuse textures enabled in the application.
  101784. */
  101785. static DiffuseTextureEnabled: boolean;
  101786. /**
  101787. * Are ambient textures enabled in the application.
  101788. */
  101789. static AmbientTextureEnabled: boolean;
  101790. /**
  101791. * Are opacity textures enabled in the application.
  101792. */
  101793. static OpacityTextureEnabled: boolean;
  101794. /**
  101795. * Are reflection textures enabled in the application.
  101796. */
  101797. static ReflectionTextureEnabled: boolean;
  101798. /**
  101799. * Are emissive textures enabled in the application.
  101800. */
  101801. static EmissiveTextureEnabled: boolean;
  101802. /**
  101803. * Are specular textures enabled in the application.
  101804. */
  101805. static SpecularTextureEnabled: boolean;
  101806. /**
  101807. * Are bump textures enabled in the application.
  101808. */
  101809. static BumpTextureEnabled: boolean;
  101810. /**
  101811. * Are lightmap textures enabled in the application.
  101812. */
  101813. static LightmapTextureEnabled: boolean;
  101814. /**
  101815. * Are refraction textures enabled in the application.
  101816. */
  101817. static RefractionTextureEnabled: boolean;
  101818. /**
  101819. * Are color grading textures enabled in the application.
  101820. */
  101821. static ColorGradingTextureEnabled: boolean;
  101822. /**
  101823. * Are fresnels enabled in the application.
  101824. */
  101825. static FresnelEnabled: boolean;
  101826. }
  101827. }
  101828. declare module BABYLON {
  101829. /**
  101830. * A class extending Texture allowing drawing on a texture
  101831. * @see http://doc.babylonjs.com/how_to/dynamictexture
  101832. */
  101833. export class DynamicTexture extends Texture {
  101834. private _generateMipMaps;
  101835. private _canvas;
  101836. private _context;
  101837. private _engine;
  101838. /**
  101839. * Creates a DynamicTexture
  101840. * @param name defines the name of the texture
  101841. * @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
  101842. * @param scene defines the scene where you want the texture
  101843. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  101844. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  101845. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  101846. */
  101847. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  101848. /**
  101849. * Get the current class name of the texture useful for serialization or dynamic coding.
  101850. * @returns "DynamicTexture"
  101851. */
  101852. getClassName(): string;
  101853. /**
  101854. * Gets the current state of canRescale
  101855. */
  101856. readonly canRescale: boolean;
  101857. private _recreate;
  101858. /**
  101859. * Scales the texture
  101860. * @param ratio the scale factor to apply to both width and height
  101861. */
  101862. scale(ratio: number): void;
  101863. /**
  101864. * Resizes the texture
  101865. * @param width the new width
  101866. * @param height the new height
  101867. */
  101868. scaleTo(width: number, height: number): void;
  101869. /**
  101870. * Gets the context of the canvas used by the texture
  101871. * @returns the canvas context of the dynamic texture
  101872. */
  101873. getContext(): CanvasRenderingContext2D;
  101874. /**
  101875. * Clears the texture
  101876. */
  101877. clear(): void;
  101878. /**
  101879. * Updates the texture
  101880. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  101881. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  101882. */
  101883. update(invertY?: boolean, premulAlpha?: boolean): void;
  101884. /**
  101885. * Draws text onto the texture
  101886. * @param text defines the text to be drawn
  101887. * @param x defines the placement of the text from the left
  101888. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  101889. * @param font defines the font to be used with font-style, font-size, font-name
  101890. * @param color defines the color used for the text
  101891. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  101892. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  101893. * @param update defines whether texture is immediately update (default is true)
  101894. */
  101895. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  101896. /**
  101897. * Clones the texture
  101898. * @returns the clone of the texture.
  101899. */
  101900. clone(): DynamicTexture;
  101901. /**
  101902. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  101903. * @returns a serialized dynamic texture object
  101904. */
  101905. serialize(): any;
  101906. /** @hidden */
  101907. _rebuild(): void;
  101908. }
  101909. }
  101910. declare module BABYLON {
  101911. /** @hidden */
  101912. export var imageProcessingPixelShader: {
  101913. name: string;
  101914. shader: string;
  101915. };
  101916. }
  101917. declare module BABYLON {
  101918. /**
  101919. * ImageProcessingPostProcess
  101920. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  101921. */
  101922. export class ImageProcessingPostProcess extends PostProcess {
  101923. /**
  101924. * Default configuration related to image processing available in the PBR Material.
  101925. */
  101926. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101927. /**
  101928. * Gets the image processing configuration used either in this material.
  101929. */
  101930. /**
  101931. * Sets the Default image processing configuration used either in the this material.
  101932. *
  101933. * If sets to null, the scene one is in use.
  101934. */
  101935. imageProcessingConfiguration: ImageProcessingConfiguration;
  101936. /**
  101937. * Keep track of the image processing observer to allow dispose and replace.
  101938. */
  101939. private _imageProcessingObserver;
  101940. /**
  101941. * Attaches a new image processing configuration to the PBR Material.
  101942. * @param configuration
  101943. */
  101944. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  101945. /**
  101946. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  101947. */
  101948. /**
  101949. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  101950. */
  101951. colorCurves: Nullable<ColorCurves>;
  101952. /**
  101953. * Gets wether the color curves effect is enabled.
  101954. */
  101955. /**
  101956. * Sets wether the color curves effect is enabled.
  101957. */
  101958. colorCurvesEnabled: boolean;
  101959. /**
  101960. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  101961. */
  101962. /**
  101963. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  101964. */
  101965. colorGradingTexture: Nullable<BaseTexture>;
  101966. /**
  101967. * Gets wether the color grading effect is enabled.
  101968. */
  101969. /**
  101970. * Gets wether the color grading effect is enabled.
  101971. */
  101972. colorGradingEnabled: boolean;
  101973. /**
  101974. * Gets exposure used in the effect.
  101975. */
  101976. /**
  101977. * Sets exposure used in the effect.
  101978. */
  101979. exposure: number;
  101980. /**
  101981. * Gets wether tonemapping is enabled or not.
  101982. */
  101983. /**
  101984. * Sets wether tonemapping is enabled or not
  101985. */
  101986. toneMappingEnabled: boolean;
  101987. /**
  101988. * Gets the type of tone mapping effect.
  101989. */
  101990. /**
  101991. * Sets the type of tone mapping effect.
  101992. */
  101993. toneMappingType: number;
  101994. /**
  101995. * Gets contrast used in the effect.
  101996. */
  101997. /**
  101998. * Sets contrast used in the effect.
  101999. */
  102000. contrast: number;
  102001. /**
  102002. * Gets Vignette stretch size.
  102003. */
  102004. /**
  102005. * Sets Vignette stretch size.
  102006. */
  102007. vignetteStretch: number;
  102008. /**
  102009. * Gets Vignette centre X Offset.
  102010. */
  102011. /**
  102012. * Sets Vignette centre X Offset.
  102013. */
  102014. vignetteCentreX: number;
  102015. /**
  102016. * Gets Vignette centre Y Offset.
  102017. */
  102018. /**
  102019. * Sets Vignette centre Y Offset.
  102020. */
  102021. vignetteCentreY: number;
  102022. /**
  102023. * Gets Vignette weight or intensity of the vignette effect.
  102024. */
  102025. /**
  102026. * Sets Vignette weight or intensity of the vignette effect.
  102027. */
  102028. vignetteWeight: number;
  102029. /**
  102030. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102031. * if vignetteEnabled is set to true.
  102032. */
  102033. /**
  102034. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102035. * if vignetteEnabled is set to true.
  102036. */
  102037. vignetteColor: Color4;
  102038. /**
  102039. * Gets Camera field of view used by the Vignette effect.
  102040. */
  102041. /**
  102042. * Sets Camera field of view used by the Vignette effect.
  102043. */
  102044. vignetteCameraFov: number;
  102045. /**
  102046. * Gets the vignette blend mode allowing different kind of effect.
  102047. */
  102048. /**
  102049. * Sets the vignette blend mode allowing different kind of effect.
  102050. */
  102051. vignetteBlendMode: number;
  102052. /**
  102053. * Gets wether the vignette effect is enabled.
  102054. */
  102055. /**
  102056. * Sets wether the vignette effect is enabled.
  102057. */
  102058. vignetteEnabled: boolean;
  102059. private _fromLinearSpace;
  102060. /**
  102061. * Gets wether the input of the processing is in Gamma or Linear Space.
  102062. */
  102063. /**
  102064. * Sets wether the input of the processing is in Gamma or Linear Space.
  102065. */
  102066. fromLinearSpace: boolean;
  102067. /**
  102068. * Defines cache preventing GC.
  102069. */
  102070. private _defines;
  102071. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102072. /**
  102073. * "ImageProcessingPostProcess"
  102074. * @returns "ImageProcessingPostProcess"
  102075. */
  102076. getClassName(): string;
  102077. protected _updateParameters(): void;
  102078. dispose(camera?: Camera): void;
  102079. }
  102080. }
  102081. declare module BABYLON {
  102082. /**
  102083. * Class containing static functions to help procedurally build meshes
  102084. */
  102085. export class GroundBuilder {
  102086. /**
  102087. * Creates a ground mesh
  102088. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  102089. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  102090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102091. * @param name defines the name of the mesh
  102092. * @param options defines the options used to create the mesh
  102093. * @param scene defines the hosting scene
  102094. * @returns the ground mesh
  102095. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  102096. */
  102097. static CreateGround(name: string, options: {
  102098. width?: number;
  102099. height?: number;
  102100. subdivisions?: number;
  102101. subdivisionsX?: number;
  102102. subdivisionsY?: number;
  102103. updatable?: boolean;
  102104. }, scene: any): Mesh;
  102105. /**
  102106. * Creates a tiled ground mesh
  102107. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  102108. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  102109. * * 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
  102110. * * 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
  102111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102112. * @param name defines the name of the mesh
  102113. * @param options defines the options used to create the mesh
  102114. * @param scene defines the hosting scene
  102115. * @returns the tiled ground mesh
  102116. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  102117. */
  102118. static CreateTiledGround(name: string, options: {
  102119. xmin: number;
  102120. zmin: number;
  102121. xmax: number;
  102122. zmax: number;
  102123. subdivisions?: {
  102124. w: number;
  102125. h: number;
  102126. };
  102127. precision?: {
  102128. w: number;
  102129. h: number;
  102130. };
  102131. updatable?: boolean;
  102132. }, scene?: Nullable<Scene>): Mesh;
  102133. /**
  102134. * Creates a ground mesh from a height map
  102135. * * The parameter `url` sets the URL of the height map image resource.
  102136. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  102137. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  102138. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  102139. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  102140. * * 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.
  102141. * * 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).
  102142. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  102143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102144. * @param name defines the name of the mesh
  102145. * @param url defines the url to the height map
  102146. * @param options defines the options used to create the mesh
  102147. * @param scene defines the hosting scene
  102148. * @returns the ground mesh
  102149. * @see https://doc.babylonjs.com/babylon101/height_map
  102150. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  102151. */
  102152. static CreateGroundFromHeightMap(name: string, url: string, options: {
  102153. width?: number;
  102154. height?: number;
  102155. subdivisions?: number;
  102156. minHeight?: number;
  102157. maxHeight?: number;
  102158. colorFilter?: Color3;
  102159. alphaFilter?: number;
  102160. updatable?: boolean;
  102161. onReady?: (mesh: GroundMesh) => void;
  102162. }, scene?: Nullable<Scene>): GroundMesh;
  102163. }
  102164. }
  102165. declare module BABYLON {
  102166. /**
  102167. * Class containing static functions to help procedurally build meshes
  102168. */
  102169. export class TorusBuilder {
  102170. /**
  102171. * Creates a torus mesh
  102172. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  102173. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  102174. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  102175. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102176. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102178. * @param name defines the name of the mesh
  102179. * @param options defines the options used to create the mesh
  102180. * @param scene defines the hosting scene
  102181. * @returns the torus mesh
  102182. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  102183. */
  102184. static CreateTorus(name: string, options: {
  102185. diameter?: number;
  102186. thickness?: number;
  102187. tessellation?: number;
  102188. updatable?: boolean;
  102189. sideOrientation?: number;
  102190. frontUVs?: Vector4;
  102191. backUVs?: Vector4;
  102192. }, scene: any): Mesh;
  102193. }
  102194. }
  102195. declare module BABYLON {
  102196. /**
  102197. * Class containing static functions to help procedurally build meshes
  102198. */
  102199. export class CylinderBuilder {
  102200. /**
  102201. * Creates a cylinder or a cone mesh
  102202. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  102203. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  102204. * * 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.
  102205. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  102206. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  102207. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  102208. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  102209. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  102210. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  102211. * * 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).
  102212. * * 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
  102213. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  102214. * * 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
  102215. * * 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.
  102216. * * If `enclose` is false, a ring surface is one element.
  102217. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  102218. * * 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
  102219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102220. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102222. * @param name defines the name of the mesh
  102223. * @param options defines the options used to create the mesh
  102224. * @param scene defines the hosting scene
  102225. * @returns the cylinder mesh
  102226. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  102227. */
  102228. static CreateCylinder(name: string, options: {
  102229. height?: number;
  102230. diameterTop?: number;
  102231. diameterBottom?: number;
  102232. diameter?: number;
  102233. tessellation?: number;
  102234. subdivisions?: number;
  102235. arc?: number;
  102236. faceColors?: Color4[];
  102237. faceUV?: Vector4[];
  102238. updatable?: boolean;
  102239. hasRings?: boolean;
  102240. enclose?: boolean;
  102241. cap?: number;
  102242. sideOrientation?: number;
  102243. frontUVs?: Vector4;
  102244. backUVs?: Vector4;
  102245. }, scene: any): Mesh;
  102246. }
  102247. }
  102248. declare module BABYLON {
  102249. /**
  102250. * Options to modify the vr teleportation behavior.
  102251. */
  102252. export interface VRTeleportationOptions {
  102253. /**
  102254. * The name of the mesh which should be used as the teleportation floor. (default: null)
  102255. */
  102256. floorMeshName?: string;
  102257. /**
  102258. * A list of meshes to be used as the teleportation floor. (default: empty)
  102259. */
  102260. floorMeshes?: Mesh[];
  102261. }
  102262. /**
  102263. * Options to modify the vr experience helper's behavior.
  102264. */
  102265. export interface VRExperienceHelperOptions extends WebVROptions {
  102266. /**
  102267. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  102268. */
  102269. createDeviceOrientationCamera?: boolean;
  102270. /**
  102271. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  102272. */
  102273. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  102274. /**
  102275. * Uses the main button on the controller to toggle the laser casted. (default: true)
  102276. */
  102277. laserToggle?: boolean;
  102278. /**
  102279. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  102280. */
  102281. floorMeshes?: Mesh[];
  102282. /**
  102283. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  102284. */
  102285. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  102286. }
  102287. /**
  102288. * Event containing information after VR has been entered
  102289. */
  102290. export class OnAfterEnteringVRObservableEvent {
  102291. /**
  102292. * If entering vr was successful
  102293. */
  102294. success: boolean;
  102295. }
  102296. /**
  102297. * Helps to quickly add VR support to an existing scene.
  102298. * See http://doc.babylonjs.com/how_to/webvr_helper
  102299. */
  102300. export class VRExperienceHelper {
  102301. /** Options to modify the vr experience helper's behavior. */
  102302. webVROptions: VRExperienceHelperOptions;
  102303. private _scene;
  102304. private _position;
  102305. private _btnVR;
  102306. private _btnVRDisplayed;
  102307. private _webVRsupported;
  102308. private _webVRready;
  102309. private _webVRrequesting;
  102310. private _webVRpresenting;
  102311. private _hasEnteredVR;
  102312. private _fullscreenVRpresenting;
  102313. private _canvas;
  102314. private _webVRCamera;
  102315. private _vrDeviceOrientationCamera;
  102316. private _deviceOrientationCamera;
  102317. private _existingCamera;
  102318. private _onKeyDown;
  102319. private _onVrDisplayPresentChange;
  102320. private _onVRDisplayChanged;
  102321. private _onVRRequestPresentStart;
  102322. private _onVRRequestPresentComplete;
  102323. /**
  102324. * Observable raised right before entering VR.
  102325. */
  102326. onEnteringVRObservable: Observable<VRExperienceHelper>;
  102327. /**
  102328. * Observable raised when entering VR has completed.
  102329. */
  102330. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  102331. /**
  102332. * Observable raised when exiting VR.
  102333. */
  102334. onExitingVRObservable: Observable<VRExperienceHelper>;
  102335. /**
  102336. * Observable raised when controller mesh is loaded.
  102337. */
  102338. onControllerMeshLoadedObservable: Observable<WebVRController>;
  102339. /** Return this.onEnteringVRObservable
  102340. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  102341. */
  102342. readonly onEnteringVR: Observable<VRExperienceHelper>;
  102343. /** Return this.onExitingVRObservable
  102344. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  102345. */
  102346. readonly onExitingVR: Observable<VRExperienceHelper>;
  102347. /** Return this.onControllerMeshLoadedObservable
  102348. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  102349. */
  102350. readonly onControllerMeshLoaded: Observable<WebVRController>;
  102351. private _rayLength;
  102352. private _useCustomVRButton;
  102353. private _teleportationRequested;
  102354. private _teleportActive;
  102355. private _floorMeshName;
  102356. private _floorMeshesCollection;
  102357. private _rotationAllowed;
  102358. private _teleportBackwardsVector;
  102359. private _teleportationTarget;
  102360. private _isDefaultTeleportationTarget;
  102361. private _postProcessMove;
  102362. private _teleportationFillColor;
  102363. private _teleportationBorderColor;
  102364. private _rotationAngle;
  102365. private _haloCenter;
  102366. private _cameraGazer;
  102367. private _padSensibilityUp;
  102368. private _padSensibilityDown;
  102369. private _leftController;
  102370. private _rightController;
  102371. /**
  102372. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  102373. */
  102374. onNewMeshSelected: Observable<AbstractMesh>;
  102375. /**
  102376. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  102377. */
  102378. onNewMeshPicked: Observable<PickingInfo>;
  102379. private _circleEase;
  102380. /**
  102381. * Observable raised before camera teleportation
  102382. */
  102383. onBeforeCameraTeleport: Observable<Vector3>;
  102384. /**
  102385. * Observable raised after camera teleportation
  102386. */
  102387. onAfterCameraTeleport: Observable<Vector3>;
  102388. /**
  102389. * Observable raised when current selected mesh gets unselected
  102390. */
  102391. onSelectedMeshUnselected: Observable<AbstractMesh>;
  102392. private _raySelectionPredicate;
  102393. /**
  102394. * To be optionaly changed by user to define custom ray selection
  102395. */
  102396. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  102397. /**
  102398. * To be optionaly changed by user to define custom selection logic (after ray selection)
  102399. */
  102400. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  102401. /**
  102402. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  102403. */
  102404. teleportationEnabled: boolean;
  102405. private _defaultHeight;
  102406. private _teleportationInitialized;
  102407. private _interactionsEnabled;
  102408. private _interactionsRequested;
  102409. private _displayGaze;
  102410. private _displayLaserPointer;
  102411. /**
  102412. * The mesh used to display where the user is going to teleport.
  102413. */
  102414. /**
  102415. * Sets the mesh to be used to display where the user is going to teleport.
  102416. */
  102417. teleportationTarget: Mesh;
  102418. /**
  102419. * 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
  102420. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  102421. * See http://doc.babylonjs.com/resources/baking_transformations
  102422. */
  102423. gazeTrackerMesh: Mesh;
  102424. /**
  102425. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  102426. */
  102427. updateGazeTrackerScale: boolean;
  102428. /**
  102429. * If the gaze trackers color should be updated when selecting meshes
  102430. */
  102431. updateGazeTrackerColor: boolean;
  102432. /**
  102433. * The gaze tracking mesh corresponding to the left controller
  102434. */
  102435. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  102436. /**
  102437. * The gaze tracking mesh corresponding to the right controller
  102438. */
  102439. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  102440. /**
  102441. * If the ray of the gaze should be displayed.
  102442. */
  102443. /**
  102444. * Sets if the ray of the gaze should be displayed.
  102445. */
  102446. displayGaze: boolean;
  102447. /**
  102448. * If the ray of the LaserPointer should be displayed.
  102449. */
  102450. /**
  102451. * Sets if the ray of the LaserPointer should be displayed.
  102452. */
  102453. displayLaserPointer: boolean;
  102454. /**
  102455. * The deviceOrientationCamera used as the camera when not in VR.
  102456. */
  102457. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  102458. /**
  102459. * Based on the current WebVR support, returns the current VR camera used.
  102460. */
  102461. readonly currentVRCamera: Nullable<Camera>;
  102462. /**
  102463. * The webVRCamera which is used when in VR.
  102464. */
  102465. readonly webVRCamera: WebVRFreeCamera;
  102466. /**
  102467. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  102468. */
  102469. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  102470. private readonly _teleportationRequestInitiated;
  102471. /**
  102472. * Defines wether or not Pointer lock should be requested when switching to
  102473. * full screen.
  102474. */
  102475. requestPointerLockOnFullScreen: boolean;
  102476. /**
  102477. * Instantiates a VRExperienceHelper.
  102478. * Helps to quickly add VR support to an existing scene.
  102479. * @param scene The scene the VRExperienceHelper belongs to.
  102480. * @param webVROptions Options to modify the vr experience helper's behavior.
  102481. */
  102482. constructor(scene: Scene,
  102483. /** Options to modify the vr experience helper's behavior. */
  102484. webVROptions?: VRExperienceHelperOptions);
  102485. private _onDefaultMeshLoaded;
  102486. private _onResize;
  102487. private _onFullscreenChange;
  102488. /**
  102489. * Gets a value indicating if we are currently in VR mode.
  102490. */
  102491. readonly isInVRMode: boolean;
  102492. private onVrDisplayPresentChange;
  102493. private onVRDisplayChanged;
  102494. private moveButtonToBottomRight;
  102495. private displayVRButton;
  102496. private updateButtonVisibility;
  102497. private _cachedAngularSensibility;
  102498. /**
  102499. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  102500. * Otherwise, will use the fullscreen API.
  102501. */
  102502. enterVR(): void;
  102503. /**
  102504. * Attempt to exit VR, or fullscreen.
  102505. */
  102506. exitVR(): void;
  102507. /**
  102508. * The position of the vr experience helper.
  102509. */
  102510. /**
  102511. * Sets the position of the vr experience helper.
  102512. */
  102513. position: Vector3;
  102514. /**
  102515. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  102516. */
  102517. enableInteractions(): void;
  102518. private readonly _noControllerIsActive;
  102519. private beforeRender;
  102520. private _isTeleportationFloor;
  102521. /**
  102522. * Adds a floor mesh to be used for teleportation.
  102523. * @param floorMesh the mesh to be used for teleportation.
  102524. */
  102525. addFloorMesh(floorMesh: Mesh): void;
  102526. /**
  102527. * Removes a floor mesh from being used for teleportation.
  102528. * @param floorMesh the mesh to be removed.
  102529. */
  102530. removeFloorMesh(floorMesh: Mesh): void;
  102531. /**
  102532. * Enables interactions and teleportation using the VR controllers and gaze.
  102533. * @param vrTeleportationOptions options to modify teleportation behavior.
  102534. */
  102535. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  102536. private _onNewGamepadConnected;
  102537. private _tryEnableInteractionOnController;
  102538. private _onNewGamepadDisconnected;
  102539. private _enableInteractionOnController;
  102540. private _checkTeleportWithRay;
  102541. private _checkRotate;
  102542. private _checkTeleportBackwards;
  102543. private _enableTeleportationOnController;
  102544. private _createTeleportationCircles;
  102545. private _displayTeleportationTarget;
  102546. private _hideTeleportationTarget;
  102547. private _rotateCamera;
  102548. private _moveTeleportationSelectorTo;
  102549. private _workingVector;
  102550. private _workingQuaternion;
  102551. private _workingMatrix;
  102552. /**
  102553. * Teleports the users feet to the desired location
  102554. * @param location The location where the user's feet should be placed
  102555. */
  102556. teleportCamera(location: Vector3): void;
  102557. private _convertNormalToDirectionOfRay;
  102558. private _castRayAndSelectObject;
  102559. private _notifySelectedMeshUnselected;
  102560. /**
  102561. * Sets the color of the laser ray from the vr controllers.
  102562. * @param color new color for the ray.
  102563. */
  102564. changeLaserColor(color: Color3): void;
  102565. /**
  102566. * Sets the color of the ray from the vr headsets gaze.
  102567. * @param color new color for the ray.
  102568. */
  102569. changeGazeColor(color: Color3): void;
  102570. /**
  102571. * Exits VR and disposes of the vr experience helper
  102572. */
  102573. dispose(): void;
  102574. /**
  102575. * Gets the name of the VRExperienceHelper class
  102576. * @returns "VRExperienceHelper"
  102577. */
  102578. getClassName(): string;
  102579. }
  102580. }
  102581. declare module BABYLON {
  102582. /**
  102583. * Manages an XRSession
  102584. * @see https://doc.babylonjs.com/how_to/webxr
  102585. */
  102586. export class WebXRSessionManager implements IDisposable {
  102587. private scene;
  102588. /**
  102589. * Fires every time a new xrFrame arrives which can be used to update the camera
  102590. */
  102591. onXRFrameObservable: Observable<any>;
  102592. /**
  102593. * Fires when the xr session is ended either by the device or manually done
  102594. */
  102595. onXRSessionEnded: Observable<any>;
  102596. /** @hidden */
  102597. _xrSession: XRSession;
  102598. /** @hidden */
  102599. _frameOfReference: XRFrameOfReference;
  102600. /** @hidden */
  102601. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  102602. /** @hidden */
  102603. _currentXRFrame: Nullable<XRFrame>;
  102604. private _xrNavigator;
  102605. private _xrDevice;
  102606. private _tmpMatrix;
  102607. /**
  102608. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  102609. * @param scene The scene which the session should be created for
  102610. */
  102611. constructor(scene: Scene);
  102612. /**
  102613. * Initializes the manager
  102614. * After initialization enterXR can be called to start an XR session
  102615. * @returns Promise which resolves after it is initialized
  102616. */
  102617. initializeAsync(): Promise<void>;
  102618. /**
  102619. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  102620. * @param sessionCreationOptions xr options to create the session with
  102621. * @param frameOfReferenceType option to configure how the xr pose is expressed
  102622. * @returns Promise which resolves after it enters XR
  102623. */
  102624. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  102625. /**
  102626. * Stops the xrSession and restores the renderloop
  102627. * @returns Promise which resolves after it exits XR
  102628. */
  102629. exitXRAsync(): Promise<void>;
  102630. /**
  102631. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  102632. * @param ray ray to cast into the environment
  102633. * @returns Promise which resolves with a collision point in the environment if it exists
  102634. */
  102635. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  102636. /**
  102637. * Checks if a session would be supported for the creation options specified
  102638. * @param options creation options to check if they are supported
  102639. * @returns true if supported
  102640. */
  102641. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  102642. /**
  102643. * @hidden
  102644. * Converts the render layer of xrSession to a render target
  102645. * @param session session to create render target for
  102646. * @param scene scene the new render target should be created for
  102647. */
  102648. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  102649. /**
  102650. * Disposes of the session manager
  102651. */
  102652. dispose(): void;
  102653. }
  102654. }
  102655. declare module BABYLON {
  102656. /**
  102657. * WebXR Camera which holds the views for the xrSession
  102658. * @see https://doc.babylonjs.com/how_to/webxr
  102659. */
  102660. export class WebXRCamera extends FreeCamera {
  102661. private static _TmpMatrix;
  102662. /**
  102663. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  102664. * @param name the name of the camera
  102665. * @param scene the scene to add the camera to
  102666. */
  102667. constructor(name: string, scene: Scene);
  102668. private _updateNumberOfRigCameras;
  102669. /** @hidden */
  102670. _updateForDualEyeDebugging(pupilDistance?: number): void;
  102671. /**
  102672. * Updates the cameras position from the current pose information of the XR session
  102673. * @param xrSessionManager the session containing pose information
  102674. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  102675. */
  102676. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  102677. }
  102678. }
  102679. declare module BABYLON {
  102680. /**
  102681. * States of the webXR experience
  102682. */
  102683. export enum WebXRState {
  102684. /**
  102685. * Transitioning to being in XR mode
  102686. */
  102687. ENTERING_XR = 0,
  102688. /**
  102689. * Transitioning to non XR mode
  102690. */
  102691. EXITING_XR = 1,
  102692. /**
  102693. * In XR mode and presenting
  102694. */
  102695. IN_XR = 2,
  102696. /**
  102697. * Not entered XR mode
  102698. */
  102699. NOT_IN_XR = 3
  102700. }
  102701. /**
  102702. * Helper class used to enable XR
  102703. * @see https://doc.babylonjs.com/how_to/webxr
  102704. */
  102705. export class WebXRExperienceHelper implements IDisposable {
  102706. private scene;
  102707. /**
  102708. * 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
  102709. */
  102710. container: AbstractMesh;
  102711. /**
  102712. * Camera used to render xr content
  102713. */
  102714. camera: WebXRCamera;
  102715. /**
  102716. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  102717. */
  102718. state: WebXRState;
  102719. private _setState;
  102720. private static _TmpVector;
  102721. /**
  102722. * Fires when the state of the experience helper has changed
  102723. */
  102724. onStateChangedObservable: Observable<WebXRState>;
  102725. /** @hidden */
  102726. _sessionManager: WebXRSessionManager;
  102727. private _nonVRCamera;
  102728. private _originalSceneAutoClear;
  102729. private _supported;
  102730. /**
  102731. * Creates the experience helper
  102732. * @param scene the scene to attach the experience helper to
  102733. * @returns a promise for the experience helper
  102734. */
  102735. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  102736. /**
  102737. * Creates a WebXRExperienceHelper
  102738. * @param scene The scene the helper should be created in
  102739. */
  102740. private constructor();
  102741. /**
  102742. * Exits XR mode and returns the scene to its original state
  102743. * @returns promise that resolves after xr mode has exited
  102744. */
  102745. exitXRAsync(): Promise<void>;
  102746. /**
  102747. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  102748. * @param sessionCreationOptions options for the XR session
  102749. * @param frameOfReference frame of reference of the XR session
  102750. * @returns promise that resolves after xr mode has entered
  102751. */
  102752. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  102753. /**
  102754. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  102755. * @param ray ray to cast into the environment
  102756. * @returns Promise which resolves with a collision point in the environment if it exists
  102757. */
  102758. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  102759. /**
  102760. * Updates the global position of the camera by moving the camera's container
  102761. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  102762. * @param position The desired global position of the camera
  102763. */
  102764. setPositionOfCameraUsingContainer(position: Vector3): void;
  102765. /**
  102766. * Rotates the xr camera by rotating the camera's container around the camera's position
  102767. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  102768. * @param rotation the desired quaternion rotation to apply to the camera
  102769. */
  102770. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  102771. /**
  102772. * Checks if the creation options are supported by the xr session
  102773. * @param options creation options
  102774. * @returns true if supported
  102775. */
  102776. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  102777. /**
  102778. * Disposes of the experience helper
  102779. */
  102780. dispose(): void;
  102781. }
  102782. }
  102783. declare module BABYLON {
  102784. /**
  102785. * Button which can be used to enter a different mode of XR
  102786. */
  102787. export class WebXREnterExitUIButton {
  102788. /** button element */
  102789. element: HTMLElement;
  102790. /** XR initialization options for the button */
  102791. initializationOptions: XRSessionCreationOptions;
  102792. /**
  102793. * Creates a WebXREnterExitUIButton
  102794. * @param element button element
  102795. * @param initializationOptions XR initialization options for the button
  102796. */
  102797. constructor(
  102798. /** button element */
  102799. element: HTMLElement,
  102800. /** XR initialization options for the button */
  102801. initializationOptions: XRSessionCreationOptions);
  102802. /**
  102803. * Overwritable function which can be used to update the button's visuals when the state changes
  102804. * @param activeButton the current active button in the UI
  102805. */
  102806. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  102807. }
  102808. /**
  102809. * Options to create the webXR UI
  102810. */
  102811. export class WebXREnterExitUIOptions {
  102812. /**
  102813. * Context to enter xr with
  102814. */
  102815. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  102816. /**
  102817. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  102818. */
  102819. customButtons?: Array<WebXREnterExitUIButton>;
  102820. }
  102821. /**
  102822. * UI to allow the user to enter/exit XR mode
  102823. */
  102824. export class WebXREnterExitUI implements IDisposable {
  102825. private scene;
  102826. private _overlay;
  102827. private _buttons;
  102828. private _activeButton;
  102829. /**
  102830. * Fired every time the active button is changed.
  102831. *
  102832. * When xr is entered via a button that launches xr that button will be the callback parameter
  102833. *
  102834. * When exiting xr the callback parameter will be null)
  102835. */
  102836. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  102837. /**
  102838. * Creates UI to allow the user to enter/exit XR mode
  102839. * @param scene the scene to add the ui to
  102840. * @param helper the xr experience helper to enter/exit xr with
  102841. * @param options options to configure the UI
  102842. * @returns the created ui
  102843. */
  102844. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  102845. private constructor();
  102846. private _updateButtons;
  102847. /**
  102848. * Disposes of the object
  102849. */
  102850. dispose(): void;
  102851. }
  102852. }
  102853. declare module BABYLON {
  102854. /**
  102855. * Represents an XR input
  102856. */
  102857. export class WebXRController {
  102858. /**
  102859. * 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
  102860. */
  102861. grip?: AbstractMesh;
  102862. /**
  102863. * Pointer which can be used to select objects or attach a visible laser to
  102864. */
  102865. pointer: AbstractMesh;
  102866. /**
  102867. * Creates the controller
  102868. * @see https://doc.babylonjs.com/how_to/webxr
  102869. * @param scene the scene which the controller should be associated to
  102870. */
  102871. constructor(scene: Scene);
  102872. /**
  102873. * Disposes of the object
  102874. */
  102875. dispose(): void;
  102876. }
  102877. /**
  102878. * XR input used to track XR inputs such as controllers/rays
  102879. */
  102880. export class WebXRInput implements IDisposable {
  102881. private helper;
  102882. /**
  102883. * XR controllers being tracked
  102884. */
  102885. controllers: Array<WebXRController>;
  102886. private _tmpMatrix;
  102887. private _frameObserver;
  102888. /**
  102889. * Initializes the WebXRInput
  102890. * @param helper experience helper which the input should be created for
  102891. */
  102892. constructor(helper: WebXRExperienceHelper);
  102893. /**
  102894. * Disposes of the object
  102895. */
  102896. dispose(): void;
  102897. }
  102898. }
  102899. declare module BABYLON {
  102900. /**
  102901. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  102902. */
  102903. export class WebXRManagedOutputCanvas implements IDisposable {
  102904. private _canvas;
  102905. /**
  102906. * xrpresent context of the canvas which can be used to display/mirror xr content
  102907. */
  102908. canvasContext: Nullable<WebGLRenderingContext>;
  102909. /**
  102910. * Initializes the canvas to be added/removed upon entering/exiting xr
  102911. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  102912. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  102913. */
  102914. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  102915. /**
  102916. * Disposes of the object
  102917. */
  102918. dispose(): void;
  102919. private _setManagedOutputCanvas;
  102920. private _addCanvas;
  102921. private _removeCanvas;
  102922. }
  102923. }
  102924. declare module BABYLON {
  102925. /**
  102926. * Contains an array of blocks representing the octree
  102927. */
  102928. export interface IOctreeContainer<T> {
  102929. /**
  102930. * Blocks within the octree
  102931. */
  102932. blocks: Array<OctreeBlock<T>>;
  102933. }
  102934. /**
  102935. * Class used to store a cell in an octree
  102936. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  102937. */
  102938. export class OctreeBlock<T> {
  102939. /**
  102940. * Gets the content of the current block
  102941. */
  102942. entries: T[];
  102943. /**
  102944. * Gets the list of block children
  102945. */
  102946. blocks: Array<OctreeBlock<T>>;
  102947. private _depth;
  102948. private _maxDepth;
  102949. private _capacity;
  102950. private _minPoint;
  102951. private _maxPoint;
  102952. private _boundingVectors;
  102953. private _creationFunc;
  102954. /**
  102955. * Creates a new block
  102956. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  102957. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  102958. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  102959. * @param depth defines the current depth of this block in the octree
  102960. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  102961. * @param creationFunc defines a callback to call when an element is added to the block
  102962. */
  102963. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  102964. /**
  102965. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  102966. */
  102967. readonly capacity: number;
  102968. /**
  102969. * Gets the minimum vector (in world space) of the block's bounding box
  102970. */
  102971. readonly minPoint: Vector3;
  102972. /**
  102973. * Gets the maximum vector (in world space) of the block's bounding box
  102974. */
  102975. readonly maxPoint: Vector3;
  102976. /**
  102977. * Add a new element to this block
  102978. * @param entry defines the element to add
  102979. */
  102980. addEntry(entry: T): void;
  102981. /**
  102982. * Remove an element from this block
  102983. * @param entry defines the element to remove
  102984. */
  102985. removeEntry(entry: T): void;
  102986. /**
  102987. * Add an array of elements to this block
  102988. * @param entries defines the array of elements to add
  102989. */
  102990. addEntries(entries: T[]): void;
  102991. /**
  102992. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  102993. * @param frustumPlanes defines the frustum planes to test
  102994. * @param selection defines the array to store current content if selection is positive
  102995. * @param allowDuplicate defines if the selection array can contains duplicated entries
  102996. */
  102997. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  102998. /**
  102999. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  103000. * @param sphereCenter defines the bounding sphere center
  103001. * @param sphereRadius defines the bounding sphere radius
  103002. * @param selection defines the array to store current content if selection is positive
  103003. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103004. */
  103005. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103006. /**
  103007. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  103008. * @param ray defines the ray to test with
  103009. * @param selection defines the array to store current content if selection is positive
  103010. */
  103011. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  103012. /**
  103013. * Subdivide the content into child blocks (this block will then be empty)
  103014. */
  103015. createInnerBlocks(): void;
  103016. /**
  103017. * @hidden
  103018. */
  103019. 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;
  103020. }
  103021. }
  103022. declare module BABYLON {
  103023. /**
  103024. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  103025. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103026. */
  103027. export class Octree<T> {
  103028. /** 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.) */
  103029. maxDepth: number;
  103030. /**
  103031. * Blocks within the octree containing objects
  103032. */
  103033. blocks: Array<OctreeBlock<T>>;
  103034. /**
  103035. * Content stored in the octree
  103036. */
  103037. dynamicContent: T[];
  103038. private _maxBlockCapacity;
  103039. private _selectionContent;
  103040. private _creationFunc;
  103041. /**
  103042. * Creates a octree
  103043. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103044. * @param creationFunc function to be used to instatiate the octree
  103045. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  103046. * @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.)
  103047. */
  103048. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  103049. /** 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.) */
  103050. maxDepth?: number);
  103051. /**
  103052. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  103053. * @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);
  103054. * @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);
  103055. * @param entries meshes to be added to the octree blocks
  103056. */
  103057. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  103058. /**
  103059. * Adds a mesh to the octree
  103060. * @param entry Mesh to add to the octree
  103061. */
  103062. addMesh(entry: T): void;
  103063. /**
  103064. * Remove an element from the octree
  103065. * @param entry defines the element to remove
  103066. */
  103067. removeMesh(entry: T): void;
  103068. /**
  103069. * Selects an array of meshes within the frustum
  103070. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  103071. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  103072. * @returns array of meshes within the frustum
  103073. */
  103074. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  103075. /**
  103076. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  103077. * @param sphereCenter defines the bounding sphere center
  103078. * @param sphereRadius defines the bounding sphere radius
  103079. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103080. * @returns an array of objects that intersect the sphere
  103081. */
  103082. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  103083. /**
  103084. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  103085. * @param ray defines the ray to test with
  103086. * @returns array of intersected objects
  103087. */
  103088. intersectsRay(ray: Ray): SmartArray<T>;
  103089. /**
  103090. * Adds a mesh into the octree block if it intersects the block
  103091. */
  103092. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  103093. /**
  103094. * Adds a submesh into the octree block if it intersects the block
  103095. */
  103096. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  103097. }
  103098. }
  103099. declare module BABYLON {
  103100. interface Scene {
  103101. /**
  103102. * @hidden
  103103. * Backing Filed
  103104. */
  103105. _selectionOctree: Octree<AbstractMesh>;
  103106. /**
  103107. * Gets the octree used to boost mesh selection (picking)
  103108. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103109. */
  103110. selectionOctree: Octree<AbstractMesh>;
  103111. /**
  103112. * Creates or updates the octree used to boost selection (picking)
  103113. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103114. * @param maxCapacity defines the maximum capacity per leaf
  103115. * @param maxDepth defines the maximum depth of the octree
  103116. * @returns an octree of AbstractMesh
  103117. */
  103118. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  103119. }
  103120. interface AbstractMesh {
  103121. /**
  103122. * @hidden
  103123. * Backing Field
  103124. */
  103125. _submeshesOctree: Octree<SubMesh>;
  103126. /**
  103127. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  103128. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103129. * @param maxCapacity defines the maximum size of each block (64 by default)
  103130. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  103131. * @returns the new octree
  103132. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  103133. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103134. */
  103135. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  103136. }
  103137. /**
  103138. * Defines the octree scene component responsible to manage any octrees
  103139. * in a given scene.
  103140. */
  103141. export class OctreeSceneComponent {
  103142. /**
  103143. * The component name help to identify the component in the list of scene components.
  103144. */
  103145. readonly name: string;
  103146. /**
  103147. * The scene the component belongs to.
  103148. */
  103149. scene: Scene;
  103150. /**
  103151. * Indicates if the meshes have been checked to make sure they are isEnabled()
  103152. */
  103153. readonly checksIsEnabled: boolean;
  103154. /**
  103155. * Creates a new instance of the component for the given scene
  103156. * @param scene Defines the scene to register the component in
  103157. */
  103158. constructor(scene: Scene);
  103159. /**
  103160. * Registers the component in a given scene
  103161. */
  103162. register(): void;
  103163. /**
  103164. * Return the list of active meshes
  103165. * @returns the list of active meshes
  103166. */
  103167. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  103168. /**
  103169. * Return the list of active sub meshes
  103170. * @param mesh The mesh to get the candidates sub meshes from
  103171. * @returns the list of active sub meshes
  103172. */
  103173. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  103174. private _tempRay;
  103175. /**
  103176. * Return the list of sub meshes intersecting with a given local ray
  103177. * @param mesh defines the mesh to find the submesh for
  103178. * @param localRay defines the ray in local space
  103179. * @returns the list of intersecting sub meshes
  103180. */
  103181. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  103182. /**
  103183. * Return the list of sub meshes colliding with a collider
  103184. * @param mesh defines the mesh to find the submesh for
  103185. * @param collider defines the collider to evaluate the collision against
  103186. * @returns the list of colliding sub meshes
  103187. */
  103188. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  103189. /**
  103190. * Rebuilds the elements related to this component in case of
  103191. * context lost for instance.
  103192. */
  103193. rebuild(): void;
  103194. /**
  103195. * Disposes the component and the associated ressources.
  103196. */
  103197. dispose(): void;
  103198. }
  103199. }
  103200. declare module BABYLON {
  103201. /**
  103202. * Renders a layer on top of an existing scene
  103203. */
  103204. export class UtilityLayerRenderer implements IDisposable {
  103205. /** the original scene that will be rendered on top of */
  103206. originalScene: Scene;
  103207. private _pointerCaptures;
  103208. private _lastPointerEvents;
  103209. private static _DefaultUtilityLayer;
  103210. private static _DefaultKeepDepthUtilityLayer;
  103211. private _sharedGizmoLight;
  103212. /**
  103213. * @hidden
  103214. * Light which used by gizmos to get light shading
  103215. */
  103216. _getSharedGizmoLight(): HemisphericLight;
  103217. /**
  103218. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  103219. */
  103220. pickUtilitySceneFirst: boolean;
  103221. /**
  103222. * 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)
  103223. */
  103224. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  103225. /**
  103226. * 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)
  103227. */
  103228. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  103229. /**
  103230. * The scene that is rendered on top of the original scene
  103231. */
  103232. utilityLayerScene: Scene;
  103233. /**
  103234. * If the utility layer should automatically be rendered on top of existing scene
  103235. */
  103236. shouldRender: boolean;
  103237. /**
  103238. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  103239. */
  103240. onlyCheckPointerDownEvents: boolean;
  103241. /**
  103242. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  103243. */
  103244. processAllEvents: boolean;
  103245. /**
  103246. * Observable raised when the pointer move from the utility layer scene to the main scene
  103247. */
  103248. onPointerOutObservable: Observable<number>;
  103249. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  103250. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  103251. private _afterRenderObserver;
  103252. private _sceneDisposeObserver;
  103253. private _originalPointerObserver;
  103254. /**
  103255. * Instantiates a UtilityLayerRenderer
  103256. * @param originalScene the original scene that will be rendered on top of
  103257. * @param handleEvents boolean indicating if the utility layer should handle events
  103258. */
  103259. constructor(
  103260. /** the original scene that will be rendered on top of */
  103261. originalScene: Scene, handleEvents?: boolean);
  103262. private _notifyObservers;
  103263. /**
  103264. * Renders the utility layers scene on top of the original scene
  103265. */
  103266. render(): void;
  103267. /**
  103268. * Disposes of the renderer
  103269. */
  103270. dispose(): void;
  103271. private _updateCamera;
  103272. }
  103273. }
  103274. declare module BABYLON {
  103275. /**
  103276. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  103277. */
  103278. export class Gizmo implements IDisposable {
  103279. /** The utility layer the gizmo will be added to */
  103280. gizmoLayer: UtilityLayerRenderer;
  103281. /**
  103282. * The root mesh of the gizmo
  103283. */
  103284. _rootMesh: Mesh;
  103285. private _attachedMesh;
  103286. /**
  103287. * Ratio for the scale of the gizmo (Default: 1)
  103288. */
  103289. scaleRatio: number;
  103290. /**
  103291. * If a custom mesh has been set (Default: false)
  103292. */
  103293. protected _customMeshSet: boolean;
  103294. /**
  103295. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  103296. * * When set, interactions will be enabled
  103297. */
  103298. attachedMesh: Nullable<AbstractMesh>;
  103299. /**
  103300. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  103301. * @param mesh The mesh to replace the default mesh of the gizmo
  103302. */
  103303. setCustomMesh(mesh: Mesh): void;
  103304. /**
  103305. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  103306. */
  103307. updateGizmoRotationToMatchAttachedMesh: boolean;
  103308. /**
  103309. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  103310. */
  103311. updateGizmoPositionToMatchAttachedMesh: boolean;
  103312. /**
  103313. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  103314. */
  103315. protected _updateScale: boolean;
  103316. protected _interactionsEnabled: boolean;
  103317. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103318. private _beforeRenderObserver;
  103319. private _tempVector;
  103320. /**
  103321. * Creates a gizmo
  103322. * @param gizmoLayer The utility layer the gizmo will be added to
  103323. */
  103324. constructor(
  103325. /** The utility layer the gizmo will be added to */
  103326. gizmoLayer?: UtilityLayerRenderer);
  103327. /**
  103328. * Updates the gizmo to match the attached mesh's position/rotation
  103329. */
  103330. protected _update(): void;
  103331. /**
  103332. * Disposes of the gizmo
  103333. */
  103334. dispose(): void;
  103335. }
  103336. }
  103337. declare module BABYLON {
  103338. /**
  103339. * Single plane drag gizmo
  103340. */
  103341. export class PlaneDragGizmo extends Gizmo {
  103342. /**
  103343. * Drag behavior responsible for the gizmos dragging interactions
  103344. */
  103345. dragBehavior: PointerDragBehavior;
  103346. private _pointerObserver;
  103347. /**
  103348. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103349. */
  103350. snapDistance: number;
  103351. /**
  103352. * Event that fires each time the gizmo snaps to a new location.
  103353. * * snapDistance is the the change in distance
  103354. */
  103355. onSnapObservable: Observable<{
  103356. snapDistance: number;
  103357. }>;
  103358. private _plane;
  103359. private _coloredMaterial;
  103360. private _hoverMaterial;
  103361. private _isEnabled;
  103362. private _parent;
  103363. /** @hidden */
  103364. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  103365. /** @hidden */
  103366. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103367. /**
  103368. * Creates a PlaneDragGizmo
  103369. * @param gizmoLayer The utility layer the gizmo will be added to
  103370. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  103371. * @param color The color of the gizmo
  103372. */
  103373. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103374. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103375. /**
  103376. * If the gizmo is enabled
  103377. */
  103378. isEnabled: boolean;
  103379. /**
  103380. * Disposes of the gizmo
  103381. */
  103382. dispose(): void;
  103383. }
  103384. }
  103385. declare module BABYLON {
  103386. /**
  103387. * Gizmo that enables dragging a mesh along 3 axis
  103388. */
  103389. export class PositionGizmo extends Gizmo {
  103390. /**
  103391. * Internal gizmo used for interactions on the x axis
  103392. */
  103393. xGizmo: AxisDragGizmo;
  103394. /**
  103395. * Internal gizmo used for interactions on the y axis
  103396. */
  103397. yGizmo: AxisDragGizmo;
  103398. /**
  103399. * Internal gizmo used for interactions on the z axis
  103400. */
  103401. zGizmo: AxisDragGizmo;
  103402. /**
  103403. * Internal gizmo used for interactions on the yz plane
  103404. */
  103405. xPlaneGizmo: PlaneDragGizmo;
  103406. /**
  103407. * Internal gizmo used for interactions on the xz plane
  103408. */
  103409. yPlaneGizmo: PlaneDragGizmo;
  103410. /**
  103411. * Internal gizmo used for interactions on the xy plane
  103412. */
  103413. zPlaneGizmo: PlaneDragGizmo;
  103414. /**
  103415. * private variables
  103416. */
  103417. private _meshAttached;
  103418. private _updateGizmoRotationToMatchAttachedMesh;
  103419. private _snapDistance;
  103420. private _scaleRatio;
  103421. /** Fires an event when any of it's sub gizmos are dragged */
  103422. onDragStartObservable: Observable<{}>;
  103423. /** Fires an event when any of it's sub gizmos are released from dragging */
  103424. onDragEndObservable: Observable<{}>;
  103425. /**
  103426. * If set to true, planar drag is enabled
  103427. */
  103428. private _planarGizmoEnabled;
  103429. attachedMesh: Nullable<AbstractMesh>;
  103430. /**
  103431. * Creates a PositionGizmo
  103432. * @param gizmoLayer The utility layer the gizmo will be added to
  103433. */
  103434. constructor(gizmoLayer?: UtilityLayerRenderer);
  103435. /**
  103436. * If the planar drag gizmo is enabled
  103437. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  103438. */
  103439. planarGizmoEnabled: boolean;
  103440. updateGizmoRotationToMatchAttachedMesh: boolean;
  103441. /**
  103442. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103443. */
  103444. snapDistance: number;
  103445. /**
  103446. * Ratio for the scale of the gizmo (Default: 1)
  103447. */
  103448. scaleRatio: number;
  103449. /**
  103450. * Disposes of the gizmo
  103451. */
  103452. dispose(): void;
  103453. /**
  103454. * CustomMeshes are not supported by this gizmo
  103455. * @param mesh The mesh to replace the default mesh of the gizmo
  103456. */
  103457. setCustomMesh(mesh: Mesh): void;
  103458. }
  103459. }
  103460. declare module BABYLON {
  103461. /**
  103462. * Single axis drag gizmo
  103463. */
  103464. export class AxisDragGizmo extends Gizmo {
  103465. /**
  103466. * Drag behavior responsible for the gizmos dragging interactions
  103467. */
  103468. dragBehavior: PointerDragBehavior;
  103469. private _pointerObserver;
  103470. /**
  103471. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103472. */
  103473. snapDistance: number;
  103474. /**
  103475. * Event that fires each time the gizmo snaps to a new location.
  103476. * * snapDistance is the the change in distance
  103477. */
  103478. onSnapObservable: Observable<{
  103479. snapDistance: number;
  103480. }>;
  103481. private _isEnabled;
  103482. private _parent;
  103483. private _arrow;
  103484. private _coloredMaterial;
  103485. private _hoverMaterial;
  103486. /** @hidden */
  103487. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  103488. /** @hidden */
  103489. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103490. /**
  103491. * Creates an AxisDragGizmo
  103492. * @param gizmoLayer The utility layer the gizmo will be added to
  103493. * @param dragAxis The axis which the gizmo will be able to drag on
  103494. * @param color The color of the gizmo
  103495. */
  103496. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103497. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103498. /**
  103499. * If the gizmo is enabled
  103500. */
  103501. isEnabled: boolean;
  103502. /**
  103503. * Disposes of the gizmo
  103504. */
  103505. dispose(): void;
  103506. }
  103507. }
  103508. declare module BABYLON.Debug {
  103509. /**
  103510. * The Axes viewer will show 3 axes in a specific point in space
  103511. */
  103512. export class AxesViewer {
  103513. private _xAxis;
  103514. private _yAxis;
  103515. private _zAxis;
  103516. private _scaleLinesFactor;
  103517. private _instanced;
  103518. /**
  103519. * Gets the hosting scene
  103520. */
  103521. scene: Scene;
  103522. /**
  103523. * Gets or sets a number used to scale line length
  103524. */
  103525. scaleLines: number;
  103526. /** Gets the node hierarchy used to render x-axis */
  103527. readonly xAxis: TransformNode;
  103528. /** Gets the node hierarchy used to render y-axis */
  103529. readonly yAxis: TransformNode;
  103530. /** Gets the node hierarchy used to render z-axis */
  103531. readonly zAxis: TransformNode;
  103532. /**
  103533. * Creates a new AxesViewer
  103534. * @param scene defines the hosting scene
  103535. * @param scaleLines defines a number used to scale line length (1 by default)
  103536. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  103537. * @param xAxis defines the node hierarchy used to render the x-axis
  103538. * @param yAxis defines the node hierarchy used to render the y-axis
  103539. * @param zAxis defines the node hierarchy used to render the z-axis
  103540. */
  103541. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  103542. /**
  103543. * Force the viewer to update
  103544. * @param position defines the position of the viewer
  103545. * @param xaxis defines the x axis of the viewer
  103546. * @param yaxis defines the y axis of the viewer
  103547. * @param zaxis defines the z axis of the viewer
  103548. */
  103549. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  103550. /**
  103551. * Creates an instance of this axes viewer.
  103552. * @returns a new axes viewer with instanced meshes
  103553. */
  103554. createInstance(): AxesViewer;
  103555. /** Releases resources */
  103556. dispose(): void;
  103557. private static _SetRenderingGroupId;
  103558. }
  103559. }
  103560. declare module BABYLON.Debug {
  103561. /**
  103562. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  103563. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  103564. */
  103565. export class BoneAxesViewer extends AxesViewer {
  103566. /**
  103567. * Gets or sets the target mesh where to display the axes viewer
  103568. */
  103569. mesh: Nullable<Mesh>;
  103570. /**
  103571. * Gets or sets the target bone where to display the axes viewer
  103572. */
  103573. bone: Nullable<Bone>;
  103574. /** Gets current position */
  103575. pos: Vector3;
  103576. /** Gets direction of X axis */
  103577. xaxis: Vector3;
  103578. /** Gets direction of Y axis */
  103579. yaxis: Vector3;
  103580. /** Gets direction of Z axis */
  103581. zaxis: Vector3;
  103582. /**
  103583. * Creates a new BoneAxesViewer
  103584. * @param scene defines the hosting scene
  103585. * @param bone defines the target bone
  103586. * @param mesh defines the target mesh
  103587. * @param scaleLines defines a scaling factor for line length (1 by default)
  103588. */
  103589. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  103590. /**
  103591. * Force the viewer to update
  103592. */
  103593. update(): void;
  103594. /** Releases resources */
  103595. dispose(): void;
  103596. }
  103597. }
  103598. declare module BABYLON {
  103599. /**
  103600. * Interface used to define scene explorer extensibility option
  103601. */
  103602. export interface IExplorerExtensibilityOption {
  103603. /**
  103604. * Define the option label
  103605. */
  103606. label: string;
  103607. /**
  103608. * Defines the action to execute on click
  103609. */
  103610. action: (entity: any) => void;
  103611. }
  103612. /**
  103613. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  103614. */
  103615. export interface IExplorerExtensibilityGroup {
  103616. /**
  103617. * Defines a predicate to test if a given type mut be extended
  103618. */
  103619. predicate: (entity: any) => boolean;
  103620. /**
  103621. * Gets the list of options added to a type
  103622. */
  103623. entries: IExplorerExtensibilityOption[];
  103624. }
  103625. /**
  103626. * Interface used to define the options to use to create the Inspector
  103627. */
  103628. export interface IInspectorOptions {
  103629. /**
  103630. * Display in overlay mode (default: false)
  103631. */
  103632. overlay?: boolean;
  103633. /**
  103634. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  103635. */
  103636. globalRoot?: HTMLElement;
  103637. /**
  103638. * Display the Scene explorer
  103639. */
  103640. showExplorer?: boolean;
  103641. /**
  103642. * Display the property inspector
  103643. */
  103644. showInspector?: boolean;
  103645. /**
  103646. * Display in embed mode (both panes on the right)
  103647. */
  103648. embedMode?: boolean;
  103649. /**
  103650. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  103651. */
  103652. handleResize?: boolean;
  103653. /**
  103654. * Allow the panes to popup (default: true)
  103655. */
  103656. enablePopup?: boolean;
  103657. /**
  103658. * Allow the panes to be closed by users (default: true)
  103659. */
  103660. enableClose?: boolean;
  103661. /**
  103662. * Optional list of extensibility entries
  103663. */
  103664. explorerExtensibility?: IExplorerExtensibilityGroup[];
  103665. /**
  103666. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  103667. */
  103668. inspectorURL?: string;
  103669. }
  103670. interface Scene {
  103671. /**
  103672. * @hidden
  103673. * Backing field
  103674. */
  103675. _debugLayer: DebugLayer;
  103676. /**
  103677. * Gets the debug layer (aka Inspector) associated with the scene
  103678. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103679. */
  103680. debugLayer: DebugLayer;
  103681. }
  103682. /**
  103683. * The debug layer (aka Inspector) is the go to tool in order to better understand
  103684. * what is happening in your scene
  103685. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103686. */
  103687. export class DebugLayer {
  103688. /**
  103689. * Define the url to get the inspector script from.
  103690. * By default it uses the babylonjs CDN.
  103691. * @ignoreNaming
  103692. */
  103693. static InspectorURL: string;
  103694. private _scene;
  103695. private BJSINSPECTOR;
  103696. /**
  103697. * Observable triggered when a property is changed through the inspector.
  103698. */
  103699. onPropertyChangedObservable: Observable<{
  103700. object: any;
  103701. property: string;
  103702. value: any;
  103703. initialValue: any;
  103704. }>;
  103705. /**
  103706. * Instantiates a new debug layer.
  103707. * The debug layer (aka Inspector) is the go to tool in order to better understand
  103708. * what is happening in your scene
  103709. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103710. * @param scene Defines the scene to inspect
  103711. */
  103712. constructor(scene: Scene);
  103713. /** Creates the inspector window. */
  103714. private _createInspector;
  103715. /**
  103716. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  103717. * @param entity defines the entity to select
  103718. * @param lineContainerTitle defines the specific block to highlight
  103719. */
  103720. select(entity: any, lineContainerTitle?: string): void;
  103721. /** Get the inspector from bundle or global */
  103722. private _getGlobalInspector;
  103723. /**
  103724. * Get if the inspector is visible or not.
  103725. * @returns true if visible otherwise, false
  103726. */
  103727. isVisible(): boolean;
  103728. /**
  103729. * Hide the inspector and close its window.
  103730. */
  103731. hide(): void;
  103732. /**
  103733. * Launch the debugLayer.
  103734. * @param config Define the configuration of the inspector
  103735. * @return a promise fulfilled when the debug layer is visible
  103736. */
  103737. show(config?: IInspectorOptions): Promise<DebugLayer>;
  103738. }
  103739. }
  103740. declare module BABYLON {
  103741. /**
  103742. * Class containing static functions to help procedurally build meshes
  103743. */
  103744. export class BoxBuilder {
  103745. /**
  103746. * Creates a box mesh
  103747. * * The parameter `size` sets the size (float) of each box side (default 1)
  103748. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  103749. * * 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)
  103750. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103752. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103754. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  103755. * @param name defines the name of the mesh
  103756. * @param options defines the options used to create the mesh
  103757. * @param scene defines the hosting scene
  103758. * @returns the box mesh
  103759. */
  103760. static CreateBox(name: string, options: {
  103761. size?: number;
  103762. width?: number;
  103763. height?: number;
  103764. depth?: number;
  103765. faceUV?: Vector4[];
  103766. faceColors?: Color4[];
  103767. sideOrientation?: number;
  103768. frontUVs?: Vector4;
  103769. backUVs?: Vector4;
  103770. wrap?: boolean;
  103771. topBaseAt?: number;
  103772. bottomBaseAt?: number;
  103773. updatable?: boolean;
  103774. }, scene?: Nullable<Scene>): Mesh;
  103775. }
  103776. }
  103777. declare module BABYLON {
  103778. /**
  103779. * Class containing static functions to help procedurally build meshes
  103780. */
  103781. export class SphereBuilder {
  103782. /**
  103783. * Creates a sphere mesh
  103784. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  103785. * * 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`)
  103786. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  103787. * * 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
  103788. * * 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)
  103789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103792. * @param name defines the name of the mesh
  103793. * @param options defines the options used to create the mesh
  103794. * @param scene defines the hosting scene
  103795. * @returns the sphere mesh
  103796. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  103797. */
  103798. static CreateSphere(name: string, options: {
  103799. segments?: number;
  103800. diameter?: number;
  103801. diameterX?: number;
  103802. diameterY?: number;
  103803. diameterZ?: number;
  103804. arc?: number;
  103805. slice?: number;
  103806. sideOrientation?: number;
  103807. frontUVs?: Vector4;
  103808. backUVs?: Vector4;
  103809. updatable?: boolean;
  103810. }, scene: any): Mesh;
  103811. }
  103812. }
  103813. declare module BABYLON.Debug {
  103814. /**
  103815. * Used to show the physics impostor around the specific mesh
  103816. */
  103817. export class PhysicsViewer {
  103818. /** @hidden */
  103819. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  103820. /** @hidden */
  103821. protected _meshes: Array<Nullable<AbstractMesh>>;
  103822. /** @hidden */
  103823. protected _scene: Nullable<Scene>;
  103824. /** @hidden */
  103825. protected _numMeshes: number;
  103826. /** @hidden */
  103827. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  103828. private _renderFunction;
  103829. private _utilityLayer;
  103830. private _debugBoxMesh;
  103831. private _debugSphereMesh;
  103832. private _debugCylinderMesh;
  103833. private _debugMaterial;
  103834. private _debugMeshMeshes;
  103835. /**
  103836. * Creates a new PhysicsViewer
  103837. * @param scene defines the hosting scene
  103838. */
  103839. constructor(scene: Scene);
  103840. /** @hidden */
  103841. protected _updateDebugMeshes(): void;
  103842. /**
  103843. * Renders a specified physic impostor
  103844. * @param impostor defines the impostor to render
  103845. * @param targetMesh defines the mesh represented by the impostor
  103846. * @returns the new debug mesh used to render the impostor
  103847. */
  103848. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  103849. /**
  103850. * Hides a specified physic impostor
  103851. * @param impostor defines the impostor to hide
  103852. */
  103853. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  103854. private _getDebugMaterial;
  103855. private _getDebugBoxMesh;
  103856. private _getDebugSphereMesh;
  103857. private _getDebugCylinderMesh;
  103858. private _getDebugMeshMesh;
  103859. private _getDebugMesh;
  103860. /** Releases all resources */
  103861. dispose(): void;
  103862. }
  103863. }
  103864. declare module BABYLON {
  103865. /**
  103866. * Class containing static functions to help procedurally build meshes
  103867. */
  103868. export class LinesBuilder {
  103869. /**
  103870. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  103871. * * 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
  103872. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  103873. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  103874. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  103875. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  103876. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  103877. * * 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
  103878. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  103879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103880. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  103881. * @param name defines the name of the new line system
  103882. * @param options defines the options used to create the line system
  103883. * @param scene defines the hosting scene
  103884. * @returns a new line system mesh
  103885. */
  103886. static CreateLineSystem(name: string, options: {
  103887. lines: Vector3[][];
  103888. updatable?: boolean;
  103889. instance?: Nullable<LinesMesh>;
  103890. colors?: Nullable<Color4[][]>;
  103891. useVertexAlpha?: boolean;
  103892. }, scene: Nullable<Scene>): LinesMesh;
  103893. /**
  103894. * Creates a line mesh
  103895. * 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
  103896. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103897. * * The parameter `points` is an array successive Vector3
  103898. * * 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
  103899. * * The optional parameter `colors` is an array of successive Color4, one per line point
  103900. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  103901. * * When updating an instance, remember that only point positions can change, not the number of points
  103902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  103904. * @param name defines the name of the new line system
  103905. * @param options defines the options used to create the line system
  103906. * @param scene defines the hosting scene
  103907. * @returns a new line mesh
  103908. */
  103909. static CreateLines(name: string, options: {
  103910. points: Vector3[];
  103911. updatable?: boolean;
  103912. instance?: Nullable<LinesMesh>;
  103913. colors?: Color4[];
  103914. useVertexAlpha?: boolean;
  103915. }, scene?: Nullable<Scene>): LinesMesh;
  103916. /**
  103917. * Creates a dashed line mesh
  103918. * * 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
  103919. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103920. * * The parameter `points` is an array successive Vector3
  103921. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  103922. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  103923. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  103924. * * 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
  103925. * * When updating an instance, remember that only point positions can change, not the number of points
  103926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103927. * @param name defines the name of the mesh
  103928. * @param options defines the options used to create the mesh
  103929. * @param scene defines the hosting scene
  103930. * @returns the dashed line mesh
  103931. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  103932. */
  103933. static CreateDashedLines(name: string, options: {
  103934. points: Vector3[];
  103935. dashSize?: number;
  103936. gapSize?: number;
  103937. dashNb?: number;
  103938. updatable?: boolean;
  103939. instance?: LinesMesh;
  103940. }, scene?: Nullable<Scene>): LinesMesh;
  103941. }
  103942. }
  103943. declare module BABYLON {
  103944. /**
  103945. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  103946. * in order to better appreciate the issue one might have.
  103947. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  103948. */
  103949. export class RayHelper {
  103950. /**
  103951. * Defines the ray we are currently tryin to visualize.
  103952. */
  103953. ray: Nullable<Ray>;
  103954. private _renderPoints;
  103955. private _renderLine;
  103956. private _renderFunction;
  103957. private _scene;
  103958. private _updateToMeshFunction;
  103959. private _attachedToMesh;
  103960. private _meshSpaceDirection;
  103961. private _meshSpaceOrigin;
  103962. /**
  103963. * Helper function to create a colored helper in a scene in one line.
  103964. * @param ray Defines the ray we are currently tryin to visualize
  103965. * @param scene Defines the scene the ray is used in
  103966. * @param color Defines the color we want to see the ray in
  103967. * @returns The newly created ray helper.
  103968. */
  103969. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  103970. /**
  103971. * Instantiate a new ray helper.
  103972. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  103973. * in order to better appreciate the issue one might have.
  103974. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  103975. * @param ray Defines the ray we are currently tryin to visualize
  103976. */
  103977. constructor(ray: Ray);
  103978. /**
  103979. * Shows the ray we are willing to debug.
  103980. * @param scene Defines the scene the ray needs to be rendered in
  103981. * @param color Defines the color the ray needs to be rendered in
  103982. */
  103983. show(scene: Scene, color?: Color3): void;
  103984. /**
  103985. * Hides the ray we are debugging.
  103986. */
  103987. hide(): void;
  103988. private _render;
  103989. /**
  103990. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  103991. * @param mesh Defines the mesh we want the helper attached to
  103992. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  103993. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  103994. * @param length Defines the length of the ray
  103995. */
  103996. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  103997. /**
  103998. * Detach the ray helper from the mesh it has previously been attached to.
  103999. */
  104000. detachFromMesh(): void;
  104001. private _updateToMesh;
  104002. /**
  104003. * Dispose the helper and release its associated resources.
  104004. */
  104005. dispose(): void;
  104006. }
  104007. }
  104008. declare module BABYLON.Debug {
  104009. /**
  104010. * Class used to render a debug view of a given skeleton
  104011. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  104012. */
  104013. export class SkeletonViewer {
  104014. /** defines the skeleton to render */
  104015. skeleton: Skeleton;
  104016. /** defines the mesh attached to the skeleton */
  104017. mesh: AbstractMesh;
  104018. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104019. autoUpdateBonesMatrices: boolean;
  104020. /** defines the rendering group id to use with the viewer */
  104021. renderingGroupId: number;
  104022. /** Gets or sets the color used to render the skeleton */
  104023. color: Color3;
  104024. private _scene;
  104025. private _debugLines;
  104026. private _debugMesh;
  104027. private _isEnabled;
  104028. private _renderFunction;
  104029. private _utilityLayer;
  104030. /**
  104031. * Returns the mesh used to render the bones
  104032. */
  104033. readonly debugMesh: Nullable<LinesMesh>;
  104034. /**
  104035. * Creates a new SkeletonViewer
  104036. * @param skeleton defines the skeleton to render
  104037. * @param mesh defines the mesh attached to the skeleton
  104038. * @param scene defines the hosting scene
  104039. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  104040. * @param renderingGroupId defines the rendering group id to use with the viewer
  104041. */
  104042. constructor(
  104043. /** defines the skeleton to render */
  104044. skeleton: Skeleton,
  104045. /** defines the mesh attached to the skeleton */
  104046. mesh: AbstractMesh, scene: Scene,
  104047. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104048. autoUpdateBonesMatrices?: boolean,
  104049. /** defines the rendering group id to use with the viewer */
  104050. renderingGroupId?: number);
  104051. /** Gets or sets a boolean indicating if the viewer is enabled */
  104052. isEnabled: boolean;
  104053. private _getBonePosition;
  104054. private _getLinesForBonesWithLength;
  104055. private _getLinesForBonesNoLength;
  104056. /** Update the viewer to sync with current skeleton state */
  104057. update(): void;
  104058. /** Release associated resources */
  104059. dispose(): void;
  104060. }
  104061. }
  104062. declare module BABYLON {
  104063. /**
  104064. * Options to create the null engine
  104065. */
  104066. export class NullEngineOptions {
  104067. /**
  104068. * Render width (Default: 512)
  104069. */
  104070. renderWidth: number;
  104071. /**
  104072. * Render height (Default: 256)
  104073. */
  104074. renderHeight: number;
  104075. /**
  104076. * Texture size (Default: 512)
  104077. */
  104078. textureSize: number;
  104079. /**
  104080. * If delta time between frames should be constant
  104081. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104082. */
  104083. deterministicLockstep: boolean;
  104084. /**
  104085. * Maximum about of steps between frames (Default: 4)
  104086. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104087. */
  104088. lockstepMaxSteps: number;
  104089. }
  104090. /**
  104091. * The null engine class provides support for headless version of babylon.js.
  104092. * This can be used in server side scenario or for testing purposes
  104093. */
  104094. export class NullEngine extends Engine {
  104095. private _options;
  104096. /**
  104097. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104098. */
  104099. isDeterministicLockStep(): boolean;
  104100. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  104101. getLockstepMaxSteps(): number;
  104102. /**
  104103. * Sets hardware scaling, used to save performance if needed
  104104. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  104105. */
  104106. getHardwareScalingLevel(): number;
  104107. constructor(options?: NullEngineOptions);
  104108. createVertexBuffer(vertices: FloatArray): DataBuffer;
  104109. createIndexBuffer(indices: IndicesArray): DataBuffer;
  104110. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104111. getRenderWidth(useScreen?: boolean): number;
  104112. getRenderHeight(useScreen?: boolean): number;
  104113. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  104114. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  104115. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104116. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104117. bindSamplers(effect: Effect): void;
  104118. enableEffect(effect: Effect): void;
  104119. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104120. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  104121. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  104122. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  104123. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  104124. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  104125. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  104126. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  104127. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  104128. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  104129. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  104130. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  104131. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  104132. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  104133. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  104134. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104135. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104136. setFloat(uniform: WebGLUniformLocation, value: number): void;
  104137. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  104138. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  104139. setBool(uniform: WebGLUniformLocation, bool: number): void;
  104140. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  104141. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  104142. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  104143. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  104144. bindBuffers(vertexBuffers: {
  104145. [key: string]: VertexBuffer;
  104146. }, indexBuffer: DataBuffer, effect: Effect): void;
  104147. wipeCaches(bruteForce?: boolean): void;
  104148. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104149. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104150. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104151. /** @hidden */
  104152. _createTexture(): WebGLTexture;
  104153. /** @hidden */
  104154. _releaseTexture(texture: InternalTexture): void;
  104155. 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;
  104156. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  104157. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  104158. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  104159. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104160. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  104161. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  104162. areAllEffectsReady(): boolean;
  104163. /**
  104164. * @hidden
  104165. * Get the current error code of the webGL context
  104166. * @returns the error code
  104167. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104168. */
  104169. getError(): number;
  104170. /** @hidden */
  104171. _getUnpackAlignement(): number;
  104172. /** @hidden */
  104173. _unpackFlipY(value: boolean): void;
  104174. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  104175. /**
  104176. * Updates a dynamic vertex buffer.
  104177. * @param vertexBuffer the vertex buffer to update
  104178. * @param data the data used to update the vertex buffer
  104179. * @param byteOffset the byte offset of the data (optional)
  104180. * @param byteLength the byte length of the data (optional)
  104181. */
  104182. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  104183. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  104184. /** @hidden */
  104185. _bindTexture(channel: number, texture: InternalTexture): void;
  104186. /** @hidden */
  104187. _releaseBuffer(buffer: DataBuffer): boolean;
  104188. releaseEffects(): void;
  104189. displayLoadingUI(): void;
  104190. hideLoadingUI(): void;
  104191. /** @hidden */
  104192. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104193. /** @hidden */
  104194. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104195. /** @hidden */
  104196. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104197. /** @hidden */
  104198. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  104199. }
  104200. }
  104201. declare module BABYLON {
  104202. /** @hidden */
  104203. export class _OcclusionDataStorage {
  104204. /** @hidden */
  104205. occlusionInternalRetryCounter: number;
  104206. /** @hidden */
  104207. isOcclusionQueryInProgress: boolean;
  104208. /** @hidden */
  104209. isOccluded: boolean;
  104210. /** @hidden */
  104211. occlusionRetryCount: number;
  104212. /** @hidden */
  104213. occlusionType: number;
  104214. /** @hidden */
  104215. occlusionQueryAlgorithmType: number;
  104216. }
  104217. interface Engine {
  104218. /**
  104219. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  104220. * @return the new query
  104221. */
  104222. createQuery(): WebGLQuery;
  104223. /**
  104224. * Delete and release a webGL query
  104225. * @param query defines the query to delete
  104226. * @return the current engine
  104227. */
  104228. deleteQuery(query: WebGLQuery): Engine;
  104229. /**
  104230. * Check if a given query has resolved and got its value
  104231. * @param query defines the query to check
  104232. * @returns true if the query got its value
  104233. */
  104234. isQueryResultAvailable(query: WebGLQuery): boolean;
  104235. /**
  104236. * Gets the value of a given query
  104237. * @param query defines the query to check
  104238. * @returns the value of the query
  104239. */
  104240. getQueryResult(query: WebGLQuery): number;
  104241. /**
  104242. * Initiates an occlusion query
  104243. * @param algorithmType defines the algorithm to use
  104244. * @param query defines the query to use
  104245. * @returns the current engine
  104246. * @see http://doc.babylonjs.com/features/occlusionquery
  104247. */
  104248. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  104249. /**
  104250. * Ends an occlusion query
  104251. * @see http://doc.babylonjs.com/features/occlusionquery
  104252. * @param algorithmType defines the algorithm to use
  104253. * @returns the current engine
  104254. */
  104255. endOcclusionQuery(algorithmType: number): Engine;
  104256. /**
  104257. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  104258. * Please note that only one query can be issued at a time
  104259. * @returns a time token used to track the time span
  104260. */
  104261. startTimeQuery(): Nullable<_TimeToken>;
  104262. /**
  104263. * Ends a time query
  104264. * @param token defines the token used to measure the time span
  104265. * @returns the time spent (in ns)
  104266. */
  104267. endTimeQuery(token: _TimeToken): int;
  104268. /** @hidden */
  104269. _currentNonTimestampToken: Nullable<_TimeToken>;
  104270. /** @hidden */
  104271. _createTimeQuery(): WebGLQuery;
  104272. /** @hidden */
  104273. _deleteTimeQuery(query: WebGLQuery): void;
  104274. /** @hidden */
  104275. _getGlAlgorithmType(algorithmType: number): number;
  104276. /** @hidden */
  104277. _getTimeQueryResult(query: WebGLQuery): any;
  104278. /** @hidden */
  104279. _getTimeQueryAvailability(query: WebGLQuery): any;
  104280. }
  104281. interface AbstractMesh {
  104282. /**
  104283. * Backing filed
  104284. * @hidden
  104285. */
  104286. __occlusionDataStorage: _OcclusionDataStorage;
  104287. /**
  104288. * Access property
  104289. * @hidden
  104290. */
  104291. _occlusionDataStorage: _OcclusionDataStorage;
  104292. /**
  104293. * 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.
  104294. * The default value is -1 which means don't break the query and wait till the result
  104295. * @see http://doc.babylonjs.com/features/occlusionquery
  104296. */
  104297. occlusionRetryCount: number;
  104298. /**
  104299. * 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:
  104300. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  104301. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  104302. * * 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.
  104303. * @see http://doc.babylonjs.com/features/occlusionquery
  104304. */
  104305. occlusionType: number;
  104306. /**
  104307. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  104308. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  104309. * * 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.
  104310. * @see http://doc.babylonjs.com/features/occlusionquery
  104311. */
  104312. occlusionQueryAlgorithmType: number;
  104313. /**
  104314. * 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
  104315. * @see http://doc.babylonjs.com/features/occlusionquery
  104316. */
  104317. isOccluded: boolean;
  104318. /**
  104319. * Flag to check the progress status of the query
  104320. * @see http://doc.babylonjs.com/features/occlusionquery
  104321. */
  104322. isOcclusionQueryInProgress: boolean;
  104323. }
  104324. }
  104325. declare module BABYLON {
  104326. /** @hidden */
  104327. export var _forceTransformFeedbackToBundle: boolean;
  104328. interface Engine {
  104329. /**
  104330. * Creates a webGL transform feedback object
  104331. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  104332. * @returns the webGL transform feedback object
  104333. */
  104334. createTransformFeedback(): WebGLTransformFeedback;
  104335. /**
  104336. * Delete a webGL transform feedback object
  104337. * @param value defines the webGL transform feedback object to delete
  104338. */
  104339. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  104340. /**
  104341. * Bind a webGL transform feedback object to the webgl context
  104342. * @param value defines the webGL transform feedback object to bind
  104343. */
  104344. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  104345. /**
  104346. * Begins a transform feedback operation
  104347. * @param usePoints defines if points or triangles must be used
  104348. */
  104349. beginTransformFeedback(usePoints: boolean): void;
  104350. /**
  104351. * Ends a transform feedback operation
  104352. */
  104353. endTransformFeedback(): void;
  104354. /**
  104355. * Specify the varyings to use with transform feedback
  104356. * @param program defines the associated webGL program
  104357. * @param value defines the list of strings representing the varying names
  104358. */
  104359. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  104360. /**
  104361. * Bind a webGL buffer for a transform feedback operation
  104362. * @param value defines the webGL buffer to bind
  104363. */
  104364. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  104365. }
  104366. }
  104367. declare module BABYLON {
  104368. /**
  104369. * Creation options of the multi render target texture.
  104370. */
  104371. export interface IMultiRenderTargetOptions {
  104372. /**
  104373. * Define if the texture needs to create mip maps after render.
  104374. */
  104375. generateMipMaps?: boolean;
  104376. /**
  104377. * Define the types of all the draw buffers we want to create
  104378. */
  104379. types?: number[];
  104380. /**
  104381. * Define the sampling modes of all the draw buffers we want to create
  104382. */
  104383. samplingModes?: number[];
  104384. /**
  104385. * Define if a depth buffer is required
  104386. */
  104387. generateDepthBuffer?: boolean;
  104388. /**
  104389. * Define if a stencil buffer is required
  104390. */
  104391. generateStencilBuffer?: boolean;
  104392. /**
  104393. * Define if a depth texture is required instead of a depth buffer
  104394. */
  104395. generateDepthTexture?: boolean;
  104396. /**
  104397. * Define the number of desired draw buffers
  104398. */
  104399. textureCount?: number;
  104400. /**
  104401. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104402. */
  104403. doNotChangeAspectRatio?: boolean;
  104404. /**
  104405. * Define the default type of the buffers we are creating
  104406. */
  104407. defaultType?: number;
  104408. }
  104409. /**
  104410. * A multi render target, like a render target provides the ability to render to a texture.
  104411. * Unlike the render target, it can render to several draw buffers in one draw.
  104412. * This is specially interesting in deferred rendering or for any effects requiring more than
  104413. * just one color from a single pass.
  104414. */
  104415. export class MultiRenderTarget extends RenderTargetTexture {
  104416. private _internalTextures;
  104417. private _textures;
  104418. private _multiRenderTargetOptions;
  104419. /**
  104420. * Get if draw buffers are currently supported by the used hardware and browser.
  104421. */
  104422. readonly isSupported: boolean;
  104423. /**
  104424. * Get the list of textures generated by the multi render target.
  104425. */
  104426. readonly textures: Texture[];
  104427. /**
  104428. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104429. */
  104430. readonly depthTexture: Texture;
  104431. /**
  104432. * Set the wrapping mode on U of all the textures we are rendering to.
  104433. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104434. */
  104435. wrapU: number;
  104436. /**
  104437. * Set the wrapping mode on V of all the textures we are rendering to.
  104438. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104439. */
  104440. wrapV: number;
  104441. /**
  104442. * Instantiate a new multi render target texture.
  104443. * A multi render target, like a render target provides the ability to render to a texture.
  104444. * Unlike the render target, it can render to several draw buffers in one draw.
  104445. * This is specially interesting in deferred rendering or for any effects requiring more than
  104446. * just one color from a single pass.
  104447. * @param name Define the name of the texture
  104448. * @param size Define the size of the buffers to render to
  104449. * @param count Define the number of target we are rendering into
  104450. * @param scene Define the scene the texture belongs to
  104451. * @param options Define the options used to create the multi render target
  104452. */
  104453. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104454. /** @hidden */
  104455. _rebuild(): void;
  104456. private _createInternalTextures;
  104457. private _createTextures;
  104458. /**
  104459. * Define the number of samples used if MSAA is enabled.
  104460. */
  104461. samples: number;
  104462. /**
  104463. * Resize all the textures in the multi render target.
  104464. * Be carrefull as it will recreate all the data in the new texture.
  104465. * @param size Define the new size
  104466. */
  104467. resize(size: any): void;
  104468. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104469. /**
  104470. * Dispose the render targets and their associated resources
  104471. */
  104472. dispose(): void;
  104473. /**
  104474. * Release all the underlying texture used as draw buffers.
  104475. */
  104476. releaseInternalTextures(): void;
  104477. }
  104478. }
  104479. declare module BABYLON {
  104480. interface Engine {
  104481. /**
  104482. * Unbind a list of render target textures from the webGL context
  104483. * This is used only when drawBuffer extension or webGL2 are active
  104484. * @param textures defines the render target textures to unbind
  104485. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104486. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104487. */
  104488. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104489. /**
  104490. * Create a multi render target texture
  104491. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  104492. * @param size defines the size of the texture
  104493. * @param options defines the creation options
  104494. * @returns the cube texture as an InternalTexture
  104495. */
  104496. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104497. /**
  104498. * Update the sample count for a given multiple render target texture
  104499. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104500. * @param textures defines the textures to update
  104501. * @param samples defines the sample count to set
  104502. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104503. */
  104504. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104505. }
  104506. }
  104507. declare module BABYLON {
  104508. /**
  104509. * Gather the list of clipboard event types as constants.
  104510. */
  104511. export class ClipboardEventTypes {
  104512. /**
  104513. * The clipboard event is fired when a copy command is active (pressed).
  104514. */
  104515. static readonly COPY: number;
  104516. /**
  104517. * The clipboard event is fired when a cut command is active (pressed).
  104518. */
  104519. static readonly CUT: number;
  104520. /**
  104521. * The clipboard event is fired when a paste command is active (pressed).
  104522. */
  104523. static readonly PASTE: number;
  104524. }
  104525. /**
  104526. * This class is used to store clipboard related info for the onClipboardObservable event.
  104527. */
  104528. export class ClipboardInfo {
  104529. /**
  104530. * Defines the type of event (BABYLON.ClipboardEventTypes)
  104531. */
  104532. type: number;
  104533. /**
  104534. * Defines the related dom event
  104535. */
  104536. event: ClipboardEvent;
  104537. /**
  104538. *Creates an instance of ClipboardInfo.
  104539. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  104540. * @param event Defines the related dom event
  104541. */
  104542. constructor(
  104543. /**
  104544. * Defines the type of event (BABYLON.ClipboardEventTypes)
  104545. */
  104546. type: number,
  104547. /**
  104548. * Defines the related dom event
  104549. */
  104550. event: ClipboardEvent);
  104551. /**
  104552. * Get the clipboard event's type from the keycode.
  104553. * @param keyCode Defines the keyCode for the current keyboard event.
  104554. * @return {number}
  104555. */
  104556. static GetTypeFromCharacter(keyCode: number): number;
  104557. }
  104558. }
  104559. declare module BABYLON {
  104560. /**
  104561. * Class used to represent data loading progression
  104562. */
  104563. export class SceneLoaderProgressEvent {
  104564. /** defines if data length to load can be evaluated */
  104565. readonly lengthComputable: boolean;
  104566. /** defines the loaded data length */
  104567. readonly loaded: number;
  104568. /** defines the data length to load */
  104569. readonly total: number;
  104570. /**
  104571. * Create a new progress event
  104572. * @param lengthComputable defines if data length to load can be evaluated
  104573. * @param loaded defines the loaded data length
  104574. * @param total defines the data length to load
  104575. */
  104576. constructor(
  104577. /** defines if data length to load can be evaluated */
  104578. lengthComputable: boolean,
  104579. /** defines the loaded data length */
  104580. loaded: number,
  104581. /** defines the data length to load */
  104582. total: number);
  104583. /**
  104584. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  104585. * @param event defines the source event
  104586. * @returns a new SceneLoaderProgressEvent
  104587. */
  104588. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  104589. }
  104590. /**
  104591. * Interface used by SceneLoader plugins to define supported file extensions
  104592. */
  104593. export interface ISceneLoaderPluginExtensions {
  104594. /**
  104595. * Defines the list of supported extensions
  104596. */
  104597. [extension: string]: {
  104598. isBinary: boolean;
  104599. };
  104600. }
  104601. /**
  104602. * Interface used by SceneLoader plugin factory
  104603. */
  104604. export interface ISceneLoaderPluginFactory {
  104605. /**
  104606. * Defines the name of the factory
  104607. */
  104608. name: string;
  104609. /**
  104610. * Function called to create a new plugin
  104611. * @return the new plugin
  104612. */
  104613. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  104614. /**
  104615. * Boolean indicating if the plugin can direct load specific data
  104616. */
  104617. canDirectLoad?: (data: string) => boolean;
  104618. }
  104619. /**
  104620. * Interface used to define a SceneLoader plugin
  104621. */
  104622. export interface ISceneLoaderPlugin {
  104623. /**
  104624. * The friendly name of this plugin.
  104625. */
  104626. name: string;
  104627. /**
  104628. * The file extensions supported by this plugin.
  104629. */
  104630. extensions: string | ISceneLoaderPluginExtensions;
  104631. /**
  104632. * Import meshes into a scene.
  104633. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104634. * @param scene The scene to import into
  104635. * @param data The data to import
  104636. * @param rootUrl The root url for scene and resources
  104637. * @param meshes The meshes array to import into
  104638. * @param particleSystems The particle systems array to import into
  104639. * @param skeletons The skeletons array to import into
  104640. * @param onError The callback when import fails
  104641. * @returns True if successful or false otherwise
  104642. */
  104643. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  104644. /**
  104645. * Load into a scene.
  104646. * @param scene The scene to load into
  104647. * @param data The data to import
  104648. * @param rootUrl The root url for scene and resources
  104649. * @param onError The callback when import fails
  104650. * @returns true if successful or false otherwise
  104651. */
  104652. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  104653. /**
  104654. * The callback that returns true if the data can be directly loaded.
  104655. */
  104656. canDirectLoad?: (data: string) => boolean;
  104657. /**
  104658. * The callback that allows custom handling of the root url based on the response url.
  104659. */
  104660. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104661. /**
  104662. * Load into an asset container.
  104663. * @param scene The scene to load into
  104664. * @param data The data to import
  104665. * @param rootUrl The root url for scene and resources
  104666. * @param onError The callback when import fails
  104667. * @returns The loaded asset container
  104668. */
  104669. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  104670. }
  104671. /**
  104672. * Interface used to define an async SceneLoader plugin
  104673. */
  104674. export interface ISceneLoaderPluginAsync {
  104675. /**
  104676. * The friendly name of this plugin.
  104677. */
  104678. name: string;
  104679. /**
  104680. * The file extensions supported by this plugin.
  104681. */
  104682. extensions: string | ISceneLoaderPluginExtensions;
  104683. /**
  104684. * Import meshes into a scene.
  104685. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104686. * @param scene The scene to import into
  104687. * @param data The data to import
  104688. * @param rootUrl The root url for scene and resources
  104689. * @param onProgress The callback when the load progresses
  104690. * @param fileName Defines the name of the file to load
  104691. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  104692. */
  104693. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  104694. meshes: AbstractMesh[];
  104695. particleSystems: IParticleSystem[];
  104696. skeletons: Skeleton[];
  104697. animationGroups: AnimationGroup[];
  104698. }>;
  104699. /**
  104700. * Load into a scene.
  104701. * @param scene The scene to load into
  104702. * @param data The data to import
  104703. * @param rootUrl The root url for scene and resources
  104704. * @param onProgress The callback when the load progresses
  104705. * @param fileName Defines the name of the file to load
  104706. * @returns Nothing
  104707. */
  104708. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  104709. /**
  104710. * The callback that returns true if the data can be directly loaded.
  104711. */
  104712. canDirectLoad?: (data: string) => boolean;
  104713. /**
  104714. * The callback that allows custom handling of the root url based on the response url.
  104715. */
  104716. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104717. /**
  104718. * Load into an asset container.
  104719. * @param scene The scene to load into
  104720. * @param data The data to import
  104721. * @param rootUrl The root url for scene and resources
  104722. * @param onProgress The callback when the load progresses
  104723. * @param fileName Defines the name of the file to load
  104724. * @returns The loaded asset container
  104725. */
  104726. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  104727. }
  104728. /**
  104729. * Class used to load scene from various file formats using registered plugins
  104730. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  104731. */
  104732. export class SceneLoader {
  104733. /**
  104734. * No logging while loading
  104735. */
  104736. static readonly NO_LOGGING: number;
  104737. /**
  104738. * Minimal logging while loading
  104739. */
  104740. static readonly MINIMAL_LOGGING: number;
  104741. /**
  104742. * Summary logging while loading
  104743. */
  104744. static readonly SUMMARY_LOGGING: number;
  104745. /**
  104746. * Detailled logging while loading
  104747. */
  104748. static readonly DETAILED_LOGGING: number;
  104749. /**
  104750. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  104751. */
  104752. static ForceFullSceneLoadingForIncremental: boolean;
  104753. /**
  104754. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  104755. */
  104756. static ShowLoadingScreen: boolean;
  104757. /**
  104758. * Defines the current logging level (while loading the scene)
  104759. * @ignorenaming
  104760. */
  104761. static loggingLevel: number;
  104762. /**
  104763. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  104764. */
  104765. static CleanBoneMatrixWeights: boolean;
  104766. /**
  104767. * Event raised when a plugin is used to load a scene
  104768. */
  104769. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  104770. private static _registeredPlugins;
  104771. private static _getDefaultPlugin;
  104772. private static _getPluginForExtension;
  104773. private static _getPluginForDirectLoad;
  104774. private static _getPluginForFilename;
  104775. private static _getDirectLoad;
  104776. private static _loadData;
  104777. private static _getFileInfo;
  104778. /**
  104779. * Gets a plugin that can load the given extension
  104780. * @param extension defines the extension to load
  104781. * @returns a plugin or null if none works
  104782. */
  104783. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  104784. /**
  104785. * Gets a boolean indicating that the given extension can be loaded
  104786. * @param extension defines the extension to load
  104787. * @returns true if the extension is supported
  104788. */
  104789. static IsPluginForExtensionAvailable(extension: string): boolean;
  104790. /**
  104791. * Adds a new plugin to the list of registered plugins
  104792. * @param plugin defines the plugin to add
  104793. */
  104794. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  104795. /**
  104796. * Import meshes into a scene
  104797. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104798. * @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)
  104799. * @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)
  104800. * @param scene the instance of BABYLON.Scene to append to
  104801. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  104802. * @param onProgress a callback with a progress event for each file being loaded
  104803. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104804. * @param pluginExtension the extension used to determine the plugin
  104805. * @returns The loaded plugin
  104806. */
  104807. 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>;
  104808. /**
  104809. * Import meshes into a scene
  104810. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104811. * @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)
  104812. * @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)
  104813. * @param scene the instance of BABYLON.Scene to append to
  104814. * @param onProgress a callback with a progress event for each file being loaded
  104815. * @param pluginExtension the extension used to determine the plugin
  104816. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  104817. */
  104818. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  104819. meshes: AbstractMesh[];
  104820. particleSystems: IParticleSystem[];
  104821. skeletons: Skeleton[];
  104822. animationGroups: AnimationGroup[];
  104823. }>;
  104824. /**
  104825. * Load a scene
  104826. * @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)
  104827. * @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)
  104828. * @param engine is the instance of BABYLON.Engine to use to create the scene
  104829. * @param onSuccess a callback with the scene when import succeeds
  104830. * @param onProgress a callback with a progress event for each file being loaded
  104831. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104832. * @param pluginExtension the extension used to determine the plugin
  104833. * @returns The loaded plugin
  104834. */
  104835. 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>;
  104836. /**
  104837. * Load a scene
  104838. * @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)
  104839. * @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)
  104840. * @param engine is the instance of BABYLON.Engine to use to create the scene
  104841. * @param onProgress a callback with a progress event for each file being loaded
  104842. * @param pluginExtension the extension used to determine the plugin
  104843. * @returns The loaded scene
  104844. */
  104845. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  104846. /**
  104847. * Append a scene
  104848. * @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)
  104849. * @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)
  104850. * @param scene is the instance of BABYLON.Scene to append to
  104851. * @param onSuccess a callback with the scene when import succeeds
  104852. * @param onProgress a callback with a progress event for each file being loaded
  104853. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104854. * @param pluginExtension the extension used to determine the plugin
  104855. * @returns The loaded plugin
  104856. */
  104857. 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>;
  104858. /**
  104859. * Append a scene
  104860. * @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)
  104861. * @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)
  104862. * @param scene is the instance of BABYLON.Scene to append to
  104863. * @param onProgress a callback with a progress event for each file being loaded
  104864. * @param pluginExtension the extension used to determine the plugin
  104865. * @returns The given scene
  104866. */
  104867. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  104868. /**
  104869. * Load a scene into an asset container
  104870. * @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)
  104871. * @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)
  104872. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  104873. * @param onSuccess a callback with the scene when import succeeds
  104874. * @param onProgress a callback with a progress event for each file being loaded
  104875. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104876. * @param pluginExtension the extension used to determine the plugin
  104877. * @returns The loaded plugin
  104878. */
  104879. 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>;
  104880. /**
  104881. * Load a scene into an asset container
  104882. * @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)
  104883. * @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)
  104884. * @param scene is the instance of Scene to append to
  104885. * @param onProgress a callback with a progress event for each file being loaded
  104886. * @param pluginExtension the extension used to determine the plugin
  104887. * @returns The loaded asset container
  104888. */
  104889. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  104890. }
  104891. }
  104892. declare module BABYLON {
  104893. /**
  104894. * Google Daydream controller
  104895. */
  104896. export class DaydreamController extends WebVRController {
  104897. /**
  104898. * Base Url for the controller model.
  104899. */
  104900. static MODEL_BASE_URL: string;
  104901. /**
  104902. * File name for the controller model.
  104903. */
  104904. static MODEL_FILENAME: string;
  104905. /**
  104906. * Gamepad Id prefix used to identify Daydream Controller.
  104907. */
  104908. static readonly GAMEPAD_ID_PREFIX: string;
  104909. /**
  104910. * Creates a new DaydreamController from a gamepad
  104911. * @param vrGamepad the gamepad that the controller should be created from
  104912. */
  104913. constructor(vrGamepad: any);
  104914. /**
  104915. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104916. * @param scene scene in which to add meshes
  104917. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104918. */
  104919. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104920. /**
  104921. * Called once for each button that changed state since the last frame
  104922. * @param buttonIdx Which button index changed
  104923. * @param state New state of the button
  104924. * @param changes Which properties on the state changed since last frame
  104925. */
  104926. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104927. }
  104928. }
  104929. declare module BABYLON {
  104930. /**
  104931. * Gear VR Controller
  104932. */
  104933. export class GearVRController extends WebVRController {
  104934. /**
  104935. * Base Url for the controller model.
  104936. */
  104937. static MODEL_BASE_URL: string;
  104938. /**
  104939. * File name for the controller model.
  104940. */
  104941. static MODEL_FILENAME: string;
  104942. /**
  104943. * Gamepad Id prefix used to identify this controller.
  104944. */
  104945. static readonly GAMEPAD_ID_PREFIX: string;
  104946. private readonly _buttonIndexToObservableNameMap;
  104947. /**
  104948. * Creates a new GearVRController from a gamepad
  104949. * @param vrGamepad the gamepad that the controller should be created from
  104950. */
  104951. constructor(vrGamepad: any);
  104952. /**
  104953. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104954. * @param scene scene in which to add meshes
  104955. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104956. */
  104957. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104958. /**
  104959. * Called once for each button that changed state since the last frame
  104960. * @param buttonIdx Which button index changed
  104961. * @param state New state of the button
  104962. * @param changes Which properties on the state changed since last frame
  104963. */
  104964. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104965. }
  104966. }
  104967. declare module BABYLON {
  104968. /**
  104969. * Generic Controller
  104970. */
  104971. export class GenericController extends WebVRController {
  104972. /**
  104973. * Base Url for the controller model.
  104974. */
  104975. static readonly MODEL_BASE_URL: string;
  104976. /**
  104977. * File name for the controller model.
  104978. */
  104979. static readonly MODEL_FILENAME: string;
  104980. /**
  104981. * Creates a new GenericController from a gamepad
  104982. * @param vrGamepad the gamepad that the controller should be created from
  104983. */
  104984. constructor(vrGamepad: any);
  104985. /**
  104986. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104987. * @param scene scene in which to add meshes
  104988. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104989. */
  104990. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104991. /**
  104992. * Called once for each button that changed state since the last frame
  104993. * @param buttonIdx Which button index changed
  104994. * @param state New state of the button
  104995. * @param changes Which properties on the state changed since last frame
  104996. */
  104997. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104998. }
  104999. }
  105000. declare module BABYLON {
  105001. /**
  105002. * Oculus Touch Controller
  105003. */
  105004. export class OculusTouchController extends WebVRController {
  105005. /**
  105006. * Base Url for the controller model.
  105007. */
  105008. static MODEL_BASE_URL: string;
  105009. /**
  105010. * File name for the left controller model.
  105011. */
  105012. static MODEL_LEFT_FILENAME: string;
  105013. /**
  105014. * File name for the right controller model.
  105015. */
  105016. static MODEL_RIGHT_FILENAME: string;
  105017. /**
  105018. * Fired when the secondary trigger on this controller is modified
  105019. */
  105020. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105021. /**
  105022. * Fired when the thumb rest on this controller is modified
  105023. */
  105024. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105025. /**
  105026. * Creates a new OculusTouchController from a gamepad
  105027. * @param vrGamepad the gamepad that the controller should be created from
  105028. */
  105029. constructor(vrGamepad: any);
  105030. /**
  105031. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105032. * @param scene scene in which to add meshes
  105033. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105034. */
  105035. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105036. /**
  105037. * Fired when the A button on this controller is modified
  105038. */
  105039. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105040. /**
  105041. * Fired when the B button on this controller is modified
  105042. */
  105043. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105044. /**
  105045. * Fired when the X button on this controller is modified
  105046. */
  105047. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105048. /**
  105049. * Fired when the Y button on this controller is modified
  105050. */
  105051. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105052. /**
  105053. * Called once for each button that changed state since the last frame
  105054. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105055. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105056. * 2) secondary trigger (same)
  105057. * 3) A (right) X (left), touch, pressed = value
  105058. * 4) B / Y
  105059. * 5) thumb rest
  105060. * @param buttonIdx Which button index changed
  105061. * @param state New state of the button
  105062. * @param changes Which properties on the state changed since last frame
  105063. */
  105064. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105065. }
  105066. }
  105067. declare module BABYLON {
  105068. /**
  105069. * Vive Controller
  105070. */
  105071. export class ViveController extends WebVRController {
  105072. /**
  105073. * Base Url for the controller model.
  105074. */
  105075. static MODEL_BASE_URL: string;
  105076. /**
  105077. * File name for the controller model.
  105078. */
  105079. static MODEL_FILENAME: string;
  105080. /**
  105081. * Creates a new ViveController from a gamepad
  105082. * @param vrGamepad the gamepad that the controller should be created from
  105083. */
  105084. constructor(vrGamepad: any);
  105085. /**
  105086. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105087. * @param scene scene in which to add meshes
  105088. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105089. */
  105090. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105091. /**
  105092. * Fired when the left button on this controller is modified
  105093. */
  105094. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105095. /**
  105096. * Fired when the right button on this controller is modified
  105097. */
  105098. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105099. /**
  105100. * Fired when the menu button on this controller is modified
  105101. */
  105102. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105103. /**
  105104. * Called once for each button that changed state since the last frame
  105105. * Vive mapping:
  105106. * 0: touchpad
  105107. * 1: trigger
  105108. * 2: left AND right buttons
  105109. * 3: menu button
  105110. * @param buttonIdx Which button index changed
  105111. * @param state New state of the button
  105112. * @param changes Which properties on the state changed since last frame
  105113. */
  105114. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105115. }
  105116. }
  105117. declare module BABYLON {
  105118. /**
  105119. * Defines the WindowsMotionController object that the state of the windows motion controller
  105120. */
  105121. export class WindowsMotionController extends WebVRController {
  105122. /**
  105123. * The base url used to load the left and right controller models
  105124. */
  105125. static MODEL_BASE_URL: string;
  105126. /**
  105127. * The name of the left controller model file
  105128. */
  105129. static MODEL_LEFT_FILENAME: string;
  105130. /**
  105131. * The name of the right controller model file
  105132. */
  105133. static MODEL_RIGHT_FILENAME: string;
  105134. /**
  105135. * The controller name prefix for this controller type
  105136. */
  105137. static readonly GAMEPAD_ID_PREFIX: string;
  105138. /**
  105139. * The controller id pattern for this controller type
  105140. */
  105141. private static readonly GAMEPAD_ID_PATTERN;
  105142. private _loadedMeshInfo;
  105143. private readonly _mapping;
  105144. /**
  105145. * Fired when the trackpad on this controller is clicked
  105146. */
  105147. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105148. /**
  105149. * Fired when the trackpad on this controller is modified
  105150. */
  105151. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105152. /**
  105153. * The current x and y values of this controller's trackpad
  105154. */
  105155. trackpad: StickValues;
  105156. /**
  105157. * Creates a new WindowsMotionController from a gamepad
  105158. * @param vrGamepad the gamepad that the controller should be created from
  105159. */
  105160. constructor(vrGamepad: any);
  105161. /**
  105162. * Fired when the trigger on this controller is modified
  105163. */
  105164. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105165. /**
  105166. * Fired when the menu button on this controller is modified
  105167. */
  105168. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105169. /**
  105170. * Fired when the grip button on this controller is modified
  105171. */
  105172. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105173. /**
  105174. * Fired when the thumbstick button on this controller is modified
  105175. */
  105176. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105177. /**
  105178. * Fired when the touchpad button on this controller is modified
  105179. */
  105180. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105181. /**
  105182. * Fired when the touchpad values on this controller are modified
  105183. */
  105184. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105185. private _updateTrackpad;
  105186. /**
  105187. * Called once per frame by the engine.
  105188. */
  105189. update(): void;
  105190. /**
  105191. * Called once for each button that changed state since the last frame
  105192. * @param buttonIdx Which button index changed
  105193. * @param state New state of the button
  105194. * @param changes Which properties on the state changed since last frame
  105195. */
  105196. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105197. /**
  105198. * Moves the buttons on the controller mesh based on their current state
  105199. * @param buttonName the name of the button to move
  105200. * @param buttonValue the value of the button which determines the buttons new position
  105201. */
  105202. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  105203. /**
  105204. * Moves the axis on the controller mesh based on its current state
  105205. * @param axis the index of the axis
  105206. * @param axisValue the value of the axis which determines the meshes new position
  105207. * @hidden
  105208. */
  105209. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  105210. /**
  105211. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105212. * @param scene scene in which to add meshes
  105213. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105214. */
  105215. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  105216. /**
  105217. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  105218. * can be transformed by button presses and axes values, based on this._mapping.
  105219. *
  105220. * @param scene scene in which the meshes exist
  105221. * @param meshes list of meshes that make up the controller model to process
  105222. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  105223. */
  105224. private processModel;
  105225. private createMeshInfo;
  105226. /**
  105227. * Gets the ray of the controller in the direction the controller is pointing
  105228. * @param length the length the resulting ray should be
  105229. * @returns a ray in the direction the controller is pointing
  105230. */
  105231. getForwardRay(length?: number): Ray;
  105232. /**
  105233. * Disposes of the controller
  105234. */
  105235. dispose(): void;
  105236. }
  105237. }
  105238. declare module BABYLON {
  105239. /**
  105240. * Class containing static functions to help procedurally build meshes
  105241. */
  105242. export class PolyhedronBuilder {
  105243. /**
  105244. * Creates a polyhedron mesh
  105245. * * 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
  105246. * * The parameter `size` (positive float, default 1) sets the polygon size
  105247. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105248. * * 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`
  105249. * * 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
  105250. * * 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)`)
  105251. * * 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
  105252. * * 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
  105253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105256. * @param name defines the name of the mesh
  105257. * @param options defines the options used to create the mesh
  105258. * @param scene defines the hosting scene
  105259. * @returns the polyhedron mesh
  105260. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  105261. */
  105262. static CreatePolyhedron(name: string, options: {
  105263. type?: number;
  105264. size?: number;
  105265. sizeX?: number;
  105266. sizeY?: number;
  105267. sizeZ?: number;
  105268. custom?: any;
  105269. faceUV?: Vector4[];
  105270. faceColors?: Color4[];
  105271. flat?: boolean;
  105272. updatable?: boolean;
  105273. sideOrientation?: number;
  105274. frontUVs?: Vector4;
  105275. backUVs?: Vector4;
  105276. }, scene?: Nullable<Scene>): Mesh;
  105277. }
  105278. }
  105279. declare module BABYLON {
  105280. /**
  105281. * Gizmo that enables scaling a mesh along 3 axis
  105282. */
  105283. export class ScaleGizmo extends Gizmo {
  105284. /**
  105285. * Internal gizmo used for interactions on the x axis
  105286. */
  105287. xGizmo: AxisScaleGizmo;
  105288. /**
  105289. * Internal gizmo used for interactions on the y axis
  105290. */
  105291. yGizmo: AxisScaleGizmo;
  105292. /**
  105293. * Internal gizmo used for interactions on the z axis
  105294. */
  105295. zGizmo: AxisScaleGizmo;
  105296. /**
  105297. * Internal gizmo used to scale all axis equally
  105298. */
  105299. uniformScaleGizmo: AxisScaleGizmo;
  105300. private _meshAttached;
  105301. private _updateGizmoRotationToMatchAttachedMesh;
  105302. private _snapDistance;
  105303. private _scaleRatio;
  105304. private _uniformScalingMesh;
  105305. private _octahedron;
  105306. /** Fires an event when any of it's sub gizmos are dragged */
  105307. onDragStartObservable: Observable<{}>;
  105308. /** Fires an event when any of it's sub gizmos are released from dragging */
  105309. onDragEndObservable: Observable<{}>;
  105310. attachedMesh: Nullable<AbstractMesh>;
  105311. /**
  105312. * Creates a ScaleGizmo
  105313. * @param gizmoLayer The utility layer the gizmo will be added to
  105314. */
  105315. constructor(gizmoLayer?: UtilityLayerRenderer);
  105316. updateGizmoRotationToMatchAttachedMesh: boolean;
  105317. /**
  105318. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105319. */
  105320. snapDistance: number;
  105321. /**
  105322. * Ratio for the scale of the gizmo (Default: 1)
  105323. */
  105324. scaleRatio: number;
  105325. /**
  105326. * Disposes of the gizmo
  105327. */
  105328. dispose(): void;
  105329. }
  105330. }
  105331. declare module BABYLON {
  105332. /**
  105333. * Single axis scale gizmo
  105334. */
  105335. export class AxisScaleGizmo extends Gizmo {
  105336. /**
  105337. * Drag behavior responsible for the gizmos dragging interactions
  105338. */
  105339. dragBehavior: PointerDragBehavior;
  105340. private _pointerObserver;
  105341. /**
  105342. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105343. */
  105344. snapDistance: number;
  105345. /**
  105346. * Event that fires each time the gizmo snaps to a new location.
  105347. * * snapDistance is the the change in distance
  105348. */
  105349. onSnapObservable: Observable<{
  105350. snapDistance: number;
  105351. }>;
  105352. /**
  105353. * If the scaling operation should be done on all axis (default: false)
  105354. */
  105355. uniformScaling: boolean;
  105356. private _isEnabled;
  105357. private _parent;
  105358. private _arrow;
  105359. private _coloredMaterial;
  105360. private _hoverMaterial;
  105361. /**
  105362. * Creates an AxisScaleGizmo
  105363. * @param gizmoLayer The utility layer the gizmo will be added to
  105364. * @param dragAxis The axis which the gizmo will be able to scale on
  105365. * @param color The color of the gizmo
  105366. */
  105367. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  105368. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105369. /**
  105370. * If the gizmo is enabled
  105371. */
  105372. isEnabled: boolean;
  105373. /**
  105374. * Disposes of the gizmo
  105375. */
  105376. dispose(): void;
  105377. /**
  105378. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  105379. * @param mesh The mesh to replace the default mesh of the gizmo
  105380. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  105381. */
  105382. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  105383. }
  105384. }
  105385. declare module BABYLON {
  105386. /**
  105387. * Bounding box gizmo
  105388. */
  105389. export class BoundingBoxGizmo extends Gizmo {
  105390. private _lineBoundingBox;
  105391. private _rotateSpheresParent;
  105392. private _scaleBoxesParent;
  105393. private _boundingDimensions;
  105394. private _renderObserver;
  105395. private _pointerObserver;
  105396. private _scaleDragSpeed;
  105397. private _tmpQuaternion;
  105398. private _tmpVector;
  105399. private _tmpRotationMatrix;
  105400. /**
  105401. * 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)
  105402. */
  105403. ignoreChildren: boolean;
  105404. /**
  105405. * 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)
  105406. */
  105407. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  105408. /**
  105409. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  105410. */
  105411. rotationSphereSize: number;
  105412. /**
  105413. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  105414. */
  105415. scaleBoxSize: number;
  105416. /**
  105417. * 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)
  105418. */
  105419. fixedDragMeshScreenSize: boolean;
  105420. /**
  105421. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  105422. */
  105423. fixedDragMeshScreenSizeDistanceFactor: number;
  105424. /**
  105425. * Fired when a rotation sphere or scale box is dragged
  105426. */
  105427. onDragStartObservable: Observable<{}>;
  105428. /**
  105429. * Fired when a scale box is dragged
  105430. */
  105431. onScaleBoxDragObservable: Observable<{}>;
  105432. /**
  105433. * Fired when a scale box drag is ended
  105434. */
  105435. onScaleBoxDragEndObservable: Observable<{}>;
  105436. /**
  105437. * Fired when a rotation sphere is dragged
  105438. */
  105439. onRotationSphereDragObservable: Observable<{}>;
  105440. /**
  105441. * Fired when a rotation sphere drag is ended
  105442. */
  105443. onRotationSphereDragEndObservable: Observable<{}>;
  105444. /**
  105445. * 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)
  105446. */
  105447. scalePivot: Nullable<Vector3>;
  105448. /**
  105449. * Mesh used as a pivot to rotate the attached mesh
  105450. */
  105451. private _anchorMesh;
  105452. private _existingMeshScale;
  105453. private _dragMesh;
  105454. private pointerDragBehavior;
  105455. private coloredMaterial;
  105456. private hoverColoredMaterial;
  105457. /**
  105458. * Sets the color of the bounding box gizmo
  105459. * @param color the color to set
  105460. */
  105461. setColor(color: Color3): void;
  105462. /**
  105463. * Creates an BoundingBoxGizmo
  105464. * @param gizmoLayer The utility layer the gizmo will be added to
  105465. * @param color The color of the gizmo
  105466. */
  105467. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  105468. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105469. private _selectNode;
  105470. /**
  105471. * Updates the bounding box information for the Gizmo
  105472. */
  105473. updateBoundingBox(): void;
  105474. private _updateRotationSpheres;
  105475. private _updateScaleBoxes;
  105476. /**
  105477. * Enables rotation on the specified axis and disables rotation on the others
  105478. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  105479. */
  105480. setEnabledRotationAxis(axis: string): void;
  105481. /**
  105482. * Enables/disables scaling
  105483. * @param enable if scaling should be enabled
  105484. */
  105485. setEnabledScaling(enable: boolean): void;
  105486. private _updateDummy;
  105487. /**
  105488. * Enables a pointer drag behavior on the bounding box of the gizmo
  105489. */
  105490. enableDragBehavior(): void;
  105491. /**
  105492. * Disposes of the gizmo
  105493. */
  105494. dispose(): void;
  105495. /**
  105496. * 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)
  105497. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  105498. * @returns the bounding box mesh with the passed in mesh as a child
  105499. */
  105500. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  105501. /**
  105502. * CustomMeshes are not supported by this gizmo
  105503. * @param mesh The mesh to replace the default mesh of the gizmo
  105504. */
  105505. setCustomMesh(mesh: Mesh): void;
  105506. }
  105507. }
  105508. declare module BABYLON {
  105509. /**
  105510. * Single plane rotation gizmo
  105511. */
  105512. export class PlaneRotationGizmo extends Gizmo {
  105513. /**
  105514. * Drag behavior responsible for the gizmos dragging interactions
  105515. */
  105516. dragBehavior: PointerDragBehavior;
  105517. private _pointerObserver;
  105518. /**
  105519. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  105520. */
  105521. snapDistance: number;
  105522. /**
  105523. * Event that fires each time the gizmo snaps to a new location.
  105524. * * snapDistance is the the change in distance
  105525. */
  105526. onSnapObservable: Observable<{
  105527. snapDistance: number;
  105528. }>;
  105529. private _isEnabled;
  105530. private _parent;
  105531. /**
  105532. * Creates a PlaneRotationGizmo
  105533. * @param gizmoLayer The utility layer the gizmo will be added to
  105534. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  105535. * @param color The color of the gizmo
  105536. * @param tessellation Amount of tessellation to be used when creating rotation circles
  105537. */
  105538. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  105539. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105540. /**
  105541. * If the gizmo is enabled
  105542. */
  105543. isEnabled: boolean;
  105544. /**
  105545. * Disposes of the gizmo
  105546. */
  105547. dispose(): void;
  105548. }
  105549. }
  105550. declare module BABYLON {
  105551. /**
  105552. * Gizmo that enables rotating a mesh along 3 axis
  105553. */
  105554. export class RotationGizmo extends Gizmo {
  105555. /**
  105556. * Internal gizmo used for interactions on the x axis
  105557. */
  105558. xGizmo: PlaneRotationGizmo;
  105559. /**
  105560. * Internal gizmo used for interactions on the y axis
  105561. */
  105562. yGizmo: PlaneRotationGizmo;
  105563. /**
  105564. * Internal gizmo used for interactions on the z axis
  105565. */
  105566. zGizmo: PlaneRotationGizmo;
  105567. /** Fires an event when any of it's sub gizmos are dragged */
  105568. onDragStartObservable: Observable<{}>;
  105569. /** Fires an event when any of it's sub gizmos are released from dragging */
  105570. onDragEndObservable: Observable<{}>;
  105571. private _meshAttached;
  105572. attachedMesh: Nullable<AbstractMesh>;
  105573. /**
  105574. * Creates a RotationGizmo
  105575. * @param gizmoLayer The utility layer the gizmo will be added to
  105576. * @param tessellation Amount of tessellation to be used when creating rotation circles
  105577. */
  105578. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  105579. updateGizmoRotationToMatchAttachedMesh: boolean;
  105580. /**
  105581. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105582. */
  105583. snapDistance: number;
  105584. /**
  105585. * Ratio for the scale of the gizmo (Default: 1)
  105586. */
  105587. scaleRatio: number;
  105588. /**
  105589. * Disposes of the gizmo
  105590. */
  105591. dispose(): void;
  105592. /**
  105593. * CustomMeshes are not supported by this gizmo
  105594. * @param mesh The mesh to replace the default mesh of the gizmo
  105595. */
  105596. setCustomMesh(mesh: Mesh): void;
  105597. }
  105598. }
  105599. declare module BABYLON {
  105600. /**
  105601. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  105602. */
  105603. export class GizmoManager implements IDisposable {
  105604. private scene;
  105605. /**
  105606. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  105607. */
  105608. gizmos: {
  105609. positionGizmo: Nullable<PositionGizmo>;
  105610. rotationGizmo: Nullable<RotationGizmo>;
  105611. scaleGizmo: Nullable<ScaleGizmo>;
  105612. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  105613. };
  105614. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  105615. clearGizmoOnEmptyPointerEvent: boolean;
  105616. /** Fires an event when the manager is attached to a mesh */
  105617. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  105618. private _gizmosEnabled;
  105619. private _pointerObserver;
  105620. private _attachedMesh;
  105621. private _boundingBoxColor;
  105622. private _defaultUtilityLayer;
  105623. private _defaultKeepDepthUtilityLayer;
  105624. /**
  105625. * When bounding box gizmo is enabled, this can be used to track drag/end events
  105626. */
  105627. boundingBoxDragBehavior: SixDofDragBehavior;
  105628. /**
  105629. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  105630. */
  105631. attachableMeshes: Nullable<Array<AbstractMesh>>;
  105632. /**
  105633. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  105634. */
  105635. usePointerToAttachGizmos: boolean;
  105636. /**
  105637. * Instatiates a gizmo manager
  105638. * @param scene the scene to overlay the gizmos on top of
  105639. */
  105640. constructor(scene: Scene);
  105641. /**
  105642. * Attaches a set of gizmos to the specified mesh
  105643. * @param mesh The mesh the gizmo's should be attached to
  105644. */
  105645. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  105646. /**
  105647. * If the position gizmo is enabled
  105648. */
  105649. positionGizmoEnabled: boolean;
  105650. /**
  105651. * If the rotation gizmo is enabled
  105652. */
  105653. rotationGizmoEnabled: boolean;
  105654. /**
  105655. * If the scale gizmo is enabled
  105656. */
  105657. scaleGizmoEnabled: boolean;
  105658. /**
  105659. * If the boundingBox gizmo is enabled
  105660. */
  105661. boundingBoxGizmoEnabled: boolean;
  105662. /**
  105663. * Disposes of the gizmo manager
  105664. */
  105665. dispose(): void;
  105666. }
  105667. }
  105668. declare module BABYLON {
  105669. /**
  105670. * A directional light is defined by a direction (what a surprise!).
  105671. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  105672. * 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.
  105673. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105674. */
  105675. export class DirectionalLight extends ShadowLight {
  105676. private _shadowFrustumSize;
  105677. /**
  105678. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  105679. */
  105680. /**
  105681. * Specifies a fix frustum size for the shadow generation.
  105682. */
  105683. shadowFrustumSize: number;
  105684. private _shadowOrthoScale;
  105685. /**
  105686. * Gets the shadow projection scale against the optimal computed one.
  105687. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105688. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105689. */
  105690. /**
  105691. * Sets the shadow projection scale against the optimal computed one.
  105692. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105693. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105694. */
  105695. shadowOrthoScale: number;
  105696. /**
  105697. * Automatically compute the projection matrix to best fit (including all the casters)
  105698. * on each frame.
  105699. */
  105700. autoUpdateExtends: boolean;
  105701. private _orthoLeft;
  105702. private _orthoRight;
  105703. private _orthoTop;
  105704. private _orthoBottom;
  105705. /**
  105706. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  105707. * The directional light is emitted from everywhere in the given direction.
  105708. * It can cast shadows.
  105709. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105710. * @param name The friendly name of the light
  105711. * @param direction The direction of the light
  105712. * @param scene The scene the light belongs to
  105713. */
  105714. constructor(name: string, direction: Vector3, scene: Scene);
  105715. /**
  105716. * Returns the string "DirectionalLight".
  105717. * @return The class name
  105718. */
  105719. getClassName(): string;
  105720. /**
  105721. * Returns the integer 1.
  105722. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105723. */
  105724. getTypeID(): number;
  105725. /**
  105726. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  105727. * Returns the DirectionalLight Shadow projection matrix.
  105728. */
  105729. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105730. /**
  105731. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  105732. * Returns the DirectionalLight Shadow projection matrix.
  105733. */
  105734. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  105735. /**
  105736. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  105737. * Returns the DirectionalLight Shadow projection matrix.
  105738. */
  105739. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105740. protected _buildUniformLayout(): void;
  105741. /**
  105742. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  105743. * @param effect The effect to update
  105744. * @param lightIndex The index of the light in the effect to update
  105745. * @returns The directional light
  105746. */
  105747. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  105748. /**
  105749. * Gets the minZ used for shadow according to both the scene and the light.
  105750. *
  105751. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105752. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105753. * @param activeCamera The camera we are returning the min for
  105754. * @returns the depth min z
  105755. */
  105756. getDepthMinZ(activeCamera: Camera): number;
  105757. /**
  105758. * Gets the maxZ used for shadow according to both the scene and the light.
  105759. *
  105760. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105761. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105762. * @param activeCamera The camera we are returning the max for
  105763. * @returns the depth max z
  105764. */
  105765. getDepthMaxZ(activeCamera: Camera): number;
  105766. /**
  105767. * Prepares the list of defines specific to the light type.
  105768. * @param defines the list of defines
  105769. * @param lightIndex defines the index of the light for the effect
  105770. */
  105771. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105772. }
  105773. }
  105774. declare module BABYLON {
  105775. /**
  105776. * Class containing static functions to help procedurally build meshes
  105777. */
  105778. export class HemisphereBuilder {
  105779. /**
  105780. * Creates a hemisphere mesh
  105781. * @param name defines the name of the mesh
  105782. * @param options defines the options used to create the mesh
  105783. * @param scene defines the hosting scene
  105784. * @returns the hemisphere mesh
  105785. */
  105786. static CreateHemisphere(name: string, options: {
  105787. segments?: number;
  105788. diameter?: number;
  105789. sideOrientation?: number;
  105790. }, scene: any): Mesh;
  105791. }
  105792. }
  105793. declare module BABYLON {
  105794. /**
  105795. * A spot light is defined by a position, a direction, an angle, and an exponent.
  105796. * These values define a cone of light starting from the position, emitting toward the direction.
  105797. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  105798. * and the exponent defines the speed of the decay of the light with distance (reach).
  105799. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105800. */
  105801. export class SpotLight extends ShadowLight {
  105802. private _angle;
  105803. private _innerAngle;
  105804. private _cosHalfAngle;
  105805. private _lightAngleScale;
  105806. private _lightAngleOffset;
  105807. /**
  105808. * Gets the cone angle of the spot light in Radians.
  105809. */
  105810. /**
  105811. * Sets the cone angle of the spot light in Radians.
  105812. */
  105813. angle: number;
  105814. /**
  105815. * Only used in gltf falloff mode, this defines the angle where
  105816. * the directional falloff will start before cutting at angle which could be seen
  105817. * as outer angle.
  105818. */
  105819. /**
  105820. * Only used in gltf falloff mode, this defines the angle where
  105821. * the directional falloff will start before cutting at angle which could be seen
  105822. * as outer angle.
  105823. */
  105824. innerAngle: number;
  105825. private _shadowAngleScale;
  105826. /**
  105827. * Allows scaling the angle of the light for shadow generation only.
  105828. */
  105829. /**
  105830. * Allows scaling the angle of the light for shadow generation only.
  105831. */
  105832. shadowAngleScale: number;
  105833. /**
  105834. * The light decay speed with the distance from the emission spot.
  105835. */
  105836. exponent: number;
  105837. private _projectionTextureMatrix;
  105838. /**
  105839. * Allows reading the projecton texture
  105840. */
  105841. readonly projectionTextureMatrix: Matrix;
  105842. protected _projectionTextureLightNear: number;
  105843. /**
  105844. * Gets the near clip of the Spotlight for texture projection.
  105845. */
  105846. /**
  105847. * Sets the near clip of the Spotlight for texture projection.
  105848. */
  105849. projectionTextureLightNear: number;
  105850. protected _projectionTextureLightFar: number;
  105851. /**
  105852. * Gets the far clip of the Spotlight for texture projection.
  105853. */
  105854. /**
  105855. * Sets the far clip of the Spotlight for texture projection.
  105856. */
  105857. projectionTextureLightFar: number;
  105858. protected _projectionTextureUpDirection: Vector3;
  105859. /**
  105860. * Gets the Up vector of the Spotlight for texture projection.
  105861. */
  105862. /**
  105863. * Sets the Up vector of the Spotlight for texture projection.
  105864. */
  105865. projectionTextureUpDirection: Vector3;
  105866. private _projectionTexture;
  105867. /**
  105868. * Gets the projection texture of the light.
  105869. */
  105870. /**
  105871. * Sets the projection texture of the light.
  105872. */
  105873. projectionTexture: Nullable<BaseTexture>;
  105874. private _projectionTextureViewLightDirty;
  105875. private _projectionTextureProjectionLightDirty;
  105876. private _projectionTextureDirty;
  105877. private _projectionTextureViewTargetVector;
  105878. private _projectionTextureViewLightMatrix;
  105879. private _projectionTextureProjectionLightMatrix;
  105880. private _projectionTextureScalingMatrix;
  105881. /**
  105882. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  105883. * It can cast shadows.
  105884. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105885. * @param name The light friendly name
  105886. * @param position The position of the spot light in the scene
  105887. * @param direction The direction of the light in the scene
  105888. * @param angle The cone angle of the light in Radians
  105889. * @param exponent The light decay speed with the distance from the emission spot
  105890. * @param scene The scene the lights belongs to
  105891. */
  105892. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  105893. /**
  105894. * Returns the string "SpotLight".
  105895. * @returns the class name
  105896. */
  105897. getClassName(): string;
  105898. /**
  105899. * Returns the integer 2.
  105900. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105901. */
  105902. getTypeID(): number;
  105903. /**
  105904. * Overrides the direction setter to recompute the projection texture view light Matrix.
  105905. */
  105906. protected _setDirection(value: Vector3): void;
  105907. /**
  105908. * Overrides the position setter to recompute the projection texture view light Matrix.
  105909. */
  105910. protected _setPosition(value: Vector3): void;
  105911. /**
  105912. * 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.
  105913. * Returns the SpotLight.
  105914. */
  105915. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105916. protected _computeProjectionTextureViewLightMatrix(): void;
  105917. protected _computeProjectionTextureProjectionLightMatrix(): void;
  105918. /**
  105919. * Main function for light texture projection matrix computing.
  105920. */
  105921. protected _computeProjectionTextureMatrix(): void;
  105922. protected _buildUniformLayout(): void;
  105923. private _computeAngleValues;
  105924. /**
  105925. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  105926. * @param effect The effect to update
  105927. * @param lightIndex The index of the light in the effect to update
  105928. * @returns The spot light
  105929. */
  105930. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  105931. /**
  105932. * Disposes the light and the associated resources.
  105933. */
  105934. dispose(): void;
  105935. /**
  105936. * Prepares the list of defines specific to the light type.
  105937. * @param defines the list of defines
  105938. * @param lightIndex defines the index of the light for the effect
  105939. */
  105940. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105941. }
  105942. }
  105943. declare module BABYLON {
  105944. /**
  105945. * Gizmo that enables viewing a light
  105946. */
  105947. export class LightGizmo extends Gizmo {
  105948. private _lightMesh;
  105949. private _material;
  105950. private cachedPosition;
  105951. private cachedForward;
  105952. /**
  105953. * Creates a LightGizmo
  105954. * @param gizmoLayer The utility layer the gizmo will be added to
  105955. */
  105956. constructor(gizmoLayer?: UtilityLayerRenderer);
  105957. private _light;
  105958. /**
  105959. * The light that the gizmo is attached to
  105960. */
  105961. light: Nullable<Light>;
  105962. /**
  105963. * @hidden
  105964. * Updates the gizmo to match the attached mesh's position/rotation
  105965. */
  105966. protected _update(): void;
  105967. private static _Scale;
  105968. /**
  105969. * Creates the lines for a light mesh
  105970. */
  105971. private static _createLightLines;
  105972. /**
  105973. * Disposes of the light gizmo
  105974. */
  105975. dispose(): void;
  105976. private static _CreateHemisphericLightMesh;
  105977. private static _CreatePointLightMesh;
  105978. private static _CreateSpotLightMesh;
  105979. private static _CreateDirectionalLightMesh;
  105980. }
  105981. }
  105982. declare module BABYLON {
  105983. /** @hidden */
  105984. export var backgroundFragmentDeclaration: {
  105985. name: string;
  105986. shader: string;
  105987. };
  105988. }
  105989. declare module BABYLON {
  105990. /** @hidden */
  105991. export var backgroundUboDeclaration: {
  105992. name: string;
  105993. shader: string;
  105994. };
  105995. }
  105996. declare module BABYLON {
  105997. /** @hidden */
  105998. export var backgroundPixelShader: {
  105999. name: string;
  106000. shader: string;
  106001. };
  106002. }
  106003. declare module BABYLON {
  106004. /** @hidden */
  106005. export var backgroundVertexDeclaration: {
  106006. name: string;
  106007. shader: string;
  106008. };
  106009. }
  106010. declare module BABYLON {
  106011. /** @hidden */
  106012. export var backgroundVertexShader: {
  106013. name: string;
  106014. shader: string;
  106015. };
  106016. }
  106017. declare module BABYLON {
  106018. /**
  106019. * Background material used to create an efficient environement around your scene.
  106020. */
  106021. export class BackgroundMaterial extends PushMaterial {
  106022. /**
  106023. * Standard reflectance value at parallel view angle.
  106024. */
  106025. static StandardReflectance0: number;
  106026. /**
  106027. * Standard reflectance value at grazing angle.
  106028. */
  106029. static StandardReflectance90: number;
  106030. protected _primaryColor: Color3;
  106031. /**
  106032. * Key light Color (multiply against the environement texture)
  106033. */
  106034. primaryColor: Color3;
  106035. protected __perceptualColor: Nullable<Color3>;
  106036. /**
  106037. * Experimental Internal Use Only.
  106038. *
  106039. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  106040. * This acts as a helper to set the primary color to a more "human friendly" value.
  106041. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  106042. * output color as close as possible from the chosen value.
  106043. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  106044. * part of lighting setup.)
  106045. */
  106046. _perceptualColor: Nullable<Color3>;
  106047. protected _primaryColorShadowLevel: float;
  106048. /**
  106049. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  106050. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  106051. */
  106052. primaryColorShadowLevel: float;
  106053. protected _primaryColorHighlightLevel: float;
  106054. /**
  106055. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  106056. * The primary color is used at the level chosen to define what the white area would look.
  106057. */
  106058. primaryColorHighlightLevel: float;
  106059. protected _reflectionTexture: Nullable<BaseTexture>;
  106060. /**
  106061. * Reflection Texture used in the material.
  106062. * Should be author in a specific way for the best result (refer to the documentation).
  106063. */
  106064. reflectionTexture: Nullable<BaseTexture>;
  106065. protected _reflectionBlur: float;
  106066. /**
  106067. * Reflection Texture level of blur.
  106068. *
  106069. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  106070. * texture twice.
  106071. */
  106072. reflectionBlur: float;
  106073. protected _diffuseTexture: Nullable<BaseTexture>;
  106074. /**
  106075. * Diffuse Texture used in the material.
  106076. * Should be author in a specific way for the best result (refer to the documentation).
  106077. */
  106078. diffuseTexture: Nullable<BaseTexture>;
  106079. protected _shadowLights: Nullable<IShadowLight[]>;
  106080. /**
  106081. * Specify the list of lights casting shadow on the material.
  106082. * All scene shadow lights will be included if null.
  106083. */
  106084. shadowLights: Nullable<IShadowLight[]>;
  106085. protected _shadowLevel: float;
  106086. /**
  106087. * Helps adjusting the shadow to a softer level if required.
  106088. * 0 means black shadows and 1 means no shadows.
  106089. */
  106090. shadowLevel: float;
  106091. protected _sceneCenter: Vector3;
  106092. /**
  106093. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  106094. * It is usually zero but might be interesting to modify according to your setup.
  106095. */
  106096. sceneCenter: Vector3;
  106097. protected _opacityFresnel: boolean;
  106098. /**
  106099. * This helps specifying that the material is falling off to the sky box at grazing angle.
  106100. * This helps ensuring a nice transition when the camera goes under the ground.
  106101. */
  106102. opacityFresnel: boolean;
  106103. protected _reflectionFresnel: boolean;
  106104. /**
  106105. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  106106. * This helps adding a mirror texture on the ground.
  106107. */
  106108. reflectionFresnel: boolean;
  106109. protected _reflectionFalloffDistance: number;
  106110. /**
  106111. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  106112. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  106113. */
  106114. reflectionFalloffDistance: number;
  106115. protected _reflectionAmount: number;
  106116. /**
  106117. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  106118. */
  106119. reflectionAmount: number;
  106120. protected _reflectionReflectance0: number;
  106121. /**
  106122. * This specifies the weight of the reflection at grazing angle.
  106123. */
  106124. reflectionReflectance0: number;
  106125. protected _reflectionReflectance90: number;
  106126. /**
  106127. * This specifies the weight of the reflection at a perpendicular point of view.
  106128. */
  106129. reflectionReflectance90: number;
  106130. /**
  106131. * Sets the reflection reflectance fresnel values according to the default standard
  106132. * empirically know to work well :-)
  106133. */
  106134. reflectionStandardFresnelWeight: number;
  106135. protected _useRGBColor: boolean;
  106136. /**
  106137. * Helps to directly use the maps channels instead of their level.
  106138. */
  106139. useRGBColor: boolean;
  106140. protected _enableNoise: boolean;
  106141. /**
  106142. * This helps reducing the banding effect that could occur on the background.
  106143. */
  106144. enableNoise: boolean;
  106145. /**
  106146. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106147. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  106148. * Recommended to be keep at 1.0 except for special cases.
  106149. */
  106150. fovMultiplier: number;
  106151. private _fovMultiplier;
  106152. /**
  106153. * Enable the FOV adjustment feature controlled by fovMultiplier.
  106154. */
  106155. useEquirectangularFOV: boolean;
  106156. private _maxSimultaneousLights;
  106157. /**
  106158. * Number of Simultaneous lights allowed on the material.
  106159. */
  106160. maxSimultaneousLights: int;
  106161. /**
  106162. * Default configuration related to image processing available in the Background Material.
  106163. */
  106164. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106165. /**
  106166. * Keep track of the image processing observer to allow dispose and replace.
  106167. */
  106168. private _imageProcessingObserver;
  106169. /**
  106170. * Attaches a new image processing configuration to the PBR Material.
  106171. * @param configuration (if null the scene configuration will be use)
  106172. */
  106173. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106174. /**
  106175. * Gets the image processing configuration used either in this material.
  106176. */
  106177. /**
  106178. * Sets the Default image processing configuration used either in the this material.
  106179. *
  106180. * If sets to null, the scene one is in use.
  106181. */
  106182. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  106183. /**
  106184. * Gets wether the color curves effect is enabled.
  106185. */
  106186. /**
  106187. * Sets wether the color curves effect is enabled.
  106188. */
  106189. cameraColorCurvesEnabled: boolean;
  106190. /**
  106191. * Gets wether the color grading effect is enabled.
  106192. */
  106193. /**
  106194. * Gets wether the color grading effect is enabled.
  106195. */
  106196. cameraColorGradingEnabled: boolean;
  106197. /**
  106198. * Gets wether tonemapping is enabled or not.
  106199. */
  106200. /**
  106201. * Sets wether tonemapping is enabled or not
  106202. */
  106203. cameraToneMappingEnabled: boolean;
  106204. /**
  106205. * The camera exposure used on this material.
  106206. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106207. * This corresponds to a photographic exposure.
  106208. */
  106209. /**
  106210. * The camera exposure used on this material.
  106211. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106212. * This corresponds to a photographic exposure.
  106213. */
  106214. cameraExposure: float;
  106215. /**
  106216. * Gets The camera contrast used on this material.
  106217. */
  106218. /**
  106219. * Sets The camera contrast used on this material.
  106220. */
  106221. cameraContrast: float;
  106222. /**
  106223. * Gets the Color Grading 2D Lookup Texture.
  106224. */
  106225. /**
  106226. * Sets the Color Grading 2D Lookup Texture.
  106227. */
  106228. cameraColorGradingTexture: Nullable<BaseTexture>;
  106229. /**
  106230. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106231. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106232. * 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;
  106233. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106234. */
  106235. /**
  106236. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106237. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106238. * 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;
  106239. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106240. */
  106241. cameraColorCurves: Nullable<ColorCurves>;
  106242. /**
  106243. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  106244. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  106245. */
  106246. switchToBGR: boolean;
  106247. private _renderTargets;
  106248. private _reflectionControls;
  106249. private _white;
  106250. private _primaryShadowColor;
  106251. private _primaryHighlightColor;
  106252. /**
  106253. * Instantiates a Background Material in the given scene
  106254. * @param name The friendly name of the material
  106255. * @param scene The scene to add the material to
  106256. */
  106257. constructor(name: string, scene: Scene);
  106258. /**
  106259. * Gets a boolean indicating that current material needs to register RTT
  106260. */
  106261. readonly hasRenderTargetTextures: boolean;
  106262. /**
  106263. * The entire material has been created in order to prevent overdraw.
  106264. * @returns false
  106265. */
  106266. needAlphaTesting(): boolean;
  106267. /**
  106268. * The entire material has been created in order to prevent overdraw.
  106269. * @returns true if blending is enable
  106270. */
  106271. needAlphaBlending(): boolean;
  106272. /**
  106273. * Checks wether the material is ready to be rendered for a given mesh.
  106274. * @param mesh The mesh to render
  106275. * @param subMesh The submesh to check against
  106276. * @param useInstances Specify wether or not the material is used with instances
  106277. * @returns true if all the dependencies are ready (Textures, Effects...)
  106278. */
  106279. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106280. /**
  106281. * Compute the primary color according to the chosen perceptual color.
  106282. */
  106283. private _computePrimaryColorFromPerceptualColor;
  106284. /**
  106285. * Compute the highlights and shadow colors according to their chosen levels.
  106286. */
  106287. private _computePrimaryColors;
  106288. /**
  106289. * Build the uniform buffer used in the material.
  106290. */
  106291. buildUniformLayout(): void;
  106292. /**
  106293. * Unbind the material.
  106294. */
  106295. unbind(): void;
  106296. /**
  106297. * Bind only the world matrix to the material.
  106298. * @param world The world matrix to bind.
  106299. */
  106300. bindOnlyWorldMatrix(world: Matrix): void;
  106301. /**
  106302. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  106303. * @param world The world matrix to bind.
  106304. * @param subMesh The submesh to bind for.
  106305. */
  106306. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106307. /**
  106308. * Dispose the material.
  106309. * @param forceDisposeEffect Force disposal of the associated effect.
  106310. * @param forceDisposeTextures Force disposal of the associated textures.
  106311. */
  106312. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106313. /**
  106314. * Clones the material.
  106315. * @param name The cloned name.
  106316. * @returns The cloned material.
  106317. */
  106318. clone(name: string): BackgroundMaterial;
  106319. /**
  106320. * Serializes the current material to its JSON representation.
  106321. * @returns The JSON representation.
  106322. */
  106323. serialize(): any;
  106324. /**
  106325. * Gets the class name of the material
  106326. * @returns "BackgroundMaterial"
  106327. */
  106328. getClassName(): string;
  106329. /**
  106330. * Parse a JSON input to create back a background material.
  106331. * @param source The JSON data to parse
  106332. * @param scene The scene to create the parsed material in
  106333. * @param rootUrl The root url of the assets the material depends upon
  106334. * @returns the instantiated BackgroundMaterial.
  106335. */
  106336. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  106337. }
  106338. }
  106339. declare module BABYLON {
  106340. /**
  106341. * Represents the different options available during the creation of
  106342. * a Environment helper.
  106343. *
  106344. * This can control the default ground, skybox and image processing setup of your scene.
  106345. */
  106346. export interface IEnvironmentHelperOptions {
  106347. /**
  106348. * Specifies wether or not to create a ground.
  106349. * True by default.
  106350. */
  106351. createGround: boolean;
  106352. /**
  106353. * Specifies the ground size.
  106354. * 15 by default.
  106355. */
  106356. groundSize: number;
  106357. /**
  106358. * The texture used on the ground for the main color.
  106359. * Comes from the BabylonJS CDN by default.
  106360. *
  106361. * Remarks: Can be either a texture or a url.
  106362. */
  106363. groundTexture: string | BaseTexture;
  106364. /**
  106365. * The color mixed in the ground texture by default.
  106366. * BabylonJS clearColor by default.
  106367. */
  106368. groundColor: Color3;
  106369. /**
  106370. * Specifies the ground opacity.
  106371. * 1 by default.
  106372. */
  106373. groundOpacity: number;
  106374. /**
  106375. * Enables the ground to receive shadows.
  106376. * True by default.
  106377. */
  106378. enableGroundShadow: boolean;
  106379. /**
  106380. * Helps preventing the shadow to be fully black on the ground.
  106381. * 0.5 by default.
  106382. */
  106383. groundShadowLevel: number;
  106384. /**
  106385. * Creates a mirror texture attach to the ground.
  106386. * false by default.
  106387. */
  106388. enableGroundMirror: boolean;
  106389. /**
  106390. * Specifies the ground mirror size ratio.
  106391. * 0.3 by default as the default kernel is 64.
  106392. */
  106393. groundMirrorSizeRatio: number;
  106394. /**
  106395. * Specifies the ground mirror blur kernel size.
  106396. * 64 by default.
  106397. */
  106398. groundMirrorBlurKernel: number;
  106399. /**
  106400. * Specifies the ground mirror visibility amount.
  106401. * 1 by default
  106402. */
  106403. groundMirrorAmount: number;
  106404. /**
  106405. * Specifies the ground mirror reflectance weight.
  106406. * This uses the standard weight of the background material to setup the fresnel effect
  106407. * of the mirror.
  106408. * 1 by default.
  106409. */
  106410. groundMirrorFresnelWeight: number;
  106411. /**
  106412. * Specifies the ground mirror Falloff distance.
  106413. * This can helps reducing the size of the reflection.
  106414. * 0 by Default.
  106415. */
  106416. groundMirrorFallOffDistance: number;
  106417. /**
  106418. * Specifies the ground mirror texture type.
  106419. * Unsigned Int by Default.
  106420. */
  106421. groundMirrorTextureType: number;
  106422. /**
  106423. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  106424. * the shown objects.
  106425. */
  106426. groundYBias: number;
  106427. /**
  106428. * Specifies wether or not to create a skybox.
  106429. * True by default.
  106430. */
  106431. createSkybox: boolean;
  106432. /**
  106433. * Specifies the skybox size.
  106434. * 20 by default.
  106435. */
  106436. skyboxSize: number;
  106437. /**
  106438. * The texture used on the skybox for the main color.
  106439. * Comes from the BabylonJS CDN by default.
  106440. *
  106441. * Remarks: Can be either a texture or a url.
  106442. */
  106443. skyboxTexture: string | BaseTexture;
  106444. /**
  106445. * The color mixed in the skybox texture by default.
  106446. * BabylonJS clearColor by default.
  106447. */
  106448. skyboxColor: Color3;
  106449. /**
  106450. * The background rotation around the Y axis of the scene.
  106451. * This helps aligning the key lights of your scene with the background.
  106452. * 0 by default.
  106453. */
  106454. backgroundYRotation: number;
  106455. /**
  106456. * Compute automatically the size of the elements to best fit with the scene.
  106457. */
  106458. sizeAuto: boolean;
  106459. /**
  106460. * Default position of the rootMesh if autoSize is not true.
  106461. */
  106462. rootPosition: Vector3;
  106463. /**
  106464. * Sets up the image processing in the scene.
  106465. * true by default.
  106466. */
  106467. setupImageProcessing: boolean;
  106468. /**
  106469. * The texture used as your environment texture in the scene.
  106470. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  106471. *
  106472. * Remarks: Can be either a texture or a url.
  106473. */
  106474. environmentTexture: string | BaseTexture;
  106475. /**
  106476. * The value of the exposure to apply to the scene.
  106477. * 0.6 by default if setupImageProcessing is true.
  106478. */
  106479. cameraExposure: number;
  106480. /**
  106481. * The value of the contrast to apply to the scene.
  106482. * 1.6 by default if setupImageProcessing is true.
  106483. */
  106484. cameraContrast: number;
  106485. /**
  106486. * Specifies wether or not tonemapping should be enabled in the scene.
  106487. * true by default if setupImageProcessing is true.
  106488. */
  106489. toneMappingEnabled: boolean;
  106490. }
  106491. /**
  106492. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  106493. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  106494. * It also helps with the default setup of your imageProcessing configuration.
  106495. */
  106496. export class EnvironmentHelper {
  106497. /**
  106498. * Default ground texture URL.
  106499. */
  106500. private static _groundTextureCDNUrl;
  106501. /**
  106502. * Default skybox texture URL.
  106503. */
  106504. private static _skyboxTextureCDNUrl;
  106505. /**
  106506. * Default environment texture URL.
  106507. */
  106508. private static _environmentTextureCDNUrl;
  106509. /**
  106510. * Creates the default options for the helper.
  106511. */
  106512. private static _getDefaultOptions;
  106513. private _rootMesh;
  106514. /**
  106515. * Gets the root mesh created by the helper.
  106516. */
  106517. readonly rootMesh: Mesh;
  106518. private _skybox;
  106519. /**
  106520. * Gets the skybox created by the helper.
  106521. */
  106522. readonly skybox: Nullable<Mesh>;
  106523. private _skyboxTexture;
  106524. /**
  106525. * Gets the skybox texture created by the helper.
  106526. */
  106527. readonly skyboxTexture: Nullable<BaseTexture>;
  106528. private _skyboxMaterial;
  106529. /**
  106530. * Gets the skybox material created by the helper.
  106531. */
  106532. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  106533. private _ground;
  106534. /**
  106535. * Gets the ground mesh created by the helper.
  106536. */
  106537. readonly ground: Nullable<Mesh>;
  106538. private _groundTexture;
  106539. /**
  106540. * Gets the ground texture created by the helper.
  106541. */
  106542. readonly groundTexture: Nullable<BaseTexture>;
  106543. private _groundMirror;
  106544. /**
  106545. * Gets the ground mirror created by the helper.
  106546. */
  106547. readonly groundMirror: Nullable<MirrorTexture>;
  106548. /**
  106549. * Gets the ground mirror render list to helps pushing the meshes
  106550. * you wish in the ground reflection.
  106551. */
  106552. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  106553. private _groundMaterial;
  106554. /**
  106555. * Gets the ground material created by the helper.
  106556. */
  106557. readonly groundMaterial: Nullable<BackgroundMaterial>;
  106558. /**
  106559. * Stores the creation options.
  106560. */
  106561. private readonly _scene;
  106562. private _options;
  106563. /**
  106564. * This observable will be notified with any error during the creation of the environment,
  106565. * mainly texture creation errors.
  106566. */
  106567. onErrorObservable: Observable<{
  106568. message?: string;
  106569. exception?: any;
  106570. }>;
  106571. /**
  106572. * constructor
  106573. * @param options Defines the options we want to customize the helper
  106574. * @param scene The scene to add the material to
  106575. */
  106576. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  106577. /**
  106578. * Updates the background according to the new options
  106579. * @param options
  106580. */
  106581. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  106582. /**
  106583. * Sets the primary color of all the available elements.
  106584. * @param color the main color to affect to the ground and the background
  106585. */
  106586. setMainColor(color: Color3): void;
  106587. /**
  106588. * Setup the image processing according to the specified options.
  106589. */
  106590. private _setupImageProcessing;
  106591. /**
  106592. * Setup the environment texture according to the specified options.
  106593. */
  106594. private _setupEnvironmentTexture;
  106595. /**
  106596. * Setup the background according to the specified options.
  106597. */
  106598. private _setupBackground;
  106599. /**
  106600. * Get the scene sizes according to the setup.
  106601. */
  106602. private _getSceneSize;
  106603. /**
  106604. * Setup the ground according to the specified options.
  106605. */
  106606. private _setupGround;
  106607. /**
  106608. * Setup the ground material according to the specified options.
  106609. */
  106610. private _setupGroundMaterial;
  106611. /**
  106612. * Setup the ground diffuse texture according to the specified options.
  106613. */
  106614. private _setupGroundDiffuseTexture;
  106615. /**
  106616. * Setup the ground mirror texture according to the specified options.
  106617. */
  106618. private _setupGroundMirrorTexture;
  106619. /**
  106620. * Setup the ground to receive the mirror texture.
  106621. */
  106622. private _setupMirrorInGroundMaterial;
  106623. /**
  106624. * Setup the skybox according to the specified options.
  106625. */
  106626. private _setupSkybox;
  106627. /**
  106628. * Setup the skybox material according to the specified options.
  106629. */
  106630. private _setupSkyboxMaterial;
  106631. /**
  106632. * Setup the skybox reflection texture according to the specified options.
  106633. */
  106634. private _setupSkyboxReflectionTexture;
  106635. private _errorHandler;
  106636. /**
  106637. * Dispose all the elements created by the Helper.
  106638. */
  106639. dispose(): void;
  106640. }
  106641. }
  106642. declare module BABYLON {
  106643. /**
  106644. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  106645. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  106646. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  106647. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106648. */
  106649. export class PhotoDome extends TransformNode {
  106650. /**
  106651. * Define the image as a Monoscopic panoramic 360 image.
  106652. */
  106653. static readonly MODE_MONOSCOPIC: number;
  106654. /**
  106655. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  106656. */
  106657. static readonly MODE_TOPBOTTOM: number;
  106658. /**
  106659. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  106660. */
  106661. static readonly MODE_SIDEBYSIDE: number;
  106662. private _useDirectMapping;
  106663. /**
  106664. * The texture being displayed on the sphere
  106665. */
  106666. protected _photoTexture: Texture;
  106667. /**
  106668. * Gets or sets the texture being displayed on the sphere
  106669. */
  106670. photoTexture: Texture;
  106671. /**
  106672. * Observable raised when an error occured while loading the 360 image
  106673. */
  106674. onLoadErrorObservable: Observable<string>;
  106675. /**
  106676. * The skybox material
  106677. */
  106678. protected _material: BackgroundMaterial;
  106679. /**
  106680. * The surface used for the skybox
  106681. */
  106682. protected _mesh: Mesh;
  106683. /**
  106684. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106685. * Also see the options.resolution property.
  106686. */
  106687. fovMultiplier: number;
  106688. private _imageMode;
  106689. /**
  106690. * Gets or set the current video mode for the video. It can be:
  106691. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  106692. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  106693. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  106694. */
  106695. imageMode: number;
  106696. /**
  106697. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  106698. * @param name Element's name, child elements will append suffixes for their own names.
  106699. * @param urlsOfPhoto defines the url of the photo to display
  106700. * @param options defines an object containing optional or exposed sub element properties
  106701. * @param onError defines a callback called when an error occured while loading the texture
  106702. */
  106703. constructor(name: string, urlOfPhoto: string, options: {
  106704. resolution?: number;
  106705. size?: number;
  106706. useDirectMapping?: boolean;
  106707. faceForward?: boolean;
  106708. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  106709. private _onBeforeCameraRenderObserver;
  106710. private _changeImageMode;
  106711. /**
  106712. * Releases resources associated with this node.
  106713. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106714. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106715. */
  106716. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106717. }
  106718. }
  106719. declare module BABYLON {
  106720. /** @hidden */
  106721. export var rgbdDecodePixelShader: {
  106722. name: string;
  106723. shader: string;
  106724. };
  106725. }
  106726. declare module BABYLON {
  106727. /**
  106728. * Class used to host texture specific utilities
  106729. */
  106730. export class BRDFTextureTools {
  106731. /**
  106732. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  106733. * @param texture the texture to expand.
  106734. */
  106735. private static _ExpandDefaultBRDFTexture;
  106736. /**
  106737. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  106738. * @param scene defines the hosting scene
  106739. * @returns the environment BRDF texture
  106740. */
  106741. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  106742. private static _environmentBRDFBase64Texture;
  106743. }
  106744. }
  106745. declare module BABYLON {
  106746. /**
  106747. * @hidden
  106748. */
  106749. export interface IMaterialClearCoatDefines {
  106750. CLEARCOAT: boolean;
  106751. CLEARCOAT_DEFAULTIOR: boolean;
  106752. CLEARCOAT_TEXTURE: boolean;
  106753. CLEARCOAT_TEXTUREDIRECTUV: number;
  106754. CLEARCOAT_BUMP: boolean;
  106755. CLEARCOAT_BUMPDIRECTUV: number;
  106756. CLEARCOAT_TINT: boolean;
  106757. CLEARCOAT_TINT_TEXTURE: boolean;
  106758. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106759. /** @hidden */
  106760. _areTexturesDirty: boolean;
  106761. }
  106762. /**
  106763. * Define the code related to the clear coat parameters of the pbr material.
  106764. */
  106765. export class PBRClearCoatConfiguration {
  106766. /**
  106767. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  106768. * The default fits with a polyurethane material.
  106769. */
  106770. private static readonly _DefaultIndiceOfRefraction;
  106771. private _isEnabled;
  106772. /**
  106773. * Defines if the clear coat is enabled in the material.
  106774. */
  106775. isEnabled: boolean;
  106776. /**
  106777. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  106778. */
  106779. intensity: number;
  106780. /**
  106781. * Defines the clear coat layer roughness.
  106782. */
  106783. roughness: number;
  106784. private _indiceOfRefraction;
  106785. /**
  106786. * Defines the indice of refraction of the clear coat.
  106787. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  106788. * The default fits with a polyurethane material.
  106789. * Changing the default value is more performance intensive.
  106790. */
  106791. indiceOfRefraction: number;
  106792. private _texture;
  106793. /**
  106794. * Stores the clear coat values in a texture.
  106795. */
  106796. texture: Nullable<BaseTexture>;
  106797. private _bumpTexture;
  106798. /**
  106799. * Define the clear coat specific bump texture.
  106800. */
  106801. bumpTexture: Nullable<BaseTexture>;
  106802. private _isTintEnabled;
  106803. /**
  106804. * Defines if the clear coat tint is enabled in the material.
  106805. */
  106806. isTintEnabled: boolean;
  106807. /**
  106808. * Defines the clear coat tint of the material.
  106809. * This is only use if tint is enabled
  106810. */
  106811. tintColor: Color3;
  106812. /**
  106813. * Defines the distance at which the tint color should be found in the
  106814. * clear coat media.
  106815. * This is only use if tint is enabled
  106816. */
  106817. tintColorAtDistance: number;
  106818. /**
  106819. * Defines the clear coat layer thickness.
  106820. * This is only use if tint is enabled
  106821. */
  106822. tintThickness: number;
  106823. private _tintTexture;
  106824. /**
  106825. * Stores the clear tint values in a texture.
  106826. * rgb is tint
  106827. * a is a thickness factor
  106828. */
  106829. tintTexture: Nullable<BaseTexture>;
  106830. /** @hidden */
  106831. private _internalMarkAllSubMeshesAsTexturesDirty;
  106832. /** @hidden */
  106833. _markAllSubMeshesAsTexturesDirty(): void;
  106834. /**
  106835. * Instantiate a new istance of clear coat configuration.
  106836. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106837. */
  106838. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106839. /**
  106840. * Gets wehter the submesh is ready to be used or not.
  106841. * @param defines the list of "defines" to update.
  106842. * @param scene defines the scene the material belongs to.
  106843. * @param engine defines the engine the material belongs to.
  106844. * @param disableBumpMap defines wether the material disables bump or not.
  106845. * @returns - boolean indicating that the submesh is ready or not.
  106846. */
  106847. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  106848. /**
  106849. * Checks to see if a texture is used in the material.
  106850. * @param defines the list of "defines" to update.
  106851. * @param scene defines the scene to the material belongs to.
  106852. */
  106853. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  106854. /**
  106855. * Binds the material data.
  106856. * @param uniformBuffer defines the Uniform buffer to fill in.
  106857. * @param scene defines the scene the material belongs to.
  106858. * @param engine defines the engine the material belongs to.
  106859. * @param disableBumpMap defines wether the material disables bump or not.
  106860. * @param isFrozen defines wether the material is frozen or not.
  106861. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  106862. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  106863. */
  106864. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  106865. /**
  106866. * Checks to see if a texture is used in the material.
  106867. * @param texture - Base texture to use.
  106868. * @returns - Boolean specifying if a texture is used in the material.
  106869. */
  106870. hasTexture(texture: BaseTexture): boolean;
  106871. /**
  106872. * Returns an array of the actively used textures.
  106873. * @param activeTextures Array of BaseTextures
  106874. */
  106875. getActiveTextures(activeTextures: BaseTexture[]): void;
  106876. /**
  106877. * Returns the animatable textures.
  106878. * @param animatables Array of animatable textures.
  106879. */
  106880. getAnimatables(animatables: IAnimatable[]): void;
  106881. /**
  106882. * Disposes the resources of the material.
  106883. * @param forceDisposeTextures - Forces the disposal of all textures.
  106884. */
  106885. dispose(forceDisposeTextures?: boolean): void;
  106886. /**
  106887. * Get the current class name of the texture useful for serialization or dynamic coding.
  106888. * @returns "PBRClearCoatConfiguration"
  106889. */
  106890. getClassName(): string;
  106891. /**
  106892. * Add fallbacks to the effect fallbacks list.
  106893. * @param defines defines the Base texture to use.
  106894. * @param fallbacks defines the current fallback list.
  106895. * @param currentRank defines the current fallback rank.
  106896. * @returns the new fallback rank.
  106897. */
  106898. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106899. /**
  106900. * Add the required uniforms to the current list.
  106901. * @param uniforms defines the current uniform list.
  106902. */
  106903. static AddUniforms(uniforms: string[]): void;
  106904. /**
  106905. * Add the required samplers to the current list.
  106906. * @param samplers defines the current sampler list.
  106907. */
  106908. static AddSamplers(samplers: string[]): void;
  106909. /**
  106910. * Add the required uniforms to the current buffer.
  106911. * @param uniformBuffer defines the current uniform buffer.
  106912. */
  106913. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106914. /**
  106915. * Makes a duplicate of the current configuration into another one.
  106916. * @param clearCoatConfiguration define the config where to copy the info
  106917. */
  106918. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  106919. /**
  106920. * Serializes this clear coat configuration.
  106921. * @returns - An object with the serialized config.
  106922. */
  106923. serialize(): any;
  106924. /**
  106925. * Parses a Clear Coat Configuration from a serialized object.
  106926. * @param source - Serialized object.
  106927. */
  106928. parse(source: any): void;
  106929. }
  106930. }
  106931. declare module BABYLON {
  106932. /**
  106933. * @hidden
  106934. */
  106935. export interface IMaterialAnisotropicDefines {
  106936. ANISOTROPIC: boolean;
  106937. ANISOTROPIC_TEXTURE: boolean;
  106938. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106939. MAINUV1: boolean;
  106940. _areTexturesDirty: boolean;
  106941. _needUVs: boolean;
  106942. }
  106943. /**
  106944. * Define the code related to the anisotropic parameters of the pbr material.
  106945. */
  106946. export class PBRAnisotropicConfiguration {
  106947. private _isEnabled;
  106948. /**
  106949. * Defines if the anisotropy is enabled in the material.
  106950. */
  106951. isEnabled: boolean;
  106952. /**
  106953. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  106954. */
  106955. intensity: number;
  106956. /**
  106957. * Defines if the effect is along the tangents, bitangents or in between.
  106958. * By default, the effect is "strectching" the highlights along the tangents.
  106959. */
  106960. direction: Vector2;
  106961. private _texture;
  106962. /**
  106963. * Stores the anisotropy values in a texture.
  106964. * rg is direction (like normal from -1 to 1)
  106965. * b is a intensity
  106966. */
  106967. texture: Nullable<BaseTexture>;
  106968. /** @hidden */
  106969. private _internalMarkAllSubMeshesAsTexturesDirty;
  106970. /** @hidden */
  106971. _markAllSubMeshesAsTexturesDirty(): void;
  106972. /**
  106973. * Instantiate a new istance of anisotropy configuration.
  106974. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106975. */
  106976. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106977. /**
  106978. * Specifies that the submesh is ready to be used.
  106979. * @param defines the list of "defines" to update.
  106980. * @param scene defines the scene the material belongs to.
  106981. * @returns - boolean indicating that the submesh is ready or not.
  106982. */
  106983. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  106984. /**
  106985. * Checks to see if a texture is used in the material.
  106986. * @param defines the list of "defines" to update.
  106987. * @param mesh the mesh we are preparing the defines for.
  106988. * @param scene defines the scene the material belongs to.
  106989. */
  106990. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  106991. /**
  106992. * Binds the material data.
  106993. * @param uniformBuffer defines the Uniform buffer to fill in.
  106994. * @param scene defines the scene the material belongs to.
  106995. * @param isFrozen defines wether the material is frozen or not.
  106996. */
  106997. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  106998. /**
  106999. * Checks to see if a texture is used in the material.
  107000. * @param texture - Base texture to use.
  107001. * @returns - Boolean specifying if a texture is used in the material.
  107002. */
  107003. hasTexture(texture: BaseTexture): boolean;
  107004. /**
  107005. * Returns an array of the actively used textures.
  107006. * @param activeTextures Array of BaseTextures
  107007. */
  107008. getActiveTextures(activeTextures: BaseTexture[]): void;
  107009. /**
  107010. * Returns the animatable textures.
  107011. * @param animatables Array of animatable textures.
  107012. */
  107013. getAnimatables(animatables: IAnimatable[]): void;
  107014. /**
  107015. * Disposes the resources of the material.
  107016. * @param forceDisposeTextures - Forces the disposal of all textures.
  107017. */
  107018. dispose(forceDisposeTextures?: boolean): void;
  107019. /**
  107020. * Get the current class name of the texture useful for serialization or dynamic coding.
  107021. * @returns "PBRAnisotropicConfiguration"
  107022. */
  107023. getClassName(): string;
  107024. /**
  107025. * Add fallbacks to the effect fallbacks list.
  107026. * @param defines defines the Base texture to use.
  107027. * @param fallbacks defines the current fallback list.
  107028. * @param currentRank defines the current fallback rank.
  107029. * @returns the new fallback rank.
  107030. */
  107031. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107032. /**
  107033. * Add the required uniforms to the current list.
  107034. * @param uniforms defines the current uniform list.
  107035. */
  107036. static AddUniforms(uniforms: string[]): void;
  107037. /**
  107038. * Add the required uniforms to the current buffer.
  107039. * @param uniformBuffer defines the current uniform buffer.
  107040. */
  107041. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107042. /**
  107043. * Add the required samplers to the current list.
  107044. * @param samplers defines the current sampler list.
  107045. */
  107046. static AddSamplers(samplers: string[]): void;
  107047. /**
  107048. * Makes a duplicate of the current configuration into another one.
  107049. * @param anisotropicConfiguration define the config where to copy the info
  107050. */
  107051. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  107052. /**
  107053. * Serializes this anisotropy configuration.
  107054. * @returns - An object with the serialized config.
  107055. */
  107056. serialize(): any;
  107057. /**
  107058. * Parses a anisotropy Configuration from a serialized object.
  107059. * @param source - Serialized object.
  107060. */
  107061. parse(source: any): void;
  107062. }
  107063. }
  107064. declare module BABYLON {
  107065. /**
  107066. * @hidden
  107067. */
  107068. export interface IMaterialBRDFDefines {
  107069. BRDF_V_HEIGHT_CORRELATED: boolean;
  107070. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107071. SPHERICAL_HARMONICS: boolean;
  107072. /** @hidden */
  107073. _areMiscDirty: boolean;
  107074. }
  107075. /**
  107076. * Define the code related to the BRDF parameters of the pbr material.
  107077. */
  107078. export class PBRBRDFConfiguration {
  107079. /**
  107080. * Default value used for the energy conservation.
  107081. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107082. */
  107083. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  107084. /**
  107085. * Default value used for the Smith Visibility Height Correlated mode.
  107086. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107087. */
  107088. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  107089. /**
  107090. * Default value used for the IBL diffuse part.
  107091. * This can help switching back to the polynomials mode globally which is a tiny bit
  107092. * less GPU intensive at the drawback of a lower quality.
  107093. */
  107094. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  107095. private _useEnergyConservation;
  107096. /**
  107097. * Defines if the material uses energy conservation.
  107098. */
  107099. useEnergyConservation: boolean;
  107100. private _useSmithVisibilityHeightCorrelated;
  107101. /**
  107102. * LEGACY Mode set to false
  107103. * Defines if the material uses height smith correlated visibility term.
  107104. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  107105. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  107106. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  107107. * Not relying on height correlated will also disable energy conservation.
  107108. */
  107109. useSmithVisibilityHeightCorrelated: boolean;
  107110. private _useSphericalHarmonics;
  107111. /**
  107112. * LEGACY Mode set to false
  107113. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  107114. * diffuse part of the IBL.
  107115. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  107116. * to the ground truth.
  107117. */
  107118. useSphericalHarmonics: boolean;
  107119. /** @hidden */
  107120. private _internalMarkAllSubMeshesAsMiscDirty;
  107121. /** @hidden */
  107122. _markAllSubMeshesAsMiscDirty(): void;
  107123. /**
  107124. * Instantiate a new istance of clear coat configuration.
  107125. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  107126. */
  107127. constructor(markAllSubMeshesAsMiscDirty: () => void);
  107128. /**
  107129. * Checks to see if a texture is used in the material.
  107130. * @param defines the list of "defines" to update.
  107131. */
  107132. prepareDefines(defines: IMaterialBRDFDefines): void;
  107133. /**
  107134. * Get the current class name of the texture useful for serialization or dynamic coding.
  107135. * @returns "PBRClearCoatConfiguration"
  107136. */
  107137. getClassName(): string;
  107138. /**
  107139. * Makes a duplicate of the current configuration into another one.
  107140. * @param brdfConfiguration define the config where to copy the info
  107141. */
  107142. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  107143. /**
  107144. * Serializes this BRDF configuration.
  107145. * @returns - An object with the serialized config.
  107146. */
  107147. serialize(): any;
  107148. /**
  107149. * Parses a BRDF Configuration from a serialized object.
  107150. * @param source - Serialized object.
  107151. */
  107152. parse(source: any): void;
  107153. }
  107154. }
  107155. declare module BABYLON {
  107156. /**
  107157. * @hidden
  107158. */
  107159. export interface IMaterialSheenDefines {
  107160. SHEEN: boolean;
  107161. SHEEN_TEXTURE: boolean;
  107162. SHEEN_TEXTUREDIRECTUV: number;
  107163. SHEEN_LINKWITHALBEDO: boolean;
  107164. /** @hidden */
  107165. _areTexturesDirty: boolean;
  107166. }
  107167. /**
  107168. * Define the code related to the Sheen parameters of the pbr material.
  107169. */
  107170. export class PBRSheenConfiguration {
  107171. private _isEnabled;
  107172. /**
  107173. * Defines if the material uses sheen.
  107174. */
  107175. isEnabled: boolean;
  107176. private _linkSheenWithAlbedo;
  107177. /**
  107178. * Defines if the sheen is linked to the sheen color.
  107179. */
  107180. linkSheenWithAlbedo: boolean;
  107181. /**
  107182. * Defines the sheen intensity.
  107183. */
  107184. intensity: number;
  107185. /**
  107186. * Defines the sheen color.
  107187. */
  107188. color: Color3;
  107189. private _texture;
  107190. /**
  107191. * Stores the sheen tint values in a texture.
  107192. * rgb is tint
  107193. * a is a intensity
  107194. */
  107195. texture: Nullable<BaseTexture>;
  107196. /** @hidden */
  107197. private _internalMarkAllSubMeshesAsTexturesDirty;
  107198. /** @hidden */
  107199. _markAllSubMeshesAsTexturesDirty(): void;
  107200. /**
  107201. * Instantiate a new istance of clear coat configuration.
  107202. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107203. */
  107204. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107205. /**
  107206. * Specifies that the submesh is ready to be used.
  107207. * @param defines the list of "defines" to update.
  107208. * @param scene defines the scene the material belongs to.
  107209. * @returns - boolean indicating that the submesh is ready or not.
  107210. */
  107211. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  107212. /**
  107213. * Checks to see if a texture is used in the material.
  107214. * @param defines the list of "defines" to update.
  107215. * @param scene defines the scene the material belongs to.
  107216. */
  107217. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  107218. /**
  107219. * Binds the material data.
  107220. * @param uniformBuffer defines the Uniform buffer to fill in.
  107221. * @param scene defines the scene the material belongs to.
  107222. * @param isFrozen defines wether the material is frozen or not.
  107223. */
  107224. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107225. /**
  107226. * Checks to see if a texture is used in the material.
  107227. * @param texture - Base texture to use.
  107228. * @returns - Boolean specifying if a texture is used in the material.
  107229. */
  107230. hasTexture(texture: BaseTexture): boolean;
  107231. /**
  107232. * Returns an array of the actively used textures.
  107233. * @param activeTextures Array of BaseTextures
  107234. */
  107235. getActiveTextures(activeTextures: BaseTexture[]): void;
  107236. /**
  107237. * Returns the animatable textures.
  107238. * @param animatables Array of animatable textures.
  107239. */
  107240. getAnimatables(animatables: IAnimatable[]): void;
  107241. /**
  107242. * Disposes the resources of the material.
  107243. * @param forceDisposeTextures - Forces the disposal of all textures.
  107244. */
  107245. dispose(forceDisposeTextures?: boolean): void;
  107246. /**
  107247. * Get the current class name of the texture useful for serialization or dynamic coding.
  107248. * @returns "PBRSheenConfiguration"
  107249. */
  107250. getClassName(): string;
  107251. /**
  107252. * Add fallbacks to the effect fallbacks list.
  107253. * @param defines defines the Base texture to use.
  107254. * @param fallbacks defines the current fallback list.
  107255. * @param currentRank defines the current fallback rank.
  107256. * @returns the new fallback rank.
  107257. */
  107258. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107259. /**
  107260. * Add the required uniforms to the current list.
  107261. * @param uniforms defines the current uniform list.
  107262. */
  107263. static AddUniforms(uniforms: string[]): void;
  107264. /**
  107265. * Add the required uniforms to the current buffer.
  107266. * @param uniformBuffer defines the current uniform buffer.
  107267. */
  107268. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107269. /**
  107270. * Add the required samplers to the current list.
  107271. * @param samplers defines the current sampler list.
  107272. */
  107273. static AddSamplers(samplers: string[]): void;
  107274. /**
  107275. * Makes a duplicate of the current configuration into another one.
  107276. * @param sheenConfiguration define the config where to copy the info
  107277. */
  107278. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  107279. /**
  107280. * Serializes this BRDF configuration.
  107281. * @returns - An object with the serialized config.
  107282. */
  107283. serialize(): any;
  107284. /**
  107285. * Parses a Sheen Configuration from a serialized object.
  107286. * @param source - Serialized object.
  107287. */
  107288. parse(source: any): void;
  107289. }
  107290. }
  107291. declare module BABYLON {
  107292. /**
  107293. * @hidden
  107294. */
  107295. export interface IMaterialSubSurfaceDefines {
  107296. SUBSURFACE: boolean;
  107297. SS_REFRACTION: boolean;
  107298. SS_TRANSLUCENCY: boolean;
  107299. SS_SCATERRING: boolean;
  107300. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107301. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107302. SS_REFRACTIONMAP_3D: boolean;
  107303. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107304. SS_LODINREFRACTIONALPHA: boolean;
  107305. SS_GAMMAREFRACTION: boolean;
  107306. SS_RGBDREFRACTION: boolean;
  107307. SS_LINEARSPECULARREFRACTION: boolean;
  107308. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107309. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107310. /** @hidden */
  107311. _areTexturesDirty: boolean;
  107312. }
  107313. /**
  107314. * Define the code related to the sub surface parameters of the pbr material.
  107315. */
  107316. export class PBRSubSurfaceConfiguration {
  107317. private _isRefractionEnabled;
  107318. /**
  107319. * Defines if the refraction is enabled in the material.
  107320. */
  107321. isRefractionEnabled: boolean;
  107322. private _isTranslucencyEnabled;
  107323. /**
  107324. * Defines if the translucency is enabled in the material.
  107325. */
  107326. isTranslucencyEnabled: boolean;
  107327. private _isScatteringEnabled;
  107328. /**
  107329. * Defines the refraction intensity of the material.
  107330. * The refraction when enabled replaces the Diffuse part of the material.
  107331. * The intensity helps transitionning between diffuse and refraction.
  107332. */
  107333. refractionIntensity: number;
  107334. /**
  107335. * Defines the translucency intensity of the material.
  107336. * When translucency has been enabled, this defines how much of the "translucency"
  107337. * is addded to the diffuse part of the material.
  107338. */
  107339. translucencyIntensity: number;
  107340. /**
  107341. * Defines the scattering intensity of the material.
  107342. * When scattering has been enabled, this defines how much of the "scattered light"
  107343. * is addded to the diffuse part of the material.
  107344. */
  107345. scatteringIntensity: number;
  107346. private _thicknessTexture;
  107347. /**
  107348. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  107349. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  107350. * 0 would mean minimumThickness
  107351. * 1 would mean maximumThickness
  107352. * The other channels might be use as a mask to vary the different effects intensity.
  107353. */
  107354. thicknessTexture: Nullable<BaseTexture>;
  107355. private _refractionTexture;
  107356. /**
  107357. * Defines the texture to use for refraction.
  107358. */
  107359. refractionTexture: Nullable<BaseTexture>;
  107360. private _indexOfRefraction;
  107361. /**
  107362. * Defines the indice of refraction used in the material.
  107363. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107364. */
  107365. indexOfRefraction: number;
  107366. private _invertRefractionY;
  107367. /**
  107368. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107369. */
  107370. invertRefractionY: boolean;
  107371. private _linkRefractionWithTransparency;
  107372. /**
  107373. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107374. * Materials half opaque for instance using refraction could benefit from this control.
  107375. */
  107376. linkRefractionWithTransparency: boolean;
  107377. /**
  107378. * Defines the minimum thickness stored in the thickness map.
  107379. * If no thickness map is defined, this value will be used to simulate thickness.
  107380. */
  107381. minimumThickness: number;
  107382. /**
  107383. * Defines the maximum thickness stored in the thickness map.
  107384. */
  107385. maximumThickness: number;
  107386. /**
  107387. * Defines the volume tint of the material.
  107388. * This is used for both translucency and scattering.
  107389. */
  107390. tintColor: Color3;
  107391. /**
  107392. * Defines the distance at which the tint color should be found in the media.
  107393. * This is used for refraction only.
  107394. */
  107395. tintColorAtDistance: number;
  107396. /**
  107397. * Defines how far each channel transmit through the media.
  107398. * It is defined as a color to simplify it selection.
  107399. */
  107400. diffusionDistance: Color3;
  107401. private _useMaskFromThicknessTexture;
  107402. /**
  107403. * Stores the intensity of the different subsurface effects in the thickness texture.
  107404. * * the green channel is the translucency intensity.
  107405. * * the blue channel is the scattering intensity.
  107406. * * the alpha channel is the refraction intensity.
  107407. */
  107408. useMaskFromThicknessTexture: boolean;
  107409. /** @hidden */
  107410. private _internalMarkAllSubMeshesAsTexturesDirty;
  107411. /** @hidden */
  107412. _markAllSubMeshesAsTexturesDirty(): void;
  107413. /**
  107414. * Instantiate a new istance of sub surface configuration.
  107415. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107416. */
  107417. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107418. /**
  107419. * Gets wehter the submesh is ready to be used or not.
  107420. * @param defines the list of "defines" to update.
  107421. * @param scene defines the scene the material belongs to.
  107422. * @returns - boolean indicating that the submesh is ready or not.
  107423. */
  107424. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  107425. /**
  107426. * Checks to see if a texture is used in the material.
  107427. * @param defines the list of "defines" to update.
  107428. * @param scene defines the scene to the material belongs to.
  107429. */
  107430. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  107431. /**
  107432. * Binds the material data.
  107433. * @param uniformBuffer defines the Uniform buffer to fill in.
  107434. * @param scene defines the scene the material belongs to.
  107435. * @param engine defines the engine the material belongs to.
  107436. * @param isFrozen defines wether the material is frozen or not.
  107437. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  107438. */
  107439. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  107440. /**
  107441. * Unbinds the material from the mesh.
  107442. * @param activeEffect defines the effect that should be unbound from.
  107443. * @returns true if unbound, otherwise false
  107444. */
  107445. unbind(activeEffect: Effect): boolean;
  107446. /**
  107447. * Returns the texture used for refraction or null if none is used.
  107448. * @param scene defines the scene the material belongs to.
  107449. * @returns - Refraction texture if present. If no refraction texture and refraction
  107450. * is linked with transparency, returns environment texture. Otherwise, returns null.
  107451. */
  107452. private _getRefractionTexture;
  107453. /**
  107454. * Returns true if alpha blending should be disabled.
  107455. */
  107456. readonly disableAlphaBlending: boolean;
  107457. /**
  107458. * Fills the list of render target textures.
  107459. * @param renderTargets the list of render targets to update
  107460. */
  107461. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  107462. /**
  107463. * Checks to see if a texture is used in the material.
  107464. * @param texture - Base texture to use.
  107465. * @returns - Boolean specifying if a texture is used in the material.
  107466. */
  107467. hasTexture(texture: BaseTexture): boolean;
  107468. /**
  107469. * Gets a boolean indicating that current material needs to register RTT
  107470. * @returns true if this uses a render target otherwise false.
  107471. */
  107472. hasRenderTargetTextures(): boolean;
  107473. /**
  107474. * Returns an array of the actively used textures.
  107475. * @param activeTextures Array of BaseTextures
  107476. */
  107477. getActiveTextures(activeTextures: BaseTexture[]): void;
  107478. /**
  107479. * Returns the animatable textures.
  107480. * @param animatables Array of animatable textures.
  107481. */
  107482. getAnimatables(animatables: IAnimatable[]): void;
  107483. /**
  107484. * Disposes the resources of the material.
  107485. * @param forceDisposeTextures - Forces the disposal of all textures.
  107486. */
  107487. dispose(forceDisposeTextures?: boolean): void;
  107488. /**
  107489. * Get the current class name of the texture useful for serialization or dynamic coding.
  107490. * @returns "PBRSubSurfaceConfiguration"
  107491. */
  107492. getClassName(): string;
  107493. /**
  107494. * Add fallbacks to the effect fallbacks list.
  107495. * @param defines defines the Base texture to use.
  107496. * @param fallbacks defines the current fallback list.
  107497. * @param currentRank defines the current fallback rank.
  107498. * @returns the new fallback rank.
  107499. */
  107500. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107501. /**
  107502. * Add the required uniforms to the current list.
  107503. * @param uniforms defines the current uniform list.
  107504. */
  107505. static AddUniforms(uniforms: string[]): void;
  107506. /**
  107507. * Add the required samplers to the current list.
  107508. * @param samplers defines the current sampler list.
  107509. */
  107510. static AddSamplers(samplers: string[]): void;
  107511. /**
  107512. * Add the required uniforms to the current buffer.
  107513. * @param uniformBuffer defines the current uniform buffer.
  107514. */
  107515. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107516. /**
  107517. * Makes a duplicate of the current configuration into another one.
  107518. * @param configuration define the config where to copy the info
  107519. */
  107520. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  107521. /**
  107522. * Serializes this Sub Surface configuration.
  107523. * @returns - An object with the serialized config.
  107524. */
  107525. serialize(): any;
  107526. /**
  107527. * Parses a Sub Surface Configuration from a serialized object.
  107528. * @param source - Serialized object.
  107529. */
  107530. parse(source: any): void;
  107531. }
  107532. }
  107533. declare module BABYLON {
  107534. /** @hidden */
  107535. export var pbrFragmentDeclaration: {
  107536. name: string;
  107537. shader: string;
  107538. };
  107539. }
  107540. declare module BABYLON {
  107541. /** @hidden */
  107542. export var pbrUboDeclaration: {
  107543. name: string;
  107544. shader: string;
  107545. };
  107546. }
  107547. declare module BABYLON {
  107548. /** @hidden */
  107549. export var pbrFragmentExtraDeclaration: {
  107550. name: string;
  107551. shader: string;
  107552. };
  107553. }
  107554. declare module BABYLON {
  107555. /** @hidden */
  107556. export var pbrFragmentSamplersDeclaration: {
  107557. name: string;
  107558. shader: string;
  107559. };
  107560. }
  107561. declare module BABYLON {
  107562. /** @hidden */
  107563. export var pbrHelperFunctions: {
  107564. name: string;
  107565. shader: string;
  107566. };
  107567. }
  107568. declare module BABYLON {
  107569. /** @hidden */
  107570. export var harmonicsFunctions: {
  107571. name: string;
  107572. shader: string;
  107573. };
  107574. }
  107575. declare module BABYLON {
  107576. /** @hidden */
  107577. export var pbrDirectLightingSetupFunctions: {
  107578. name: string;
  107579. shader: string;
  107580. };
  107581. }
  107582. declare module BABYLON {
  107583. /** @hidden */
  107584. export var pbrDirectLightingFalloffFunctions: {
  107585. name: string;
  107586. shader: string;
  107587. };
  107588. }
  107589. declare module BABYLON {
  107590. /** @hidden */
  107591. export var pbrBRDFFunctions: {
  107592. name: string;
  107593. shader: string;
  107594. };
  107595. }
  107596. declare module BABYLON {
  107597. /** @hidden */
  107598. export var pbrDirectLightingFunctions: {
  107599. name: string;
  107600. shader: string;
  107601. };
  107602. }
  107603. declare module BABYLON {
  107604. /** @hidden */
  107605. export var pbrIBLFunctions: {
  107606. name: string;
  107607. shader: string;
  107608. };
  107609. }
  107610. declare module BABYLON {
  107611. /** @hidden */
  107612. export var pbrDebug: {
  107613. name: string;
  107614. shader: string;
  107615. };
  107616. }
  107617. declare module BABYLON {
  107618. /** @hidden */
  107619. export var pbrPixelShader: {
  107620. name: string;
  107621. shader: string;
  107622. };
  107623. }
  107624. declare module BABYLON {
  107625. /** @hidden */
  107626. export var pbrVertexDeclaration: {
  107627. name: string;
  107628. shader: string;
  107629. };
  107630. }
  107631. declare module BABYLON {
  107632. /** @hidden */
  107633. export var pbrVertexShader: {
  107634. name: string;
  107635. shader: string;
  107636. };
  107637. }
  107638. declare module BABYLON {
  107639. /**
  107640. * Manages the defines for the PBR Material.
  107641. * @hidden
  107642. */
  107643. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  107644. PBR: boolean;
  107645. MAINUV1: boolean;
  107646. MAINUV2: boolean;
  107647. UV1: boolean;
  107648. UV2: boolean;
  107649. ALBEDO: boolean;
  107650. ALBEDODIRECTUV: number;
  107651. VERTEXCOLOR: boolean;
  107652. AMBIENT: boolean;
  107653. AMBIENTDIRECTUV: number;
  107654. AMBIENTINGRAYSCALE: boolean;
  107655. OPACITY: boolean;
  107656. VERTEXALPHA: boolean;
  107657. OPACITYDIRECTUV: number;
  107658. OPACITYRGB: boolean;
  107659. ALPHATEST: boolean;
  107660. DEPTHPREPASS: boolean;
  107661. ALPHABLEND: boolean;
  107662. ALPHAFROMALBEDO: boolean;
  107663. ALPHATESTVALUE: string;
  107664. SPECULAROVERALPHA: boolean;
  107665. RADIANCEOVERALPHA: boolean;
  107666. ALPHAFRESNEL: boolean;
  107667. LINEARALPHAFRESNEL: boolean;
  107668. PREMULTIPLYALPHA: boolean;
  107669. EMISSIVE: boolean;
  107670. EMISSIVEDIRECTUV: number;
  107671. REFLECTIVITY: boolean;
  107672. REFLECTIVITYDIRECTUV: number;
  107673. SPECULARTERM: boolean;
  107674. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  107675. MICROSURFACEAUTOMATIC: boolean;
  107676. LODBASEDMICROSFURACE: boolean;
  107677. MICROSURFACEMAP: boolean;
  107678. MICROSURFACEMAPDIRECTUV: number;
  107679. METALLICWORKFLOW: boolean;
  107680. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  107681. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  107682. METALLNESSSTOREINMETALMAPBLUE: boolean;
  107683. AOSTOREINMETALMAPRED: boolean;
  107684. ENVIRONMENTBRDF: boolean;
  107685. ENVIRONMENTBRDF_RGBD: boolean;
  107686. NORMAL: boolean;
  107687. TANGENT: boolean;
  107688. BUMP: boolean;
  107689. BUMPDIRECTUV: number;
  107690. OBJECTSPACE_NORMALMAP: boolean;
  107691. PARALLAX: boolean;
  107692. PARALLAXOCCLUSION: boolean;
  107693. NORMALXYSCALE: boolean;
  107694. LIGHTMAP: boolean;
  107695. LIGHTMAPDIRECTUV: number;
  107696. USELIGHTMAPASSHADOWMAP: boolean;
  107697. GAMMALIGHTMAP: boolean;
  107698. REFLECTION: boolean;
  107699. REFLECTIONMAP_3D: boolean;
  107700. REFLECTIONMAP_SPHERICAL: boolean;
  107701. REFLECTIONMAP_PLANAR: boolean;
  107702. REFLECTIONMAP_CUBIC: boolean;
  107703. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107704. REFLECTIONMAP_PROJECTION: boolean;
  107705. REFLECTIONMAP_SKYBOX: boolean;
  107706. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  107707. REFLECTIONMAP_EXPLICIT: boolean;
  107708. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107709. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107710. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107711. INVERTCUBICMAP: boolean;
  107712. USESPHERICALFROMREFLECTIONMAP: boolean;
  107713. USEIRRADIANCEMAP: boolean;
  107714. SPHERICAL_HARMONICS: boolean;
  107715. USESPHERICALINVERTEX: boolean;
  107716. REFLECTIONMAP_OPPOSITEZ: boolean;
  107717. LODINREFLECTIONALPHA: boolean;
  107718. GAMMAREFLECTION: boolean;
  107719. RGBDREFLECTION: boolean;
  107720. LINEARSPECULARREFLECTION: boolean;
  107721. RADIANCEOCCLUSION: boolean;
  107722. HORIZONOCCLUSION: boolean;
  107723. INSTANCES: boolean;
  107724. NUM_BONE_INFLUENCERS: number;
  107725. BonesPerMesh: number;
  107726. BONETEXTURE: boolean;
  107727. NONUNIFORMSCALING: boolean;
  107728. MORPHTARGETS: boolean;
  107729. MORPHTARGETS_NORMAL: boolean;
  107730. MORPHTARGETS_TANGENT: boolean;
  107731. NUM_MORPH_INFLUENCERS: number;
  107732. IMAGEPROCESSING: boolean;
  107733. VIGNETTE: boolean;
  107734. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107735. VIGNETTEBLENDMODEOPAQUE: boolean;
  107736. TONEMAPPING: boolean;
  107737. TONEMAPPING_ACES: boolean;
  107738. CONTRAST: boolean;
  107739. COLORCURVES: boolean;
  107740. COLORGRADING: boolean;
  107741. COLORGRADING3D: boolean;
  107742. SAMPLER3DGREENDEPTH: boolean;
  107743. SAMPLER3DBGRMAP: boolean;
  107744. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107745. EXPOSURE: boolean;
  107746. MULTIVIEW: boolean;
  107747. USEPHYSICALLIGHTFALLOFF: boolean;
  107748. USEGLTFLIGHTFALLOFF: boolean;
  107749. TWOSIDEDLIGHTING: boolean;
  107750. SHADOWFLOAT: boolean;
  107751. CLIPPLANE: boolean;
  107752. CLIPPLANE2: boolean;
  107753. CLIPPLANE3: boolean;
  107754. CLIPPLANE4: boolean;
  107755. POINTSIZE: boolean;
  107756. FOG: boolean;
  107757. LOGARITHMICDEPTH: boolean;
  107758. FORCENORMALFORWARD: boolean;
  107759. SPECULARAA: boolean;
  107760. CLEARCOAT: boolean;
  107761. CLEARCOAT_DEFAULTIOR: boolean;
  107762. CLEARCOAT_TEXTURE: boolean;
  107763. CLEARCOAT_TEXTUREDIRECTUV: number;
  107764. CLEARCOAT_BUMP: boolean;
  107765. CLEARCOAT_BUMPDIRECTUV: number;
  107766. CLEARCOAT_TINT: boolean;
  107767. CLEARCOAT_TINT_TEXTURE: boolean;
  107768. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107769. ANISOTROPIC: boolean;
  107770. ANISOTROPIC_TEXTURE: boolean;
  107771. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107772. BRDF_V_HEIGHT_CORRELATED: boolean;
  107773. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107774. SHEEN: boolean;
  107775. SHEEN_TEXTURE: boolean;
  107776. SHEEN_TEXTUREDIRECTUV: number;
  107777. SHEEN_LINKWITHALBEDO: boolean;
  107778. SUBSURFACE: boolean;
  107779. SS_REFRACTION: boolean;
  107780. SS_TRANSLUCENCY: boolean;
  107781. SS_SCATERRING: boolean;
  107782. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107783. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107784. SS_REFRACTIONMAP_3D: boolean;
  107785. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107786. SS_LODINREFRACTIONALPHA: boolean;
  107787. SS_GAMMAREFRACTION: boolean;
  107788. SS_RGBDREFRACTION: boolean;
  107789. SS_LINEARSPECULARREFRACTION: boolean;
  107790. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107791. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107792. UNLIT: boolean;
  107793. DEBUGMODE: number;
  107794. /**
  107795. * Initializes the PBR Material defines.
  107796. */
  107797. constructor();
  107798. /**
  107799. * Resets the PBR Material defines.
  107800. */
  107801. reset(): void;
  107802. }
  107803. /**
  107804. * The Physically based material base class of BJS.
  107805. *
  107806. * This offers the main features of a standard PBR material.
  107807. * For more information, please refer to the documentation :
  107808. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107809. */
  107810. export abstract class PBRBaseMaterial extends PushMaterial {
  107811. /**
  107812. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107813. */
  107814. static readonly PBRMATERIAL_OPAQUE: number;
  107815. /**
  107816. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107817. */
  107818. static readonly PBRMATERIAL_ALPHATEST: number;
  107819. /**
  107820. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107821. */
  107822. static readonly PBRMATERIAL_ALPHABLEND: number;
  107823. /**
  107824. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107825. * They are also discarded below the alpha cutoff threshold to improve performances.
  107826. */
  107827. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107828. /**
  107829. * Defines the default value of how much AO map is occluding the analytical lights
  107830. * (point spot...).
  107831. */
  107832. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107833. /**
  107834. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  107835. */
  107836. static readonly LIGHTFALLOFF_PHYSICAL: number;
  107837. /**
  107838. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  107839. * to enhance interoperability with other engines.
  107840. */
  107841. static readonly LIGHTFALLOFF_GLTF: number;
  107842. /**
  107843. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  107844. * to enhance interoperability with other materials.
  107845. */
  107846. static readonly LIGHTFALLOFF_STANDARD: number;
  107847. /**
  107848. * Intensity of the direct lights e.g. the four lights available in your scene.
  107849. * This impacts both the direct diffuse and specular highlights.
  107850. */
  107851. protected _directIntensity: number;
  107852. /**
  107853. * Intensity of the emissive part of the material.
  107854. * This helps controlling the emissive effect without modifying the emissive color.
  107855. */
  107856. protected _emissiveIntensity: number;
  107857. /**
  107858. * Intensity of the environment e.g. how much the environment will light the object
  107859. * either through harmonics for rough material or through the refelction for shiny ones.
  107860. */
  107861. protected _environmentIntensity: number;
  107862. /**
  107863. * This is a special control allowing the reduction of the specular highlights coming from the
  107864. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107865. */
  107866. protected _specularIntensity: number;
  107867. /**
  107868. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  107869. */
  107870. private _lightingInfos;
  107871. /**
  107872. * Debug Control allowing disabling the bump map on this material.
  107873. */
  107874. protected _disableBumpMap: boolean;
  107875. /**
  107876. * AKA Diffuse Texture in standard nomenclature.
  107877. */
  107878. protected _albedoTexture: Nullable<BaseTexture>;
  107879. /**
  107880. * AKA Occlusion Texture in other nomenclature.
  107881. */
  107882. protected _ambientTexture: Nullable<BaseTexture>;
  107883. /**
  107884. * AKA Occlusion Texture Intensity in other nomenclature.
  107885. */
  107886. protected _ambientTextureStrength: number;
  107887. /**
  107888. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107889. * 1 means it completely occludes it
  107890. * 0 mean it has no impact
  107891. */
  107892. protected _ambientTextureImpactOnAnalyticalLights: number;
  107893. /**
  107894. * Stores the alpha values in a texture.
  107895. */
  107896. protected _opacityTexture: Nullable<BaseTexture>;
  107897. /**
  107898. * Stores the reflection values in a texture.
  107899. */
  107900. protected _reflectionTexture: Nullable<BaseTexture>;
  107901. /**
  107902. * Stores the emissive values in a texture.
  107903. */
  107904. protected _emissiveTexture: Nullable<BaseTexture>;
  107905. /**
  107906. * AKA Specular texture in other nomenclature.
  107907. */
  107908. protected _reflectivityTexture: Nullable<BaseTexture>;
  107909. /**
  107910. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107911. */
  107912. protected _metallicTexture: Nullable<BaseTexture>;
  107913. /**
  107914. * Specifies the metallic scalar of the metallic/roughness workflow.
  107915. * Can also be used to scale the metalness values of the metallic texture.
  107916. */
  107917. protected _metallic: Nullable<number>;
  107918. /**
  107919. * Specifies the roughness scalar of the metallic/roughness workflow.
  107920. * Can also be used to scale the roughness values of the metallic texture.
  107921. */
  107922. protected _roughness: Nullable<number>;
  107923. /**
  107924. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107925. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107926. */
  107927. protected _microSurfaceTexture: Nullable<BaseTexture>;
  107928. /**
  107929. * Stores surface normal data used to displace a mesh in a texture.
  107930. */
  107931. protected _bumpTexture: Nullable<BaseTexture>;
  107932. /**
  107933. * Stores the pre-calculated light information of a mesh in a texture.
  107934. */
  107935. protected _lightmapTexture: Nullable<BaseTexture>;
  107936. /**
  107937. * The color of a material in ambient lighting.
  107938. */
  107939. protected _ambientColor: Color3;
  107940. /**
  107941. * AKA Diffuse Color in other nomenclature.
  107942. */
  107943. protected _albedoColor: Color3;
  107944. /**
  107945. * AKA Specular Color in other nomenclature.
  107946. */
  107947. protected _reflectivityColor: Color3;
  107948. /**
  107949. * The color applied when light is reflected from a material.
  107950. */
  107951. protected _reflectionColor: Color3;
  107952. /**
  107953. * The color applied when light is emitted from a material.
  107954. */
  107955. protected _emissiveColor: Color3;
  107956. /**
  107957. * AKA Glossiness in other nomenclature.
  107958. */
  107959. protected _microSurface: number;
  107960. /**
  107961. * Specifies that the material will use the light map as a show map.
  107962. */
  107963. protected _useLightmapAsShadowmap: boolean;
  107964. /**
  107965. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107966. * makes the reflect vector face the model (under horizon).
  107967. */
  107968. protected _useHorizonOcclusion: boolean;
  107969. /**
  107970. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107971. * too much the area relying on ambient texture to define their ambient occlusion.
  107972. */
  107973. protected _useRadianceOcclusion: boolean;
  107974. /**
  107975. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107976. */
  107977. protected _useAlphaFromAlbedoTexture: boolean;
  107978. /**
  107979. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  107980. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107981. */
  107982. protected _useSpecularOverAlpha: boolean;
  107983. /**
  107984. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107985. */
  107986. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107987. /**
  107988. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107989. */
  107990. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  107991. /**
  107992. * Specifies if the metallic texture contains the roughness information in its green channel.
  107993. */
  107994. protected _useRoughnessFromMetallicTextureGreen: boolean;
  107995. /**
  107996. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107997. */
  107998. protected _useMetallnessFromMetallicTextureBlue: boolean;
  107999. /**
  108000. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108001. */
  108002. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  108003. /**
  108004. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108005. */
  108006. protected _useAmbientInGrayScale: boolean;
  108007. /**
  108008. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108009. * The material will try to infer what glossiness each pixel should be.
  108010. */
  108011. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  108012. /**
  108013. * Defines the falloff type used in this material.
  108014. * It by default is Physical.
  108015. */
  108016. protected _lightFalloff: number;
  108017. /**
  108018. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108019. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108020. */
  108021. protected _useRadianceOverAlpha: boolean;
  108022. /**
  108023. * Allows using an object space normal map (instead of tangent space).
  108024. */
  108025. protected _useObjectSpaceNormalMap: boolean;
  108026. /**
  108027. * Allows using the bump map in parallax mode.
  108028. */
  108029. protected _useParallax: boolean;
  108030. /**
  108031. * Allows using the bump map in parallax occlusion mode.
  108032. */
  108033. protected _useParallaxOcclusion: boolean;
  108034. /**
  108035. * Controls the scale bias of the parallax mode.
  108036. */
  108037. protected _parallaxScaleBias: number;
  108038. /**
  108039. * If sets to true, disables all the lights affecting the material.
  108040. */
  108041. protected _disableLighting: boolean;
  108042. /**
  108043. * Number of Simultaneous lights allowed on the material.
  108044. */
  108045. protected _maxSimultaneousLights: number;
  108046. /**
  108047. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108048. */
  108049. protected _invertNormalMapX: boolean;
  108050. /**
  108051. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108052. */
  108053. protected _invertNormalMapY: boolean;
  108054. /**
  108055. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108056. */
  108057. protected _twoSidedLighting: boolean;
  108058. /**
  108059. * Defines the alpha limits in alpha test mode.
  108060. */
  108061. protected _alphaCutOff: number;
  108062. /**
  108063. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108064. */
  108065. protected _forceAlphaTest: boolean;
  108066. /**
  108067. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108068. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108069. */
  108070. protected _useAlphaFresnel: boolean;
  108071. /**
  108072. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108073. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108074. */
  108075. protected _useLinearAlphaFresnel: boolean;
  108076. /**
  108077. * The transparency mode of the material.
  108078. */
  108079. protected _transparencyMode: Nullable<number>;
  108080. /**
  108081. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  108082. * from cos thetav and roughness:
  108083. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  108084. */
  108085. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  108086. /**
  108087. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108088. */
  108089. protected _forceIrradianceInFragment: boolean;
  108090. /**
  108091. * Force normal to face away from face.
  108092. */
  108093. protected _forceNormalForward: boolean;
  108094. /**
  108095. * Enables specular anti aliasing in the PBR shader.
  108096. * It will both interacts on the Geometry for analytical and IBL lighting.
  108097. * It also prefilter the roughness map based on the bump values.
  108098. */
  108099. protected _enableSpecularAntiAliasing: boolean;
  108100. /**
  108101. * Default configuration related to image processing available in the PBR Material.
  108102. */
  108103. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108104. /**
  108105. * Keep track of the image processing observer to allow dispose and replace.
  108106. */
  108107. private _imageProcessingObserver;
  108108. /**
  108109. * Attaches a new image processing configuration to the PBR Material.
  108110. * @param configuration
  108111. */
  108112. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108113. /**
  108114. * Stores the available render targets.
  108115. */
  108116. private _renderTargets;
  108117. /**
  108118. * Sets the global ambient color for the material used in lighting calculations.
  108119. */
  108120. private _globalAmbientColor;
  108121. /**
  108122. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  108123. */
  108124. private _useLogarithmicDepth;
  108125. /**
  108126. * If set to true, no lighting calculations will be applied.
  108127. */
  108128. private _unlit;
  108129. private _debugMode;
  108130. /**
  108131. * @hidden
  108132. * This is reserved for the inspector.
  108133. * Defines the material debug mode.
  108134. * It helps seeing only some components of the material while troubleshooting.
  108135. */
  108136. debugMode: number;
  108137. /**
  108138. * @hidden
  108139. * This is reserved for the inspector.
  108140. * Specify from where on screen the debug mode should start.
  108141. * The value goes from -1 (full screen) to 1 (not visible)
  108142. * It helps with side by side comparison against the final render
  108143. * This defaults to -1
  108144. */
  108145. private debugLimit;
  108146. /**
  108147. * @hidden
  108148. * This is reserved for the inspector.
  108149. * As the default viewing range might not be enough (if the ambient is really small for instance)
  108150. * You can use the factor to better multiply the final value.
  108151. */
  108152. private debugFactor;
  108153. /**
  108154. * Defines the clear coat layer parameters for the material.
  108155. */
  108156. readonly clearCoat: PBRClearCoatConfiguration;
  108157. /**
  108158. * Defines the anisotropic parameters for the material.
  108159. */
  108160. readonly anisotropy: PBRAnisotropicConfiguration;
  108161. /**
  108162. * Defines the BRDF parameters for the material.
  108163. */
  108164. readonly brdf: PBRBRDFConfiguration;
  108165. /**
  108166. * Defines the Sheen parameters for the material.
  108167. */
  108168. readonly sheen: PBRSheenConfiguration;
  108169. /**
  108170. * Defines the SubSurface parameters for the material.
  108171. */
  108172. readonly subSurface: PBRSubSurfaceConfiguration;
  108173. /**
  108174. * Custom callback helping to override the default shader used in the material.
  108175. */
  108176. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  108177. /**
  108178. * Instantiates a new PBRMaterial instance.
  108179. *
  108180. * @param name The material name
  108181. * @param scene The scene the material will be use in.
  108182. */
  108183. constructor(name: string, scene: Scene);
  108184. /**
  108185. * Gets a boolean indicating that current material needs to register RTT
  108186. */
  108187. readonly hasRenderTargetTextures: boolean;
  108188. /**
  108189. * Gets the name of the material class.
  108190. */
  108191. getClassName(): string;
  108192. /**
  108193. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108194. */
  108195. /**
  108196. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108197. */
  108198. useLogarithmicDepth: boolean;
  108199. /**
  108200. * Gets the current transparency mode.
  108201. */
  108202. /**
  108203. * Sets the transparency mode of the material.
  108204. *
  108205. * | Value | Type | Description |
  108206. * | ----- | ----------------------------------- | ----------- |
  108207. * | 0 | OPAQUE | |
  108208. * | 1 | ALPHATEST | |
  108209. * | 2 | ALPHABLEND | |
  108210. * | 3 | ALPHATESTANDBLEND | |
  108211. *
  108212. */
  108213. transparencyMode: Nullable<number>;
  108214. /**
  108215. * Returns true if alpha blending should be disabled.
  108216. */
  108217. private readonly _disableAlphaBlending;
  108218. /**
  108219. * Specifies whether or not this material should be rendered in alpha blend mode.
  108220. */
  108221. needAlphaBlending(): boolean;
  108222. /**
  108223. * Specifies if the mesh will require alpha blending.
  108224. * @param mesh - BJS mesh.
  108225. */
  108226. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  108227. /**
  108228. * Specifies whether or not this material should be rendered in alpha test mode.
  108229. */
  108230. needAlphaTesting(): boolean;
  108231. /**
  108232. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  108233. */
  108234. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  108235. /**
  108236. * Gets the texture used for the alpha test.
  108237. */
  108238. getAlphaTestTexture(): Nullable<BaseTexture>;
  108239. /**
  108240. * Specifies that the submesh is ready to be used.
  108241. * @param mesh - BJS mesh.
  108242. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  108243. * @param useInstances - Specifies that instances should be used.
  108244. * @returns - boolean indicating that the submesh is ready or not.
  108245. */
  108246. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108247. /**
  108248. * Specifies if the material uses metallic roughness workflow.
  108249. * @returns boolean specifiying if the material uses metallic roughness workflow.
  108250. */
  108251. isMetallicWorkflow(): boolean;
  108252. private _prepareEffect;
  108253. private _prepareDefines;
  108254. /**
  108255. * Force shader compilation
  108256. */
  108257. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  108258. clipPlane: boolean;
  108259. }>): void;
  108260. /**
  108261. * Initializes the uniform buffer layout for the shader.
  108262. */
  108263. buildUniformLayout(): void;
  108264. /**
  108265. * Unbinds the material from the mesh
  108266. */
  108267. unbind(): void;
  108268. /**
  108269. * Binds the submesh data.
  108270. * @param world - The world matrix.
  108271. * @param mesh - The BJS mesh.
  108272. * @param subMesh - A submesh of the BJS mesh.
  108273. */
  108274. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108275. /**
  108276. * Returns the animatable textures.
  108277. * @returns - Array of animatable textures.
  108278. */
  108279. getAnimatables(): IAnimatable[];
  108280. /**
  108281. * Returns the texture used for reflections.
  108282. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  108283. */
  108284. private _getReflectionTexture;
  108285. /**
  108286. * Returns an array of the actively used textures.
  108287. * @returns - Array of BaseTextures
  108288. */
  108289. getActiveTextures(): BaseTexture[];
  108290. /**
  108291. * Checks to see if a texture is used in the material.
  108292. * @param texture - Base texture to use.
  108293. * @returns - Boolean specifying if a texture is used in the material.
  108294. */
  108295. hasTexture(texture: BaseTexture): boolean;
  108296. /**
  108297. * Disposes the resources of the material.
  108298. * @param forceDisposeEffect - Forces the disposal of effects.
  108299. * @param forceDisposeTextures - Forces the disposal of all textures.
  108300. */
  108301. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108302. }
  108303. }
  108304. declare module BABYLON {
  108305. /**
  108306. * The Physically based material of BJS.
  108307. *
  108308. * This offers the main features of a standard PBR material.
  108309. * For more information, please refer to the documentation :
  108310. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108311. */
  108312. export class PBRMaterial extends PBRBaseMaterial {
  108313. /**
  108314. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108315. */
  108316. static readonly PBRMATERIAL_OPAQUE: number;
  108317. /**
  108318. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108319. */
  108320. static readonly PBRMATERIAL_ALPHATEST: number;
  108321. /**
  108322. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108323. */
  108324. static readonly PBRMATERIAL_ALPHABLEND: number;
  108325. /**
  108326. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108327. * They are also discarded below the alpha cutoff threshold to improve performances.
  108328. */
  108329. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108330. /**
  108331. * Defines the default value of how much AO map is occluding the analytical lights
  108332. * (point spot...).
  108333. */
  108334. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108335. /**
  108336. * Intensity of the direct lights e.g. the four lights available in your scene.
  108337. * This impacts both the direct diffuse and specular highlights.
  108338. */
  108339. directIntensity: number;
  108340. /**
  108341. * Intensity of the emissive part of the material.
  108342. * This helps controlling the emissive effect without modifying the emissive color.
  108343. */
  108344. emissiveIntensity: number;
  108345. /**
  108346. * Intensity of the environment e.g. how much the environment will light the object
  108347. * either through harmonics for rough material or through the refelction for shiny ones.
  108348. */
  108349. environmentIntensity: number;
  108350. /**
  108351. * This is a special control allowing the reduction of the specular highlights coming from the
  108352. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108353. */
  108354. specularIntensity: number;
  108355. /**
  108356. * Debug Control allowing disabling the bump map on this material.
  108357. */
  108358. disableBumpMap: boolean;
  108359. /**
  108360. * AKA Diffuse Texture in standard nomenclature.
  108361. */
  108362. albedoTexture: BaseTexture;
  108363. /**
  108364. * AKA Occlusion Texture in other nomenclature.
  108365. */
  108366. ambientTexture: BaseTexture;
  108367. /**
  108368. * AKA Occlusion Texture Intensity in other nomenclature.
  108369. */
  108370. ambientTextureStrength: number;
  108371. /**
  108372. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108373. * 1 means it completely occludes it
  108374. * 0 mean it has no impact
  108375. */
  108376. ambientTextureImpactOnAnalyticalLights: number;
  108377. /**
  108378. * Stores the alpha values in a texture.
  108379. */
  108380. opacityTexture: BaseTexture;
  108381. /**
  108382. * Stores the reflection values in a texture.
  108383. */
  108384. reflectionTexture: Nullable<BaseTexture>;
  108385. /**
  108386. * Stores the emissive values in a texture.
  108387. */
  108388. emissiveTexture: BaseTexture;
  108389. /**
  108390. * AKA Specular texture in other nomenclature.
  108391. */
  108392. reflectivityTexture: BaseTexture;
  108393. /**
  108394. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108395. */
  108396. metallicTexture: BaseTexture;
  108397. /**
  108398. * Specifies the metallic scalar of the metallic/roughness workflow.
  108399. * Can also be used to scale the metalness values of the metallic texture.
  108400. */
  108401. metallic: Nullable<number>;
  108402. /**
  108403. * Specifies the roughness scalar of the metallic/roughness workflow.
  108404. * Can also be used to scale the roughness values of the metallic texture.
  108405. */
  108406. roughness: Nullable<number>;
  108407. /**
  108408. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108409. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108410. */
  108411. microSurfaceTexture: BaseTexture;
  108412. /**
  108413. * Stores surface normal data used to displace a mesh in a texture.
  108414. */
  108415. bumpTexture: BaseTexture;
  108416. /**
  108417. * Stores the pre-calculated light information of a mesh in a texture.
  108418. */
  108419. lightmapTexture: BaseTexture;
  108420. /**
  108421. * Stores the refracted light information in a texture.
  108422. */
  108423. refractionTexture: Nullable<BaseTexture>;
  108424. /**
  108425. * The color of a material in ambient lighting.
  108426. */
  108427. ambientColor: Color3;
  108428. /**
  108429. * AKA Diffuse Color in other nomenclature.
  108430. */
  108431. albedoColor: Color3;
  108432. /**
  108433. * AKA Specular Color in other nomenclature.
  108434. */
  108435. reflectivityColor: Color3;
  108436. /**
  108437. * The color reflected from the material.
  108438. */
  108439. reflectionColor: Color3;
  108440. /**
  108441. * The color emitted from the material.
  108442. */
  108443. emissiveColor: Color3;
  108444. /**
  108445. * AKA Glossiness in other nomenclature.
  108446. */
  108447. microSurface: number;
  108448. /**
  108449. * source material index of refraction (IOR)' / 'destination material IOR.
  108450. */
  108451. indexOfRefraction: number;
  108452. /**
  108453. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108454. */
  108455. invertRefractionY: boolean;
  108456. /**
  108457. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108458. * Materials half opaque for instance using refraction could benefit from this control.
  108459. */
  108460. linkRefractionWithTransparency: boolean;
  108461. /**
  108462. * If true, the light map contains occlusion information instead of lighting info.
  108463. */
  108464. useLightmapAsShadowmap: boolean;
  108465. /**
  108466. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108467. */
  108468. useAlphaFromAlbedoTexture: boolean;
  108469. /**
  108470. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108471. */
  108472. forceAlphaTest: boolean;
  108473. /**
  108474. * Defines the alpha limits in alpha test mode.
  108475. */
  108476. alphaCutOff: number;
  108477. /**
  108478. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108479. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108480. */
  108481. useSpecularOverAlpha: boolean;
  108482. /**
  108483. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108484. */
  108485. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108486. /**
  108487. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108488. */
  108489. useRoughnessFromMetallicTextureAlpha: boolean;
  108490. /**
  108491. * Specifies if the metallic texture contains the roughness information in its green channel.
  108492. */
  108493. useRoughnessFromMetallicTextureGreen: boolean;
  108494. /**
  108495. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108496. */
  108497. useMetallnessFromMetallicTextureBlue: boolean;
  108498. /**
  108499. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108500. */
  108501. useAmbientOcclusionFromMetallicTextureRed: boolean;
  108502. /**
  108503. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108504. */
  108505. useAmbientInGrayScale: boolean;
  108506. /**
  108507. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108508. * The material will try to infer what glossiness each pixel should be.
  108509. */
  108510. useAutoMicroSurfaceFromReflectivityMap: boolean;
  108511. /**
  108512. * BJS is using an harcoded light falloff based on a manually sets up range.
  108513. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108514. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108515. */
  108516. /**
  108517. * BJS is using an harcoded light falloff based on a manually sets up range.
  108518. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108519. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108520. */
  108521. usePhysicalLightFalloff: boolean;
  108522. /**
  108523. * In order to support the falloff compatibility with gltf, a special mode has been added
  108524. * to reproduce the gltf light falloff.
  108525. */
  108526. /**
  108527. * In order to support the falloff compatibility with gltf, a special mode has been added
  108528. * to reproduce the gltf light falloff.
  108529. */
  108530. useGLTFLightFalloff: boolean;
  108531. /**
  108532. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108533. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108534. */
  108535. useRadianceOverAlpha: boolean;
  108536. /**
  108537. * Allows using an object space normal map (instead of tangent space).
  108538. */
  108539. useObjectSpaceNormalMap: boolean;
  108540. /**
  108541. * Allows using the bump map in parallax mode.
  108542. */
  108543. useParallax: boolean;
  108544. /**
  108545. * Allows using the bump map in parallax occlusion mode.
  108546. */
  108547. useParallaxOcclusion: boolean;
  108548. /**
  108549. * Controls the scale bias of the parallax mode.
  108550. */
  108551. parallaxScaleBias: number;
  108552. /**
  108553. * If sets to true, disables all the lights affecting the material.
  108554. */
  108555. disableLighting: boolean;
  108556. /**
  108557. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108558. */
  108559. forceIrradianceInFragment: boolean;
  108560. /**
  108561. * Number of Simultaneous lights allowed on the material.
  108562. */
  108563. maxSimultaneousLights: number;
  108564. /**
  108565. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108566. */
  108567. invertNormalMapX: boolean;
  108568. /**
  108569. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108570. */
  108571. invertNormalMapY: boolean;
  108572. /**
  108573. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108574. */
  108575. twoSidedLighting: boolean;
  108576. /**
  108577. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108578. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108579. */
  108580. useAlphaFresnel: boolean;
  108581. /**
  108582. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108583. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108584. */
  108585. useLinearAlphaFresnel: boolean;
  108586. /**
  108587. * Let user defines the brdf lookup texture used for IBL.
  108588. * A default 8bit version is embedded but you could point at :
  108589. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  108590. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108591. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  108592. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108593. */
  108594. environmentBRDFTexture: Nullable<BaseTexture>;
  108595. /**
  108596. * Force normal to face away from face.
  108597. */
  108598. forceNormalForward: boolean;
  108599. /**
  108600. * Enables specular anti aliasing in the PBR shader.
  108601. * It will both interacts on the Geometry for analytical and IBL lighting.
  108602. * It also prefilter the roughness map based on the bump values.
  108603. */
  108604. enableSpecularAntiAliasing: boolean;
  108605. /**
  108606. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108607. * makes the reflect vector face the model (under horizon).
  108608. */
  108609. useHorizonOcclusion: boolean;
  108610. /**
  108611. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108612. * too much the area relying on ambient texture to define their ambient occlusion.
  108613. */
  108614. useRadianceOcclusion: boolean;
  108615. /**
  108616. * If set to true, no lighting calculations will be applied.
  108617. */
  108618. unlit: boolean;
  108619. /**
  108620. * Gets the image processing configuration used either in this material.
  108621. */
  108622. /**
  108623. * Sets the Default image processing configuration used either in the this material.
  108624. *
  108625. * If sets to null, the scene one is in use.
  108626. */
  108627. imageProcessingConfiguration: ImageProcessingConfiguration;
  108628. /**
  108629. * Gets wether the color curves effect is enabled.
  108630. */
  108631. /**
  108632. * Sets wether the color curves effect is enabled.
  108633. */
  108634. cameraColorCurvesEnabled: boolean;
  108635. /**
  108636. * Gets wether the color grading effect is enabled.
  108637. */
  108638. /**
  108639. * Gets wether the color grading effect is enabled.
  108640. */
  108641. cameraColorGradingEnabled: boolean;
  108642. /**
  108643. * Gets wether tonemapping is enabled or not.
  108644. */
  108645. /**
  108646. * Sets wether tonemapping is enabled or not
  108647. */
  108648. cameraToneMappingEnabled: boolean;
  108649. /**
  108650. * The camera exposure used on this material.
  108651. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108652. * This corresponds to a photographic exposure.
  108653. */
  108654. /**
  108655. * The camera exposure used on this material.
  108656. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108657. * This corresponds to a photographic exposure.
  108658. */
  108659. cameraExposure: number;
  108660. /**
  108661. * Gets The camera contrast used on this material.
  108662. */
  108663. /**
  108664. * Sets The camera contrast used on this material.
  108665. */
  108666. cameraContrast: number;
  108667. /**
  108668. * Gets the Color Grading 2D Lookup Texture.
  108669. */
  108670. /**
  108671. * Sets the Color Grading 2D Lookup Texture.
  108672. */
  108673. cameraColorGradingTexture: Nullable<BaseTexture>;
  108674. /**
  108675. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108676. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108677. * 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;
  108678. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108679. */
  108680. /**
  108681. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108682. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108683. * 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;
  108684. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108685. */
  108686. cameraColorCurves: Nullable<ColorCurves>;
  108687. /**
  108688. * Instantiates a new PBRMaterial instance.
  108689. *
  108690. * @param name The material name
  108691. * @param scene The scene the material will be use in.
  108692. */
  108693. constructor(name: string, scene: Scene);
  108694. /**
  108695. * Returns the name of this material class.
  108696. */
  108697. getClassName(): string;
  108698. /**
  108699. * Makes a duplicate of the current material.
  108700. * @param name - name to use for the new material.
  108701. */
  108702. clone(name: string): PBRMaterial;
  108703. /**
  108704. * Serializes this PBR Material.
  108705. * @returns - An object with the serialized material.
  108706. */
  108707. serialize(): any;
  108708. /**
  108709. * Parses a PBR Material from a serialized object.
  108710. * @param source - Serialized object.
  108711. * @param scene - BJS scene instance.
  108712. * @param rootUrl - url for the scene object
  108713. * @returns - PBRMaterial
  108714. */
  108715. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  108716. }
  108717. }
  108718. declare module BABYLON {
  108719. /**
  108720. * Direct draw surface info
  108721. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  108722. */
  108723. export interface DDSInfo {
  108724. /**
  108725. * Width of the texture
  108726. */
  108727. width: number;
  108728. /**
  108729. * Width of the texture
  108730. */
  108731. height: number;
  108732. /**
  108733. * Number of Mipmaps for the texture
  108734. * @see https://en.wikipedia.org/wiki/Mipmap
  108735. */
  108736. mipmapCount: number;
  108737. /**
  108738. * If the textures format is a known fourCC format
  108739. * @see https://www.fourcc.org/
  108740. */
  108741. isFourCC: boolean;
  108742. /**
  108743. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  108744. */
  108745. isRGB: boolean;
  108746. /**
  108747. * If the texture is a lumincance format
  108748. */
  108749. isLuminance: boolean;
  108750. /**
  108751. * If this is a cube texture
  108752. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  108753. */
  108754. isCube: boolean;
  108755. /**
  108756. * If the texture is a compressed format eg. FOURCC_DXT1
  108757. */
  108758. isCompressed: boolean;
  108759. /**
  108760. * The dxgiFormat of the texture
  108761. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  108762. */
  108763. dxgiFormat: number;
  108764. /**
  108765. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  108766. */
  108767. textureType: number;
  108768. /**
  108769. * Sphericle polynomial created for the dds texture
  108770. */
  108771. sphericalPolynomial?: SphericalPolynomial;
  108772. }
  108773. /**
  108774. * Class used to provide DDS decompression tools
  108775. */
  108776. export class DDSTools {
  108777. /**
  108778. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  108779. */
  108780. static StoreLODInAlphaChannel: boolean;
  108781. /**
  108782. * Gets DDS information from an array buffer
  108783. * @param arrayBuffer defines the array buffer to read data from
  108784. * @returns the DDS information
  108785. */
  108786. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  108787. private static _FloatView;
  108788. private static _Int32View;
  108789. private static _ToHalfFloat;
  108790. private static _FromHalfFloat;
  108791. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  108792. private static _GetHalfFloatRGBAArrayBuffer;
  108793. private static _GetFloatRGBAArrayBuffer;
  108794. private static _GetFloatAsUIntRGBAArrayBuffer;
  108795. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  108796. private static _GetRGBAArrayBuffer;
  108797. private static _ExtractLongWordOrder;
  108798. private static _GetRGBArrayBuffer;
  108799. private static _GetLuminanceArrayBuffer;
  108800. /**
  108801. * Uploads DDS Levels to a Babylon Texture
  108802. * @hidden
  108803. */
  108804. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  108805. }
  108806. interface Engine {
  108807. /**
  108808. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  108809. * @param rootUrl defines the url where the file to load is located
  108810. * @param scene defines the current scene
  108811. * @param lodScale defines scale to apply to the mip map selection
  108812. * @param lodOffset defines offset to apply to the mip map selection
  108813. * @param onLoad defines an optional callback raised when the texture is loaded
  108814. * @param onError defines an optional callback raised if there is an issue to load the texture
  108815. * @param format defines the format of the data
  108816. * @param forcedExtension defines the extension to use to pick the right loader
  108817. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  108818. * @returns the cube texture as an InternalTexture
  108819. */
  108820. 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;
  108821. }
  108822. }
  108823. declare module BABYLON {
  108824. /**
  108825. * Implementation of the DDS Texture Loader.
  108826. * @hidden
  108827. */
  108828. export class _DDSTextureLoader implements IInternalTextureLoader {
  108829. /**
  108830. * Defines wether the loader supports cascade loading the different faces.
  108831. */
  108832. readonly supportCascades: boolean;
  108833. /**
  108834. * This returns if the loader support the current file information.
  108835. * @param extension defines the file extension of the file being loaded
  108836. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108837. * @param fallback defines the fallback internal texture if any
  108838. * @param isBase64 defines whether the texture is encoded as a base64
  108839. * @param isBuffer defines whether the texture data are stored as a buffer
  108840. * @returns true if the loader can load the specified file
  108841. */
  108842. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108843. /**
  108844. * Transform the url before loading if required.
  108845. * @param rootUrl the url of the texture
  108846. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108847. * @returns the transformed texture
  108848. */
  108849. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108850. /**
  108851. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108852. * @param rootUrl the url of the texture
  108853. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108854. * @returns the fallback texture
  108855. */
  108856. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108857. /**
  108858. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108859. * @param data contains the texture data
  108860. * @param texture defines the BabylonJS internal texture
  108861. * @param createPolynomials will be true if polynomials have been requested
  108862. * @param onLoad defines the callback to trigger once the texture is ready
  108863. * @param onError defines the callback to trigger in case of error
  108864. */
  108865. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108866. /**
  108867. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108868. * @param data contains the texture data
  108869. * @param texture defines the BabylonJS internal texture
  108870. * @param callback defines the method to call once ready to upload
  108871. */
  108872. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  108873. }
  108874. }
  108875. declare module BABYLON {
  108876. /** @hidden */
  108877. export var rgbdEncodePixelShader: {
  108878. name: string;
  108879. shader: string;
  108880. };
  108881. }
  108882. declare module BABYLON {
  108883. /**
  108884. * Raw texture data and descriptor sufficient for WebGL texture upload
  108885. */
  108886. export interface EnvironmentTextureInfo {
  108887. /**
  108888. * Version of the environment map
  108889. */
  108890. version: number;
  108891. /**
  108892. * Width of image
  108893. */
  108894. width: number;
  108895. /**
  108896. * Irradiance information stored in the file.
  108897. */
  108898. irradiance: any;
  108899. /**
  108900. * Specular information stored in the file.
  108901. */
  108902. specular: any;
  108903. }
  108904. /**
  108905. * Sets of helpers addressing the serialization and deserialization of environment texture
  108906. * stored in a BabylonJS env file.
  108907. * Those files are usually stored as .env files.
  108908. */
  108909. export class EnvironmentTextureTools {
  108910. /**
  108911. * Magic number identifying the env file.
  108912. */
  108913. private static _MagicBytes;
  108914. /**
  108915. * Gets the environment info from an env file.
  108916. * @param data The array buffer containing the .env bytes.
  108917. * @returns the environment file info (the json header) if successfully parsed.
  108918. */
  108919. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  108920. /**
  108921. * Creates an environment texture from a loaded cube texture.
  108922. * @param texture defines the cube texture to convert in env file
  108923. * @return a promise containing the environment data if succesfull.
  108924. */
  108925. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  108926. /**
  108927. * Creates a JSON representation of the spherical data.
  108928. * @param texture defines the texture containing the polynomials
  108929. * @return the JSON representation of the spherical info
  108930. */
  108931. private static _CreateEnvTextureIrradiance;
  108932. /**
  108933. * Uploads the texture info contained in the env file to the GPU.
  108934. * @param texture defines the internal texture to upload to
  108935. * @param arrayBuffer defines the buffer cotaining the data to load
  108936. * @param info defines the texture info retrieved through the GetEnvInfo method
  108937. * @returns a promise
  108938. */
  108939. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  108940. /**
  108941. * Uploads the levels of image data to the GPU.
  108942. * @param texture defines the internal texture to upload to
  108943. * @param imageData defines the array buffer views of image data [mipmap][face]
  108944. * @returns a promise
  108945. */
  108946. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  108947. /**
  108948. * Uploads spherical polynomials information to the texture.
  108949. * @param texture defines the texture we are trying to upload the information to
  108950. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  108951. */
  108952. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  108953. /** @hidden */
  108954. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  108955. }
  108956. }
  108957. declare module BABYLON {
  108958. /**
  108959. * Implementation of the ENV Texture Loader.
  108960. * @hidden
  108961. */
  108962. export class _ENVTextureLoader implements IInternalTextureLoader {
  108963. /**
  108964. * Defines wether the loader supports cascade loading the different faces.
  108965. */
  108966. readonly supportCascades: boolean;
  108967. /**
  108968. * This returns if the loader support the current file information.
  108969. * @param extension defines the file extension of the file being loaded
  108970. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108971. * @param fallback defines the fallback internal texture if any
  108972. * @param isBase64 defines whether the texture is encoded as a base64
  108973. * @param isBuffer defines whether the texture data are stored as a buffer
  108974. * @returns true if the loader can load the specified file
  108975. */
  108976. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108977. /**
  108978. * Transform the url before loading if required.
  108979. * @param rootUrl the url of the texture
  108980. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108981. * @returns the transformed texture
  108982. */
  108983. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108984. /**
  108985. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108986. * @param rootUrl the url of the texture
  108987. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108988. * @returns the fallback texture
  108989. */
  108990. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108991. /**
  108992. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108993. * @param data contains the texture data
  108994. * @param texture defines the BabylonJS internal texture
  108995. * @param createPolynomials will be true if polynomials have been requested
  108996. * @param onLoad defines the callback to trigger once the texture is ready
  108997. * @param onError defines the callback to trigger in case of error
  108998. */
  108999. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109000. /**
  109001. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109002. * @param data contains the texture data
  109003. * @param texture defines the BabylonJS internal texture
  109004. * @param callback defines the method to call once ready to upload
  109005. */
  109006. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109007. }
  109008. }
  109009. declare module BABYLON {
  109010. /**
  109011. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  109012. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  109013. */
  109014. export class KhronosTextureContainer {
  109015. /** contents of the KTX container file */
  109016. arrayBuffer: any;
  109017. private static HEADER_LEN;
  109018. private static COMPRESSED_2D;
  109019. private static COMPRESSED_3D;
  109020. private static TEX_2D;
  109021. private static TEX_3D;
  109022. /**
  109023. * Gets the openGL type
  109024. */
  109025. glType: number;
  109026. /**
  109027. * Gets the openGL type size
  109028. */
  109029. glTypeSize: number;
  109030. /**
  109031. * Gets the openGL format
  109032. */
  109033. glFormat: number;
  109034. /**
  109035. * Gets the openGL internal format
  109036. */
  109037. glInternalFormat: number;
  109038. /**
  109039. * Gets the base internal format
  109040. */
  109041. glBaseInternalFormat: number;
  109042. /**
  109043. * Gets image width in pixel
  109044. */
  109045. pixelWidth: number;
  109046. /**
  109047. * Gets image height in pixel
  109048. */
  109049. pixelHeight: number;
  109050. /**
  109051. * Gets image depth in pixels
  109052. */
  109053. pixelDepth: number;
  109054. /**
  109055. * Gets the number of array elements
  109056. */
  109057. numberOfArrayElements: number;
  109058. /**
  109059. * Gets the number of faces
  109060. */
  109061. numberOfFaces: number;
  109062. /**
  109063. * Gets the number of mipmap levels
  109064. */
  109065. numberOfMipmapLevels: number;
  109066. /**
  109067. * Gets the bytes of key value data
  109068. */
  109069. bytesOfKeyValueData: number;
  109070. /**
  109071. * Gets the load type
  109072. */
  109073. loadType: number;
  109074. /**
  109075. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  109076. */
  109077. isInvalid: boolean;
  109078. /**
  109079. * Creates a new KhronosTextureContainer
  109080. * @param arrayBuffer contents of the KTX container file
  109081. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  109082. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  109083. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  109084. */
  109085. constructor(
  109086. /** contents of the KTX container file */
  109087. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  109088. /**
  109089. * Uploads KTX content to a Babylon Texture.
  109090. * It is assumed that the texture has already been created & is currently bound
  109091. * @hidden
  109092. */
  109093. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  109094. private _upload2DCompressedLevels;
  109095. }
  109096. }
  109097. declare module BABYLON {
  109098. /**
  109099. * Implementation of the KTX Texture Loader.
  109100. * @hidden
  109101. */
  109102. export class _KTXTextureLoader implements IInternalTextureLoader {
  109103. /**
  109104. * Defines wether the loader supports cascade loading the different faces.
  109105. */
  109106. readonly supportCascades: boolean;
  109107. /**
  109108. * This returns if the loader support the current file information.
  109109. * @param extension defines the file extension of the file being loaded
  109110. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109111. * @param fallback defines the fallback internal texture if any
  109112. * @param isBase64 defines whether the texture is encoded as a base64
  109113. * @param isBuffer defines whether the texture data are stored as a buffer
  109114. * @returns true if the loader can load the specified file
  109115. */
  109116. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109117. /**
  109118. * Transform the url before loading if required.
  109119. * @param rootUrl the url of the texture
  109120. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109121. * @returns the transformed texture
  109122. */
  109123. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109124. /**
  109125. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109126. * @param rootUrl the url of the texture
  109127. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109128. * @returns the fallback texture
  109129. */
  109130. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109131. /**
  109132. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109133. * @param data contains the texture data
  109134. * @param texture defines the BabylonJS internal texture
  109135. * @param createPolynomials will be true if polynomials have been requested
  109136. * @param onLoad defines the callback to trigger once the texture is ready
  109137. * @param onError defines the callback to trigger in case of error
  109138. */
  109139. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109140. /**
  109141. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109142. * @param data contains the texture data
  109143. * @param texture defines the BabylonJS internal texture
  109144. * @param callback defines the method to call once ready to upload
  109145. */
  109146. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  109147. }
  109148. }
  109149. declare module BABYLON {
  109150. /** @hidden */
  109151. export var _forceSceneHelpersToBundle: boolean;
  109152. interface Scene {
  109153. /**
  109154. * Creates a default light for the scene.
  109155. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  109156. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  109157. */
  109158. createDefaultLight(replace?: boolean): void;
  109159. /**
  109160. * Creates a default camera for the scene.
  109161. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  109162. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109163. * @param replace has default false, when true replaces the active camera in the scene
  109164. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  109165. */
  109166. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109167. /**
  109168. * Creates a default camera and a default light.
  109169. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  109170. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109171. * @param replace has the default false, when true replaces the active camera/light in the scene
  109172. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  109173. */
  109174. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109175. /**
  109176. * Creates a new sky box
  109177. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  109178. * @param environmentTexture defines the texture to use as environment texture
  109179. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  109180. * @param scale defines the overall scale of the skybox
  109181. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  109182. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  109183. * @returns a new mesh holding the sky box
  109184. */
  109185. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  109186. /**
  109187. * Creates a new environment
  109188. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  109189. * @param options defines the options you can use to configure the environment
  109190. * @returns the new EnvironmentHelper
  109191. */
  109192. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  109193. /**
  109194. * Creates a new VREXperienceHelper
  109195. * @see http://doc.babylonjs.com/how_to/webvr_helper
  109196. * @param webVROptions defines the options used to create the new VREXperienceHelper
  109197. * @returns a new VREXperienceHelper
  109198. */
  109199. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  109200. /**
  109201. * Creates a new XREXperienceHelper
  109202. * @see http://doc.babylonjs.com/how_to/webxr
  109203. * @returns a promise for a new XREXperienceHelper
  109204. */
  109205. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  109206. }
  109207. }
  109208. declare module BABYLON {
  109209. /**
  109210. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  109211. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  109212. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  109213. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  109214. */
  109215. export class VideoDome extends TransformNode {
  109216. /**
  109217. * Define the video source as a Monoscopic panoramic 360 video.
  109218. */
  109219. static readonly MODE_MONOSCOPIC: number;
  109220. /**
  109221. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109222. */
  109223. static readonly MODE_TOPBOTTOM: number;
  109224. /**
  109225. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109226. */
  109227. static readonly MODE_SIDEBYSIDE: number;
  109228. private _useDirectMapping;
  109229. /**
  109230. * The video texture being displayed on the sphere
  109231. */
  109232. protected _videoTexture: VideoTexture;
  109233. /**
  109234. * Gets the video texture being displayed on the sphere
  109235. */
  109236. readonly videoTexture: VideoTexture;
  109237. /**
  109238. * The skybox material
  109239. */
  109240. protected _material: BackgroundMaterial;
  109241. /**
  109242. * The surface used for the skybox
  109243. */
  109244. protected _mesh: Mesh;
  109245. /**
  109246. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109247. * Also see the options.resolution property.
  109248. */
  109249. fovMultiplier: number;
  109250. private _videoMode;
  109251. /**
  109252. * Gets or set the current video mode for the video. It can be:
  109253. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  109254. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109255. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109256. */
  109257. videoMode: number;
  109258. /**
  109259. * Oberserver used in Stereoscopic VR Mode.
  109260. */
  109261. private _onBeforeCameraRenderObserver;
  109262. /**
  109263. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  109264. * @param name Element's name, child elements will append suffixes for their own names.
  109265. * @param urlsOrVideo defines the url(s) or the video element to use
  109266. * @param options An object containing optional or exposed sub element properties
  109267. */
  109268. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  109269. resolution?: number;
  109270. clickToPlay?: boolean;
  109271. autoPlay?: boolean;
  109272. loop?: boolean;
  109273. size?: number;
  109274. poster?: string;
  109275. faceForward?: boolean;
  109276. useDirectMapping?: boolean;
  109277. }, scene: Scene);
  109278. private _changeVideoMode;
  109279. /**
  109280. * Releases resources associated with this node.
  109281. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109282. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109283. */
  109284. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109285. }
  109286. }
  109287. declare module BABYLON {
  109288. /**
  109289. * This class can be used to get instrumentation data from a Babylon engine
  109290. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109291. */
  109292. export class EngineInstrumentation implements IDisposable {
  109293. /**
  109294. * Define the instrumented engine.
  109295. */
  109296. engine: Engine;
  109297. private _captureGPUFrameTime;
  109298. private _gpuFrameTimeToken;
  109299. private _gpuFrameTime;
  109300. private _captureShaderCompilationTime;
  109301. private _shaderCompilationTime;
  109302. private _onBeginFrameObserver;
  109303. private _onEndFrameObserver;
  109304. private _onBeforeShaderCompilationObserver;
  109305. private _onAfterShaderCompilationObserver;
  109306. /**
  109307. * Gets the perf counter used for GPU frame time
  109308. */
  109309. readonly gpuFrameTimeCounter: PerfCounter;
  109310. /**
  109311. * Gets the GPU frame time capture status
  109312. */
  109313. /**
  109314. * Enable or disable the GPU frame time capture
  109315. */
  109316. captureGPUFrameTime: boolean;
  109317. /**
  109318. * Gets the perf counter used for shader compilation time
  109319. */
  109320. readonly shaderCompilationTimeCounter: PerfCounter;
  109321. /**
  109322. * Gets the shader compilation time capture status
  109323. */
  109324. /**
  109325. * Enable or disable the shader compilation time capture
  109326. */
  109327. captureShaderCompilationTime: boolean;
  109328. /**
  109329. * Instantiates a new engine instrumentation.
  109330. * This class can be used to get instrumentation data from a Babylon engine
  109331. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109332. * @param engine Defines the engine to instrument
  109333. */
  109334. constructor(
  109335. /**
  109336. * Define the instrumented engine.
  109337. */
  109338. engine: Engine);
  109339. /**
  109340. * Dispose and release associated resources.
  109341. */
  109342. dispose(): void;
  109343. }
  109344. }
  109345. declare module BABYLON {
  109346. /**
  109347. * This class can be used to get instrumentation data from a Babylon engine
  109348. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109349. */
  109350. export class SceneInstrumentation implements IDisposable {
  109351. /**
  109352. * Defines the scene to instrument
  109353. */
  109354. scene: Scene;
  109355. private _captureActiveMeshesEvaluationTime;
  109356. private _activeMeshesEvaluationTime;
  109357. private _captureRenderTargetsRenderTime;
  109358. private _renderTargetsRenderTime;
  109359. private _captureFrameTime;
  109360. private _frameTime;
  109361. private _captureRenderTime;
  109362. private _renderTime;
  109363. private _captureInterFrameTime;
  109364. private _interFrameTime;
  109365. private _captureParticlesRenderTime;
  109366. private _particlesRenderTime;
  109367. private _captureSpritesRenderTime;
  109368. private _spritesRenderTime;
  109369. private _capturePhysicsTime;
  109370. private _physicsTime;
  109371. private _captureAnimationsTime;
  109372. private _animationsTime;
  109373. private _captureCameraRenderTime;
  109374. private _cameraRenderTime;
  109375. private _onBeforeActiveMeshesEvaluationObserver;
  109376. private _onAfterActiveMeshesEvaluationObserver;
  109377. private _onBeforeRenderTargetsRenderObserver;
  109378. private _onAfterRenderTargetsRenderObserver;
  109379. private _onAfterRenderObserver;
  109380. private _onBeforeDrawPhaseObserver;
  109381. private _onAfterDrawPhaseObserver;
  109382. private _onBeforeAnimationsObserver;
  109383. private _onBeforeParticlesRenderingObserver;
  109384. private _onAfterParticlesRenderingObserver;
  109385. private _onBeforeSpritesRenderingObserver;
  109386. private _onAfterSpritesRenderingObserver;
  109387. private _onBeforePhysicsObserver;
  109388. private _onAfterPhysicsObserver;
  109389. private _onAfterAnimationsObserver;
  109390. private _onBeforeCameraRenderObserver;
  109391. private _onAfterCameraRenderObserver;
  109392. /**
  109393. * Gets the perf counter used for active meshes evaluation time
  109394. */
  109395. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  109396. /**
  109397. * Gets the active meshes evaluation time capture status
  109398. */
  109399. /**
  109400. * Enable or disable the active meshes evaluation time capture
  109401. */
  109402. captureActiveMeshesEvaluationTime: boolean;
  109403. /**
  109404. * Gets the perf counter used for render targets render time
  109405. */
  109406. readonly renderTargetsRenderTimeCounter: PerfCounter;
  109407. /**
  109408. * Gets the render targets render time capture status
  109409. */
  109410. /**
  109411. * Enable or disable the render targets render time capture
  109412. */
  109413. captureRenderTargetsRenderTime: boolean;
  109414. /**
  109415. * Gets the perf counter used for particles render time
  109416. */
  109417. readonly particlesRenderTimeCounter: PerfCounter;
  109418. /**
  109419. * Gets the particles render time capture status
  109420. */
  109421. /**
  109422. * Enable or disable the particles render time capture
  109423. */
  109424. captureParticlesRenderTime: boolean;
  109425. /**
  109426. * Gets the perf counter used for sprites render time
  109427. */
  109428. readonly spritesRenderTimeCounter: PerfCounter;
  109429. /**
  109430. * Gets the sprites render time capture status
  109431. */
  109432. /**
  109433. * Enable or disable the sprites render time capture
  109434. */
  109435. captureSpritesRenderTime: boolean;
  109436. /**
  109437. * Gets the perf counter used for physics time
  109438. */
  109439. readonly physicsTimeCounter: PerfCounter;
  109440. /**
  109441. * Gets the physics time capture status
  109442. */
  109443. /**
  109444. * Enable or disable the physics time capture
  109445. */
  109446. capturePhysicsTime: boolean;
  109447. /**
  109448. * Gets the perf counter used for animations time
  109449. */
  109450. readonly animationsTimeCounter: PerfCounter;
  109451. /**
  109452. * Gets the animations time capture status
  109453. */
  109454. /**
  109455. * Enable or disable the animations time capture
  109456. */
  109457. captureAnimationsTime: boolean;
  109458. /**
  109459. * Gets the perf counter used for frame time capture
  109460. */
  109461. readonly frameTimeCounter: PerfCounter;
  109462. /**
  109463. * Gets the frame time capture status
  109464. */
  109465. /**
  109466. * Enable or disable the frame time capture
  109467. */
  109468. captureFrameTime: boolean;
  109469. /**
  109470. * Gets the perf counter used for inter-frames time capture
  109471. */
  109472. readonly interFrameTimeCounter: PerfCounter;
  109473. /**
  109474. * Gets the inter-frames time capture status
  109475. */
  109476. /**
  109477. * Enable or disable the inter-frames time capture
  109478. */
  109479. captureInterFrameTime: boolean;
  109480. /**
  109481. * Gets the perf counter used for render time capture
  109482. */
  109483. readonly renderTimeCounter: PerfCounter;
  109484. /**
  109485. * Gets the render time capture status
  109486. */
  109487. /**
  109488. * Enable or disable the render time capture
  109489. */
  109490. captureRenderTime: boolean;
  109491. /**
  109492. * Gets the perf counter used for camera render time capture
  109493. */
  109494. readonly cameraRenderTimeCounter: PerfCounter;
  109495. /**
  109496. * Gets the camera render time capture status
  109497. */
  109498. /**
  109499. * Enable or disable the camera render time capture
  109500. */
  109501. captureCameraRenderTime: boolean;
  109502. /**
  109503. * Gets the perf counter used for draw calls
  109504. */
  109505. readonly drawCallsCounter: PerfCounter;
  109506. /**
  109507. * Instantiates a new scene instrumentation.
  109508. * This class can be used to get instrumentation data from a Babylon engine
  109509. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109510. * @param scene Defines the scene to instrument
  109511. */
  109512. constructor(
  109513. /**
  109514. * Defines the scene to instrument
  109515. */
  109516. scene: Scene);
  109517. /**
  109518. * Dispose and release associated resources.
  109519. */
  109520. dispose(): void;
  109521. }
  109522. }
  109523. declare module BABYLON {
  109524. /** @hidden */
  109525. export var glowMapGenerationPixelShader: {
  109526. name: string;
  109527. shader: string;
  109528. };
  109529. }
  109530. declare module BABYLON {
  109531. /** @hidden */
  109532. export var glowMapGenerationVertexShader: {
  109533. name: string;
  109534. shader: string;
  109535. };
  109536. }
  109537. declare module BABYLON {
  109538. /**
  109539. * Effect layer options. This helps customizing the behaviour
  109540. * of the effect layer.
  109541. */
  109542. export interface IEffectLayerOptions {
  109543. /**
  109544. * Multiplication factor apply to the canvas size to compute the render target size
  109545. * used to generated the objects (the smaller the faster).
  109546. */
  109547. mainTextureRatio: number;
  109548. /**
  109549. * Enforces a fixed size texture to ensure effect stability across devices.
  109550. */
  109551. mainTextureFixedSize?: number;
  109552. /**
  109553. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  109554. */
  109555. alphaBlendingMode: number;
  109556. /**
  109557. * The camera attached to the layer.
  109558. */
  109559. camera: Nullable<Camera>;
  109560. /**
  109561. * The rendering group to draw the layer in.
  109562. */
  109563. renderingGroupId: number;
  109564. }
  109565. /**
  109566. * The effect layer Helps adding post process effect blended with the main pass.
  109567. *
  109568. * This can be for instance use to generate glow or higlight effects on the scene.
  109569. *
  109570. * The effect layer class can not be used directly and is intented to inherited from to be
  109571. * customized per effects.
  109572. */
  109573. export abstract class EffectLayer {
  109574. private _vertexBuffers;
  109575. private _indexBuffer;
  109576. private _cachedDefines;
  109577. private _effectLayerMapGenerationEffect;
  109578. private _effectLayerOptions;
  109579. private _mergeEffect;
  109580. protected _scene: Scene;
  109581. protected _engine: Engine;
  109582. protected _maxSize: number;
  109583. protected _mainTextureDesiredSize: ISize;
  109584. protected _mainTexture: RenderTargetTexture;
  109585. protected _shouldRender: boolean;
  109586. protected _postProcesses: PostProcess[];
  109587. protected _textures: BaseTexture[];
  109588. protected _emissiveTextureAndColor: {
  109589. texture: Nullable<BaseTexture>;
  109590. color: Color4;
  109591. };
  109592. /**
  109593. * The name of the layer
  109594. */
  109595. name: string;
  109596. /**
  109597. * The clear color of the texture used to generate the glow map.
  109598. */
  109599. neutralColor: Color4;
  109600. /**
  109601. * Specifies wether the highlight layer is enabled or not.
  109602. */
  109603. isEnabled: boolean;
  109604. /**
  109605. * Gets the camera attached to the layer.
  109606. */
  109607. readonly camera: Nullable<Camera>;
  109608. /**
  109609. * Gets the rendering group id the layer should render in.
  109610. */
  109611. readonly renderingGroupId: number;
  109612. /**
  109613. * An event triggered when the effect layer has been disposed.
  109614. */
  109615. onDisposeObservable: Observable<EffectLayer>;
  109616. /**
  109617. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  109618. */
  109619. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  109620. /**
  109621. * An event triggered when the generated texture is being merged in the scene.
  109622. */
  109623. onBeforeComposeObservable: Observable<EffectLayer>;
  109624. /**
  109625. * An event triggered when the generated texture has been merged in the scene.
  109626. */
  109627. onAfterComposeObservable: Observable<EffectLayer>;
  109628. /**
  109629. * An event triggered when the efffect layer changes its size.
  109630. */
  109631. onSizeChangedObservable: Observable<EffectLayer>;
  109632. /** @hidden */
  109633. static _SceneComponentInitialization: (scene: Scene) => void;
  109634. /**
  109635. * Instantiates a new effect Layer and references it in the scene.
  109636. * @param name The name of the layer
  109637. * @param scene The scene to use the layer in
  109638. */
  109639. constructor(
  109640. /** The Friendly of the effect in the scene */
  109641. name: string, scene: Scene);
  109642. /**
  109643. * Get the effect name of the layer.
  109644. * @return The effect name
  109645. */
  109646. abstract getEffectName(): string;
  109647. /**
  109648. * Checks for the readiness of the element composing the layer.
  109649. * @param subMesh the mesh to check for
  109650. * @param useInstances specify wether or not to use instances to render the mesh
  109651. * @return true if ready otherwise, false
  109652. */
  109653. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109654. /**
  109655. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  109656. * @returns true if the effect requires stencil during the main canvas render pass.
  109657. */
  109658. abstract needStencil(): boolean;
  109659. /**
  109660. * Create the merge effect. This is the shader use to blit the information back
  109661. * to the main canvas at the end of the scene rendering.
  109662. * @returns The effect containing the shader used to merge the effect on the main canvas
  109663. */
  109664. protected abstract _createMergeEffect(): Effect;
  109665. /**
  109666. * Creates the render target textures and post processes used in the effect layer.
  109667. */
  109668. protected abstract _createTextureAndPostProcesses(): void;
  109669. /**
  109670. * Implementation specific of rendering the generating effect on the main canvas.
  109671. * @param effect The effect used to render through
  109672. */
  109673. protected abstract _internalRender(effect: Effect): void;
  109674. /**
  109675. * Sets the required values for both the emissive texture and and the main color.
  109676. */
  109677. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  109678. /**
  109679. * Free any resources and references associated to a mesh.
  109680. * Internal use
  109681. * @param mesh The mesh to free.
  109682. */
  109683. abstract _disposeMesh(mesh: Mesh): void;
  109684. /**
  109685. * Serializes this layer (Glow or Highlight for example)
  109686. * @returns a serialized layer object
  109687. */
  109688. abstract serialize?(): any;
  109689. /**
  109690. * Initializes the effect layer with the required options.
  109691. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  109692. */
  109693. protected _init(options: Partial<IEffectLayerOptions>): void;
  109694. /**
  109695. * Generates the index buffer of the full screen quad blending to the main canvas.
  109696. */
  109697. private _generateIndexBuffer;
  109698. /**
  109699. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  109700. */
  109701. private _generateVertexBuffer;
  109702. /**
  109703. * Sets the main texture desired size which is the closest power of two
  109704. * of the engine canvas size.
  109705. */
  109706. private _setMainTextureSize;
  109707. /**
  109708. * Creates the main texture for the effect layer.
  109709. */
  109710. protected _createMainTexture(): void;
  109711. /**
  109712. * Adds specific effects defines.
  109713. * @param defines The defines to add specifics to.
  109714. */
  109715. protected _addCustomEffectDefines(defines: string[]): void;
  109716. /**
  109717. * Checks for the readiness of the element composing the layer.
  109718. * @param subMesh the mesh to check for
  109719. * @param useInstances specify wether or not to use instances to render the mesh
  109720. * @param emissiveTexture the associated emissive texture used to generate the glow
  109721. * @return true if ready otherwise, false
  109722. */
  109723. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  109724. /**
  109725. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  109726. */
  109727. render(): void;
  109728. /**
  109729. * Determine if a given mesh will be used in the current effect.
  109730. * @param mesh mesh to test
  109731. * @returns true if the mesh will be used
  109732. */
  109733. hasMesh(mesh: AbstractMesh): boolean;
  109734. /**
  109735. * Returns true if the layer contains information to display, otherwise false.
  109736. * @returns true if the glow layer should be rendered
  109737. */
  109738. shouldRender(): boolean;
  109739. /**
  109740. * Returns true if the mesh should render, otherwise false.
  109741. * @param mesh The mesh to render
  109742. * @returns true if it should render otherwise false
  109743. */
  109744. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  109745. /**
  109746. * Returns true if the mesh can be rendered, otherwise false.
  109747. * @param mesh The mesh to render
  109748. * @param material The material used on the mesh
  109749. * @returns true if it can be rendered otherwise false
  109750. */
  109751. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  109752. /**
  109753. * Returns true if the mesh should render, otherwise false.
  109754. * @param mesh The mesh to render
  109755. * @returns true if it should render otherwise false
  109756. */
  109757. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  109758. /**
  109759. * Renders the submesh passed in parameter to the generation map.
  109760. */
  109761. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  109762. /**
  109763. * Rebuild the required buffers.
  109764. * @hidden Internal use only.
  109765. */
  109766. _rebuild(): void;
  109767. /**
  109768. * Dispose only the render target textures and post process.
  109769. */
  109770. private _disposeTextureAndPostProcesses;
  109771. /**
  109772. * Dispose the highlight layer and free resources.
  109773. */
  109774. dispose(): void;
  109775. /**
  109776. * Gets the class name of the effect layer
  109777. * @returns the string with the class name of the effect layer
  109778. */
  109779. getClassName(): string;
  109780. /**
  109781. * Creates an effect layer from parsed effect layer data
  109782. * @param parsedEffectLayer defines effect layer data
  109783. * @param scene defines the current scene
  109784. * @param rootUrl defines the root URL containing the effect layer information
  109785. * @returns a parsed effect Layer
  109786. */
  109787. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  109788. }
  109789. }
  109790. declare module BABYLON {
  109791. interface AbstractScene {
  109792. /**
  109793. * The list of effect layers (highlights/glow) added to the scene
  109794. * @see http://doc.babylonjs.com/how_to/highlight_layer
  109795. * @see http://doc.babylonjs.com/how_to/glow_layer
  109796. */
  109797. effectLayers: Array<EffectLayer>;
  109798. /**
  109799. * Removes the given effect layer from this scene.
  109800. * @param toRemove defines the effect layer to remove
  109801. * @returns the index of the removed effect layer
  109802. */
  109803. removeEffectLayer(toRemove: EffectLayer): number;
  109804. /**
  109805. * Adds the given effect layer to this scene
  109806. * @param newEffectLayer defines the effect layer to add
  109807. */
  109808. addEffectLayer(newEffectLayer: EffectLayer): void;
  109809. }
  109810. /**
  109811. * Defines the layer scene component responsible to manage any effect layers
  109812. * in a given scene.
  109813. */
  109814. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  109815. /**
  109816. * The component name helpfull to identify the component in the list of scene components.
  109817. */
  109818. readonly name: string;
  109819. /**
  109820. * The scene the component belongs to.
  109821. */
  109822. scene: Scene;
  109823. private _engine;
  109824. private _renderEffects;
  109825. private _needStencil;
  109826. private _previousStencilState;
  109827. /**
  109828. * Creates a new instance of the component for the given scene
  109829. * @param scene Defines the scene to register the component in
  109830. */
  109831. constructor(scene: Scene);
  109832. /**
  109833. * Registers the component in a given scene
  109834. */
  109835. register(): void;
  109836. /**
  109837. * Rebuilds the elements related to this component in case of
  109838. * context lost for instance.
  109839. */
  109840. rebuild(): void;
  109841. /**
  109842. * Serializes the component data to the specified json object
  109843. * @param serializationObject The object to serialize to
  109844. */
  109845. serialize(serializationObject: any): void;
  109846. /**
  109847. * Adds all the elements from the container to the scene
  109848. * @param container the container holding the elements
  109849. */
  109850. addFromContainer(container: AbstractScene): void;
  109851. /**
  109852. * Removes all the elements in the container from the scene
  109853. * @param container contains the elements to remove
  109854. * @param dispose if the removed element should be disposed (default: false)
  109855. */
  109856. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  109857. /**
  109858. * Disposes the component and the associated ressources.
  109859. */
  109860. dispose(): void;
  109861. private _isReadyForMesh;
  109862. private _renderMainTexture;
  109863. private _setStencil;
  109864. private _setStencilBack;
  109865. private _draw;
  109866. private _drawCamera;
  109867. private _drawRenderingGroup;
  109868. }
  109869. }
  109870. declare module BABYLON {
  109871. /** @hidden */
  109872. export var glowMapMergePixelShader: {
  109873. name: string;
  109874. shader: string;
  109875. };
  109876. }
  109877. declare module BABYLON {
  109878. /** @hidden */
  109879. export var glowMapMergeVertexShader: {
  109880. name: string;
  109881. shader: string;
  109882. };
  109883. }
  109884. declare module BABYLON {
  109885. interface AbstractScene {
  109886. /**
  109887. * Return a the first highlight layer of the scene with a given name.
  109888. * @param name The name of the highlight layer to look for.
  109889. * @return The highlight layer if found otherwise null.
  109890. */
  109891. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  109892. }
  109893. /**
  109894. * Glow layer options. This helps customizing the behaviour
  109895. * of the glow layer.
  109896. */
  109897. export interface IGlowLayerOptions {
  109898. /**
  109899. * Multiplication factor apply to the canvas size to compute the render target size
  109900. * used to generated the glowing objects (the smaller the faster).
  109901. */
  109902. mainTextureRatio: number;
  109903. /**
  109904. * Enforces a fixed size texture to ensure resize independant blur.
  109905. */
  109906. mainTextureFixedSize?: number;
  109907. /**
  109908. * How big is the kernel of the blur texture.
  109909. */
  109910. blurKernelSize: number;
  109911. /**
  109912. * The camera attached to the layer.
  109913. */
  109914. camera: Nullable<Camera>;
  109915. /**
  109916. * Enable MSAA by chosing the number of samples.
  109917. */
  109918. mainTextureSamples?: number;
  109919. /**
  109920. * The rendering group to draw the layer in.
  109921. */
  109922. renderingGroupId: number;
  109923. }
  109924. /**
  109925. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  109926. *
  109927. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  109928. * glowy meshes to your scene.
  109929. *
  109930. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  109931. */
  109932. export class GlowLayer extends EffectLayer {
  109933. /**
  109934. * Effect Name of the layer.
  109935. */
  109936. static readonly EffectName: string;
  109937. /**
  109938. * The default blur kernel size used for the glow.
  109939. */
  109940. static DefaultBlurKernelSize: number;
  109941. /**
  109942. * The default texture size ratio used for the glow.
  109943. */
  109944. static DefaultTextureRatio: number;
  109945. /**
  109946. * Sets the kernel size of the blur.
  109947. */
  109948. /**
  109949. * Gets the kernel size of the blur.
  109950. */
  109951. blurKernelSize: number;
  109952. /**
  109953. * Sets the glow intensity.
  109954. */
  109955. /**
  109956. * Gets the glow intensity.
  109957. */
  109958. intensity: number;
  109959. private _options;
  109960. private _intensity;
  109961. private _horizontalBlurPostprocess1;
  109962. private _verticalBlurPostprocess1;
  109963. private _horizontalBlurPostprocess2;
  109964. private _verticalBlurPostprocess2;
  109965. private _blurTexture1;
  109966. private _blurTexture2;
  109967. private _postProcesses1;
  109968. private _postProcesses2;
  109969. private _includedOnlyMeshes;
  109970. private _excludedMeshes;
  109971. /**
  109972. * Callback used to let the user override the color selection on a per mesh basis
  109973. */
  109974. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  109975. /**
  109976. * Callback used to let the user override the texture selection on a per mesh basis
  109977. */
  109978. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  109979. /**
  109980. * Instantiates a new glow Layer and references it to the scene.
  109981. * @param name The name of the layer
  109982. * @param scene The scene to use the layer in
  109983. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  109984. */
  109985. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  109986. /**
  109987. * Get the effect name of the layer.
  109988. * @return The effect name
  109989. */
  109990. getEffectName(): string;
  109991. /**
  109992. * Create the merge effect. This is the shader use to blit the information back
  109993. * to the main canvas at the end of the scene rendering.
  109994. */
  109995. protected _createMergeEffect(): Effect;
  109996. /**
  109997. * Creates the render target textures and post processes used in the glow layer.
  109998. */
  109999. protected _createTextureAndPostProcesses(): void;
  110000. /**
  110001. * Checks for the readiness of the element composing the layer.
  110002. * @param subMesh the mesh to check for
  110003. * @param useInstances specify wether or not to use instances to render the mesh
  110004. * @param emissiveTexture the associated emissive texture used to generate the glow
  110005. * @return true if ready otherwise, false
  110006. */
  110007. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110008. /**
  110009. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110010. */
  110011. needStencil(): boolean;
  110012. /**
  110013. * Returns true if the mesh can be rendered, otherwise false.
  110014. * @param mesh The mesh to render
  110015. * @param material The material used on the mesh
  110016. * @returns true if it can be rendered otherwise false
  110017. */
  110018. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110019. /**
  110020. * Implementation specific of rendering the generating effect on the main canvas.
  110021. * @param effect The effect used to render through
  110022. */
  110023. protected _internalRender(effect: Effect): void;
  110024. /**
  110025. * Sets the required values for both the emissive texture and and the main color.
  110026. */
  110027. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110028. /**
  110029. * Returns true if the mesh should render, otherwise false.
  110030. * @param mesh The mesh to render
  110031. * @returns true if it should render otherwise false
  110032. */
  110033. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110034. /**
  110035. * Adds specific effects defines.
  110036. * @param defines The defines to add specifics to.
  110037. */
  110038. protected _addCustomEffectDefines(defines: string[]): void;
  110039. /**
  110040. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  110041. * @param mesh The mesh to exclude from the glow layer
  110042. */
  110043. addExcludedMesh(mesh: Mesh): void;
  110044. /**
  110045. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  110046. * @param mesh The mesh to remove
  110047. */
  110048. removeExcludedMesh(mesh: Mesh): void;
  110049. /**
  110050. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  110051. * @param mesh The mesh to include in the glow layer
  110052. */
  110053. addIncludedOnlyMesh(mesh: Mesh): void;
  110054. /**
  110055. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  110056. * @param mesh The mesh to remove
  110057. */
  110058. removeIncludedOnlyMesh(mesh: Mesh): void;
  110059. /**
  110060. * Determine if a given mesh will be used in the glow layer
  110061. * @param mesh The mesh to test
  110062. * @returns true if the mesh will be highlighted by the current glow layer
  110063. */
  110064. hasMesh(mesh: AbstractMesh): boolean;
  110065. /**
  110066. * Free any resources and references associated to a mesh.
  110067. * Internal use
  110068. * @param mesh The mesh to free.
  110069. * @hidden
  110070. */
  110071. _disposeMesh(mesh: Mesh): void;
  110072. /**
  110073. * Gets the class name of the effect layer
  110074. * @returns the string with the class name of the effect layer
  110075. */
  110076. getClassName(): string;
  110077. /**
  110078. * Serializes this glow layer
  110079. * @returns a serialized glow layer object
  110080. */
  110081. serialize(): any;
  110082. /**
  110083. * Creates a Glow Layer from parsed glow layer data
  110084. * @param parsedGlowLayer defines glow layer data
  110085. * @param scene defines the current scene
  110086. * @param rootUrl defines the root URL containing the glow layer information
  110087. * @returns a parsed Glow Layer
  110088. */
  110089. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  110090. }
  110091. }
  110092. declare module BABYLON {
  110093. /** @hidden */
  110094. export var glowBlurPostProcessPixelShader: {
  110095. name: string;
  110096. shader: string;
  110097. };
  110098. }
  110099. declare module BABYLON {
  110100. interface AbstractScene {
  110101. /**
  110102. * Return a the first highlight layer of the scene with a given name.
  110103. * @param name The name of the highlight layer to look for.
  110104. * @return The highlight layer if found otherwise null.
  110105. */
  110106. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  110107. }
  110108. /**
  110109. * Highlight layer options. This helps customizing the behaviour
  110110. * of the highlight layer.
  110111. */
  110112. export interface IHighlightLayerOptions {
  110113. /**
  110114. * Multiplication factor apply to the canvas size to compute the render target size
  110115. * used to generated the glowing objects (the smaller the faster).
  110116. */
  110117. mainTextureRatio: number;
  110118. /**
  110119. * Enforces a fixed size texture to ensure resize independant blur.
  110120. */
  110121. mainTextureFixedSize?: number;
  110122. /**
  110123. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  110124. * of the picture to blur (the smaller the faster).
  110125. */
  110126. blurTextureSizeRatio: number;
  110127. /**
  110128. * How big in texel of the blur texture is the vertical blur.
  110129. */
  110130. blurVerticalSize: number;
  110131. /**
  110132. * How big in texel of the blur texture is the horizontal blur.
  110133. */
  110134. blurHorizontalSize: number;
  110135. /**
  110136. * Alpha blending mode used to apply the blur. Default is combine.
  110137. */
  110138. alphaBlendingMode: number;
  110139. /**
  110140. * The camera attached to the layer.
  110141. */
  110142. camera: Nullable<Camera>;
  110143. /**
  110144. * Should we display highlight as a solid stroke?
  110145. */
  110146. isStroke?: boolean;
  110147. /**
  110148. * The rendering group to draw the layer in.
  110149. */
  110150. renderingGroupId: number;
  110151. }
  110152. /**
  110153. * The highlight layer Helps adding a glow effect around a mesh.
  110154. *
  110155. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110156. * glowy meshes to your scene.
  110157. *
  110158. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  110159. */
  110160. export class HighlightLayer extends EffectLayer {
  110161. name: string;
  110162. /**
  110163. * Effect Name of the highlight layer.
  110164. */
  110165. static readonly EffectName: string;
  110166. /**
  110167. * The neutral color used during the preparation of the glow effect.
  110168. * This is black by default as the blend operation is a blend operation.
  110169. */
  110170. static NeutralColor: Color4;
  110171. /**
  110172. * Stencil value used for glowing meshes.
  110173. */
  110174. static GlowingMeshStencilReference: number;
  110175. /**
  110176. * Stencil value used for the other meshes in the scene.
  110177. */
  110178. static NormalMeshStencilReference: number;
  110179. /**
  110180. * Specifies whether or not the inner glow is ACTIVE in the layer.
  110181. */
  110182. innerGlow: boolean;
  110183. /**
  110184. * Specifies whether or not the outer glow is ACTIVE in the layer.
  110185. */
  110186. outerGlow: boolean;
  110187. /**
  110188. * Specifies the horizontal size of the blur.
  110189. */
  110190. /**
  110191. * Gets the horizontal size of the blur.
  110192. */
  110193. blurHorizontalSize: number;
  110194. /**
  110195. * Specifies the vertical size of the blur.
  110196. */
  110197. /**
  110198. * Gets the vertical size of the blur.
  110199. */
  110200. blurVerticalSize: number;
  110201. /**
  110202. * An event triggered when the highlight layer is being blurred.
  110203. */
  110204. onBeforeBlurObservable: Observable<HighlightLayer>;
  110205. /**
  110206. * An event triggered when the highlight layer has been blurred.
  110207. */
  110208. onAfterBlurObservable: Observable<HighlightLayer>;
  110209. private _instanceGlowingMeshStencilReference;
  110210. private _options;
  110211. private _downSamplePostprocess;
  110212. private _horizontalBlurPostprocess;
  110213. private _verticalBlurPostprocess;
  110214. private _blurTexture;
  110215. private _meshes;
  110216. private _excludedMeshes;
  110217. /**
  110218. * Instantiates a new highlight Layer and references it to the scene..
  110219. * @param name The name of the layer
  110220. * @param scene The scene to use the layer in
  110221. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  110222. */
  110223. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  110224. /**
  110225. * Get the effect name of the layer.
  110226. * @return The effect name
  110227. */
  110228. getEffectName(): string;
  110229. /**
  110230. * Create the merge effect. This is the shader use to blit the information back
  110231. * to the main canvas at the end of the scene rendering.
  110232. */
  110233. protected _createMergeEffect(): Effect;
  110234. /**
  110235. * Creates the render target textures and post processes used in the highlight layer.
  110236. */
  110237. protected _createTextureAndPostProcesses(): void;
  110238. /**
  110239. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110240. */
  110241. needStencil(): boolean;
  110242. /**
  110243. * Checks for the readiness of the element composing the layer.
  110244. * @param subMesh the mesh to check for
  110245. * @param useInstances specify wether or not to use instances to render the mesh
  110246. * @param emissiveTexture the associated emissive texture used to generate the glow
  110247. * @return true if ready otherwise, false
  110248. */
  110249. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110250. /**
  110251. * Implementation specific of rendering the generating effect on the main canvas.
  110252. * @param effect The effect used to render through
  110253. */
  110254. protected _internalRender(effect: Effect): void;
  110255. /**
  110256. * Returns true if the layer contains information to display, otherwise false.
  110257. */
  110258. shouldRender(): boolean;
  110259. /**
  110260. * Returns true if the mesh should render, otherwise false.
  110261. * @param mesh The mesh to render
  110262. * @returns true if it should render otherwise false
  110263. */
  110264. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110265. /**
  110266. * Sets the required values for both the emissive texture and and the main color.
  110267. */
  110268. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110269. /**
  110270. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  110271. * @param mesh The mesh to exclude from the highlight layer
  110272. */
  110273. addExcludedMesh(mesh: Mesh): void;
  110274. /**
  110275. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  110276. * @param mesh The mesh to highlight
  110277. */
  110278. removeExcludedMesh(mesh: Mesh): void;
  110279. /**
  110280. * Determine if a given mesh will be highlighted by the current HighlightLayer
  110281. * @param mesh mesh to test
  110282. * @returns true if the mesh will be highlighted by the current HighlightLayer
  110283. */
  110284. hasMesh(mesh: AbstractMesh): boolean;
  110285. /**
  110286. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  110287. * @param mesh The mesh to highlight
  110288. * @param color The color of the highlight
  110289. * @param glowEmissiveOnly Extract the glow from the emissive texture
  110290. */
  110291. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  110292. /**
  110293. * Remove a mesh from the highlight layer in order to make it stop glowing.
  110294. * @param mesh The mesh to highlight
  110295. */
  110296. removeMesh(mesh: Mesh): void;
  110297. /**
  110298. * Force the stencil to the normal expected value for none glowing parts
  110299. */
  110300. private _defaultStencilReference;
  110301. /**
  110302. * Free any resources and references associated to a mesh.
  110303. * Internal use
  110304. * @param mesh The mesh to free.
  110305. * @hidden
  110306. */
  110307. _disposeMesh(mesh: Mesh): void;
  110308. /**
  110309. * Dispose the highlight layer and free resources.
  110310. */
  110311. dispose(): void;
  110312. /**
  110313. * Gets the class name of the effect layer
  110314. * @returns the string with the class name of the effect layer
  110315. */
  110316. getClassName(): string;
  110317. /**
  110318. * Serializes this Highlight layer
  110319. * @returns a serialized Highlight layer object
  110320. */
  110321. serialize(): any;
  110322. /**
  110323. * Creates a Highlight layer from parsed Highlight layer data
  110324. * @param parsedHightlightLayer defines the Highlight layer data
  110325. * @param scene defines the current scene
  110326. * @param rootUrl defines the root URL containing the Highlight layer information
  110327. * @returns a parsed Highlight layer
  110328. */
  110329. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  110330. }
  110331. }
  110332. declare module BABYLON {
  110333. interface AbstractScene {
  110334. /**
  110335. * The list of layers (background and foreground) of the scene
  110336. */
  110337. layers: Array<Layer>;
  110338. }
  110339. /**
  110340. * Defines the layer scene component responsible to manage any layers
  110341. * in a given scene.
  110342. */
  110343. export class LayerSceneComponent implements ISceneComponent {
  110344. /**
  110345. * The component name helpfull to identify the component in the list of scene components.
  110346. */
  110347. readonly name: string;
  110348. /**
  110349. * The scene the component belongs to.
  110350. */
  110351. scene: Scene;
  110352. private _engine;
  110353. /**
  110354. * Creates a new instance of the component for the given scene
  110355. * @param scene Defines the scene to register the component in
  110356. */
  110357. constructor(scene: Scene);
  110358. /**
  110359. * Registers the component in a given scene
  110360. */
  110361. register(): void;
  110362. /**
  110363. * Rebuilds the elements related to this component in case of
  110364. * context lost for instance.
  110365. */
  110366. rebuild(): void;
  110367. /**
  110368. * Disposes the component and the associated ressources.
  110369. */
  110370. dispose(): void;
  110371. private _draw;
  110372. private _drawCameraPredicate;
  110373. private _drawCameraBackground;
  110374. private _drawCameraForeground;
  110375. private _drawRenderTargetPredicate;
  110376. private _drawRenderTargetBackground;
  110377. private _drawRenderTargetForeground;
  110378. /**
  110379. * Adds all the elements from the container to the scene
  110380. * @param container the container holding the elements
  110381. */
  110382. addFromContainer(container: AbstractScene): void;
  110383. /**
  110384. * Removes all the elements in the container from the scene
  110385. * @param container contains the elements to remove
  110386. * @param dispose if the removed element should be disposed (default: false)
  110387. */
  110388. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110389. }
  110390. }
  110391. declare module BABYLON {
  110392. /** @hidden */
  110393. export var layerPixelShader: {
  110394. name: string;
  110395. shader: string;
  110396. };
  110397. }
  110398. declare module BABYLON {
  110399. /** @hidden */
  110400. export var layerVertexShader: {
  110401. name: string;
  110402. shader: string;
  110403. };
  110404. }
  110405. declare module BABYLON {
  110406. /**
  110407. * This represents a full screen 2d layer.
  110408. * This can be useful to display a picture in the background of your scene for instance.
  110409. * @see https://www.babylonjs-playground.com/#08A2BS#1
  110410. */
  110411. export class Layer {
  110412. /**
  110413. * Define the name of the layer.
  110414. */
  110415. name: string;
  110416. /**
  110417. * Define the texture the layer should display.
  110418. */
  110419. texture: Nullable<Texture>;
  110420. /**
  110421. * Is the layer in background or foreground.
  110422. */
  110423. isBackground: boolean;
  110424. /**
  110425. * Define the color of the layer (instead of texture).
  110426. */
  110427. color: Color4;
  110428. /**
  110429. * Define the scale of the layer in order to zoom in out of the texture.
  110430. */
  110431. scale: Vector2;
  110432. /**
  110433. * Define an offset for the layer in order to shift the texture.
  110434. */
  110435. offset: Vector2;
  110436. /**
  110437. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  110438. */
  110439. alphaBlendingMode: number;
  110440. /**
  110441. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  110442. * Alpha test will not mix with the background color in case of transparency.
  110443. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  110444. */
  110445. alphaTest: boolean;
  110446. /**
  110447. * Define a mask to restrict the layer to only some of the scene cameras.
  110448. */
  110449. layerMask: number;
  110450. /**
  110451. * Define the list of render target the layer is visible into.
  110452. */
  110453. renderTargetTextures: RenderTargetTexture[];
  110454. /**
  110455. * Define if the layer is only used in renderTarget or if it also
  110456. * renders in the main frame buffer of the canvas.
  110457. */
  110458. renderOnlyInRenderTargetTextures: boolean;
  110459. private _scene;
  110460. private _vertexBuffers;
  110461. private _indexBuffer;
  110462. private _effect;
  110463. private _alphaTestEffect;
  110464. /**
  110465. * An event triggered when the layer is disposed.
  110466. */
  110467. onDisposeObservable: Observable<Layer>;
  110468. private _onDisposeObserver;
  110469. /**
  110470. * Back compatibility with callback before the onDisposeObservable existed.
  110471. * The set callback will be triggered when the layer has been disposed.
  110472. */
  110473. onDispose: () => void;
  110474. /**
  110475. * An event triggered before rendering the scene
  110476. */
  110477. onBeforeRenderObservable: Observable<Layer>;
  110478. private _onBeforeRenderObserver;
  110479. /**
  110480. * Back compatibility with callback before the onBeforeRenderObservable existed.
  110481. * The set callback will be triggered just before rendering the layer.
  110482. */
  110483. onBeforeRender: () => void;
  110484. /**
  110485. * An event triggered after rendering the scene
  110486. */
  110487. onAfterRenderObservable: Observable<Layer>;
  110488. private _onAfterRenderObserver;
  110489. /**
  110490. * Back compatibility with callback before the onAfterRenderObservable existed.
  110491. * The set callback will be triggered just after rendering the layer.
  110492. */
  110493. onAfterRender: () => void;
  110494. /**
  110495. * Instantiates a new layer.
  110496. * This represents a full screen 2d layer.
  110497. * This can be useful to display a picture in the background of your scene for instance.
  110498. * @see https://www.babylonjs-playground.com/#08A2BS#1
  110499. * @param name Define the name of the layer in the scene
  110500. * @param imgUrl Define the url of the texture to display in the layer
  110501. * @param scene Define the scene the layer belongs to
  110502. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  110503. * @param color Defines a color for the layer
  110504. */
  110505. constructor(
  110506. /**
  110507. * Define the name of the layer.
  110508. */
  110509. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  110510. private _createIndexBuffer;
  110511. /** @hidden */
  110512. _rebuild(): void;
  110513. /**
  110514. * Renders the layer in the scene.
  110515. */
  110516. render(): void;
  110517. /**
  110518. * Disposes and releases the associated ressources.
  110519. */
  110520. dispose(): void;
  110521. }
  110522. }
  110523. declare module BABYLON {
  110524. /** @hidden */
  110525. export var lensFlarePixelShader: {
  110526. name: string;
  110527. shader: string;
  110528. };
  110529. }
  110530. declare module BABYLON {
  110531. /** @hidden */
  110532. export var lensFlareVertexShader: {
  110533. name: string;
  110534. shader: string;
  110535. };
  110536. }
  110537. declare module BABYLON {
  110538. /**
  110539. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  110540. * It is usually composed of several `lensFlare`.
  110541. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110542. */
  110543. export class LensFlareSystem {
  110544. /**
  110545. * Define the name of the lens flare system
  110546. */
  110547. name: string;
  110548. /**
  110549. * List of lens flares used in this system.
  110550. */
  110551. lensFlares: LensFlare[];
  110552. /**
  110553. * Define a limit from the border the lens flare can be visible.
  110554. */
  110555. borderLimit: number;
  110556. /**
  110557. * Define a viewport border we do not want to see the lens flare in.
  110558. */
  110559. viewportBorder: number;
  110560. /**
  110561. * Define a predicate which could limit the list of meshes able to occlude the effect.
  110562. */
  110563. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  110564. /**
  110565. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  110566. */
  110567. layerMask: number;
  110568. /**
  110569. * Define the id of the lens flare system in the scene.
  110570. * (equal to name by default)
  110571. */
  110572. id: string;
  110573. private _scene;
  110574. private _emitter;
  110575. private _vertexBuffers;
  110576. private _indexBuffer;
  110577. private _effect;
  110578. private _positionX;
  110579. private _positionY;
  110580. private _isEnabled;
  110581. /** @hidden */
  110582. static _SceneComponentInitialization: (scene: Scene) => void;
  110583. /**
  110584. * Instantiates a lens flare system.
  110585. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  110586. * It is usually composed of several `lensFlare`.
  110587. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110588. * @param name Define the name of the lens flare system in the scene
  110589. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  110590. * @param scene Define the scene the lens flare system belongs to
  110591. */
  110592. constructor(
  110593. /**
  110594. * Define the name of the lens flare system
  110595. */
  110596. name: string, emitter: any, scene: Scene);
  110597. /**
  110598. * Define if the lens flare system is enabled.
  110599. */
  110600. isEnabled: boolean;
  110601. /**
  110602. * Get the scene the effects belongs to.
  110603. * @returns the scene holding the lens flare system
  110604. */
  110605. getScene(): Scene;
  110606. /**
  110607. * Get the emitter of the lens flare system.
  110608. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  110609. * @returns the emitter of the lens flare system
  110610. */
  110611. getEmitter(): any;
  110612. /**
  110613. * Set the emitter of the lens flare system.
  110614. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  110615. * @param newEmitter Define the new emitter of the system
  110616. */
  110617. setEmitter(newEmitter: any): void;
  110618. /**
  110619. * Get the lens flare system emitter position.
  110620. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  110621. * @returns the position
  110622. */
  110623. getEmitterPosition(): Vector3;
  110624. /**
  110625. * @hidden
  110626. */
  110627. computeEffectivePosition(globalViewport: Viewport): boolean;
  110628. /** @hidden */
  110629. _isVisible(): boolean;
  110630. /**
  110631. * @hidden
  110632. */
  110633. render(): boolean;
  110634. /**
  110635. * Dispose and release the lens flare with its associated resources.
  110636. */
  110637. dispose(): void;
  110638. /**
  110639. * Parse a lens flare system from a JSON repressentation
  110640. * @param parsedLensFlareSystem Define the JSON to parse
  110641. * @param scene Define the scene the parsed system should be instantiated in
  110642. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  110643. * @returns the parsed system
  110644. */
  110645. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  110646. /**
  110647. * Serialize the current Lens Flare System into a JSON representation.
  110648. * @returns the serialized JSON
  110649. */
  110650. serialize(): any;
  110651. }
  110652. }
  110653. declare module BABYLON {
  110654. /**
  110655. * This represents one of the lens effect in a `lensFlareSystem`.
  110656. * It controls one of the indiviual texture used in the effect.
  110657. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110658. */
  110659. export class LensFlare {
  110660. /**
  110661. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  110662. */
  110663. size: number;
  110664. /**
  110665. * 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.
  110666. */
  110667. position: number;
  110668. /**
  110669. * Define the lens color.
  110670. */
  110671. color: Color3;
  110672. /**
  110673. * Define the lens texture.
  110674. */
  110675. texture: Nullable<Texture>;
  110676. /**
  110677. * Define the alpha mode to render this particular lens.
  110678. */
  110679. alphaMode: number;
  110680. private _system;
  110681. /**
  110682. * Creates a new Lens Flare.
  110683. * This represents one of the lens effect in a `lensFlareSystem`.
  110684. * It controls one of the indiviual texture used in the effect.
  110685. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110686. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  110687. * @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.
  110688. * @param color Define the lens color
  110689. * @param imgUrl Define the lens texture url
  110690. * @param system Define the `lensFlareSystem` this flare is part of
  110691. * @returns The newly created Lens Flare
  110692. */
  110693. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  110694. /**
  110695. * Instantiates a new Lens Flare.
  110696. * This represents one of the lens effect in a `lensFlareSystem`.
  110697. * It controls one of the indiviual texture used in the effect.
  110698. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110699. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  110700. * @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.
  110701. * @param color Define the lens color
  110702. * @param imgUrl Define the lens texture url
  110703. * @param system Define the `lensFlareSystem` this flare is part of
  110704. */
  110705. constructor(
  110706. /**
  110707. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  110708. */
  110709. size: number,
  110710. /**
  110711. * 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.
  110712. */
  110713. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  110714. /**
  110715. * Dispose and release the lens flare with its associated resources.
  110716. */
  110717. dispose(): void;
  110718. }
  110719. }
  110720. declare module BABYLON {
  110721. interface AbstractScene {
  110722. /**
  110723. * The list of lens flare system added to the scene
  110724. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110725. */
  110726. lensFlareSystems: Array<LensFlareSystem>;
  110727. /**
  110728. * Removes the given lens flare system from this scene.
  110729. * @param toRemove The lens flare system to remove
  110730. * @returns The index of the removed lens flare system
  110731. */
  110732. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  110733. /**
  110734. * Adds the given lens flare system to this scene
  110735. * @param newLensFlareSystem The lens flare system to add
  110736. */
  110737. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  110738. /**
  110739. * Gets a lens flare system using its name
  110740. * @param name defines the name to look for
  110741. * @returns the lens flare system or null if not found
  110742. */
  110743. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  110744. /**
  110745. * Gets a lens flare system using its id
  110746. * @param id defines the id to look for
  110747. * @returns the lens flare system or null if not found
  110748. */
  110749. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  110750. }
  110751. /**
  110752. * Defines the lens flare scene component responsible to manage any lens flares
  110753. * in a given scene.
  110754. */
  110755. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  110756. /**
  110757. * The component name helpfull to identify the component in the list of scene components.
  110758. */
  110759. readonly name: string;
  110760. /**
  110761. * The scene the component belongs to.
  110762. */
  110763. scene: Scene;
  110764. /**
  110765. * Creates a new instance of the component for the given scene
  110766. * @param scene Defines the scene to register the component in
  110767. */
  110768. constructor(scene: Scene);
  110769. /**
  110770. * Registers the component in a given scene
  110771. */
  110772. register(): void;
  110773. /**
  110774. * Rebuilds the elements related to this component in case of
  110775. * context lost for instance.
  110776. */
  110777. rebuild(): void;
  110778. /**
  110779. * Adds all the elements from the container to the scene
  110780. * @param container the container holding the elements
  110781. */
  110782. addFromContainer(container: AbstractScene): void;
  110783. /**
  110784. * Removes all the elements in the container from the scene
  110785. * @param container contains the elements to remove
  110786. * @param dispose if the removed element should be disposed (default: false)
  110787. */
  110788. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110789. /**
  110790. * Serializes the component data to the specified json object
  110791. * @param serializationObject The object to serialize to
  110792. */
  110793. serialize(serializationObject: any): void;
  110794. /**
  110795. * Disposes the component and the associated ressources.
  110796. */
  110797. dispose(): void;
  110798. private _draw;
  110799. }
  110800. }
  110801. declare module BABYLON {
  110802. /**
  110803. * Defines the shadow generator component responsible to manage any shadow generators
  110804. * in a given scene.
  110805. */
  110806. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  110807. /**
  110808. * The component name helpfull to identify the component in the list of scene components.
  110809. */
  110810. readonly name: string;
  110811. /**
  110812. * The scene the component belongs to.
  110813. */
  110814. scene: Scene;
  110815. /**
  110816. * Creates a new instance of the component for the given scene
  110817. * @param scene Defines the scene to register the component in
  110818. */
  110819. constructor(scene: Scene);
  110820. /**
  110821. * Registers the component in a given scene
  110822. */
  110823. register(): void;
  110824. /**
  110825. * Rebuilds the elements related to this component in case of
  110826. * context lost for instance.
  110827. */
  110828. rebuild(): void;
  110829. /**
  110830. * Serializes the component data to the specified json object
  110831. * @param serializationObject The object to serialize to
  110832. */
  110833. serialize(serializationObject: any): void;
  110834. /**
  110835. * Adds all the elements from the container to the scene
  110836. * @param container the container holding the elements
  110837. */
  110838. addFromContainer(container: AbstractScene): void;
  110839. /**
  110840. * Removes all the elements in the container from the scene
  110841. * @param container contains the elements to remove
  110842. * @param dispose if the removed element should be disposed (default: false)
  110843. */
  110844. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110845. /**
  110846. * Rebuilds the elements related to this component in case of
  110847. * context lost for instance.
  110848. */
  110849. dispose(): void;
  110850. private _gatherRenderTargets;
  110851. }
  110852. }
  110853. declare module BABYLON {
  110854. /**
  110855. * A point light is a light defined by an unique point in world space.
  110856. * The light is emitted in every direction from this point.
  110857. * A good example of a point light is a standard light bulb.
  110858. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110859. */
  110860. export class PointLight extends ShadowLight {
  110861. private _shadowAngle;
  110862. /**
  110863. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110864. * This specifies what angle the shadow will use to be created.
  110865. *
  110866. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  110867. */
  110868. /**
  110869. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110870. * This specifies what angle the shadow will use to be created.
  110871. *
  110872. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  110873. */
  110874. shadowAngle: number;
  110875. /**
  110876. * Gets the direction if it has been set.
  110877. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110878. */
  110879. /**
  110880. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110881. */
  110882. direction: Vector3;
  110883. /**
  110884. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  110885. * A PointLight emits the light in every direction.
  110886. * It can cast shadows.
  110887. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  110888. * ```javascript
  110889. * var pointLight = new PointLight("pl", camera.position, scene);
  110890. * ```
  110891. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110892. * @param name The light friendly name
  110893. * @param position The position of the point light in the scene
  110894. * @param scene The scene the lights belongs to
  110895. */
  110896. constructor(name: string, position: Vector3, scene: Scene);
  110897. /**
  110898. * Returns the string "PointLight"
  110899. * @returns the class name
  110900. */
  110901. getClassName(): string;
  110902. /**
  110903. * Returns the integer 0.
  110904. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110905. */
  110906. getTypeID(): number;
  110907. /**
  110908. * Specifies wether or not the shadowmap should be a cube texture.
  110909. * @returns true if the shadowmap needs to be a cube texture.
  110910. */
  110911. needCube(): boolean;
  110912. /**
  110913. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  110914. * @param faceIndex The index of the face we are computed the direction to generate shadow
  110915. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  110916. */
  110917. getShadowDirection(faceIndex?: number): Vector3;
  110918. /**
  110919. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  110920. * - fov = PI / 2
  110921. * - aspect ratio : 1.0
  110922. * - z-near and far equal to the active camera minZ and maxZ.
  110923. * Returns the PointLight.
  110924. */
  110925. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110926. protected _buildUniformLayout(): void;
  110927. /**
  110928. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  110929. * @param effect The effect to update
  110930. * @param lightIndex The index of the light in the effect to update
  110931. * @returns The point light
  110932. */
  110933. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  110934. /**
  110935. * Prepares the list of defines specific to the light type.
  110936. * @param defines the list of defines
  110937. * @param lightIndex defines the index of the light for the effect
  110938. */
  110939. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110940. }
  110941. }
  110942. declare module BABYLON {
  110943. /**
  110944. * Header information of HDR texture files.
  110945. */
  110946. export interface HDRInfo {
  110947. /**
  110948. * The height of the texture in pixels.
  110949. */
  110950. height: number;
  110951. /**
  110952. * The width of the texture in pixels.
  110953. */
  110954. width: number;
  110955. /**
  110956. * The index of the beginning of the data in the binary file.
  110957. */
  110958. dataPosition: number;
  110959. }
  110960. /**
  110961. * This groups tools to convert HDR texture to native colors array.
  110962. */
  110963. export class HDRTools {
  110964. private static Ldexp;
  110965. private static Rgbe2float;
  110966. private static readStringLine;
  110967. /**
  110968. * Reads header information from an RGBE texture stored in a native array.
  110969. * More information on this format are available here:
  110970. * https://en.wikipedia.org/wiki/RGBE_image_format
  110971. *
  110972. * @param uint8array The binary file stored in native array.
  110973. * @return The header information.
  110974. */
  110975. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  110976. /**
  110977. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  110978. * This RGBE texture needs to store the information as a panorama.
  110979. *
  110980. * More information on this format are available here:
  110981. * https://en.wikipedia.org/wiki/RGBE_image_format
  110982. *
  110983. * @param buffer The binary file stored in an array buffer.
  110984. * @param size The expected size of the extracted cubemap.
  110985. * @return The Cube Map information.
  110986. */
  110987. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  110988. /**
  110989. * Returns the pixels data extracted from an RGBE texture.
  110990. * This pixels will be stored left to right up to down in the R G B order in one array.
  110991. *
  110992. * More information on this format are available here:
  110993. * https://en.wikipedia.org/wiki/RGBE_image_format
  110994. *
  110995. * @param uint8array The binary file stored in an array buffer.
  110996. * @param hdrInfo The header information of the file.
  110997. * @return The pixels data in RGB right to left up to down order.
  110998. */
  110999. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  111000. private static RGBE_ReadPixels_RLE;
  111001. }
  111002. }
  111003. declare module BABYLON {
  111004. /**
  111005. * This represents a texture coming from an HDR input.
  111006. *
  111007. * The only supported format is currently panorama picture stored in RGBE format.
  111008. * Example of such files can be found on HDRLib: http://hdrlib.com/
  111009. */
  111010. export class HDRCubeTexture extends BaseTexture {
  111011. private static _facesMapping;
  111012. private _generateHarmonics;
  111013. private _noMipmap;
  111014. private _textureMatrix;
  111015. private _size;
  111016. private _onLoad;
  111017. private _onError;
  111018. /**
  111019. * The texture URL.
  111020. */
  111021. url: string;
  111022. /**
  111023. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  111024. */
  111025. coordinatesMode: number;
  111026. protected _isBlocking: boolean;
  111027. /**
  111028. * Sets wether or not the texture is blocking during loading.
  111029. */
  111030. /**
  111031. * Gets wether or not the texture is blocking during loading.
  111032. */
  111033. isBlocking: boolean;
  111034. protected _rotationY: number;
  111035. /**
  111036. * Sets texture matrix rotation angle around Y axis in radians.
  111037. */
  111038. /**
  111039. * Gets texture matrix rotation angle around Y axis radians.
  111040. */
  111041. rotationY: number;
  111042. /**
  111043. * Gets or sets the center of the bounding box associated with the cube texture
  111044. * It must define where the camera used to render the texture was set
  111045. */
  111046. boundingBoxPosition: Vector3;
  111047. private _boundingBoxSize;
  111048. /**
  111049. * Gets or sets the size of the bounding box associated with the cube texture
  111050. * When defined, the cubemap will switch to local mode
  111051. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  111052. * @example https://www.babylonjs-playground.com/#RNASML
  111053. */
  111054. boundingBoxSize: Vector3;
  111055. /**
  111056. * Instantiates an HDRTexture from the following parameters.
  111057. *
  111058. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  111059. * @param scene The scene the texture will be used in
  111060. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  111061. * @param noMipmap Forces to not generate the mipmap if true
  111062. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  111063. * @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)
  111064. * @param reserved Reserved flag for internal use.
  111065. */
  111066. 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>);
  111067. /**
  111068. * Get the current class name of the texture useful for serialization or dynamic coding.
  111069. * @returns "HDRCubeTexture"
  111070. */
  111071. getClassName(): string;
  111072. /**
  111073. * Occurs when the file is raw .hdr file.
  111074. */
  111075. private loadTexture;
  111076. clone(): HDRCubeTexture;
  111077. delayLoad(): void;
  111078. /**
  111079. * Get the texture reflection matrix used to rotate/transform the reflection.
  111080. * @returns the reflection matrix
  111081. */
  111082. getReflectionTextureMatrix(): Matrix;
  111083. /**
  111084. * Set the texture reflection matrix used to rotate/transform the reflection.
  111085. * @param value Define the reflection matrix to set
  111086. */
  111087. setReflectionTextureMatrix(value: Matrix): void;
  111088. /**
  111089. * Parses a JSON representation of an HDR Texture in order to create the texture
  111090. * @param parsedTexture Define the JSON representation
  111091. * @param scene Define the scene the texture should be created in
  111092. * @param rootUrl Define the root url in case we need to load relative dependencies
  111093. * @returns the newly created texture after parsing
  111094. */
  111095. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  111096. serialize(): any;
  111097. }
  111098. }
  111099. declare module BABYLON {
  111100. /**
  111101. * Class used to control physics engine
  111102. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111103. */
  111104. export class PhysicsEngine implements IPhysicsEngine {
  111105. private _physicsPlugin;
  111106. /**
  111107. * Global value used to control the smallest number supported by the simulation
  111108. */
  111109. static Epsilon: number;
  111110. private _impostors;
  111111. private _joints;
  111112. /**
  111113. * Gets the gravity vector used by the simulation
  111114. */
  111115. gravity: Vector3;
  111116. /**
  111117. * Factory used to create the default physics plugin.
  111118. * @returns The default physics plugin
  111119. */
  111120. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  111121. /**
  111122. * Creates a new Physics Engine
  111123. * @param gravity defines the gravity vector used by the simulation
  111124. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  111125. */
  111126. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  111127. /**
  111128. * Sets the gravity vector used by the simulation
  111129. * @param gravity defines the gravity vector to use
  111130. */
  111131. setGravity(gravity: Vector3): void;
  111132. /**
  111133. * Set the time step of the physics engine.
  111134. * Default is 1/60.
  111135. * To slow it down, enter 1/600 for example.
  111136. * To speed it up, 1/30
  111137. * @param newTimeStep defines the new timestep to apply to this world.
  111138. */
  111139. setTimeStep(newTimeStep?: number): void;
  111140. /**
  111141. * Get the time step of the physics engine.
  111142. * @returns the current time step
  111143. */
  111144. getTimeStep(): number;
  111145. /**
  111146. * Release all resources
  111147. */
  111148. dispose(): void;
  111149. /**
  111150. * Gets the name of the current physics plugin
  111151. * @returns the name of the plugin
  111152. */
  111153. getPhysicsPluginName(): string;
  111154. /**
  111155. * Adding a new impostor for the impostor tracking.
  111156. * This will be done by the impostor itself.
  111157. * @param impostor the impostor to add
  111158. */
  111159. addImpostor(impostor: PhysicsImpostor): void;
  111160. /**
  111161. * Remove an impostor from the engine.
  111162. * This impostor and its mesh will not longer be updated by the physics engine.
  111163. * @param impostor the impostor to remove
  111164. */
  111165. removeImpostor(impostor: PhysicsImpostor): void;
  111166. /**
  111167. * Add a joint to the physics engine
  111168. * @param mainImpostor defines the main impostor to which the joint is added.
  111169. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  111170. * @param joint defines the joint that will connect both impostors.
  111171. */
  111172. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111173. /**
  111174. * Removes a joint from the simulation
  111175. * @param mainImpostor defines the impostor used with the joint
  111176. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  111177. * @param joint defines the joint to remove
  111178. */
  111179. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111180. /**
  111181. * Called by the scene. No need to call it.
  111182. * @param delta defines the timespam between frames
  111183. */
  111184. _step(delta: number): void;
  111185. /**
  111186. * Gets the current plugin used to run the simulation
  111187. * @returns current plugin
  111188. */
  111189. getPhysicsPlugin(): IPhysicsEnginePlugin;
  111190. /**
  111191. * Gets the list of physic impostors
  111192. * @returns an array of PhysicsImpostor
  111193. */
  111194. getImpostors(): Array<PhysicsImpostor>;
  111195. /**
  111196. * Gets the impostor for a physics enabled object
  111197. * @param object defines the object impersonated by the impostor
  111198. * @returns the PhysicsImpostor or null if not found
  111199. */
  111200. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  111201. /**
  111202. * Gets the impostor for a physics body object
  111203. * @param body defines physics body used by the impostor
  111204. * @returns the PhysicsImpostor or null if not found
  111205. */
  111206. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  111207. /**
  111208. * Does a raycast in the physics world
  111209. * @param from when should the ray start?
  111210. * @param to when should the ray end?
  111211. * @returns PhysicsRaycastResult
  111212. */
  111213. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111214. }
  111215. }
  111216. declare module BABYLON {
  111217. /** @hidden */
  111218. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  111219. private _useDeltaForWorldStep;
  111220. world: any;
  111221. name: string;
  111222. private _physicsMaterials;
  111223. private _fixedTimeStep;
  111224. private _cannonRaycastResult;
  111225. private _raycastResult;
  111226. private _removeAfterStep;
  111227. BJSCANNON: any;
  111228. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  111229. setGravity(gravity: Vector3): void;
  111230. setTimeStep(timeStep: number): void;
  111231. getTimeStep(): number;
  111232. executeStep(delta: number): void;
  111233. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111234. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111235. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111236. private _processChildMeshes;
  111237. removePhysicsBody(impostor: PhysicsImpostor): void;
  111238. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111239. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111240. private _addMaterial;
  111241. private _checkWithEpsilon;
  111242. private _createShape;
  111243. private _createHeightmap;
  111244. private _minus90X;
  111245. private _plus90X;
  111246. private _tmpPosition;
  111247. private _tmpDeltaPosition;
  111248. private _tmpUnityRotation;
  111249. private _updatePhysicsBodyTransformation;
  111250. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111251. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111252. isSupported(): boolean;
  111253. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111254. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111255. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111256. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111257. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111258. getBodyMass(impostor: PhysicsImpostor): number;
  111259. getBodyFriction(impostor: PhysicsImpostor): number;
  111260. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111261. getBodyRestitution(impostor: PhysicsImpostor): number;
  111262. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111263. sleepBody(impostor: PhysicsImpostor): void;
  111264. wakeUpBody(impostor: PhysicsImpostor): void;
  111265. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  111266. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  111267. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  111268. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111269. getRadius(impostor: PhysicsImpostor): number;
  111270. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111271. dispose(): void;
  111272. private _extendNamespace;
  111273. /**
  111274. * Does a raycast in the physics world
  111275. * @param from when should the ray start?
  111276. * @param to when should the ray end?
  111277. * @returns PhysicsRaycastResult
  111278. */
  111279. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111280. }
  111281. }
  111282. declare module BABYLON {
  111283. /** @hidden */
  111284. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  111285. world: any;
  111286. name: string;
  111287. BJSOIMO: any;
  111288. private _raycastResult;
  111289. constructor(iterations?: number, oimoInjection?: any);
  111290. setGravity(gravity: Vector3): void;
  111291. setTimeStep(timeStep: number): void;
  111292. getTimeStep(): number;
  111293. private _tmpImpostorsArray;
  111294. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111295. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111296. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111297. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111298. private _tmpPositionVector;
  111299. removePhysicsBody(impostor: PhysicsImpostor): void;
  111300. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111301. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111302. isSupported(): boolean;
  111303. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111304. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111305. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111306. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111307. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111308. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111309. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111310. getBodyMass(impostor: PhysicsImpostor): number;
  111311. getBodyFriction(impostor: PhysicsImpostor): number;
  111312. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111313. getBodyRestitution(impostor: PhysicsImpostor): number;
  111314. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111315. sleepBody(impostor: PhysicsImpostor): void;
  111316. wakeUpBody(impostor: PhysicsImpostor): void;
  111317. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  111318. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  111319. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  111320. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111321. getRadius(impostor: PhysicsImpostor): number;
  111322. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111323. dispose(): void;
  111324. /**
  111325. * Does a raycast in the physics world
  111326. * @param from when should the ray start?
  111327. * @param to when should the ray end?
  111328. * @returns PhysicsRaycastResult
  111329. */
  111330. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111331. }
  111332. }
  111333. declare module BABYLON {
  111334. /**
  111335. * Class containing static functions to help procedurally build meshes
  111336. */
  111337. export class RibbonBuilder {
  111338. /**
  111339. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  111340. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  111341. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  111342. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  111343. * * 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
  111344. * * 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
  111345. * * 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
  111346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111348. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111349. * * 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
  111350. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  111351. * * 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
  111352. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  111353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111354. * @param name defines the name of the mesh
  111355. * @param options defines the options used to create the mesh
  111356. * @param scene defines the hosting scene
  111357. * @returns the ribbon mesh
  111358. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  111359. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111360. */
  111361. static CreateRibbon(name: string, options: {
  111362. pathArray: Vector3[][];
  111363. closeArray?: boolean;
  111364. closePath?: boolean;
  111365. offset?: number;
  111366. updatable?: boolean;
  111367. sideOrientation?: number;
  111368. frontUVs?: Vector4;
  111369. backUVs?: Vector4;
  111370. instance?: Mesh;
  111371. invertUV?: boolean;
  111372. uvs?: Vector2[];
  111373. colors?: Color4[];
  111374. }, scene?: Nullable<Scene>): Mesh;
  111375. }
  111376. }
  111377. declare module BABYLON {
  111378. /**
  111379. * Class containing static functions to help procedurally build meshes
  111380. */
  111381. export class ShapeBuilder {
  111382. /**
  111383. * 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.
  111384. * * 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.
  111385. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111386. * * 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.
  111387. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  111388. * * 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
  111389. * * 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
  111390. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  111391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111393. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  111394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111395. * @param name defines the name of the mesh
  111396. * @param options defines the options used to create the mesh
  111397. * @param scene defines the hosting scene
  111398. * @returns the extruded shape mesh
  111399. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111401. */
  111402. static ExtrudeShape(name: string, options: {
  111403. shape: Vector3[];
  111404. path: Vector3[];
  111405. scale?: number;
  111406. rotation?: number;
  111407. cap?: number;
  111408. updatable?: boolean;
  111409. sideOrientation?: number;
  111410. frontUVs?: Vector4;
  111411. backUVs?: Vector4;
  111412. instance?: Mesh;
  111413. invertUV?: boolean;
  111414. }, scene?: Nullable<Scene>): Mesh;
  111415. /**
  111416. * Creates an custom extruded shape mesh.
  111417. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  111418. * * 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.
  111419. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111420. * * 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
  111421. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  111422. * * 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
  111423. * * It must returns a float value that will be the scale value applied to the shape on each path point
  111424. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  111425. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  111426. * * 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
  111427. * * 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
  111428. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  111429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111431. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111433. * @param name defines the name of the mesh
  111434. * @param options defines the options used to create the mesh
  111435. * @param scene defines the hosting scene
  111436. * @returns the custom extruded shape mesh
  111437. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  111438. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111439. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111440. */
  111441. static ExtrudeShapeCustom(name: string, options: {
  111442. shape: Vector3[];
  111443. path: Vector3[];
  111444. scaleFunction?: any;
  111445. rotationFunction?: any;
  111446. ribbonCloseArray?: boolean;
  111447. ribbonClosePath?: boolean;
  111448. cap?: number;
  111449. updatable?: boolean;
  111450. sideOrientation?: number;
  111451. frontUVs?: Vector4;
  111452. backUVs?: Vector4;
  111453. instance?: Mesh;
  111454. invertUV?: boolean;
  111455. }, scene?: Nullable<Scene>): Mesh;
  111456. private static _ExtrudeShapeGeneric;
  111457. }
  111458. }
  111459. declare module BABYLON {
  111460. /**
  111461. * AmmoJS Physics plugin
  111462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111463. * @see https://github.com/kripken/ammo.js/
  111464. */
  111465. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  111466. private _useDeltaForWorldStep;
  111467. /**
  111468. * Reference to the Ammo library
  111469. */
  111470. bjsAMMO: any;
  111471. /**
  111472. * Created ammoJS world which physics bodies are added to
  111473. */
  111474. world: any;
  111475. /**
  111476. * Name of the plugin
  111477. */
  111478. name: string;
  111479. private _timeStep;
  111480. private _fixedTimeStep;
  111481. private _maxSteps;
  111482. private _tmpQuaternion;
  111483. private _tmpAmmoTransform;
  111484. private _tmpAmmoQuaternion;
  111485. private _tmpAmmoConcreteContactResultCallback;
  111486. private _collisionConfiguration;
  111487. private _dispatcher;
  111488. private _overlappingPairCache;
  111489. private _solver;
  111490. private _softBodySolver;
  111491. private _tmpAmmoVectorA;
  111492. private _tmpAmmoVectorB;
  111493. private _tmpAmmoVectorC;
  111494. private _tmpAmmoVectorD;
  111495. private _tmpContactCallbackResult;
  111496. private _tmpAmmoVectorRCA;
  111497. private _tmpAmmoVectorRCB;
  111498. private _raycastResult;
  111499. private static readonly DISABLE_COLLISION_FLAG;
  111500. private static readonly KINEMATIC_FLAG;
  111501. private static readonly DISABLE_DEACTIVATION_FLAG;
  111502. /**
  111503. * Initializes the ammoJS plugin
  111504. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  111505. * @param ammoInjection can be used to inject your own ammo reference
  111506. */
  111507. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  111508. /**
  111509. * Sets the gravity of the physics world (m/(s^2))
  111510. * @param gravity Gravity to set
  111511. */
  111512. setGravity(gravity: Vector3): void;
  111513. /**
  111514. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  111515. * @param timeStep timestep to use in seconds
  111516. */
  111517. setTimeStep(timeStep: number): void;
  111518. /**
  111519. * 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)
  111520. * @param fixedTimeStep fixedTimeStep to use in seconds
  111521. */
  111522. setFixedTimeStep(fixedTimeStep: number): void;
  111523. /**
  111524. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  111525. * @param maxSteps the maximum number of steps by the physics engine per frame
  111526. */
  111527. setMaxSteps(maxSteps: number): void;
  111528. /**
  111529. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  111530. * @returns the current timestep in seconds
  111531. */
  111532. getTimeStep(): number;
  111533. private _isImpostorInContact;
  111534. private _isImpostorPairInContact;
  111535. private _stepSimulation;
  111536. /**
  111537. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  111538. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  111539. * After the step the babylon meshes are set to the position of the physics imposters
  111540. * @param delta amount of time to step forward
  111541. * @param impostors array of imposters to update before/after the step
  111542. */
  111543. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111544. /**
  111545. * Update babylon mesh to match physics world object
  111546. * @param impostor imposter to match
  111547. */
  111548. private _afterSoftStep;
  111549. /**
  111550. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  111551. * @param impostor imposter to match
  111552. */
  111553. private _ropeStep;
  111554. /**
  111555. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  111556. * @param impostor imposter to match
  111557. */
  111558. private _softbodyOrClothStep;
  111559. private _tmpVector;
  111560. private _tmpMatrix;
  111561. /**
  111562. * Applies an impulse on the imposter
  111563. * @param impostor imposter to apply impulse to
  111564. * @param force amount of force to be applied to the imposter
  111565. * @param contactPoint the location to apply the impulse on the imposter
  111566. */
  111567. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111568. /**
  111569. * Applies a force on the imposter
  111570. * @param impostor imposter to apply force
  111571. * @param force amount of force to be applied to the imposter
  111572. * @param contactPoint the location to apply the force on the imposter
  111573. */
  111574. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111575. /**
  111576. * Creates a physics body using the plugin
  111577. * @param impostor the imposter to create the physics body on
  111578. */
  111579. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111580. /**
  111581. * Removes the physics body from the imposter and disposes of the body's memory
  111582. * @param impostor imposter to remove the physics body from
  111583. */
  111584. removePhysicsBody(impostor: PhysicsImpostor): void;
  111585. /**
  111586. * Generates a joint
  111587. * @param impostorJoint the imposter joint to create the joint with
  111588. */
  111589. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111590. /**
  111591. * Removes a joint
  111592. * @param impostorJoint the imposter joint to remove the joint from
  111593. */
  111594. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111595. private _addMeshVerts;
  111596. /**
  111597. * Initialise the soft body vertices to match its object's (mesh) vertices
  111598. * Softbody vertices (nodes) are in world space and to match this
  111599. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  111600. * @param impostor to create the softbody for
  111601. */
  111602. private _softVertexData;
  111603. /**
  111604. * Create an impostor's soft body
  111605. * @param impostor to create the softbody for
  111606. */
  111607. private _createSoftbody;
  111608. /**
  111609. * Create cloth for an impostor
  111610. * @param impostor to create the softbody for
  111611. */
  111612. private _createCloth;
  111613. /**
  111614. * Create rope for an impostor
  111615. * @param impostor to create the softbody for
  111616. */
  111617. private _createRope;
  111618. private _addHullVerts;
  111619. private _createShape;
  111620. /**
  111621. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  111622. * @param impostor imposter containing the physics body and babylon object
  111623. */
  111624. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111625. /**
  111626. * Sets the babylon object's position/rotation from the physics body's position/rotation
  111627. * @param impostor imposter containing the physics body and babylon object
  111628. * @param newPosition new position
  111629. * @param newRotation new rotation
  111630. */
  111631. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111632. /**
  111633. * If this plugin is supported
  111634. * @returns true if its supported
  111635. */
  111636. isSupported(): boolean;
  111637. /**
  111638. * Sets the linear velocity of the physics body
  111639. * @param impostor imposter to set the velocity on
  111640. * @param velocity velocity to set
  111641. */
  111642. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111643. /**
  111644. * Sets the angular velocity of the physics body
  111645. * @param impostor imposter to set the velocity on
  111646. * @param velocity velocity to set
  111647. */
  111648. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111649. /**
  111650. * gets the linear velocity
  111651. * @param impostor imposter to get linear velocity from
  111652. * @returns linear velocity
  111653. */
  111654. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111655. /**
  111656. * gets the angular velocity
  111657. * @param impostor imposter to get angular velocity from
  111658. * @returns angular velocity
  111659. */
  111660. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111661. /**
  111662. * Sets the mass of physics body
  111663. * @param impostor imposter to set the mass on
  111664. * @param mass mass to set
  111665. */
  111666. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111667. /**
  111668. * Gets the mass of the physics body
  111669. * @param impostor imposter to get the mass from
  111670. * @returns mass
  111671. */
  111672. getBodyMass(impostor: PhysicsImpostor): number;
  111673. /**
  111674. * Gets friction of the impostor
  111675. * @param impostor impostor to get friction from
  111676. * @returns friction value
  111677. */
  111678. getBodyFriction(impostor: PhysicsImpostor): number;
  111679. /**
  111680. * Sets friction of the impostor
  111681. * @param impostor impostor to set friction on
  111682. * @param friction friction value
  111683. */
  111684. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111685. /**
  111686. * Gets restitution of the impostor
  111687. * @param impostor impostor to get restitution from
  111688. * @returns restitution value
  111689. */
  111690. getBodyRestitution(impostor: PhysicsImpostor): number;
  111691. /**
  111692. * Sets resitution of the impostor
  111693. * @param impostor impostor to set resitution on
  111694. * @param restitution resitution value
  111695. */
  111696. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111697. /**
  111698. * Gets pressure inside the impostor
  111699. * @param impostor impostor to get pressure from
  111700. * @returns pressure value
  111701. */
  111702. getBodyPressure(impostor: PhysicsImpostor): number;
  111703. /**
  111704. * Sets pressure inside a soft body impostor
  111705. * Cloth and rope must remain 0 pressure
  111706. * @param impostor impostor to set pressure on
  111707. * @param pressure pressure value
  111708. */
  111709. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  111710. /**
  111711. * Gets stiffness of the impostor
  111712. * @param impostor impostor to get stiffness from
  111713. * @returns pressure value
  111714. */
  111715. getBodyStiffness(impostor: PhysicsImpostor): number;
  111716. /**
  111717. * Sets stiffness of the impostor
  111718. * @param impostor impostor to set stiffness on
  111719. * @param stiffness stiffness value from 0 to 1
  111720. */
  111721. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  111722. /**
  111723. * Gets velocityIterations of the impostor
  111724. * @param impostor impostor to get velocity iterations from
  111725. * @returns velocityIterations value
  111726. */
  111727. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  111728. /**
  111729. * Sets velocityIterations of the impostor
  111730. * @param impostor impostor to set velocity iterations on
  111731. * @param velocityIterations velocityIterations value
  111732. */
  111733. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  111734. /**
  111735. * Gets positionIterations of the impostor
  111736. * @param impostor impostor to get position iterations from
  111737. * @returns positionIterations value
  111738. */
  111739. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  111740. /**
  111741. * Sets positionIterations of the impostor
  111742. * @param impostor impostor to set position on
  111743. * @param positionIterations positionIterations value
  111744. */
  111745. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  111746. /**
  111747. * Append an anchor to a cloth object
  111748. * @param impostor is the cloth impostor to add anchor to
  111749. * @param otherImpostor is the rigid impostor to anchor to
  111750. * @param width ratio across width from 0 to 1
  111751. * @param height ratio up height from 0 to 1
  111752. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  111753. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  111754. */
  111755. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  111756. /**
  111757. * Append an hook to a rope object
  111758. * @param impostor is the rope impostor to add hook to
  111759. * @param otherImpostor is the rigid impostor to hook to
  111760. * @param length ratio along the rope from 0 to 1
  111761. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  111762. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  111763. */
  111764. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  111765. /**
  111766. * Sleeps the physics body and stops it from being active
  111767. * @param impostor impostor to sleep
  111768. */
  111769. sleepBody(impostor: PhysicsImpostor): void;
  111770. /**
  111771. * Activates the physics body
  111772. * @param impostor impostor to activate
  111773. */
  111774. wakeUpBody(impostor: PhysicsImpostor): void;
  111775. /**
  111776. * Updates the distance parameters of the joint
  111777. * @param joint joint to update
  111778. * @param maxDistance maximum distance of the joint
  111779. * @param minDistance minimum distance of the joint
  111780. */
  111781. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  111782. /**
  111783. * Sets a motor on the joint
  111784. * @param joint joint to set motor on
  111785. * @param speed speed of the motor
  111786. * @param maxForce maximum force of the motor
  111787. * @param motorIndex index of the motor
  111788. */
  111789. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  111790. /**
  111791. * Sets the motors limit
  111792. * @param joint joint to set limit on
  111793. * @param upperLimit upper limit
  111794. * @param lowerLimit lower limit
  111795. */
  111796. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  111797. /**
  111798. * Syncs the position and rotation of a mesh with the impostor
  111799. * @param mesh mesh to sync
  111800. * @param impostor impostor to update the mesh with
  111801. */
  111802. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111803. /**
  111804. * Gets the radius of the impostor
  111805. * @param impostor impostor to get radius from
  111806. * @returns the radius
  111807. */
  111808. getRadius(impostor: PhysicsImpostor): number;
  111809. /**
  111810. * Gets the box size of the impostor
  111811. * @param impostor impostor to get box size from
  111812. * @param result the resulting box size
  111813. */
  111814. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111815. /**
  111816. * Disposes of the impostor
  111817. */
  111818. dispose(): void;
  111819. /**
  111820. * Does a raycast in the physics world
  111821. * @param from when should the ray start?
  111822. * @param to when should the ray end?
  111823. * @returns PhysicsRaycastResult
  111824. */
  111825. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111826. }
  111827. }
  111828. declare module BABYLON {
  111829. interface AbstractScene {
  111830. /**
  111831. * The list of reflection probes added to the scene
  111832. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  111833. */
  111834. reflectionProbes: Array<ReflectionProbe>;
  111835. /**
  111836. * Removes the given reflection probe from this scene.
  111837. * @param toRemove The reflection probe to remove
  111838. * @returns The index of the removed reflection probe
  111839. */
  111840. removeReflectionProbe(toRemove: ReflectionProbe): number;
  111841. /**
  111842. * Adds the given reflection probe to this scene.
  111843. * @param newReflectionProbe The reflection probe to add
  111844. */
  111845. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  111846. }
  111847. /**
  111848. * Class used to generate realtime reflection / refraction cube textures
  111849. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  111850. */
  111851. export class ReflectionProbe {
  111852. /** defines the name of the probe */
  111853. name: string;
  111854. private _scene;
  111855. private _renderTargetTexture;
  111856. private _projectionMatrix;
  111857. private _viewMatrix;
  111858. private _target;
  111859. private _add;
  111860. private _attachedMesh;
  111861. private _invertYAxis;
  111862. /** Gets or sets probe position (center of the cube map) */
  111863. position: Vector3;
  111864. /**
  111865. * Creates a new reflection probe
  111866. * @param name defines the name of the probe
  111867. * @param size defines the texture resolution (for each face)
  111868. * @param scene defines the hosting scene
  111869. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  111870. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  111871. */
  111872. constructor(
  111873. /** defines the name of the probe */
  111874. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  111875. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  111876. samples: number;
  111877. /** Gets or sets the refresh rate to use (on every frame by default) */
  111878. refreshRate: number;
  111879. /**
  111880. * Gets the hosting scene
  111881. * @returns a Scene
  111882. */
  111883. getScene(): Scene;
  111884. /** Gets the internal CubeTexture used to render to */
  111885. readonly cubeTexture: RenderTargetTexture;
  111886. /** Gets the list of meshes to render */
  111887. readonly renderList: Nullable<AbstractMesh[]>;
  111888. /**
  111889. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  111890. * @param mesh defines the mesh to attach to
  111891. */
  111892. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  111893. /**
  111894. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  111895. * @param renderingGroupId The rendering group id corresponding to its index
  111896. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  111897. */
  111898. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  111899. /**
  111900. * Clean all associated resources
  111901. */
  111902. dispose(): void;
  111903. /**
  111904. * Converts the reflection probe information to a readable string for debug purpose.
  111905. * @param fullDetails Supports for multiple levels of logging within scene loading
  111906. * @returns the human readable reflection probe info
  111907. */
  111908. toString(fullDetails?: boolean): string;
  111909. /**
  111910. * Get the class name of the relfection probe.
  111911. * @returns "ReflectionProbe"
  111912. */
  111913. getClassName(): string;
  111914. /**
  111915. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  111916. * @returns The JSON representation of the texture
  111917. */
  111918. serialize(): any;
  111919. /**
  111920. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  111921. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  111922. * @param scene Define the scene the parsed reflection probe should be instantiated in
  111923. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  111924. * @returns The parsed reflection probe if successful
  111925. */
  111926. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  111927. }
  111928. }
  111929. declare module BABYLON {
  111930. /** @hidden */
  111931. export var _BabylonLoaderRegistered: boolean;
  111932. }
  111933. declare module BABYLON {
  111934. /**
  111935. * The Physically based simple base material of BJS.
  111936. *
  111937. * This enables better naming and convention enforcements on top of the pbrMaterial.
  111938. * It is used as the base class for both the specGloss and metalRough conventions.
  111939. */
  111940. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  111941. /**
  111942. * Number of Simultaneous lights allowed on the material.
  111943. */
  111944. maxSimultaneousLights: number;
  111945. /**
  111946. * If sets to true, disables all the lights affecting the material.
  111947. */
  111948. disableLighting: boolean;
  111949. /**
  111950. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  111951. */
  111952. environmentTexture: BaseTexture;
  111953. /**
  111954. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111955. */
  111956. invertNormalMapX: boolean;
  111957. /**
  111958. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111959. */
  111960. invertNormalMapY: boolean;
  111961. /**
  111962. * Normal map used in the model.
  111963. */
  111964. normalTexture: BaseTexture;
  111965. /**
  111966. * Emissivie color used to self-illuminate the model.
  111967. */
  111968. emissiveColor: Color3;
  111969. /**
  111970. * Emissivie texture used to self-illuminate the model.
  111971. */
  111972. emissiveTexture: BaseTexture;
  111973. /**
  111974. * Occlusion Channel Strenght.
  111975. */
  111976. occlusionStrength: number;
  111977. /**
  111978. * Occlusion Texture of the material (adding extra occlusion effects).
  111979. */
  111980. occlusionTexture: BaseTexture;
  111981. /**
  111982. * Defines the alpha limits in alpha test mode.
  111983. */
  111984. alphaCutOff: number;
  111985. /**
  111986. * Gets the current double sided mode.
  111987. */
  111988. /**
  111989. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111990. */
  111991. doubleSided: boolean;
  111992. /**
  111993. * Stores the pre-calculated light information of a mesh in a texture.
  111994. */
  111995. lightmapTexture: BaseTexture;
  111996. /**
  111997. * If true, the light map contains occlusion information instead of lighting info.
  111998. */
  111999. useLightmapAsShadowmap: boolean;
  112000. /**
  112001. * Instantiates a new PBRMaterial instance.
  112002. *
  112003. * @param name The material name
  112004. * @param scene The scene the material will be use in.
  112005. */
  112006. constructor(name: string, scene: Scene);
  112007. getClassName(): string;
  112008. }
  112009. }
  112010. declare module BABYLON {
  112011. /**
  112012. * The PBR material of BJS following the metal roughness convention.
  112013. *
  112014. * This fits to the PBR convention in the GLTF definition:
  112015. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  112016. */
  112017. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  112018. /**
  112019. * The base color has two different interpretations depending on the value of metalness.
  112020. * When the material is a metal, the base color is the specific measured reflectance value
  112021. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  112022. * of the material.
  112023. */
  112024. baseColor: Color3;
  112025. /**
  112026. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  112027. * well as opacity information in the alpha channel.
  112028. */
  112029. baseTexture: BaseTexture;
  112030. /**
  112031. * Specifies the metallic scalar value of the material.
  112032. * Can also be used to scale the metalness values of the metallic texture.
  112033. */
  112034. metallic: number;
  112035. /**
  112036. * Specifies the roughness scalar value of the material.
  112037. * Can also be used to scale the roughness values of the metallic texture.
  112038. */
  112039. roughness: number;
  112040. /**
  112041. * Texture containing both the metallic value in the B channel and the
  112042. * roughness value in the G channel to keep better precision.
  112043. */
  112044. metallicRoughnessTexture: BaseTexture;
  112045. /**
  112046. * Instantiates a new PBRMetalRoughnessMaterial instance.
  112047. *
  112048. * @param name The material name
  112049. * @param scene The scene the material will be use in.
  112050. */
  112051. constructor(name: string, scene: Scene);
  112052. /**
  112053. * Return the currrent class name of the material.
  112054. */
  112055. getClassName(): string;
  112056. /**
  112057. * Makes a duplicate of the current material.
  112058. * @param name - name to use for the new material.
  112059. */
  112060. clone(name: string): PBRMetallicRoughnessMaterial;
  112061. /**
  112062. * Serialize the material to a parsable JSON object.
  112063. */
  112064. serialize(): any;
  112065. /**
  112066. * Parses a JSON object correponding to the serialize function.
  112067. */
  112068. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  112069. }
  112070. }
  112071. declare module BABYLON {
  112072. /**
  112073. * The PBR material of BJS following the specular glossiness convention.
  112074. *
  112075. * This fits to the PBR convention in the GLTF definition:
  112076. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  112077. */
  112078. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  112079. /**
  112080. * Specifies the diffuse color of the material.
  112081. */
  112082. diffuseColor: Color3;
  112083. /**
  112084. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  112085. * channel.
  112086. */
  112087. diffuseTexture: BaseTexture;
  112088. /**
  112089. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  112090. */
  112091. specularColor: Color3;
  112092. /**
  112093. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  112094. */
  112095. glossiness: number;
  112096. /**
  112097. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  112098. */
  112099. specularGlossinessTexture: BaseTexture;
  112100. /**
  112101. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  112102. *
  112103. * @param name The material name
  112104. * @param scene The scene the material will be use in.
  112105. */
  112106. constructor(name: string, scene: Scene);
  112107. /**
  112108. * Return the currrent class name of the material.
  112109. */
  112110. getClassName(): string;
  112111. /**
  112112. * Makes a duplicate of the current material.
  112113. * @param name - name to use for the new material.
  112114. */
  112115. clone(name: string): PBRSpecularGlossinessMaterial;
  112116. /**
  112117. * Serialize the material to a parsable JSON object.
  112118. */
  112119. serialize(): any;
  112120. /**
  112121. * Parses a JSON object correponding to the serialize function.
  112122. */
  112123. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  112124. }
  112125. }
  112126. declare module BABYLON {
  112127. /**
  112128. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  112129. * It can help converting any input color in a desired output one. This can then be used to create effects
  112130. * from sepia, black and white to sixties or futuristic rendering...
  112131. *
  112132. * The only supported format is currently 3dl.
  112133. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  112134. */
  112135. export class ColorGradingTexture extends BaseTexture {
  112136. /**
  112137. * The current texture matrix. (will always be identity in color grading texture)
  112138. */
  112139. private _textureMatrix;
  112140. /**
  112141. * The texture URL.
  112142. */
  112143. url: string;
  112144. /**
  112145. * Empty line regex stored for GC.
  112146. */
  112147. private static _noneEmptyLineRegex;
  112148. private _engine;
  112149. /**
  112150. * Instantiates a ColorGradingTexture from the following parameters.
  112151. *
  112152. * @param url The location of the color gradind data (currently only supporting 3dl)
  112153. * @param scene The scene the texture will be used in
  112154. */
  112155. constructor(url: string, scene: Scene);
  112156. /**
  112157. * Returns the texture matrix used in most of the material.
  112158. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  112159. */
  112160. getTextureMatrix(): Matrix;
  112161. /**
  112162. * Occurs when the file being loaded is a .3dl LUT file.
  112163. */
  112164. private load3dlTexture;
  112165. /**
  112166. * Starts the loading process of the texture.
  112167. */
  112168. private loadTexture;
  112169. /**
  112170. * Clones the color gradind texture.
  112171. */
  112172. clone(): ColorGradingTexture;
  112173. /**
  112174. * Called during delayed load for textures.
  112175. */
  112176. delayLoad(): void;
  112177. /**
  112178. * Parses a color grading texture serialized by Babylon.
  112179. * @param parsedTexture The texture information being parsedTexture
  112180. * @param scene The scene to load the texture in
  112181. * @param rootUrl The root url of the data assets to load
  112182. * @return A color gradind texture
  112183. */
  112184. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  112185. /**
  112186. * Serializes the LUT texture to json format.
  112187. */
  112188. serialize(): any;
  112189. }
  112190. }
  112191. declare module BABYLON {
  112192. /**
  112193. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  112194. */
  112195. export class EquiRectangularCubeTexture extends BaseTexture {
  112196. /** The six faces of the cube. */
  112197. private static _FacesMapping;
  112198. private _noMipmap;
  112199. private _onLoad;
  112200. private _onError;
  112201. /** The size of the cubemap. */
  112202. private _size;
  112203. /** The buffer of the image. */
  112204. private _buffer;
  112205. /** The width of the input image. */
  112206. private _width;
  112207. /** The height of the input image. */
  112208. private _height;
  112209. /** The URL to the image. */
  112210. url: string;
  112211. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  112212. coordinatesMode: number;
  112213. /**
  112214. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  112215. * @param url The location of the image
  112216. * @param scene The scene the texture will be used in
  112217. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  112218. * @param noMipmap Forces to not generate the mipmap if true
  112219. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  112220. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  112221. * @param onLoad — defines a callback called when texture is loaded
  112222. * @param onError — defines a callback called if there is an error
  112223. */
  112224. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  112225. /**
  112226. * Load the image data, by putting the image on a canvas and extracting its buffer.
  112227. */
  112228. private loadImage;
  112229. /**
  112230. * Convert the image buffer into a cubemap and create a CubeTexture.
  112231. */
  112232. private loadTexture;
  112233. /**
  112234. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  112235. * @param buffer The ArrayBuffer that should be converted.
  112236. * @returns The buffer as Float32Array.
  112237. */
  112238. private getFloat32ArrayFromArrayBuffer;
  112239. /**
  112240. * Get the current class name of the texture useful for serialization or dynamic coding.
  112241. * @returns "EquiRectangularCubeTexture"
  112242. */
  112243. getClassName(): string;
  112244. /**
  112245. * Create a clone of the current EquiRectangularCubeTexture and return it.
  112246. * @returns A clone of the current EquiRectangularCubeTexture.
  112247. */
  112248. clone(): EquiRectangularCubeTexture;
  112249. }
  112250. }
  112251. declare module BABYLON {
  112252. /**
  112253. * Based on jsTGALoader - Javascript loader for TGA file
  112254. * By Vincent Thibault
  112255. * @see http://blog.robrowser.com/javascript-tga-loader.html
  112256. */
  112257. export class TGATools {
  112258. private static _TYPE_INDEXED;
  112259. private static _TYPE_RGB;
  112260. private static _TYPE_GREY;
  112261. private static _TYPE_RLE_INDEXED;
  112262. private static _TYPE_RLE_RGB;
  112263. private static _TYPE_RLE_GREY;
  112264. private static _ORIGIN_MASK;
  112265. private static _ORIGIN_SHIFT;
  112266. private static _ORIGIN_BL;
  112267. private static _ORIGIN_BR;
  112268. private static _ORIGIN_UL;
  112269. private static _ORIGIN_UR;
  112270. /**
  112271. * Gets the header of a TGA file
  112272. * @param data defines the TGA data
  112273. * @returns the header
  112274. */
  112275. static GetTGAHeader(data: Uint8Array): any;
  112276. /**
  112277. * Uploads TGA content to a Babylon Texture
  112278. * @hidden
  112279. */
  112280. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  112281. /** @hidden */
  112282. 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;
  112283. /** @hidden */
  112284. 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;
  112285. /** @hidden */
  112286. 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;
  112287. /** @hidden */
  112288. 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;
  112289. /** @hidden */
  112290. 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;
  112291. /** @hidden */
  112292. 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;
  112293. }
  112294. }
  112295. declare module BABYLON {
  112296. /**
  112297. * Implementation of the TGA Texture Loader.
  112298. * @hidden
  112299. */
  112300. export class _TGATextureLoader implements IInternalTextureLoader {
  112301. /**
  112302. * Defines wether the loader supports cascade loading the different faces.
  112303. */
  112304. readonly supportCascades: boolean;
  112305. /**
  112306. * This returns if the loader support the current file information.
  112307. * @param extension defines the file extension of the file being loaded
  112308. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112309. * @param fallback defines the fallback internal texture if any
  112310. * @param isBase64 defines whether the texture is encoded as a base64
  112311. * @param isBuffer defines whether the texture data are stored as a buffer
  112312. * @returns true if the loader can load the specified file
  112313. */
  112314. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112315. /**
  112316. * Transform the url before loading if required.
  112317. * @param rootUrl the url of the texture
  112318. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112319. * @returns the transformed texture
  112320. */
  112321. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112322. /**
  112323. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112324. * @param rootUrl the url of the texture
  112325. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112326. * @returns the fallback texture
  112327. */
  112328. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112329. /**
  112330. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112331. * @param data contains the texture data
  112332. * @param texture defines the BabylonJS internal texture
  112333. * @param createPolynomials will be true if polynomials have been requested
  112334. * @param onLoad defines the callback to trigger once the texture is ready
  112335. * @param onError defines the callback to trigger in case of error
  112336. */
  112337. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112338. /**
  112339. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112340. * @param data contains the texture data
  112341. * @param texture defines the BabylonJS internal texture
  112342. * @param callback defines the method to call once ready to upload
  112343. */
  112344. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112345. }
  112346. }
  112347. declare module BABYLON {
  112348. /**
  112349. * 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.
  112350. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  112351. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  112352. */
  112353. export class CustomProceduralTexture extends ProceduralTexture {
  112354. private _animate;
  112355. private _time;
  112356. private _config;
  112357. private _texturePath;
  112358. /**
  112359. * Instantiates a new Custom Procedural Texture.
  112360. * 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.
  112361. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  112362. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  112363. * @param name Define the name of the texture
  112364. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  112365. * @param size Define the size of the texture to create
  112366. * @param scene Define the scene the texture belongs to
  112367. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  112368. * @param generateMipMaps Define if the texture should creates mip maps or not
  112369. */
  112370. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  112371. private _loadJson;
  112372. /**
  112373. * Is the texture ready to be used ? (rendered at least once)
  112374. * @returns true if ready, otherwise, false.
  112375. */
  112376. isReady(): boolean;
  112377. /**
  112378. * Render the texture to its associated render target.
  112379. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  112380. */
  112381. render(useCameraPostProcess?: boolean): void;
  112382. /**
  112383. * Update the list of dependant textures samplers in the shader.
  112384. */
  112385. updateTextures(): void;
  112386. /**
  112387. * Update the uniform values of the procedural texture in the shader.
  112388. */
  112389. updateShaderUniforms(): void;
  112390. /**
  112391. * Define if the texture animates or not.
  112392. */
  112393. animate: boolean;
  112394. }
  112395. }
  112396. declare module BABYLON {
  112397. /** @hidden */
  112398. export var noisePixelShader: {
  112399. name: string;
  112400. shader: string;
  112401. };
  112402. }
  112403. declare module BABYLON {
  112404. /**
  112405. * Class used to generate noise procedural textures
  112406. */
  112407. export class NoiseProceduralTexture extends ProceduralTexture {
  112408. private _time;
  112409. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  112410. brightness: number;
  112411. /** Defines the number of octaves to process */
  112412. octaves: number;
  112413. /** Defines the level of persistence (0.8 by default) */
  112414. persistence: number;
  112415. /** Gets or sets animation speed factor (default is 1) */
  112416. animationSpeedFactor: number;
  112417. /**
  112418. * Creates a new NoiseProceduralTexture
  112419. * @param name defines the name fo the texture
  112420. * @param size defines the size of the texture (default is 256)
  112421. * @param scene defines the hosting scene
  112422. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  112423. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  112424. */
  112425. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  112426. private _updateShaderUniforms;
  112427. protected _getDefines(): string;
  112428. /** Generate the current state of the procedural texture */
  112429. render(useCameraPostProcess?: boolean): void;
  112430. /**
  112431. * Serializes this noise procedural texture
  112432. * @returns a serialized noise procedural texture object
  112433. */
  112434. serialize(): any;
  112435. /**
  112436. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  112437. * @param parsedTexture defines parsed texture data
  112438. * @param scene defines the current scene
  112439. * @param rootUrl defines the root URL containing noise procedural texture information
  112440. * @returns a parsed NoiseProceduralTexture
  112441. */
  112442. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  112443. }
  112444. }
  112445. declare module BABYLON {
  112446. /**
  112447. * Raw cube texture where the raw buffers are passed in
  112448. */
  112449. export class RawCubeTexture extends CubeTexture {
  112450. /**
  112451. * Creates a cube texture where the raw buffers are passed in.
  112452. * @param scene defines the scene the texture is attached to
  112453. * @param data defines the array of data to use to create each face
  112454. * @param size defines the size of the textures
  112455. * @param format defines the format of the data
  112456. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  112457. * @param generateMipMaps defines if the engine should generate the mip levels
  112458. * @param invertY defines if data must be stored with Y axis inverted
  112459. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  112460. * @param compression defines the compression used (null by default)
  112461. */
  112462. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  112463. /**
  112464. * Updates the raw cube texture.
  112465. * @param data defines the data to store
  112466. * @param format defines the data format
  112467. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  112468. * @param invertY defines if data must be stored with Y axis inverted
  112469. * @param compression defines the compression used (null by default)
  112470. * @param level defines which level of the texture to update
  112471. */
  112472. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  112473. /**
  112474. * Updates a raw cube texture with RGBD encoded data.
  112475. * @param data defines the array of data [mipmap][face] to use to create each face
  112476. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  112477. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  112478. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  112479. * @returns a promsie that resolves when the operation is complete
  112480. */
  112481. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  112482. /**
  112483. * Clones the raw cube texture.
  112484. * @return a new cube texture
  112485. */
  112486. clone(): CubeTexture;
  112487. /** @hidden */
  112488. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112489. }
  112490. }
  112491. declare module BABYLON {
  112492. /**
  112493. * Class used to store 3D textures containing user data
  112494. */
  112495. export class RawTexture3D extends Texture {
  112496. /** Gets or sets the texture format to use */
  112497. format: number;
  112498. private _engine;
  112499. /**
  112500. * Create a new RawTexture3D
  112501. * @param data defines the data of the texture
  112502. * @param width defines the width of the texture
  112503. * @param height defines the height of the texture
  112504. * @param depth defines the depth of the texture
  112505. * @param format defines the texture format to use
  112506. * @param scene defines the hosting scene
  112507. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  112508. * @param invertY defines if texture must be stored with Y axis inverted
  112509. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  112510. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  112511. */
  112512. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  112513. /** Gets or sets the texture format to use */
  112514. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  112515. /**
  112516. * Update the texture with new data
  112517. * @param data defines the data to store in the texture
  112518. */
  112519. update(data: ArrayBufferView): void;
  112520. }
  112521. }
  112522. declare module BABYLON {
  112523. /**
  112524. * Creates a refraction texture used by refraction channel of the standard material.
  112525. * It is like a mirror but to see through a material.
  112526. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  112527. */
  112528. export class RefractionTexture extends RenderTargetTexture {
  112529. /**
  112530. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  112531. * 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.
  112532. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  112533. */
  112534. refractionPlane: Plane;
  112535. /**
  112536. * Define how deep under the surface we should see.
  112537. */
  112538. depth: number;
  112539. /**
  112540. * Creates a refraction texture used by refraction channel of the standard material.
  112541. * It is like a mirror but to see through a material.
  112542. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  112543. * @param name Define the texture name
  112544. * @param size Define the size of the underlying texture
  112545. * @param scene Define the scene the refraction belongs to
  112546. * @param generateMipMaps Define if we need to generate mips level for the refraction
  112547. */
  112548. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  112549. /**
  112550. * Clone the refraction texture.
  112551. * @returns the cloned texture
  112552. */
  112553. clone(): RefractionTexture;
  112554. /**
  112555. * Serialize the texture to a JSON representation you could use in Parse later on
  112556. * @returns the serialized JSON representation
  112557. */
  112558. serialize(): any;
  112559. }
  112560. }
  112561. declare module BABYLON {
  112562. /**
  112563. * Defines the options related to the creation of an HtmlElementTexture
  112564. */
  112565. export interface IHtmlElementTextureOptions {
  112566. /**
  112567. * Defines wether mip maps should be created or not.
  112568. */
  112569. generateMipMaps?: boolean;
  112570. /**
  112571. * Defines the sampling mode of the texture.
  112572. */
  112573. samplingMode?: number;
  112574. /**
  112575. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  112576. */
  112577. engine: Nullable<Engine>;
  112578. /**
  112579. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  112580. */
  112581. scene: Nullable<Scene>;
  112582. }
  112583. /**
  112584. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  112585. * To be as efficient as possible depending on your constraints nothing aside the first upload
  112586. * is automatically managed.
  112587. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  112588. * in your application.
  112589. *
  112590. * As the update is not automatic, you need to call them manually.
  112591. */
  112592. export class HtmlElementTexture extends BaseTexture {
  112593. /**
  112594. * The texture URL.
  112595. */
  112596. element: HTMLVideoElement | HTMLCanvasElement;
  112597. private static readonly DefaultOptions;
  112598. private _textureMatrix;
  112599. private _engine;
  112600. private _isVideo;
  112601. private _generateMipMaps;
  112602. private _samplingMode;
  112603. /**
  112604. * Instantiates a HtmlElementTexture from the following parameters.
  112605. *
  112606. * @param name Defines the name of the texture
  112607. * @param element Defines the video or canvas the texture is filled with
  112608. * @param options Defines the other none mandatory texture creation options
  112609. */
  112610. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  112611. private _createInternalTexture;
  112612. /**
  112613. * Returns the texture matrix used in most of the material.
  112614. */
  112615. getTextureMatrix(): Matrix;
  112616. /**
  112617. * Updates the content of the texture.
  112618. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  112619. */
  112620. update(invertY?: Nullable<boolean>): void;
  112621. }
  112622. }
  112623. declare module BABYLON {
  112624. /**
  112625. * Enum used to define the target of a block
  112626. */
  112627. export enum NodeMaterialBlockTargets {
  112628. /** Vertex shader */
  112629. Vertex = 1,
  112630. /** Fragment shader */
  112631. Fragment = 2,
  112632. /** Vertex and Fragment */
  112633. VertexAndFragment = 3
  112634. }
  112635. }
  112636. declare module BABYLON {
  112637. /**
  112638. * Defines the kind of connection point for node based material
  112639. */
  112640. export enum NodeMaterialBlockConnectionPointTypes {
  112641. /** Float */
  112642. Float = 1,
  112643. /** Int */
  112644. Int = 2,
  112645. /** Vector2 */
  112646. Vector2 = 4,
  112647. /** Vector3 */
  112648. Vector3 = 8,
  112649. /** Vector4 */
  112650. Vector4 = 16,
  112651. /** Color3 */
  112652. Color3 = 32,
  112653. /** Color4 */
  112654. Color4 = 64,
  112655. /** Matrix */
  112656. Matrix = 128,
  112657. /** Texture */
  112658. Texture = 256,
  112659. /** Texture3D */
  112660. Texture3D = 512,
  112661. /** Vector3 or Color3 */
  112662. Vector3OrColor3 = 40,
  112663. /** Vector3 or Vector4 */
  112664. Vector3OrVector4 = 24,
  112665. /** Vector4 or Color4 */
  112666. Vector4OrColor4 = 80,
  112667. /** Color3 or Color4 */
  112668. Color3OrColor4 = 96,
  112669. /** Vector3 or Color3 */
  112670. Vector3OrColor3OrVector4OrColor4 = 120
  112671. }
  112672. }
  112673. declare module BABYLON {
  112674. /**
  112675. * Enum used to define well known values e.g. values automatically provided by the system
  112676. */
  112677. export enum NodeMaterialWellKnownValues {
  112678. /** World */
  112679. World = 1,
  112680. /** View */
  112681. View = 2,
  112682. /** Projection */
  112683. Projection = 3,
  112684. /** ViewProjection */
  112685. ViewProjection = 4,
  112686. /** WorldView */
  112687. WorldView = 5,
  112688. /** WorldViewProjection */
  112689. WorldViewProjection = 6,
  112690. /** Will be filled by the block itself */
  112691. Automatic = 7
  112692. }
  112693. }
  112694. declare module BABYLON {
  112695. /**
  112696. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  112697. */
  112698. export enum NodeMaterialBlockConnectionPointMode {
  112699. /** Value is an uniform */
  112700. Uniform = 0,
  112701. /** Value is a mesh attribute */
  112702. Attribute = 1,
  112703. /** Value is a varying between vertex and fragment shaders */
  112704. Varying = 2,
  112705. /** Mode is undefined */
  112706. Undefined = 3
  112707. }
  112708. }
  112709. declare module BABYLON {
  112710. /**
  112711. * Class used to store shared data between 2 NodeMaterialBuildState
  112712. */
  112713. export class NodeMaterialBuildStateSharedData {
  112714. /**
  112715. * Gets the list of emitted varyings
  112716. */
  112717. varyings: string[];
  112718. /**
  112719. * Gets the varying declaration string
  112720. */
  112721. varyingDeclaration: string;
  112722. /**
  112723. * Uniform connection points
  112724. */
  112725. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  112726. /**
  112727. * Bindable blocks (Blocks that need to set data to the effect)
  112728. */
  112729. bindableBlocks: NodeMaterialBlock[];
  112730. /**
  112731. * List of blocks that can provide a compilation fallback
  112732. */
  112733. blocksWithFallbacks: NodeMaterialBlock[];
  112734. /**
  112735. * List of blocks that can provide a define update
  112736. */
  112737. blocksWithDefines: NodeMaterialBlock[];
  112738. /**
  112739. * List of blocks that can provide a repeatable content
  112740. */
  112741. repeatableContentBlocks: NodeMaterialBlock[];
  112742. /**
  112743. * List of blocks that can block the isReady function for the material
  112744. */
  112745. blockingBlocks: NodeMaterialBlock[];
  112746. /**
  112747. * Build Id used to avoid multiple recompilations
  112748. */
  112749. buildId: number;
  112750. /** List of emitted variables */
  112751. variableNames: {
  112752. [key: string]: number;
  112753. };
  112754. /** List of emitted defines */
  112755. defineNames: {
  112756. [key: string]: number;
  112757. };
  112758. /** Should emit comments? */
  112759. emitComments: boolean;
  112760. /** Emit build activity */
  112761. verbose: boolean;
  112762. /**
  112763. * Gets the compilation hints emitted at compilation time
  112764. */
  112765. hints: {
  112766. needWorldViewMatrix: boolean;
  112767. needWorldViewProjectionMatrix: boolean;
  112768. needAlphaBlending: boolean;
  112769. needAlphaTesting: boolean;
  112770. };
  112771. /**
  112772. * List of compilation checks
  112773. */
  112774. checks: {
  112775. emitVertex: boolean;
  112776. emitFragment: boolean;
  112777. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  112778. };
  112779. /** Creates a new shared data */
  112780. constructor();
  112781. /**
  112782. * Emits console errors and exceptions if there is a failing check
  112783. */
  112784. emitErrors(): void;
  112785. }
  112786. }
  112787. declare module BABYLON {
  112788. /**
  112789. * Class used to store node based material build state
  112790. */
  112791. export class NodeMaterialBuildState {
  112792. /**
  112793. * Gets the list of emitted attributes
  112794. */
  112795. attributes: string[];
  112796. /**
  112797. * Gets the list of emitted uniforms
  112798. */
  112799. uniforms: string[];
  112800. /**
  112801. * Gets the list of emitted samplers
  112802. */
  112803. samplers: string[];
  112804. /**
  112805. * Gets the list of emitted functions
  112806. */
  112807. functions: {
  112808. [key: string]: string;
  112809. };
  112810. /**
  112811. * Gets the target of the compilation state
  112812. */
  112813. target: NodeMaterialBlockTargets;
  112814. /**
  112815. * Shared data between multiple NodeMaterialBuildState instances
  112816. */
  112817. sharedData: NodeMaterialBuildStateSharedData;
  112818. /** @hidden */
  112819. _vertexState: NodeMaterialBuildState;
  112820. private _attributeDeclaration;
  112821. private _uniformDeclaration;
  112822. private _samplerDeclaration;
  112823. private _varyingTransfer;
  112824. private _repeatableContentAnchorIndex;
  112825. /** @hidden */
  112826. _builtCompilationString: string;
  112827. /**
  112828. * Gets the emitted compilation strings
  112829. */
  112830. compilationString: string;
  112831. /**
  112832. * Finalize the compilation strings
  112833. * @param state defines the current compilation state
  112834. */
  112835. finalize(state: NodeMaterialBuildState): void;
  112836. /** @hidden */
  112837. readonly _repeatableContentAnchor: string;
  112838. /** @hidden */
  112839. _getFreeVariableName(prefix: string): string;
  112840. /** @hidden */
  112841. _getFreeDefineName(prefix: string): string;
  112842. /** @hidden */
  112843. _excludeVariableName(name: string): void;
  112844. /** @hidden */
  112845. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  112846. /** @hidden */
  112847. _emitFunction(name: string, code: string, comments: string): void;
  112848. /** @hidden */
  112849. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  112850. replaceStrings?: {
  112851. search: RegExp;
  112852. replace: string;
  112853. }[];
  112854. }): string;
  112855. /** @hidden */
  112856. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  112857. repeatKey?: string;
  112858. removeAttributes?: boolean;
  112859. removeUniforms?: boolean;
  112860. removeVaryings?: boolean;
  112861. removeIfDef?: boolean;
  112862. replaceStrings?: {
  112863. search: RegExp;
  112864. replace: string;
  112865. }[];
  112866. }): void;
  112867. /** @hidden */
  112868. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  112869. private _emitDefine;
  112870. /** @hidden */
  112871. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  112872. }
  112873. }
  112874. declare module BABYLON {
  112875. /**
  112876. * Root class for all node material optimizers
  112877. */
  112878. export class NodeMaterialOptimizer {
  112879. /**
  112880. * Function used to optimize a NodeMaterial graph
  112881. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  112882. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  112883. */
  112884. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  112885. }
  112886. }
  112887. declare module BABYLON {
  112888. /**
  112889. * Block used to transform a vector4 with a matrix
  112890. */
  112891. export class Vector4TransformBlock extends NodeMaterialBlock {
  112892. /**
  112893. * Defines the value to use to complement Vector3 to transform it to a Vector4
  112894. */
  112895. complementW: number;
  112896. /**
  112897. * Creates a new Vector4TransformBlock
  112898. * @param name defines the block name
  112899. */
  112900. constructor(name: string);
  112901. /**
  112902. * Gets the current class name
  112903. * @returns the class name
  112904. */
  112905. getClassName(): string;
  112906. /**
  112907. * Gets the vector input
  112908. */
  112909. readonly vector: NodeMaterialConnectionPoint;
  112910. /**
  112911. * Gets the matrix transform input
  112912. */
  112913. readonly transform: NodeMaterialConnectionPoint;
  112914. protected _buildBlock(state: NodeMaterialBuildState): this;
  112915. }
  112916. }
  112917. declare module BABYLON {
  112918. /**
  112919. * Block used to output the vertex position
  112920. */
  112921. export class VertexOutputBlock extends NodeMaterialBlock {
  112922. /**
  112923. * Creates a new VertexOutputBlock
  112924. * @param name defines the block name
  112925. */
  112926. constructor(name: string);
  112927. /**
  112928. * Gets the current class name
  112929. * @returns the class name
  112930. */
  112931. getClassName(): string;
  112932. /**
  112933. * Gets the vector input component
  112934. */
  112935. readonly vector: NodeMaterialConnectionPoint;
  112936. protected _buildBlock(state: NodeMaterialBuildState): this;
  112937. }
  112938. }
  112939. declare module BABYLON {
  112940. /**
  112941. * Block used to output the final color
  112942. */
  112943. export class FragmentOutputBlock extends NodeMaterialBlock {
  112944. /**
  112945. * Gets or sets a boolean indicating if this block will output an alpha value
  112946. */
  112947. alphaBlendingEnabled: boolean;
  112948. /**
  112949. * Create a new FragmentOutputBlock
  112950. * @param name defines the block name
  112951. */
  112952. constructor(name: string);
  112953. /**
  112954. * Gets the current class name
  112955. * @returns the class name
  112956. */
  112957. getClassName(): string;
  112958. /**
  112959. * Gets the color input component
  112960. */
  112961. readonly color: NodeMaterialConnectionPoint;
  112962. protected _buildBlock(state: NodeMaterialBuildState): this;
  112963. }
  112964. }
  112965. declare module BABYLON {
  112966. /**
  112967. * Interface used to configure the node material editor
  112968. */
  112969. export interface INodeMaterialEditorOptions {
  112970. /** Define the URl to load node editor script */
  112971. editorURL?: string;
  112972. }
  112973. /** @hidden */
  112974. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  112975. /** BONES */
  112976. NUM_BONE_INFLUENCERS: number;
  112977. BonesPerMesh: number;
  112978. BONETEXTURE: boolean;
  112979. /** MORPH TARGETS */
  112980. MORPHTARGETS: boolean;
  112981. MORPHTARGETS_NORMAL: boolean;
  112982. MORPHTARGETS_TANGENT: boolean;
  112983. NUM_MORPH_INFLUENCERS: number;
  112984. /** IMAGE PROCESSING */
  112985. IMAGEPROCESSING: boolean;
  112986. VIGNETTE: boolean;
  112987. VIGNETTEBLENDMODEMULTIPLY: boolean;
  112988. VIGNETTEBLENDMODEOPAQUE: boolean;
  112989. TONEMAPPING: boolean;
  112990. TONEMAPPING_ACES: boolean;
  112991. CONTRAST: boolean;
  112992. EXPOSURE: boolean;
  112993. COLORCURVES: boolean;
  112994. COLORGRADING: boolean;
  112995. COLORGRADING3D: boolean;
  112996. SAMPLER3DGREENDEPTH: boolean;
  112997. SAMPLER3DBGRMAP: boolean;
  112998. IMAGEPROCESSINGPOSTPROCESS: boolean;
  112999. constructor();
  113000. setValue(name: string, value: boolean): void;
  113001. }
  113002. /**
  113003. * Class used to configure NodeMaterial
  113004. */
  113005. export interface INodeMaterialOptions {
  113006. /**
  113007. * Defines if blocks should emit comments
  113008. */
  113009. emitComments: boolean;
  113010. }
  113011. /**
  113012. * Class used to create a node based material built by assembling shader blocks
  113013. */
  113014. export class NodeMaterial extends PushMaterial {
  113015. private _options;
  113016. private _vertexCompilationState;
  113017. private _fragmentCompilationState;
  113018. private _sharedData;
  113019. private _buildId;
  113020. private _buildWasSuccessful;
  113021. private _cachedWorldViewMatrix;
  113022. private _cachedWorldViewProjectionMatrix;
  113023. private _textureConnectionPoints;
  113024. private _optimizers;
  113025. /** Define the URl to load node editor script */
  113026. static EditorURL: string;
  113027. private BJSNODEMATERIALEDITOR;
  113028. /** Get the inspector from bundle or global */
  113029. private _getGlobalNodeMaterialEditor;
  113030. /**
  113031. * Defines the maximum number of lights that can be used in the material
  113032. */
  113033. maxSimultaneousLights: number;
  113034. /**
  113035. * Observable raised when the material is built
  113036. */
  113037. onBuildObservable: Observable<NodeMaterial>;
  113038. /**
  113039. * Gets or sets the root nodes of the material vertex shader
  113040. */
  113041. _vertexOutputNodes: NodeMaterialBlock[];
  113042. /**
  113043. * Gets or sets the root nodes of the material fragment (pixel) shader
  113044. */
  113045. _fragmentOutputNodes: NodeMaterialBlock[];
  113046. /** Gets or sets options to control the node material overall behavior */
  113047. options: INodeMaterialOptions;
  113048. /**
  113049. * Default configuration related to image processing available in the standard Material.
  113050. */
  113051. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113052. /**
  113053. * Gets the image processing configuration used either in this material.
  113054. */
  113055. /**
  113056. * Sets the Default image processing configuration used either in the this material.
  113057. *
  113058. * If sets to null, the scene one is in use.
  113059. */
  113060. imageProcessingConfiguration: ImageProcessingConfiguration;
  113061. /**
  113062. * Create a new node based material
  113063. * @param name defines the material name
  113064. * @param scene defines the hosting scene
  113065. * @param options defines creation option
  113066. */
  113067. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  113068. /**
  113069. * Gets the current class name of the material e.g. "NodeMaterial"
  113070. * @returns the class name
  113071. */
  113072. getClassName(): string;
  113073. /**
  113074. * Keep track of the image processing observer to allow dispose and replace.
  113075. */
  113076. private _imageProcessingObserver;
  113077. /**
  113078. * Attaches a new image processing configuration to the Standard Material.
  113079. * @param configuration
  113080. */
  113081. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113082. /**
  113083. * Adds a new optimizer to the list of optimizers
  113084. * @param optimizer defines the optimizers to add
  113085. * @returns the current material
  113086. */
  113087. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113088. /**
  113089. * Remove an optimizer from the list of optimizers
  113090. * @param optimizer defines the optimizers to remove
  113091. * @returns the current material
  113092. */
  113093. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113094. /**
  113095. * Add a new block to the list of output nodes
  113096. * @param node defines the node to add
  113097. * @returns the current material
  113098. */
  113099. addOutputNode(node: NodeMaterialBlock): this;
  113100. /**
  113101. * Remove a block from the list of root nodes
  113102. * @param node defines the node to remove
  113103. * @returns the current material
  113104. */
  113105. removeOutputNode(node: NodeMaterialBlock): this;
  113106. private _addVertexOutputNode;
  113107. private _removeVertexOutputNode;
  113108. private _addFragmentOutputNode;
  113109. private _removeFragmentOutputNode;
  113110. /**
  113111. * Specifies if the material will require alpha blending
  113112. * @returns a boolean specifying if alpha blending is needed
  113113. */
  113114. needAlphaBlending(): boolean;
  113115. /**
  113116. * Specifies if this material should be rendered in alpha test mode
  113117. * @returns a boolean specifying if an alpha test is needed.
  113118. */
  113119. needAlphaTesting(): boolean;
  113120. private _initializeBlock;
  113121. private _resetDualBlocks;
  113122. /**
  113123. * Build the material and generates the inner effect
  113124. * @param verbose defines if the build should log activity
  113125. */
  113126. build(verbose?: boolean): void;
  113127. /**
  113128. * Runs an otpimization phase to try to improve the shader code
  113129. */
  113130. optimize(): void;
  113131. private _prepareDefinesForAttributes;
  113132. /**
  113133. * Get if the submesh is ready to be used and all its information available.
  113134. * Child classes can use it to update shaders
  113135. * @param mesh defines the mesh to check
  113136. * @param subMesh defines which submesh to check
  113137. * @param useInstances specifies that instances should be used
  113138. * @returns a boolean indicating that the submesh is ready or not
  113139. */
  113140. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113141. /**
  113142. * Binds the world matrix to the material
  113143. * @param world defines the world transformation matrix
  113144. */
  113145. bindOnlyWorldMatrix(world: Matrix): void;
  113146. /**
  113147. * Binds the submesh to this material by preparing the effect and shader to draw
  113148. * @param world defines the world transformation matrix
  113149. * @param mesh defines the mesh containing the submesh
  113150. * @param subMesh defines the submesh to bind the material to
  113151. */
  113152. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113153. /**
  113154. * Gets the active textures from the material
  113155. * @returns an array of textures
  113156. */
  113157. getActiveTextures(): BaseTexture[];
  113158. /**
  113159. * Specifies if the material uses a texture
  113160. * @param texture defines the texture to check against the material
  113161. * @returns a boolean specifying if the material uses the texture
  113162. */
  113163. hasTexture(texture: BaseTexture): boolean;
  113164. /**
  113165. * Disposes the material
  113166. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  113167. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  113168. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  113169. */
  113170. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  113171. /** Creates the node editor window. */
  113172. private _createNodeEditor;
  113173. /**
  113174. * Launch the node material editor
  113175. * @param config Define the configuration of the editor
  113176. * @return a promise fulfilled when the node editor is visible
  113177. */
  113178. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  113179. /**
  113180. * Clear the current material
  113181. */
  113182. clear(): void;
  113183. /**
  113184. * Clear the current material and set it to a default state
  113185. */
  113186. setToDefault(): void;
  113187. }
  113188. }
  113189. declare module BABYLON {
  113190. /**
  113191. * Defines a block that can be used inside a node based material
  113192. */
  113193. export class NodeMaterialBlock {
  113194. private _buildId;
  113195. private _target;
  113196. private _isFinalMerger;
  113197. /** @hidden */
  113198. _inputs: NodeMaterialConnectionPoint[];
  113199. /** @hidden */
  113200. _outputs: NodeMaterialConnectionPoint[];
  113201. /**
  113202. * Gets or sets the name of the block
  113203. */
  113204. name: string;
  113205. /**
  113206. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  113207. */
  113208. readonly isFinalMerger: boolean;
  113209. /**
  113210. * Gets or sets the build Id
  113211. */
  113212. buildId: number;
  113213. /**
  113214. * Gets or sets the target of the block
  113215. */
  113216. target: NodeMaterialBlockTargets;
  113217. /**
  113218. * Gets the list of input points
  113219. */
  113220. readonly inputs: NodeMaterialConnectionPoint[];
  113221. /** Gets the list of output points */
  113222. readonly outputs: NodeMaterialConnectionPoint[];
  113223. /**
  113224. * Find an input by its name
  113225. * @param name defines the name of the input to look for
  113226. * @returns the input or null if not found
  113227. */
  113228. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  113229. /**
  113230. * Find an output by its name
  113231. * @param name defines the name of the outputto look for
  113232. * @returns the output or null if not found
  113233. */
  113234. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  113235. /**
  113236. * Creates a new NodeMaterialBlock
  113237. * @param name defines the block name
  113238. * @param target defines the target of that block (Vertex by default)
  113239. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  113240. */
  113241. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  113242. /**
  113243. * Initialize the block and prepare the context for build
  113244. * @param state defines the state that will be used for the build
  113245. */
  113246. initialize(state: NodeMaterialBuildState): void;
  113247. /**
  113248. * Bind data to effect. Will only be called for blocks with isBindable === true
  113249. * @param effect defines the effect to bind data to
  113250. * @param nodeMaterial defines the hosting NodeMaterial
  113251. * @param mesh defines the mesh that will be rendered
  113252. */
  113253. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113254. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  113255. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  113256. protected _writeFloat(value: number): string;
  113257. /**
  113258. * Gets the current class name e.g. "NodeMaterialBlock"
  113259. * @returns the class name
  113260. */
  113261. getClassName(): string;
  113262. /**
  113263. * Register a new input. Must be called inside a block constructor
  113264. * @param name defines the connection point name
  113265. * @param type defines the connection point type
  113266. * @param isOptional defines a boolean indicating that this input can be omitted
  113267. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  113268. * @returns the current block
  113269. */
  113270. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  113271. /**
  113272. * Register a new output. Must be called inside a block constructor
  113273. * @param name defines the connection point name
  113274. * @param type defines the connection point type
  113275. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  113276. * @returns the current block
  113277. */
  113278. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  113279. /**
  113280. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  113281. * @param forOutput defines an optional connection point to check compatibility with
  113282. * @returns the first available input or null
  113283. */
  113284. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  113285. /**
  113286. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  113287. * @param forBlock defines an optional block to check compatibility with
  113288. * @returns the first available input or null
  113289. */
  113290. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  113291. /**
  113292. * Connect current block with another block
  113293. * @param other defines the block to connect with
  113294. * @param options define the various options to help pick the right connections
  113295. * @returns the current block
  113296. */
  113297. connectTo(other: NodeMaterialBlock, options?: {
  113298. input?: string;
  113299. output?: string;
  113300. outputSwizzle?: string;
  113301. }): this | undefined;
  113302. protected _buildBlock(state: NodeMaterialBuildState): void;
  113303. /**
  113304. * Add potential fallbacks if shader compilation fails
  113305. * @param mesh defines the mesh to be rendered
  113306. * @param fallbacks defines the current prioritized list of fallbacks
  113307. */
  113308. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  113309. /**
  113310. * Update defines for shader compilation
  113311. * @param mesh defines the mesh to be rendered
  113312. * @param nodeMaterial defines the node material requesting the update
  113313. * @param defines defines the material defines to update
  113314. * @param useInstances specifies that instances should be used
  113315. */
  113316. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  113317. /**
  113318. * Lets the block try to connect some inputs automatically
  113319. */
  113320. autoConfigure(): void;
  113321. /**
  113322. * Function called when a block is declared as repeatable content generator
  113323. * @param vertexShaderState defines the current compilation state for the vertex shader
  113324. * @param fragmentShaderState defines the current compilation state for the fragment shader
  113325. * @param mesh defines the mesh to be rendered
  113326. * @param defines defines the material defines to update
  113327. */
  113328. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  113329. /**
  113330. * Checks if the block is ready
  113331. * @param mesh defines the mesh to be rendered
  113332. * @param nodeMaterial defines the node material requesting the update
  113333. * @param defines defines the material defines to update
  113334. * @param useInstances specifies that instances should be used
  113335. * @returns true if the block is ready
  113336. */
  113337. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  113338. /**
  113339. * Compile the current node and generate the shader code
  113340. * @param state defines the current compilation state (uniforms, samplers, current string)
  113341. * @returns the current block
  113342. */
  113343. build(state: NodeMaterialBuildState): this | undefined;
  113344. }
  113345. }
  113346. declare module BABYLON {
  113347. /**
  113348. * Defines a connection point for a block
  113349. */
  113350. export class NodeMaterialConnectionPoint {
  113351. /** @hidden */
  113352. _ownerBlock: NodeMaterialBlock;
  113353. /** @hidden */
  113354. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  113355. private _associatedVariableName;
  113356. private _endpoints;
  113357. private _storedValue;
  113358. private _valueCallback;
  113359. private _mode;
  113360. /** @hidden */
  113361. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  113362. /** @hidden */
  113363. _needToEmitVarying: boolean;
  113364. /**
  113365. * Gets or sets the connection point type (default is float)
  113366. */
  113367. type: NodeMaterialBlockConnectionPointTypes;
  113368. /**
  113369. * Gets or sets the connection point name
  113370. */
  113371. name: string;
  113372. /**
  113373. * Gets or sets the swizzle to apply to this connection point when reading or writing
  113374. */
  113375. swizzle: string;
  113376. /**
  113377. * Gets or sets a boolean indicating that this connection point can be omitted
  113378. */
  113379. isOptional: boolean;
  113380. /**
  113381. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  113382. */
  113383. define: string;
  113384. /** Gets or sets the target of that connection point */
  113385. target: NodeMaterialBlockTargets;
  113386. /**
  113387. * Gets or sets the value of that point.
  113388. * Please note that this value will be ignored if valueCallback is defined
  113389. */
  113390. value: any;
  113391. /**
  113392. * Gets or sets a callback used to get the value of that point.
  113393. * Please note that setting this value will force the connection point to ignore the value property
  113394. */
  113395. valueCallback: () => any;
  113396. /**
  113397. * Gets or sets the associated variable name in the shader
  113398. */
  113399. associatedVariableName: string;
  113400. /**
  113401. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  113402. * In this case the connection point name must be the name of the uniform to use.
  113403. * Can only be set on inputs
  113404. */
  113405. isUniform: boolean;
  113406. /**
  113407. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  113408. * In this case the connection point name must be the name of the attribute to use
  113409. * Can only be set on inputs
  113410. */
  113411. isAttribute: boolean;
  113412. /**
  113413. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  113414. * Can only be set on exit points
  113415. */
  113416. isVarying: boolean;
  113417. /** Get the other side of the connection (if any) */
  113418. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  113419. /** Get the block that owns this connection point */
  113420. readonly ownerBlock: NodeMaterialBlock;
  113421. /** Get the block connected on the other side of this connection (if any) */
  113422. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  113423. /** Get the block connected on the endpoints of this connection (if any) */
  113424. readonly connectedBlocks: Array<NodeMaterialBlock>;
  113425. /**
  113426. * Creates a new connection point
  113427. * @param name defines the connection point name
  113428. * @param ownerBlock defines the block hosting this connection point
  113429. */
  113430. constructor(name: string, ownerBlock: NodeMaterialBlock);
  113431. /**
  113432. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  113433. * @returns the class name
  113434. */
  113435. getClassName(): string;
  113436. /**
  113437. * Set the source of this connection point to a vertex attribute
  113438. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  113439. * @returns the current connection point
  113440. */
  113441. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  113442. /**
  113443. * Set the source of this connection point to a well known value
  113444. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  113445. * @returns the current connection point
  113446. */
  113447. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  113448. /**
  113449. * Gets a boolean indicating that the current connection point is a well known value
  113450. */
  113451. readonly isWellKnownValue: boolean;
  113452. /**
  113453. * Gets or sets the current well known value or null if not defined as well know value
  113454. */
  113455. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  113456. private _getTypeLength;
  113457. /**
  113458. * Connect this point to another connection point
  113459. * @param connectionPoint defines the other connection point
  113460. * @returns the current connection point
  113461. */
  113462. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  113463. /**
  113464. * Disconnect this point from one of his endpoint
  113465. * @param endpoint defines the other connection point
  113466. * @returns the current connection point
  113467. */
  113468. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  113469. /**
  113470. * When connection point is an uniform, this function will send its value to the effect
  113471. * @param effect defines the effect to transmit value to
  113472. * @param world defines the world matrix
  113473. * @param worldView defines the worldxview matrix
  113474. * @param worldViewProjection defines the worldxviewxprojection matrix
  113475. */
  113476. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  113477. /**
  113478. * When connection point is an uniform, this function will send its value to the effect
  113479. * @param effect defines the effect to transmit value to
  113480. * @param scene defines the hosting scene
  113481. */
  113482. transmit(effect: Effect, scene: Scene): void;
  113483. }
  113484. }
  113485. declare module BABYLON {
  113486. /**
  113487. * Block used to add support for vertex skinning (bones)
  113488. */
  113489. export class BonesBlock extends NodeMaterialBlock {
  113490. /**
  113491. * Creates a new BonesBlock
  113492. * @param name defines the block name
  113493. */
  113494. constructor(name: string);
  113495. /**
  113496. * Initialize the block and prepare the context for build
  113497. * @param state defines the state that will be used for the build
  113498. */
  113499. initialize(state: NodeMaterialBuildState): void;
  113500. /**
  113501. * Gets the current class name
  113502. * @returns the class name
  113503. */
  113504. getClassName(): string;
  113505. /**
  113506. * Gets the matrix indices input component
  113507. */
  113508. readonly matricesIndices: NodeMaterialConnectionPoint;
  113509. /**
  113510. * Gets the matrix weights input component
  113511. */
  113512. readonly matricesWeights: NodeMaterialConnectionPoint;
  113513. /**
  113514. * Gets the extra matrix indices input component
  113515. */
  113516. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  113517. /**
  113518. * Gets the extra matrix weights input component
  113519. */
  113520. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  113521. /**
  113522. * Gets the world input component
  113523. */
  113524. readonly world: NodeMaterialConnectionPoint;
  113525. autoConfigure(): void;
  113526. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  113527. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113528. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113529. protected _buildBlock(state: NodeMaterialBuildState): this;
  113530. }
  113531. }
  113532. declare module BABYLON {
  113533. /**
  113534. * Block used to add support for instances
  113535. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113536. */
  113537. export class InstancesBlock extends NodeMaterialBlock {
  113538. /**
  113539. * Creates a new InstancesBlock
  113540. * @param name defines the block name
  113541. */
  113542. constructor(name: string);
  113543. /**
  113544. * Gets the current class name
  113545. * @returns the class name
  113546. */
  113547. getClassName(): string;
  113548. /**
  113549. * Gets the first world row input component
  113550. */
  113551. readonly world0: NodeMaterialConnectionPoint;
  113552. /**
  113553. * Gets the second world row input component
  113554. */
  113555. readonly world1: NodeMaterialConnectionPoint;
  113556. /**
  113557. * Gets the third world row input component
  113558. */
  113559. readonly world2: NodeMaterialConnectionPoint;
  113560. /**
  113561. * Gets the forth world row input component
  113562. */
  113563. readonly world3: NodeMaterialConnectionPoint;
  113564. /**
  113565. * Gets the world input component
  113566. */
  113567. readonly world: NodeMaterialConnectionPoint;
  113568. /**
  113569. * Gets the output component
  113570. */
  113571. readonly output: NodeMaterialConnectionPoint;
  113572. autoConfigure(): void;
  113573. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  113574. protected _buildBlock(state: NodeMaterialBuildState): this;
  113575. }
  113576. }
  113577. declare module BABYLON {
  113578. /**
  113579. * Block used to add morph targets support to vertex shader
  113580. */
  113581. export class MorphTargetsBlock extends NodeMaterialBlock {
  113582. private _repeatableContentAnchor;
  113583. private _repeatebleContentGenerated;
  113584. /**
  113585. * Create a new MorphTargetsBlock
  113586. * @param name defines the block name
  113587. */
  113588. constructor(name: string);
  113589. /**
  113590. * Gets the current class name
  113591. * @returns the class name
  113592. */
  113593. getClassName(): string;
  113594. /**
  113595. * Gets the position input component
  113596. */
  113597. readonly position: NodeMaterialConnectionPoint;
  113598. /**
  113599. * Gets the normal input component
  113600. */
  113601. readonly normal: NodeMaterialConnectionPoint;
  113602. /**
  113603. * Gets the tangent input component
  113604. */
  113605. readonly tangent: NodeMaterialConnectionPoint;
  113606. /**
  113607. * Gets the position output component
  113608. */
  113609. readonly positionOutput: NodeMaterialConnectionPoint;
  113610. /**
  113611. * Gets the normal output component
  113612. */
  113613. readonly normalOutput: NodeMaterialConnectionPoint;
  113614. /**
  113615. * Gets the tangent output component
  113616. */
  113617. readonly tangentOutput: NodeMaterialConnectionPoint;
  113618. initialize(state: NodeMaterialBuildState): void;
  113619. autoConfigure(): void;
  113620. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113621. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113622. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  113623. protected _buildBlock(state: NodeMaterialBuildState): this;
  113624. }
  113625. }
  113626. declare module BABYLON {
  113627. /**
  113628. * Block used to add an alpha test in the fragment shader
  113629. */
  113630. export class AlphaTestBlock extends NodeMaterialBlock {
  113631. /**
  113632. * Gets or sets the alpha value where alpha testing happens
  113633. */
  113634. alphaCutOff: number;
  113635. /**
  113636. * Create a new AlphaTestBlock
  113637. * @param name defines the block name
  113638. */
  113639. constructor(name: string);
  113640. /**
  113641. * Gets the current class name
  113642. * @returns the class name
  113643. */
  113644. getClassName(): string;
  113645. /**
  113646. * Gets the color input component
  113647. */
  113648. readonly color: NodeMaterialConnectionPoint;
  113649. protected _buildBlock(state: NodeMaterialBuildState): this;
  113650. }
  113651. }
  113652. declare module BABYLON {
  113653. /**
  113654. * Block used to create a Color4 out of 4 inputs (one for each component)
  113655. */
  113656. export class RGBAMergerBlock extends NodeMaterialBlock {
  113657. /**
  113658. * Create a new RGBAMergerBlock
  113659. * @param name defines the block name
  113660. */
  113661. constructor(name: string);
  113662. /**
  113663. * Gets the current class name
  113664. * @returns the class name
  113665. */
  113666. getClassName(): string;
  113667. /**
  113668. * Gets the R input component
  113669. */
  113670. readonly r: NodeMaterialConnectionPoint;
  113671. /**
  113672. * Gets the G input component
  113673. */
  113674. readonly g: NodeMaterialConnectionPoint;
  113675. /**
  113676. * Gets the B input component
  113677. */
  113678. readonly b: NodeMaterialConnectionPoint;
  113679. /**
  113680. * Gets the RGB input component
  113681. */
  113682. readonly rgb: NodeMaterialConnectionPoint;
  113683. /**
  113684. * Gets the R input component
  113685. */
  113686. readonly a: NodeMaterialConnectionPoint;
  113687. protected _buildBlock(state: NodeMaterialBuildState): this;
  113688. }
  113689. }
  113690. declare module BABYLON {
  113691. /**
  113692. * Block used to create a Color3 out of 3 inputs (one for each component)
  113693. */
  113694. export class RGBMergerBlock extends NodeMaterialBlock {
  113695. /**
  113696. * Create a new RGBMergerBlock
  113697. * @param name defines the block name
  113698. */
  113699. constructor(name: string);
  113700. /**
  113701. * Gets the current class name
  113702. * @returns the class name
  113703. */
  113704. getClassName(): string;
  113705. /**
  113706. * Gets the R component input
  113707. */
  113708. readonly r: NodeMaterialConnectionPoint;
  113709. /**
  113710. * Gets the G component input
  113711. */
  113712. readonly g: NodeMaterialConnectionPoint;
  113713. /**
  113714. * Gets the B component input
  113715. */
  113716. readonly b: NodeMaterialConnectionPoint;
  113717. protected _buildBlock(state: NodeMaterialBuildState): this;
  113718. }
  113719. }
  113720. declare module BABYLON {
  113721. /**
  113722. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  113723. */
  113724. export class RGBASplitterBlock extends NodeMaterialBlock {
  113725. /**
  113726. * Create a new RGBASplitterBlock
  113727. * @param name defines the block name
  113728. */
  113729. constructor(name: string);
  113730. /**
  113731. * Gets the current class name
  113732. * @returns the class name
  113733. */
  113734. getClassName(): string;
  113735. /**
  113736. * Gets the input component
  113737. */
  113738. readonly input: NodeMaterialConnectionPoint;
  113739. protected _buildBlock(state: NodeMaterialBuildState): this;
  113740. }
  113741. }
  113742. declare module BABYLON {
  113743. /**
  113744. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  113745. */
  113746. export class RGBSplitterBlock extends NodeMaterialBlock {
  113747. /**
  113748. * Create a new RGBSplitterBlock
  113749. * @param name defines the block name
  113750. */
  113751. constructor(name: string);
  113752. /**
  113753. * Gets the current class name
  113754. * @returns the class name
  113755. */
  113756. getClassName(): string;
  113757. /**
  113758. * Gets the input component
  113759. */
  113760. readonly input: NodeMaterialConnectionPoint;
  113761. protected _buildBlock(state: NodeMaterialBuildState): this;
  113762. }
  113763. }
  113764. declare module BABYLON {
  113765. /**
  113766. * Block used to read a texture from a sampler
  113767. */
  113768. export class TextureBlock extends NodeMaterialBlock {
  113769. private _defineName;
  113770. /**
  113771. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  113772. */
  113773. autoConnectTextureMatrix: boolean;
  113774. /**
  113775. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  113776. */
  113777. autoSelectUV: boolean;
  113778. /**
  113779. * Create a new TextureBlock
  113780. * @param name defines the block name
  113781. */
  113782. constructor(name: string);
  113783. /**
  113784. * Gets the current class name
  113785. * @returns the class name
  113786. */
  113787. getClassName(): string;
  113788. /**
  113789. * Gets the uv input component
  113790. */
  113791. readonly uv: NodeMaterialConnectionPoint;
  113792. /**
  113793. * Gets the texture information input component
  113794. */
  113795. readonly textureInfo: NodeMaterialConnectionPoint;
  113796. /**
  113797. * Gets the transformed uv input component
  113798. */
  113799. readonly transformedUV: NodeMaterialConnectionPoint;
  113800. /**
  113801. * Gets the texture input component
  113802. */
  113803. readonly texture: NodeMaterialConnectionPoint;
  113804. /**
  113805. * Gets the texture transform input component
  113806. */
  113807. readonly textureTransform: NodeMaterialConnectionPoint;
  113808. autoConfigure(): void;
  113809. initialize(state: NodeMaterialBuildState): void;
  113810. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113811. isReady(): boolean;
  113812. private _injectVertexCode;
  113813. protected _buildBlock(state: NodeMaterialBuildState): this;
  113814. }
  113815. }
  113816. declare module BABYLON {
  113817. /**
  113818. * Block used to add image processing support to fragment shader
  113819. */
  113820. export class ImageProcessingBlock extends NodeMaterialBlock {
  113821. /**
  113822. * Create a new ImageProcessingBlock
  113823. * @param name defines the block name
  113824. */
  113825. constructor(name: string);
  113826. /**
  113827. * Gets the current class name
  113828. * @returns the class name
  113829. */
  113830. getClassName(): string;
  113831. /**
  113832. * Gets the color input component
  113833. */
  113834. readonly color: NodeMaterialConnectionPoint;
  113835. /**
  113836. * Initialize the block and prepare the context for build
  113837. * @param state defines the state that will be used for the build
  113838. */
  113839. initialize(state: NodeMaterialBuildState): void;
  113840. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  113841. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113842. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113843. protected _buildBlock(state: NodeMaterialBuildState): this;
  113844. }
  113845. }
  113846. declare module BABYLON {
  113847. /**
  113848. * Block used to add support for scene fog
  113849. */
  113850. export class FogBlock extends NodeMaterialBlock {
  113851. /**
  113852. * Create a new FogBlock
  113853. * @param name defines the block name
  113854. */
  113855. constructor(name: string);
  113856. /**
  113857. * Gets the current class name
  113858. * @returns the class name
  113859. */
  113860. getClassName(): string;
  113861. /**
  113862. * Gets the world position input component
  113863. */
  113864. readonly worldPosition: NodeMaterialConnectionPoint;
  113865. /**
  113866. * Gets the view input component
  113867. */
  113868. readonly view: NodeMaterialConnectionPoint;
  113869. /**
  113870. * Gets the color input component
  113871. */
  113872. readonly color: NodeMaterialConnectionPoint;
  113873. /**
  113874. * Gets the fog color input component
  113875. */
  113876. readonly fogColor: NodeMaterialConnectionPoint;
  113877. /**
  113878. * Gets the for parameter input component
  113879. */
  113880. readonly fogParameters: NodeMaterialConnectionPoint;
  113881. autoConfigure(): void;
  113882. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113883. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113884. protected _buildBlock(state: NodeMaterialBuildState): this;
  113885. }
  113886. }
  113887. declare module BABYLON {
  113888. /**
  113889. * Block used to multiply 2 vector4
  113890. */
  113891. export class MultiplyBlock extends NodeMaterialBlock {
  113892. /**
  113893. * Creates a new MultiplyBlock
  113894. * @param name defines the block name
  113895. */
  113896. constructor(name: string);
  113897. /**
  113898. * Gets the current class name
  113899. * @returns the class name
  113900. */
  113901. getClassName(): string;
  113902. /**
  113903. * Gets the left operand input component
  113904. */
  113905. readonly left: NodeMaterialConnectionPoint;
  113906. /**
  113907. * Gets the right operand input component
  113908. */
  113909. readonly right: NodeMaterialConnectionPoint;
  113910. protected _buildBlock(state: NodeMaterialBuildState): this;
  113911. }
  113912. }
  113913. declare module BABYLON {
  113914. /**
  113915. * Block used to add 2 vector4
  113916. */
  113917. export class AddBlock extends NodeMaterialBlock {
  113918. /**
  113919. * Creates a new AddBlock
  113920. * @param name defines the block name
  113921. */
  113922. constructor(name: string);
  113923. /**
  113924. * Gets the current class name
  113925. * @returns the class name
  113926. */
  113927. getClassName(): string;
  113928. /**
  113929. * Gets the left operand input component
  113930. */
  113931. readonly left: NodeMaterialConnectionPoint;
  113932. /**
  113933. * Gets the right operand input component
  113934. */
  113935. readonly right: NodeMaterialConnectionPoint;
  113936. protected _buildBlock(state: NodeMaterialBuildState): this;
  113937. }
  113938. }
  113939. declare module BABYLON {
  113940. /**
  113941. * Block used to clamp a float
  113942. */
  113943. export class ClampBlock extends NodeMaterialBlock {
  113944. /** Gets or sets the minimum range */
  113945. minimum: number;
  113946. /** Gets or sets the maximum range */
  113947. maximum: number;
  113948. /**
  113949. * Creates a new ClampBlock
  113950. * @param name defines the block name
  113951. */
  113952. constructor(name: string);
  113953. /**
  113954. * Gets the current class name
  113955. * @returns the class name
  113956. */
  113957. getClassName(): string;
  113958. /**
  113959. * Gets the value input component
  113960. */
  113961. readonly value: NodeMaterialConnectionPoint;
  113962. protected _buildBlock(state: NodeMaterialBuildState): this;
  113963. }
  113964. }
  113965. declare module BABYLON {
  113966. /**
  113967. * Block used to transform a vector2 with a matrix
  113968. */
  113969. export class Vector2TransformBlock extends NodeMaterialBlock {
  113970. /**
  113971. * Defines the value to use to complement Vector2 to transform it to a Vector4
  113972. */
  113973. complementZ: number;
  113974. /**
  113975. * Defines the value to use to complement Vector2 to transform it to a Vector4
  113976. */
  113977. complementW: number;
  113978. /**
  113979. * Creates a new Vector2TransformBlock
  113980. * @param name defines the block name
  113981. */
  113982. constructor(name: string);
  113983. /**
  113984. * Gets the vector input
  113985. */
  113986. readonly vector: NodeMaterialConnectionPoint;
  113987. /**
  113988. * Gets the matrix transform input
  113989. */
  113990. readonly transform: NodeMaterialConnectionPoint;
  113991. /**
  113992. * Gets the current class name
  113993. * @returns the class name
  113994. */
  113995. getClassName(): string;
  113996. protected _buildBlock(state: NodeMaterialBuildState): this;
  113997. }
  113998. }
  113999. declare module BABYLON {
  114000. /**
  114001. * Block used to transform a vector3 with a matrix
  114002. */
  114003. export class Vector3TransformBlock extends NodeMaterialBlock {
  114004. /**
  114005. * Defines the value to use to complement Vector3 to transform it to a Vector4
  114006. */
  114007. complement: number;
  114008. /**
  114009. * Creates a new Vector3TransformBlock
  114010. * @param name defines the block name
  114011. */
  114012. constructor(name: string);
  114013. /**
  114014. * Gets the vector input
  114015. */
  114016. readonly vector: NodeMaterialConnectionPoint;
  114017. /**
  114018. * Gets the matrix transform input
  114019. */
  114020. readonly transform: NodeMaterialConnectionPoint;
  114021. /**
  114022. * Gets the current class name
  114023. * @returns the class name
  114024. */
  114025. getClassName(): string;
  114026. protected _buildBlock(state: NodeMaterialBuildState): this;
  114027. }
  114028. }
  114029. declare module BABYLON {
  114030. /**
  114031. * Block used to multiply two matrices
  114032. */
  114033. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  114034. /**
  114035. * Creates a new MatrixMultiplicationBlock
  114036. * @param name defines the block name
  114037. */
  114038. constructor(name: string);
  114039. /**
  114040. * Gets the left operand
  114041. */
  114042. readonly left: NodeMaterialConnectionPoint;
  114043. /**
  114044. * Gets the right operand
  114045. */
  114046. readonly right: NodeMaterialConnectionPoint;
  114047. /**
  114048. * Gets the current class name
  114049. * @returns the class name
  114050. */
  114051. getClassName(): string;
  114052. protected _buildBlock(state: NodeMaterialBuildState): this;
  114053. }
  114054. }
  114055. declare module BABYLON {
  114056. /**
  114057. * Helper class to push actions to a pool of workers.
  114058. */
  114059. export class WorkerPool implements IDisposable {
  114060. private _workerInfos;
  114061. private _pendingActions;
  114062. /**
  114063. * Constructor
  114064. * @param workers Array of workers to use for actions
  114065. */
  114066. constructor(workers: Array<Worker>);
  114067. /**
  114068. * Terminates all workers and clears any pending actions.
  114069. */
  114070. dispose(): void;
  114071. /**
  114072. * Pushes an action to the worker pool. If all the workers are active, the action will be
  114073. * pended until a worker has completed its action.
  114074. * @param action The action to perform. Call onComplete when the action is complete.
  114075. */
  114076. push(action: (worker: Worker, onComplete: () => void) => void): void;
  114077. private _execute;
  114078. }
  114079. }
  114080. declare module BABYLON {
  114081. /**
  114082. * Configuration for Draco compression
  114083. */
  114084. export interface IDracoCompressionConfiguration {
  114085. /**
  114086. * Configuration for the decoder.
  114087. */
  114088. decoder: {
  114089. /**
  114090. * The url to the WebAssembly module.
  114091. */
  114092. wasmUrl?: string;
  114093. /**
  114094. * The url to the WebAssembly binary.
  114095. */
  114096. wasmBinaryUrl?: string;
  114097. /**
  114098. * The url to the fallback JavaScript module.
  114099. */
  114100. fallbackUrl?: string;
  114101. };
  114102. }
  114103. /**
  114104. * Draco compression (https://google.github.io/draco/)
  114105. *
  114106. * This class wraps the Draco module.
  114107. *
  114108. * **Encoder**
  114109. *
  114110. * The encoder is not currently implemented.
  114111. *
  114112. * **Decoder**
  114113. *
  114114. * 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.
  114115. *
  114116. * To update the configuration, use the following code:
  114117. * ```javascript
  114118. * DracoCompression.Configuration = {
  114119. * decoder: {
  114120. * wasmUrl: "<url to the WebAssembly library>",
  114121. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  114122. * fallbackUrl: "<url to the fallback JavaScript library>",
  114123. * }
  114124. * };
  114125. * ```
  114126. *
  114127. * 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.
  114128. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  114129. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  114130. *
  114131. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  114132. * ```javascript
  114133. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  114134. * ```
  114135. *
  114136. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  114137. */
  114138. export class DracoCompression implements IDisposable {
  114139. private _workerPoolPromise?;
  114140. private _decoderModulePromise?;
  114141. /**
  114142. * The configuration. Defaults to the following urls:
  114143. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  114144. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  114145. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  114146. */
  114147. static Configuration: IDracoCompressionConfiguration;
  114148. /**
  114149. * Returns true if the decoder configuration is available.
  114150. */
  114151. static readonly DecoderAvailable: boolean;
  114152. /**
  114153. * Default number of workers to create when creating the draco compression object.
  114154. */
  114155. static DefaultNumWorkers: number;
  114156. private static GetDefaultNumWorkers;
  114157. private static _Default;
  114158. /**
  114159. * Default instance for the draco compression object.
  114160. */
  114161. static readonly Default: DracoCompression;
  114162. /**
  114163. * Constructor
  114164. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  114165. */
  114166. constructor(numWorkers?: number);
  114167. /**
  114168. * Stop all async operations and release resources.
  114169. */
  114170. dispose(): void;
  114171. /**
  114172. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  114173. * @returns a promise that resolves when ready
  114174. */
  114175. whenReadyAsync(): Promise<void>;
  114176. /**
  114177. * Decode Draco compressed mesh data to vertex data.
  114178. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  114179. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  114180. * @returns A promise that resolves with the decoded vertex data
  114181. */
  114182. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  114183. [kind: string]: number;
  114184. }): Promise<VertexData>;
  114185. }
  114186. }
  114187. declare module BABYLON {
  114188. /**
  114189. * Class for building Constructive Solid Geometry
  114190. */
  114191. export class CSG {
  114192. private polygons;
  114193. /**
  114194. * The world matrix
  114195. */
  114196. matrix: Matrix;
  114197. /**
  114198. * Stores the position
  114199. */
  114200. position: Vector3;
  114201. /**
  114202. * Stores the rotation
  114203. */
  114204. rotation: Vector3;
  114205. /**
  114206. * Stores the rotation quaternion
  114207. */
  114208. rotationQuaternion: Nullable<Quaternion>;
  114209. /**
  114210. * Stores the scaling vector
  114211. */
  114212. scaling: Vector3;
  114213. /**
  114214. * Convert the Mesh to CSG
  114215. * @param mesh The Mesh to convert to CSG
  114216. * @returns A new CSG from the Mesh
  114217. */
  114218. static FromMesh(mesh: Mesh): CSG;
  114219. /**
  114220. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  114221. * @param polygons Polygons used to construct a CSG solid
  114222. */
  114223. private static FromPolygons;
  114224. /**
  114225. * Clones, or makes a deep copy, of the CSG
  114226. * @returns A new CSG
  114227. */
  114228. clone(): CSG;
  114229. /**
  114230. * Unions this CSG with another CSG
  114231. * @param csg The CSG to union against this CSG
  114232. * @returns The unioned CSG
  114233. */
  114234. union(csg: CSG): CSG;
  114235. /**
  114236. * Unions this CSG with another CSG in place
  114237. * @param csg The CSG to union against this CSG
  114238. */
  114239. unionInPlace(csg: CSG): void;
  114240. /**
  114241. * Subtracts this CSG with another CSG
  114242. * @param csg The CSG to subtract against this CSG
  114243. * @returns A new CSG
  114244. */
  114245. subtract(csg: CSG): CSG;
  114246. /**
  114247. * Subtracts this CSG with another CSG in place
  114248. * @param csg The CSG to subtact against this CSG
  114249. */
  114250. subtractInPlace(csg: CSG): void;
  114251. /**
  114252. * Intersect this CSG with another CSG
  114253. * @param csg The CSG to intersect against this CSG
  114254. * @returns A new CSG
  114255. */
  114256. intersect(csg: CSG): CSG;
  114257. /**
  114258. * Intersects this CSG with another CSG in place
  114259. * @param csg The CSG to intersect against this CSG
  114260. */
  114261. intersectInPlace(csg: CSG): void;
  114262. /**
  114263. * Return a new CSG solid with solid and empty space switched. This solid is
  114264. * not modified.
  114265. * @returns A new CSG solid with solid and empty space switched
  114266. */
  114267. inverse(): CSG;
  114268. /**
  114269. * Inverses the CSG in place
  114270. */
  114271. inverseInPlace(): void;
  114272. /**
  114273. * This is used to keep meshes transformations so they can be restored
  114274. * when we build back a Babylon Mesh
  114275. * NB : All CSG operations are performed in world coordinates
  114276. * @param csg The CSG to copy the transform attributes from
  114277. * @returns This CSG
  114278. */
  114279. copyTransformAttributes(csg: CSG): CSG;
  114280. /**
  114281. * Build Raw mesh from CSG
  114282. * Coordinates here are in world space
  114283. * @param name The name of the mesh geometry
  114284. * @param scene The Scene
  114285. * @param keepSubMeshes Specifies if the submeshes should be kept
  114286. * @returns A new Mesh
  114287. */
  114288. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  114289. /**
  114290. * Build Mesh from CSG taking material and transforms into account
  114291. * @param name The name of the Mesh
  114292. * @param material The material of the Mesh
  114293. * @param scene The Scene
  114294. * @param keepSubMeshes Specifies if submeshes should be kept
  114295. * @returns The new Mesh
  114296. */
  114297. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  114298. }
  114299. }
  114300. declare module BABYLON {
  114301. /**
  114302. * Class used to create a trail following a mesh
  114303. */
  114304. export class TrailMesh extends Mesh {
  114305. private _generator;
  114306. private _autoStart;
  114307. private _running;
  114308. private _diameter;
  114309. private _length;
  114310. private _sectionPolygonPointsCount;
  114311. private _sectionVectors;
  114312. private _sectionNormalVectors;
  114313. private _beforeRenderObserver;
  114314. /**
  114315. * @constructor
  114316. * @param name The value used by scene.getMeshByName() to do a lookup.
  114317. * @param generator The mesh to generate a trail.
  114318. * @param scene The scene to add this mesh to.
  114319. * @param diameter Diameter of trailing mesh. Default is 1.
  114320. * @param length Length of trailing mesh. Default is 60.
  114321. * @param autoStart Automatically start trailing mesh. Default true.
  114322. */
  114323. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  114324. /**
  114325. * "TrailMesh"
  114326. * @returns "TrailMesh"
  114327. */
  114328. getClassName(): string;
  114329. private _createMesh;
  114330. /**
  114331. * Start trailing mesh.
  114332. */
  114333. start(): void;
  114334. /**
  114335. * Stop trailing mesh.
  114336. */
  114337. stop(): void;
  114338. /**
  114339. * Update trailing mesh geometry.
  114340. */
  114341. update(): void;
  114342. /**
  114343. * Returns a new TrailMesh object.
  114344. * @param name is a string, the name given to the new mesh
  114345. * @param newGenerator use new generator object for cloned trail mesh
  114346. * @returns a new mesh
  114347. */
  114348. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  114349. /**
  114350. * Serializes this trail mesh
  114351. * @param serializationObject object to write serialization to
  114352. */
  114353. serialize(serializationObject: any): void;
  114354. /**
  114355. * Parses a serialized trail mesh
  114356. * @param parsedMesh the serialized mesh
  114357. * @param scene the scene to create the trail mesh in
  114358. * @returns the created trail mesh
  114359. */
  114360. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  114361. }
  114362. }
  114363. declare module BABYLON {
  114364. /**
  114365. * Class containing static functions to help procedurally build meshes
  114366. */
  114367. export class TiledBoxBuilder {
  114368. /**
  114369. * Creates a box mesh
  114370. * faceTiles sets the pattern, tile size and number of tiles for a face * * 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)
  114371. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114375. * @param name defines the name of the mesh
  114376. * @param options defines the options used to create the mesh
  114377. * @param scene defines the hosting scene
  114378. * @returns the box mesh
  114379. */
  114380. static CreateTiledBox(name: string, options: {
  114381. pattern?: number;
  114382. width?: number;
  114383. height?: number;
  114384. depth?: number;
  114385. tileSize?: number;
  114386. tileWidth?: number;
  114387. tileHeight?: number;
  114388. alignHorizontal?: number;
  114389. alignVertical?: number;
  114390. faceUV?: Vector4[];
  114391. faceColors?: Color4[];
  114392. sideOrientation?: number;
  114393. updatable?: boolean;
  114394. }, scene?: Nullable<Scene>): Mesh;
  114395. }
  114396. }
  114397. declare module BABYLON {
  114398. /**
  114399. * Class containing static functions to help procedurally build meshes
  114400. */
  114401. export class TorusKnotBuilder {
  114402. /**
  114403. * Creates a torus knot mesh
  114404. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  114405. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  114406. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  114407. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  114408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114411. * @param name defines the name of the mesh
  114412. * @param options defines the options used to create the mesh
  114413. * @param scene defines the hosting scene
  114414. * @returns the torus knot mesh
  114415. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  114416. */
  114417. static CreateTorusKnot(name: string, options: {
  114418. radius?: number;
  114419. tube?: number;
  114420. radialSegments?: number;
  114421. tubularSegments?: number;
  114422. p?: number;
  114423. q?: number;
  114424. updatable?: boolean;
  114425. sideOrientation?: number;
  114426. frontUVs?: Vector4;
  114427. backUVs?: Vector4;
  114428. }, scene: any): Mesh;
  114429. }
  114430. }
  114431. declare module BABYLON {
  114432. /**
  114433. * Polygon
  114434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114435. */
  114436. export class Polygon {
  114437. /**
  114438. * Creates a rectangle
  114439. * @param xmin bottom X coord
  114440. * @param ymin bottom Y coord
  114441. * @param xmax top X coord
  114442. * @param ymax top Y coord
  114443. * @returns points that make the resulting rectation
  114444. */
  114445. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  114446. /**
  114447. * Creates a circle
  114448. * @param radius radius of circle
  114449. * @param cx scale in x
  114450. * @param cy scale in y
  114451. * @param numberOfSides number of sides that make up the circle
  114452. * @returns points that make the resulting circle
  114453. */
  114454. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  114455. /**
  114456. * Creates a polygon from input string
  114457. * @param input Input polygon data
  114458. * @returns the parsed points
  114459. */
  114460. static Parse(input: string): Vector2[];
  114461. /**
  114462. * Starts building a polygon from x and y coordinates
  114463. * @param x x coordinate
  114464. * @param y y coordinate
  114465. * @returns the started path2
  114466. */
  114467. static StartingAt(x: number, y: number): Path2;
  114468. }
  114469. /**
  114470. * Builds a polygon
  114471. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  114472. */
  114473. export class PolygonMeshBuilder {
  114474. private _points;
  114475. private _outlinepoints;
  114476. private _holes;
  114477. private _name;
  114478. private _scene;
  114479. private _epoints;
  114480. private _eholes;
  114481. private _addToepoint;
  114482. /**
  114483. * Babylon reference to the earcut plugin.
  114484. */
  114485. bjsEarcut: any;
  114486. /**
  114487. * Creates a PolygonMeshBuilder
  114488. * @param name name of the builder
  114489. * @param contours Path of the polygon
  114490. * @param scene scene to add to when creating the mesh
  114491. * @param earcutInjection can be used to inject your own earcut reference
  114492. */
  114493. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  114494. /**
  114495. * Adds a whole within the polygon
  114496. * @param hole Array of points defining the hole
  114497. * @returns this
  114498. */
  114499. addHole(hole: Vector2[]): PolygonMeshBuilder;
  114500. /**
  114501. * Creates the polygon
  114502. * @param updatable If the mesh should be updatable
  114503. * @param depth The depth of the mesh created
  114504. * @returns the created mesh
  114505. */
  114506. build(updatable?: boolean, depth?: number): Mesh;
  114507. /**
  114508. * Creates the polygon
  114509. * @param depth The depth of the mesh created
  114510. * @returns the created VertexData
  114511. */
  114512. buildVertexData(depth?: number): VertexData;
  114513. /**
  114514. * Adds a side to the polygon
  114515. * @param positions points that make the polygon
  114516. * @param normals normals of the polygon
  114517. * @param uvs uvs of the polygon
  114518. * @param indices indices of the polygon
  114519. * @param bounds bounds of the polygon
  114520. * @param points points of the polygon
  114521. * @param depth depth of the polygon
  114522. * @param flip flip of the polygon
  114523. */
  114524. private addSide;
  114525. }
  114526. }
  114527. declare module BABYLON {
  114528. /**
  114529. * Class containing static functions to help procedurally build meshes
  114530. */
  114531. export class PolygonBuilder {
  114532. /**
  114533. * Creates a polygon mesh
  114534. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  114535. * * 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
  114536. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  114539. * * Remember you can only change the shape positions, not their number when updating a polygon
  114540. * @param name defines the name of the mesh
  114541. * @param options defines the options used to create the mesh
  114542. * @param scene defines the hosting scene
  114543. * @param earcutInjection can be used to inject your own earcut reference
  114544. * @returns the polygon mesh
  114545. */
  114546. static CreatePolygon(name: string, options: {
  114547. shape: Vector3[];
  114548. holes?: Vector3[][];
  114549. depth?: number;
  114550. faceUV?: Vector4[];
  114551. faceColors?: Color4[];
  114552. updatable?: boolean;
  114553. sideOrientation?: number;
  114554. frontUVs?: Vector4;
  114555. backUVs?: Vector4;
  114556. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  114557. /**
  114558. * Creates an extruded polygon mesh, with depth in the Y direction.
  114559. * * 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)
  114560. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114561. * @param name defines the name of the mesh
  114562. * @param options defines the options used to create the mesh
  114563. * @param scene defines the hosting scene
  114564. * @param earcutInjection can be used to inject your own earcut reference
  114565. * @returns the polygon mesh
  114566. */
  114567. static ExtrudePolygon(name: string, options: {
  114568. shape: Vector3[];
  114569. holes?: Vector3[][];
  114570. depth?: number;
  114571. faceUV?: Vector4[];
  114572. faceColors?: Color4[];
  114573. updatable?: boolean;
  114574. sideOrientation?: number;
  114575. frontUVs?: Vector4;
  114576. backUVs?: Vector4;
  114577. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  114578. }
  114579. }
  114580. declare module BABYLON {
  114581. /**
  114582. * Class containing static functions to help procedurally build meshes
  114583. */
  114584. export class LatheBuilder {
  114585. /**
  114586. * Creates lathe mesh.
  114587. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  114588. * * 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
  114589. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  114590. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  114591. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  114592. * * 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
  114593. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  114594. * * 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
  114595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114597. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114599. * @param name defines the name of the mesh
  114600. * @param options defines the options used to create the mesh
  114601. * @param scene defines the hosting scene
  114602. * @returns the lathe mesh
  114603. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  114604. */
  114605. static CreateLathe(name: string, options: {
  114606. shape: Vector3[];
  114607. radius?: number;
  114608. tessellation?: number;
  114609. clip?: number;
  114610. arc?: number;
  114611. closed?: boolean;
  114612. updatable?: boolean;
  114613. sideOrientation?: number;
  114614. frontUVs?: Vector4;
  114615. backUVs?: Vector4;
  114616. cap?: number;
  114617. invertUV?: boolean;
  114618. }, scene?: Nullable<Scene>): Mesh;
  114619. }
  114620. }
  114621. declare module BABYLON {
  114622. /**
  114623. * Class containing static functions to help procedurally build meshes
  114624. */
  114625. export class TiledPlaneBuilder {
  114626. /**
  114627. * Creates a tiled plane mesh
  114628. * * The parameter `pattern` will, depending on value, do nothing or
  114629. * * * flip (reflect about central vertical) alternate tiles across and up
  114630. * * * flip every tile on alternate rows
  114631. * * * rotate (180 degs) alternate tiles across and up
  114632. * * * rotate every tile on alternate rows
  114633. * * * flip and rotate alternate tiles across and up
  114634. * * * flip and rotate every tile on alternate rows
  114635. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  114636. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  114637. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114638. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114639. * * 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)
  114640. * * 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)
  114641. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  114642. * @param name defines the name of the mesh
  114643. * @param options defines the options used to create the mesh
  114644. * @param scene defines the hosting scene
  114645. * @returns the box mesh
  114646. */
  114647. static CreateTiledPlane(name: string, options: {
  114648. pattern?: number;
  114649. tileSize?: number;
  114650. tileWidth?: number;
  114651. tileHeight?: number;
  114652. size?: number;
  114653. width?: number;
  114654. height?: number;
  114655. alignHorizontal?: number;
  114656. alignVertical?: number;
  114657. sideOrientation?: number;
  114658. frontUVs?: Vector4;
  114659. backUVs?: Vector4;
  114660. updatable?: boolean;
  114661. }, scene?: Nullable<Scene>): Mesh;
  114662. }
  114663. }
  114664. declare module BABYLON {
  114665. /**
  114666. * Class containing static functions to help procedurally build meshes
  114667. */
  114668. export class TubeBuilder {
  114669. /**
  114670. * Creates a tube mesh.
  114671. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  114672. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  114673. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  114674. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  114675. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  114676. * * 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)
  114677. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  114678. * * 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
  114679. * * 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
  114680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114682. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114684. * @param name defines the name of the mesh
  114685. * @param options defines the options used to create the mesh
  114686. * @param scene defines the hosting scene
  114687. * @returns the tube mesh
  114688. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114689. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  114690. */
  114691. static CreateTube(name: string, options: {
  114692. path: Vector3[];
  114693. radius?: number;
  114694. tessellation?: number;
  114695. radiusFunction?: {
  114696. (i: number, distance: number): number;
  114697. };
  114698. cap?: number;
  114699. arc?: number;
  114700. updatable?: boolean;
  114701. sideOrientation?: number;
  114702. frontUVs?: Vector4;
  114703. backUVs?: Vector4;
  114704. instance?: Mesh;
  114705. invertUV?: boolean;
  114706. }, scene?: Nullable<Scene>): Mesh;
  114707. }
  114708. }
  114709. declare module BABYLON {
  114710. /**
  114711. * Class containing static functions to help procedurally build meshes
  114712. */
  114713. export class IcoSphereBuilder {
  114714. /**
  114715. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114716. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114717. * * 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`)
  114718. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114719. * * 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
  114720. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114721. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114723. * @param name defines the name of the mesh
  114724. * @param options defines the options used to create the mesh
  114725. * @param scene defines the hosting scene
  114726. * @returns the icosahedron mesh
  114727. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114728. */
  114729. static CreateIcoSphere(name: string, options: {
  114730. radius?: number;
  114731. radiusX?: number;
  114732. radiusY?: number;
  114733. radiusZ?: number;
  114734. flat?: boolean;
  114735. subdivisions?: number;
  114736. sideOrientation?: number;
  114737. frontUVs?: Vector4;
  114738. backUVs?: Vector4;
  114739. updatable?: boolean;
  114740. }, scene?: Nullable<Scene>): Mesh;
  114741. }
  114742. }
  114743. declare module BABYLON {
  114744. /**
  114745. * Class containing static functions to help procedurally build meshes
  114746. */
  114747. export class DecalBuilder {
  114748. /**
  114749. * Creates a decal mesh.
  114750. * 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
  114751. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  114752. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  114753. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  114754. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  114755. * @param name defines the name of the mesh
  114756. * @param sourceMesh defines the mesh where the decal must be applied
  114757. * @param options defines the options used to create the mesh
  114758. * @param scene defines the hosting scene
  114759. * @returns the decal mesh
  114760. * @see https://doc.babylonjs.com/how_to/decals
  114761. */
  114762. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  114763. position?: Vector3;
  114764. normal?: Vector3;
  114765. size?: Vector3;
  114766. angle?: number;
  114767. }): Mesh;
  114768. }
  114769. }
  114770. declare module BABYLON {
  114771. /**
  114772. * Class containing static functions to help procedurally build meshes
  114773. */
  114774. export class MeshBuilder {
  114775. /**
  114776. * Creates a box mesh
  114777. * * The parameter `size` sets the size (float) of each box side (default 1)
  114778. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  114779. * * 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)
  114780. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114782. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114784. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  114785. * @param name defines the name of the mesh
  114786. * @param options defines the options used to create the mesh
  114787. * @param scene defines the hosting scene
  114788. * @returns the box mesh
  114789. */
  114790. static CreateBox(name: string, options: {
  114791. size?: number;
  114792. width?: number;
  114793. height?: number;
  114794. depth?: number;
  114795. faceUV?: Vector4[];
  114796. faceColors?: Color4[];
  114797. sideOrientation?: number;
  114798. frontUVs?: Vector4;
  114799. backUVs?: Vector4;
  114800. updatable?: boolean;
  114801. }, scene?: Nullable<Scene>): Mesh;
  114802. /**
  114803. * Creates a tiled box mesh
  114804. * * faceTiles sets the pattern, tile size and number of tiles for a face
  114805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114806. * @param name defines the name of the mesh
  114807. * @param options defines the options used to create the mesh
  114808. * @param scene defines the hosting scene
  114809. * @returns the tiled box mesh
  114810. */
  114811. static CreateTiledBox(name: string, options: {
  114812. pattern?: number;
  114813. size?: number;
  114814. width?: number;
  114815. height?: number;
  114816. depth: number;
  114817. tileSize?: number;
  114818. tileWidth?: number;
  114819. tileHeight?: number;
  114820. faceUV?: Vector4[];
  114821. faceColors?: Color4[];
  114822. alignHorizontal?: number;
  114823. alignVertical?: number;
  114824. sideOrientation?: number;
  114825. updatable?: boolean;
  114826. }, scene?: Nullable<Scene>): Mesh;
  114827. /**
  114828. * Creates a sphere mesh
  114829. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  114830. * * 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`)
  114831. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  114832. * * 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
  114833. * * 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)
  114834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114835. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114837. * @param name defines the name of the mesh
  114838. * @param options defines the options used to create the mesh
  114839. * @param scene defines the hosting scene
  114840. * @returns the sphere mesh
  114841. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  114842. */
  114843. static CreateSphere(name: string, options: {
  114844. segments?: number;
  114845. diameter?: number;
  114846. diameterX?: number;
  114847. diameterY?: number;
  114848. diameterZ?: number;
  114849. arc?: number;
  114850. slice?: number;
  114851. sideOrientation?: number;
  114852. frontUVs?: Vector4;
  114853. backUVs?: Vector4;
  114854. updatable?: boolean;
  114855. }, scene?: Nullable<Scene>): Mesh;
  114856. /**
  114857. * Creates a plane polygonal mesh. By default, this is a disc
  114858. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  114859. * * 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
  114860. * * 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
  114861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114864. * @param name defines the name of the mesh
  114865. * @param options defines the options used to create the mesh
  114866. * @param scene defines the hosting scene
  114867. * @returns the plane polygonal mesh
  114868. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  114869. */
  114870. static CreateDisc(name: string, options: {
  114871. radius?: number;
  114872. tessellation?: number;
  114873. arc?: number;
  114874. updatable?: boolean;
  114875. sideOrientation?: number;
  114876. frontUVs?: Vector4;
  114877. backUVs?: Vector4;
  114878. }, scene?: Nullable<Scene>): Mesh;
  114879. /**
  114880. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114881. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114882. * * 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`)
  114883. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114884. * * 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
  114885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114888. * @param name defines the name of the mesh
  114889. * @param options defines the options used to create the mesh
  114890. * @param scene defines the hosting scene
  114891. * @returns the icosahedron mesh
  114892. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114893. */
  114894. static CreateIcoSphere(name: string, options: {
  114895. radius?: number;
  114896. radiusX?: number;
  114897. radiusY?: number;
  114898. radiusZ?: number;
  114899. flat?: boolean;
  114900. subdivisions?: number;
  114901. sideOrientation?: number;
  114902. frontUVs?: Vector4;
  114903. backUVs?: Vector4;
  114904. updatable?: boolean;
  114905. }, scene?: Nullable<Scene>): Mesh;
  114906. /**
  114907. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  114908. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  114909. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  114910. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  114911. * * 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
  114912. * * 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
  114913. * * 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
  114914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114916. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114917. * * 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
  114918. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  114919. * * 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
  114920. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  114921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114922. * @param name defines the name of the mesh
  114923. * @param options defines the options used to create the mesh
  114924. * @param scene defines the hosting scene
  114925. * @returns the ribbon mesh
  114926. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  114927. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114928. */
  114929. static CreateRibbon(name: string, options: {
  114930. pathArray: Vector3[][];
  114931. closeArray?: boolean;
  114932. closePath?: boolean;
  114933. offset?: number;
  114934. updatable?: boolean;
  114935. sideOrientation?: number;
  114936. frontUVs?: Vector4;
  114937. backUVs?: Vector4;
  114938. instance?: Mesh;
  114939. invertUV?: boolean;
  114940. uvs?: Vector2[];
  114941. colors?: Color4[];
  114942. }, scene?: Nullable<Scene>): Mesh;
  114943. /**
  114944. * Creates a cylinder or a cone mesh
  114945. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  114946. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  114947. * * 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.
  114948. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  114949. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  114950. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  114951. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  114952. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  114953. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  114954. * * 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).
  114955. * * 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
  114956. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  114957. * * 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
  114958. * * 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.
  114959. * * If `enclose` is false, a ring surface is one element.
  114960. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  114961. * * 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
  114962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114963. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114965. * @param name defines the name of the mesh
  114966. * @param options defines the options used to create the mesh
  114967. * @param scene defines the hosting scene
  114968. * @returns the cylinder mesh
  114969. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  114970. */
  114971. static CreateCylinder(name: string, options: {
  114972. height?: number;
  114973. diameterTop?: number;
  114974. diameterBottom?: number;
  114975. diameter?: number;
  114976. tessellation?: number;
  114977. subdivisions?: number;
  114978. arc?: number;
  114979. faceColors?: Color4[];
  114980. faceUV?: Vector4[];
  114981. updatable?: boolean;
  114982. hasRings?: boolean;
  114983. enclose?: boolean;
  114984. cap?: number;
  114985. sideOrientation?: number;
  114986. frontUVs?: Vector4;
  114987. backUVs?: Vector4;
  114988. }, scene?: Nullable<Scene>): Mesh;
  114989. /**
  114990. * Creates a torus mesh
  114991. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  114992. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  114993. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  114994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114995. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114997. * @param name defines the name of the mesh
  114998. * @param options defines the options used to create the mesh
  114999. * @param scene defines the hosting scene
  115000. * @returns the torus mesh
  115001. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115002. */
  115003. static CreateTorus(name: string, options: {
  115004. diameter?: number;
  115005. thickness?: number;
  115006. tessellation?: number;
  115007. updatable?: boolean;
  115008. sideOrientation?: number;
  115009. frontUVs?: Vector4;
  115010. backUVs?: Vector4;
  115011. }, scene?: Nullable<Scene>): Mesh;
  115012. /**
  115013. * Creates a torus knot mesh
  115014. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115015. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115016. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115017. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115021. * @param name defines the name of the mesh
  115022. * @param options defines the options used to create the mesh
  115023. * @param scene defines the hosting scene
  115024. * @returns the torus knot mesh
  115025. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115026. */
  115027. static CreateTorusKnot(name: string, options: {
  115028. radius?: number;
  115029. tube?: number;
  115030. radialSegments?: number;
  115031. tubularSegments?: number;
  115032. p?: number;
  115033. q?: number;
  115034. updatable?: boolean;
  115035. sideOrientation?: number;
  115036. frontUVs?: Vector4;
  115037. backUVs?: Vector4;
  115038. }, scene?: Nullable<Scene>): Mesh;
  115039. /**
  115040. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  115041. * * 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
  115042. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  115043. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  115044. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  115045. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  115046. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  115047. * * 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
  115048. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  115049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115050. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  115051. * @param name defines the name of the new line system
  115052. * @param options defines the options used to create the line system
  115053. * @param scene defines the hosting scene
  115054. * @returns a new line system mesh
  115055. */
  115056. static CreateLineSystem(name: string, options: {
  115057. lines: Vector3[][];
  115058. updatable?: boolean;
  115059. instance?: Nullable<LinesMesh>;
  115060. colors?: Nullable<Color4[][]>;
  115061. useVertexAlpha?: boolean;
  115062. }, scene: Nullable<Scene>): LinesMesh;
  115063. /**
  115064. * Creates a line mesh
  115065. * 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
  115066. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115067. * * The parameter `points` is an array successive Vector3
  115068. * * 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
  115069. * * The optional parameter `colors` is an array of successive Color4, one per line point
  115070. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  115071. * * When updating an instance, remember that only point positions can change, not the number of points
  115072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115073. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  115074. * @param name defines the name of the new line system
  115075. * @param options defines the options used to create the line system
  115076. * @param scene defines the hosting scene
  115077. * @returns a new line mesh
  115078. */
  115079. static CreateLines(name: string, options: {
  115080. points: Vector3[];
  115081. updatable?: boolean;
  115082. instance?: Nullable<LinesMesh>;
  115083. colors?: Color4[];
  115084. useVertexAlpha?: boolean;
  115085. }, scene?: Nullable<Scene>): LinesMesh;
  115086. /**
  115087. * Creates a dashed line mesh
  115088. * * 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
  115089. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115090. * * The parameter `points` is an array successive Vector3
  115091. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  115092. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  115093. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  115094. * * 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
  115095. * * When updating an instance, remember that only point positions can change, not the number of points
  115096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115097. * @param name defines the name of the mesh
  115098. * @param options defines the options used to create the mesh
  115099. * @param scene defines the hosting scene
  115100. * @returns the dashed line mesh
  115101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  115102. */
  115103. static CreateDashedLines(name: string, options: {
  115104. points: Vector3[];
  115105. dashSize?: number;
  115106. gapSize?: number;
  115107. dashNb?: number;
  115108. updatable?: boolean;
  115109. instance?: LinesMesh;
  115110. }, scene?: Nullable<Scene>): LinesMesh;
  115111. /**
  115112. * 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.
  115113. * * 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.
  115114. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115115. * * 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.
  115116. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  115117. * * 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
  115118. * * 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
  115119. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  115120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115121. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115122. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  115123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115124. * @param name defines the name of the mesh
  115125. * @param options defines the options used to create the mesh
  115126. * @param scene defines the hosting scene
  115127. * @returns the extruded shape mesh
  115128. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115130. */
  115131. static ExtrudeShape(name: string, options: {
  115132. shape: Vector3[];
  115133. path: Vector3[];
  115134. scale?: number;
  115135. rotation?: number;
  115136. cap?: number;
  115137. updatable?: boolean;
  115138. sideOrientation?: number;
  115139. frontUVs?: Vector4;
  115140. backUVs?: Vector4;
  115141. instance?: Mesh;
  115142. invertUV?: boolean;
  115143. }, scene?: Nullable<Scene>): Mesh;
  115144. /**
  115145. * Creates an custom extruded shape mesh.
  115146. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  115147. * * 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.
  115148. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115149. * * 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
  115150. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  115151. * * 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
  115152. * * It must returns a float value that will be the scale value applied to the shape on each path point
  115153. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  115154. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  115155. * * 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
  115156. * * 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
  115157. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  115158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115159. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115160. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115162. * @param name defines the name of the mesh
  115163. * @param options defines the options used to create the mesh
  115164. * @param scene defines the hosting scene
  115165. * @returns the custom extruded shape mesh
  115166. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  115167. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115168. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115169. */
  115170. static ExtrudeShapeCustom(name: string, options: {
  115171. shape: Vector3[];
  115172. path: Vector3[];
  115173. scaleFunction?: any;
  115174. rotationFunction?: any;
  115175. ribbonCloseArray?: boolean;
  115176. ribbonClosePath?: boolean;
  115177. cap?: number;
  115178. updatable?: boolean;
  115179. sideOrientation?: number;
  115180. frontUVs?: Vector4;
  115181. backUVs?: Vector4;
  115182. instance?: Mesh;
  115183. invertUV?: boolean;
  115184. }, scene?: Nullable<Scene>): Mesh;
  115185. /**
  115186. * Creates lathe mesh.
  115187. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115188. * * 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
  115189. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115190. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115191. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115192. * * 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
  115193. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115194. * * 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
  115195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115197. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115199. * @param name defines the name of the mesh
  115200. * @param options defines the options used to create the mesh
  115201. * @param scene defines the hosting scene
  115202. * @returns the lathe mesh
  115203. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115204. */
  115205. static CreateLathe(name: string, options: {
  115206. shape: Vector3[];
  115207. radius?: number;
  115208. tessellation?: number;
  115209. clip?: number;
  115210. arc?: number;
  115211. closed?: boolean;
  115212. updatable?: boolean;
  115213. sideOrientation?: number;
  115214. frontUVs?: Vector4;
  115215. backUVs?: Vector4;
  115216. cap?: number;
  115217. invertUV?: boolean;
  115218. }, scene?: Nullable<Scene>): Mesh;
  115219. /**
  115220. * Creates a tiled plane mesh
  115221. * * You can set a limited pattern arrangement with the tiles
  115222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115223. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115225. * @param name defines the name of the mesh
  115226. * @param options defines the options used to create the mesh
  115227. * @param scene defines the hosting scene
  115228. * @returns the plane mesh
  115229. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115230. */
  115231. static CreateTiledPlane(name: string, options: {
  115232. pattern?: number;
  115233. tileSize?: number;
  115234. tileWidth?: number;
  115235. tileHeight?: number;
  115236. size?: number;
  115237. width?: number;
  115238. height?: number;
  115239. alignHorizontal?: number;
  115240. alignVertical?: number;
  115241. sideOrientation?: number;
  115242. frontUVs?: Vector4;
  115243. backUVs?: Vector4;
  115244. updatable?: boolean;
  115245. }, scene?: Nullable<Scene>): Mesh;
  115246. /**
  115247. * Creates a plane mesh
  115248. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  115249. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  115250. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  115251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115252. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115254. * @param name defines the name of the mesh
  115255. * @param options defines the options used to create the mesh
  115256. * @param scene defines the hosting scene
  115257. * @returns the plane mesh
  115258. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115259. */
  115260. static CreatePlane(name: string, options: {
  115261. size?: number;
  115262. width?: number;
  115263. height?: number;
  115264. sideOrientation?: number;
  115265. frontUVs?: Vector4;
  115266. backUVs?: Vector4;
  115267. updatable?: boolean;
  115268. sourcePlane?: Plane;
  115269. }, scene?: Nullable<Scene>): Mesh;
  115270. /**
  115271. * Creates a ground mesh
  115272. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115273. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115275. * @param name defines the name of the mesh
  115276. * @param options defines the options used to create the mesh
  115277. * @param scene defines the hosting scene
  115278. * @returns the ground mesh
  115279. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115280. */
  115281. static CreateGround(name: string, options: {
  115282. width?: number;
  115283. height?: number;
  115284. subdivisions?: number;
  115285. subdivisionsX?: number;
  115286. subdivisionsY?: number;
  115287. updatable?: boolean;
  115288. }, scene?: Nullable<Scene>): Mesh;
  115289. /**
  115290. * Creates a tiled ground mesh
  115291. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115292. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115293. * * 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
  115294. * * 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
  115295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115296. * @param name defines the name of the mesh
  115297. * @param options defines the options used to create the mesh
  115298. * @param scene defines the hosting scene
  115299. * @returns the tiled ground mesh
  115300. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115301. */
  115302. static CreateTiledGround(name: string, options: {
  115303. xmin: number;
  115304. zmin: number;
  115305. xmax: number;
  115306. zmax: number;
  115307. subdivisions?: {
  115308. w: number;
  115309. h: number;
  115310. };
  115311. precision?: {
  115312. w: number;
  115313. h: number;
  115314. };
  115315. updatable?: boolean;
  115316. }, scene?: Nullable<Scene>): Mesh;
  115317. /**
  115318. * Creates a ground mesh from a height map
  115319. * * The parameter `url` sets the URL of the height map image resource.
  115320. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115321. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115322. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115323. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115324. * * 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.
  115325. * * 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).
  115326. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115328. * @param name defines the name of the mesh
  115329. * @param url defines the url to the height map
  115330. * @param options defines the options used to create the mesh
  115331. * @param scene defines the hosting scene
  115332. * @returns the ground mesh
  115333. * @see https://doc.babylonjs.com/babylon101/height_map
  115334. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115335. */
  115336. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115337. width?: number;
  115338. height?: number;
  115339. subdivisions?: number;
  115340. minHeight?: number;
  115341. maxHeight?: number;
  115342. colorFilter?: Color3;
  115343. alphaFilter?: number;
  115344. updatable?: boolean;
  115345. onReady?: (mesh: GroundMesh) => void;
  115346. }, scene?: Nullable<Scene>): GroundMesh;
  115347. /**
  115348. * Creates a polygon mesh
  115349. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115350. * * 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
  115351. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115353. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  115354. * * Remember you can only change the shape positions, not their number when updating a polygon
  115355. * @param name defines the name of the mesh
  115356. * @param options defines the options used to create the mesh
  115357. * @param scene defines the hosting scene
  115358. * @param earcutInjection can be used to inject your own earcut reference
  115359. * @returns the polygon mesh
  115360. */
  115361. static CreatePolygon(name: string, options: {
  115362. shape: Vector3[];
  115363. holes?: Vector3[][];
  115364. depth?: number;
  115365. faceUV?: Vector4[];
  115366. faceColors?: Color4[];
  115367. updatable?: boolean;
  115368. sideOrientation?: number;
  115369. frontUVs?: Vector4;
  115370. backUVs?: Vector4;
  115371. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115372. /**
  115373. * Creates an extruded polygon mesh, with depth in the Y direction.
  115374. * * 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)
  115375. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115376. * @param name defines the name of the mesh
  115377. * @param options defines the options used to create the mesh
  115378. * @param scene defines the hosting scene
  115379. * @param earcutInjection can be used to inject your own earcut reference
  115380. * @returns the polygon mesh
  115381. */
  115382. static ExtrudePolygon(name: string, options: {
  115383. shape: Vector3[];
  115384. holes?: Vector3[][];
  115385. depth?: number;
  115386. faceUV?: Vector4[];
  115387. faceColors?: Color4[];
  115388. updatable?: boolean;
  115389. sideOrientation?: number;
  115390. frontUVs?: Vector4;
  115391. backUVs?: Vector4;
  115392. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115393. /**
  115394. * Creates a tube mesh.
  115395. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115396. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115397. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115398. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115399. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115400. * * 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)
  115401. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115402. * * 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
  115403. * * 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
  115404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115406. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115408. * @param name defines the name of the mesh
  115409. * @param options defines the options used to create the mesh
  115410. * @param scene defines the hosting scene
  115411. * @returns the tube mesh
  115412. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115413. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115414. */
  115415. static CreateTube(name: string, options: {
  115416. path: Vector3[];
  115417. radius?: number;
  115418. tessellation?: number;
  115419. radiusFunction?: {
  115420. (i: number, distance: number): number;
  115421. };
  115422. cap?: number;
  115423. arc?: number;
  115424. updatable?: boolean;
  115425. sideOrientation?: number;
  115426. frontUVs?: Vector4;
  115427. backUVs?: Vector4;
  115428. instance?: Mesh;
  115429. invertUV?: boolean;
  115430. }, scene?: Nullable<Scene>): Mesh;
  115431. /**
  115432. * Creates a polyhedron mesh
  115433. * * 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
  115434. * * The parameter `size` (positive float, default 1) sets the polygon size
  115435. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  115436. * * 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`
  115437. * * 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
  115438. * * 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)`)
  115439. * * 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
  115440. * * 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
  115441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115444. * @param name defines the name of the mesh
  115445. * @param options defines the options used to create the mesh
  115446. * @param scene defines the hosting scene
  115447. * @returns the polyhedron mesh
  115448. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  115449. */
  115450. static CreatePolyhedron(name: string, options: {
  115451. type?: number;
  115452. size?: number;
  115453. sizeX?: number;
  115454. sizeY?: number;
  115455. sizeZ?: number;
  115456. custom?: any;
  115457. faceUV?: Vector4[];
  115458. faceColors?: Color4[];
  115459. flat?: boolean;
  115460. updatable?: boolean;
  115461. sideOrientation?: number;
  115462. frontUVs?: Vector4;
  115463. backUVs?: Vector4;
  115464. }, scene?: Nullable<Scene>): Mesh;
  115465. /**
  115466. * Creates a decal mesh.
  115467. * 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
  115468. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115469. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115470. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115471. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115472. * @param name defines the name of the mesh
  115473. * @param sourceMesh defines the mesh where the decal must be applied
  115474. * @param options defines the options used to create the mesh
  115475. * @param scene defines the hosting scene
  115476. * @returns the decal mesh
  115477. * @see https://doc.babylonjs.com/how_to/decals
  115478. */
  115479. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115480. position?: Vector3;
  115481. normal?: Vector3;
  115482. size?: Vector3;
  115483. angle?: number;
  115484. }): Mesh;
  115485. }
  115486. }
  115487. declare module BABYLON {
  115488. /**
  115489. * A simplifier interface for future simplification implementations
  115490. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115491. */
  115492. export interface ISimplifier {
  115493. /**
  115494. * Simplification of a given mesh according to the given settings.
  115495. * Since this requires computation, it is assumed that the function runs async.
  115496. * @param settings The settings of the simplification, including quality and distance
  115497. * @param successCallback A callback that will be called after the mesh was simplified.
  115498. * @param errorCallback in case of an error, this callback will be called. optional.
  115499. */
  115500. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  115501. }
  115502. /**
  115503. * Expected simplification settings.
  115504. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  115505. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115506. */
  115507. export interface ISimplificationSettings {
  115508. /**
  115509. * Gets or sets the expected quality
  115510. */
  115511. quality: number;
  115512. /**
  115513. * Gets or sets the distance when this optimized version should be used
  115514. */
  115515. distance: number;
  115516. /**
  115517. * Gets an already optimized mesh
  115518. */
  115519. optimizeMesh?: boolean;
  115520. }
  115521. /**
  115522. * Class used to specify simplification options
  115523. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115524. */
  115525. export class SimplificationSettings implements ISimplificationSettings {
  115526. /** expected quality */
  115527. quality: number;
  115528. /** distance when this optimized version should be used */
  115529. distance: number;
  115530. /** already optimized mesh */
  115531. optimizeMesh?: boolean | undefined;
  115532. /**
  115533. * Creates a SimplificationSettings
  115534. * @param quality expected quality
  115535. * @param distance distance when this optimized version should be used
  115536. * @param optimizeMesh already optimized mesh
  115537. */
  115538. constructor(
  115539. /** expected quality */
  115540. quality: number,
  115541. /** distance when this optimized version should be used */
  115542. distance: number,
  115543. /** already optimized mesh */
  115544. optimizeMesh?: boolean | undefined);
  115545. }
  115546. /**
  115547. * Interface used to define a simplification task
  115548. */
  115549. export interface ISimplificationTask {
  115550. /**
  115551. * Array of settings
  115552. */
  115553. settings: Array<ISimplificationSettings>;
  115554. /**
  115555. * Simplification type
  115556. */
  115557. simplificationType: SimplificationType;
  115558. /**
  115559. * Mesh to simplify
  115560. */
  115561. mesh: Mesh;
  115562. /**
  115563. * Callback called on success
  115564. */
  115565. successCallback?: () => void;
  115566. /**
  115567. * Defines if parallel processing can be used
  115568. */
  115569. parallelProcessing: boolean;
  115570. }
  115571. /**
  115572. * Queue used to order the simplification tasks
  115573. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115574. */
  115575. export class SimplificationQueue {
  115576. private _simplificationArray;
  115577. /**
  115578. * Gets a boolean indicating that the process is still running
  115579. */
  115580. running: boolean;
  115581. /**
  115582. * Creates a new queue
  115583. */
  115584. constructor();
  115585. /**
  115586. * Adds a new simplification task
  115587. * @param task defines a task to add
  115588. */
  115589. addTask(task: ISimplificationTask): void;
  115590. /**
  115591. * Execute next task
  115592. */
  115593. executeNext(): void;
  115594. /**
  115595. * Execute a simplification task
  115596. * @param task defines the task to run
  115597. */
  115598. runSimplification(task: ISimplificationTask): void;
  115599. private getSimplifier;
  115600. }
  115601. /**
  115602. * The implemented types of simplification
  115603. * At the moment only Quadratic Error Decimation is implemented
  115604. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115605. */
  115606. export enum SimplificationType {
  115607. /** Quadratic error decimation */
  115608. QUADRATIC = 0
  115609. }
  115610. }
  115611. declare module BABYLON {
  115612. interface Scene {
  115613. /** @hidden (Backing field) */
  115614. _simplificationQueue: SimplificationQueue;
  115615. /**
  115616. * Gets or sets the simplification queue attached to the scene
  115617. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115618. */
  115619. simplificationQueue: SimplificationQueue;
  115620. }
  115621. interface Mesh {
  115622. /**
  115623. * Simplify the mesh according to the given array of settings.
  115624. * Function will return immediately and will simplify async
  115625. * @param settings a collection of simplification settings
  115626. * @param parallelProcessing should all levels calculate parallel or one after the other
  115627. * @param simplificationType the type of simplification to run
  115628. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  115629. * @returns the current mesh
  115630. */
  115631. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  115632. }
  115633. /**
  115634. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  115635. * created in a scene
  115636. */
  115637. export class SimplicationQueueSceneComponent implements ISceneComponent {
  115638. /**
  115639. * The component name helpfull to identify the component in the list of scene components.
  115640. */
  115641. readonly name: string;
  115642. /**
  115643. * The scene the component belongs to.
  115644. */
  115645. scene: Scene;
  115646. /**
  115647. * Creates a new instance of the component for the given scene
  115648. * @param scene Defines the scene to register the component in
  115649. */
  115650. constructor(scene: Scene);
  115651. /**
  115652. * Registers the component in a given scene
  115653. */
  115654. register(): void;
  115655. /**
  115656. * Rebuilds the elements related to this component in case of
  115657. * context lost for instance.
  115658. */
  115659. rebuild(): void;
  115660. /**
  115661. * Disposes the component and the associated ressources
  115662. */
  115663. dispose(): void;
  115664. private _beforeCameraUpdate;
  115665. }
  115666. }
  115667. declare module BABYLON {
  115668. /**
  115669. * Class used to enable access to IndexedDB
  115670. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  115671. */
  115672. export class Database implements IOfflineProvider {
  115673. private _callbackManifestChecked;
  115674. private _currentSceneUrl;
  115675. private _db;
  115676. private _enableSceneOffline;
  115677. private _enableTexturesOffline;
  115678. private _manifestVersionFound;
  115679. private _mustUpdateRessources;
  115680. private _hasReachedQuota;
  115681. private _isSupported;
  115682. private _idbFactory;
  115683. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  115684. private static IsUASupportingBlobStorage;
  115685. /**
  115686. * Gets a boolean indicating if Database storate is enabled (off by default)
  115687. */
  115688. static IDBStorageEnabled: boolean;
  115689. /**
  115690. * Gets a boolean indicating if scene must be saved in the database
  115691. */
  115692. readonly enableSceneOffline: boolean;
  115693. /**
  115694. * Gets a boolean indicating if textures must be saved in the database
  115695. */
  115696. readonly enableTexturesOffline: boolean;
  115697. /**
  115698. * Creates a new Database
  115699. * @param urlToScene defines the url to load the scene
  115700. * @param callbackManifestChecked defines the callback to use when manifest is checked
  115701. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  115702. */
  115703. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  115704. private static _ParseURL;
  115705. private static _ReturnFullUrlLocation;
  115706. private _checkManifestFile;
  115707. /**
  115708. * Open the database and make it available
  115709. * @param successCallback defines the callback to call on success
  115710. * @param errorCallback defines the callback to call on error
  115711. */
  115712. open(successCallback: () => void, errorCallback: () => void): void;
  115713. /**
  115714. * Loads an image from the database
  115715. * @param url defines the url to load from
  115716. * @param image defines the target DOM image
  115717. */
  115718. loadImage(url: string, image: HTMLImageElement): void;
  115719. private _loadImageFromDBAsync;
  115720. private _saveImageIntoDBAsync;
  115721. private _checkVersionFromDB;
  115722. private _loadVersionFromDBAsync;
  115723. private _saveVersionIntoDBAsync;
  115724. /**
  115725. * Loads a file from database
  115726. * @param url defines the URL to load from
  115727. * @param sceneLoaded defines a callback to call on success
  115728. * @param progressCallBack defines a callback to call when progress changed
  115729. * @param errorCallback defines a callback to call on error
  115730. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  115731. */
  115732. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  115733. private _loadFileAsync;
  115734. private _saveFileAsync;
  115735. /**
  115736. * Validates if xhr data is correct
  115737. * @param xhr defines the request to validate
  115738. * @param dataType defines the expected data type
  115739. * @returns true if data is correct
  115740. */
  115741. private static _ValidateXHRData;
  115742. }
  115743. }
  115744. declare module BABYLON {
  115745. /** @hidden */
  115746. export var gpuUpdateParticlesPixelShader: {
  115747. name: string;
  115748. shader: string;
  115749. };
  115750. }
  115751. declare module BABYLON {
  115752. /** @hidden */
  115753. export var gpuUpdateParticlesVertexShader: {
  115754. name: string;
  115755. shader: string;
  115756. };
  115757. }
  115758. declare module BABYLON {
  115759. /** @hidden */
  115760. export var clipPlaneFragmentDeclaration2: {
  115761. name: string;
  115762. shader: string;
  115763. };
  115764. }
  115765. declare module BABYLON {
  115766. /** @hidden */
  115767. export var gpuRenderParticlesPixelShader: {
  115768. name: string;
  115769. shader: string;
  115770. };
  115771. }
  115772. declare module BABYLON {
  115773. /** @hidden */
  115774. export var clipPlaneVertexDeclaration2: {
  115775. name: string;
  115776. shader: string;
  115777. };
  115778. }
  115779. declare module BABYLON {
  115780. /** @hidden */
  115781. export var gpuRenderParticlesVertexShader: {
  115782. name: string;
  115783. shader: string;
  115784. };
  115785. }
  115786. declare module BABYLON {
  115787. /**
  115788. * This represents a GPU particle system in Babylon
  115789. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  115790. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  115791. */
  115792. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  115793. /**
  115794. * The layer mask we are rendering the particles through.
  115795. */
  115796. layerMask: number;
  115797. private _capacity;
  115798. private _activeCount;
  115799. private _currentActiveCount;
  115800. private _accumulatedCount;
  115801. private _renderEffect;
  115802. private _updateEffect;
  115803. private _buffer0;
  115804. private _buffer1;
  115805. private _spriteBuffer;
  115806. private _updateVAO;
  115807. private _renderVAO;
  115808. private _targetIndex;
  115809. private _sourceBuffer;
  115810. private _targetBuffer;
  115811. private _engine;
  115812. private _currentRenderId;
  115813. private _started;
  115814. private _stopped;
  115815. private _timeDelta;
  115816. private _randomTexture;
  115817. private _randomTexture2;
  115818. private _attributesStrideSize;
  115819. private _updateEffectOptions;
  115820. private _randomTextureSize;
  115821. private _actualFrame;
  115822. private readonly _rawTextureWidth;
  115823. /**
  115824. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  115825. */
  115826. static readonly IsSupported: boolean;
  115827. /**
  115828. * An event triggered when the system is disposed.
  115829. */
  115830. onDisposeObservable: Observable<GPUParticleSystem>;
  115831. /**
  115832. * Gets the maximum number of particles active at the same time.
  115833. * @returns The max number of active particles.
  115834. */
  115835. getCapacity(): number;
  115836. /**
  115837. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  115838. * to override the particles.
  115839. */
  115840. forceDepthWrite: boolean;
  115841. /**
  115842. * Gets or set the number of active particles
  115843. */
  115844. activeParticleCount: number;
  115845. private _preWarmDone;
  115846. /**
  115847. * Is this system ready to be used/rendered
  115848. * @return true if the system is ready
  115849. */
  115850. isReady(): boolean;
  115851. /**
  115852. * Gets if the system has been started. (Note: this will still be true after stop is called)
  115853. * @returns True if it has been started, otherwise false.
  115854. */
  115855. isStarted(): boolean;
  115856. /**
  115857. * Starts the particle system and begins to emit
  115858. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  115859. */
  115860. start(delay?: number): void;
  115861. /**
  115862. * Stops the particle system.
  115863. */
  115864. stop(): void;
  115865. /**
  115866. * Remove all active particles
  115867. */
  115868. reset(): void;
  115869. /**
  115870. * Returns the string "GPUParticleSystem"
  115871. * @returns a string containing the class name
  115872. */
  115873. getClassName(): string;
  115874. private _colorGradientsTexture;
  115875. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  115876. /**
  115877. * Adds a new color gradient
  115878. * @param gradient defines the gradient to use (between 0 and 1)
  115879. * @param color1 defines the color to affect to the specified gradient
  115880. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  115881. * @returns the current particle system
  115882. */
  115883. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  115884. /**
  115885. * Remove a specific color gradient
  115886. * @param gradient defines the gradient to remove
  115887. * @returns the current particle system
  115888. */
  115889. removeColorGradient(gradient: number): GPUParticleSystem;
  115890. private _angularSpeedGradientsTexture;
  115891. private _sizeGradientsTexture;
  115892. private _velocityGradientsTexture;
  115893. private _limitVelocityGradientsTexture;
  115894. private _dragGradientsTexture;
  115895. private _addFactorGradient;
  115896. /**
  115897. * Adds a new size gradient
  115898. * @param gradient defines the gradient to use (between 0 and 1)
  115899. * @param factor defines the size factor to affect to the specified gradient
  115900. * @returns the current particle system
  115901. */
  115902. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  115903. /**
  115904. * Remove a specific size gradient
  115905. * @param gradient defines the gradient to remove
  115906. * @returns the current particle system
  115907. */
  115908. removeSizeGradient(gradient: number): GPUParticleSystem;
  115909. /**
  115910. * Adds a new angular speed gradient
  115911. * @param gradient defines the gradient to use (between 0 and 1)
  115912. * @param factor defines the angular speed to affect to the specified gradient
  115913. * @returns the current particle system
  115914. */
  115915. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  115916. /**
  115917. * Remove a specific angular speed gradient
  115918. * @param gradient defines the gradient to remove
  115919. * @returns the current particle system
  115920. */
  115921. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  115922. /**
  115923. * Adds a new velocity gradient
  115924. * @param gradient defines the gradient to use (between 0 and 1)
  115925. * @param factor defines the velocity to affect to the specified gradient
  115926. * @returns the current particle system
  115927. */
  115928. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  115929. /**
  115930. * Remove a specific velocity gradient
  115931. * @param gradient defines the gradient to remove
  115932. * @returns the current particle system
  115933. */
  115934. removeVelocityGradient(gradient: number): GPUParticleSystem;
  115935. /**
  115936. * Adds a new limit velocity gradient
  115937. * @param gradient defines the gradient to use (between 0 and 1)
  115938. * @param factor defines the limit velocity value to affect to the specified gradient
  115939. * @returns the current particle system
  115940. */
  115941. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  115942. /**
  115943. * Remove a specific limit velocity gradient
  115944. * @param gradient defines the gradient to remove
  115945. * @returns the current particle system
  115946. */
  115947. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  115948. /**
  115949. * Adds a new drag gradient
  115950. * @param gradient defines the gradient to use (between 0 and 1)
  115951. * @param factor defines the drag value to affect to the specified gradient
  115952. * @returns the current particle system
  115953. */
  115954. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  115955. /**
  115956. * Remove a specific drag gradient
  115957. * @param gradient defines the gradient to remove
  115958. * @returns the current particle system
  115959. */
  115960. removeDragGradient(gradient: number): GPUParticleSystem;
  115961. /**
  115962. * Not supported by GPUParticleSystem
  115963. * @param gradient defines the gradient to use (between 0 and 1)
  115964. * @param factor defines the emit rate value to affect to the specified gradient
  115965. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  115966. * @returns the current particle system
  115967. */
  115968. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  115969. /**
  115970. * Not supported by GPUParticleSystem
  115971. * @param gradient defines the gradient to remove
  115972. * @returns the current particle system
  115973. */
  115974. removeEmitRateGradient(gradient: number): IParticleSystem;
  115975. /**
  115976. * Not supported by GPUParticleSystem
  115977. * @param gradient defines the gradient to use (between 0 and 1)
  115978. * @param factor defines the start size value to affect to the specified gradient
  115979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  115980. * @returns the current particle system
  115981. */
  115982. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  115983. /**
  115984. * Not supported by GPUParticleSystem
  115985. * @param gradient defines the gradient to remove
  115986. * @returns the current particle system
  115987. */
  115988. removeStartSizeGradient(gradient: number): IParticleSystem;
  115989. /**
  115990. * Not supported by GPUParticleSystem
  115991. * @param gradient defines the gradient to use (between 0 and 1)
  115992. * @param min defines the color remap minimal range
  115993. * @param max defines the color remap maximal range
  115994. * @returns the current particle system
  115995. */
  115996. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  115997. /**
  115998. * Not supported by GPUParticleSystem
  115999. * @param gradient defines the gradient to remove
  116000. * @returns the current particle system
  116001. */
  116002. removeColorRemapGradient(): IParticleSystem;
  116003. /**
  116004. * Not supported by GPUParticleSystem
  116005. * @param gradient defines the gradient to use (between 0 and 1)
  116006. * @param min defines the alpha remap minimal range
  116007. * @param max defines the alpha remap maximal range
  116008. * @returns the current particle system
  116009. */
  116010. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  116011. /**
  116012. * Not supported by GPUParticleSystem
  116013. * @param gradient defines the gradient to remove
  116014. * @returns the current particle system
  116015. */
  116016. removeAlphaRemapGradient(): IParticleSystem;
  116017. /**
  116018. * Not supported by GPUParticleSystem
  116019. * @param gradient defines the gradient to use (between 0 and 1)
  116020. * @param color defines the color to affect to the specified gradient
  116021. * @returns the current particle system
  116022. */
  116023. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  116024. /**
  116025. * Not supported by GPUParticleSystem
  116026. * @param gradient defines the gradient to remove
  116027. * @returns the current particle system
  116028. */
  116029. removeRampGradient(): IParticleSystem;
  116030. /**
  116031. * Not supported by GPUParticleSystem
  116032. * @returns the list of ramp gradients
  116033. */
  116034. getRampGradients(): Nullable<Array<Color3Gradient>>;
  116035. /**
  116036. * Not supported by GPUParticleSystem
  116037. * Gets or sets a boolean indicating that ramp gradients must be used
  116038. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  116039. */
  116040. useRampGradients: boolean;
  116041. /**
  116042. * Not supported by GPUParticleSystem
  116043. * @param gradient defines the gradient to use (between 0 and 1)
  116044. * @param factor defines the life time factor to affect to the specified gradient
  116045. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116046. * @returns the current particle system
  116047. */
  116048. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116049. /**
  116050. * Not supported by GPUParticleSystem
  116051. * @param gradient defines the gradient to remove
  116052. * @returns the current particle system
  116053. */
  116054. removeLifeTimeGradient(gradient: number): IParticleSystem;
  116055. /**
  116056. * Instantiates a GPU particle system.
  116057. * 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.
  116058. * @param name The name of the particle system
  116059. * @param options The options used to create the system
  116060. * @param scene The scene the particle system belongs to
  116061. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  116062. */
  116063. constructor(name: string, options: Partial<{
  116064. capacity: number;
  116065. randomTextureSize: number;
  116066. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  116067. protected _reset(): void;
  116068. private _createUpdateVAO;
  116069. private _createRenderVAO;
  116070. private _initialize;
  116071. /** @hidden */
  116072. _recreateUpdateEffect(): void;
  116073. /** @hidden */
  116074. _recreateRenderEffect(): void;
  116075. /**
  116076. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  116077. * @param preWarm defines if we are in the pre-warmimg phase
  116078. */
  116079. animate(preWarm?: boolean): void;
  116080. private _createFactorGradientTexture;
  116081. private _createSizeGradientTexture;
  116082. private _createAngularSpeedGradientTexture;
  116083. private _createVelocityGradientTexture;
  116084. private _createLimitVelocityGradientTexture;
  116085. private _createDragGradientTexture;
  116086. private _createColorGradientTexture;
  116087. /**
  116088. * Renders the particle system in its current state
  116089. * @param preWarm defines if the system should only update the particles but not render them
  116090. * @returns the current number of particles
  116091. */
  116092. render(preWarm?: boolean): number;
  116093. /**
  116094. * Rebuilds the particle system
  116095. */
  116096. rebuild(): void;
  116097. private _releaseBuffers;
  116098. private _releaseVAOs;
  116099. /**
  116100. * Disposes the particle system and free the associated resources
  116101. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  116102. */
  116103. dispose(disposeTexture?: boolean): void;
  116104. /**
  116105. * Clones the particle system.
  116106. * @param name The name of the cloned object
  116107. * @param newEmitter The new emitter to use
  116108. * @returns the cloned particle system
  116109. */
  116110. clone(name: string, newEmitter: any): GPUParticleSystem;
  116111. /**
  116112. * Serializes the particle system to a JSON object.
  116113. * @returns the JSON object
  116114. */
  116115. serialize(): any;
  116116. /**
  116117. * Parses a JSON object to create a GPU particle system.
  116118. * @param parsedParticleSystem The JSON object to parse
  116119. * @param scene The scene to create the particle system in
  116120. * @param rootUrl The root url to use to load external dependencies like texture
  116121. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  116122. * @returns the parsed GPU particle system
  116123. */
  116124. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  116125. }
  116126. }
  116127. declare module BABYLON {
  116128. /**
  116129. * Represents a set of particle systems working together to create a specific effect
  116130. */
  116131. export class ParticleSystemSet implements IDisposable {
  116132. private _emitterCreationOptions;
  116133. private _emitterNode;
  116134. /**
  116135. * Gets the particle system list
  116136. */
  116137. systems: IParticleSystem[];
  116138. /**
  116139. * Gets the emitter node used with this set
  116140. */
  116141. readonly emitterNode: Nullable<TransformNode>;
  116142. /**
  116143. * Creates a new emitter mesh as a sphere
  116144. * @param options defines the options used to create the sphere
  116145. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  116146. * @param scene defines the hosting scene
  116147. */
  116148. setEmitterAsSphere(options: {
  116149. diameter: number;
  116150. segments: number;
  116151. color: Color3;
  116152. }, renderingGroupId: number, scene: Scene): void;
  116153. /**
  116154. * Starts all particle systems of the set
  116155. * @param emitter defines an optional mesh to use as emitter for the particle systems
  116156. */
  116157. start(emitter?: AbstractMesh): void;
  116158. /**
  116159. * Release all associated resources
  116160. */
  116161. dispose(): void;
  116162. /**
  116163. * Serialize the set into a JSON compatible object
  116164. * @returns a JSON compatible representation of the set
  116165. */
  116166. serialize(): any;
  116167. /**
  116168. * Parse a new ParticleSystemSet from a serialized source
  116169. * @param data defines a JSON compatible representation of the set
  116170. * @param scene defines the hosting scene
  116171. * @param gpu defines if we want GPU particles or CPU particles
  116172. * @returns a new ParticleSystemSet
  116173. */
  116174. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  116175. }
  116176. }
  116177. declare module BABYLON {
  116178. /**
  116179. * This class is made for on one-liner static method to help creating particle system set.
  116180. */
  116181. export class ParticleHelper {
  116182. /**
  116183. * Gets or sets base Assets URL
  116184. */
  116185. static BaseAssetsUrl: string;
  116186. /**
  116187. * Create a default particle system that you can tweak
  116188. * @param emitter defines the emitter to use
  116189. * @param capacity defines the system capacity (default is 500 particles)
  116190. * @param scene defines the hosting scene
  116191. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  116192. * @returns the new Particle system
  116193. */
  116194. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  116195. /**
  116196. * This is the main static method (one-liner) of this helper to create different particle systems
  116197. * @param type This string represents the type to the particle system to create
  116198. * @param scene The scene where the particle system should live
  116199. * @param gpu If the system will use gpu
  116200. * @returns the ParticleSystemSet created
  116201. */
  116202. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  116203. /**
  116204. * Static function used to export a particle system to a ParticleSystemSet variable.
  116205. * Please note that the emitter shape is not exported
  116206. * @param systems defines the particle systems to export
  116207. * @returns the created particle system set
  116208. */
  116209. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  116210. }
  116211. }
  116212. declare module BABYLON {
  116213. interface Engine {
  116214. /**
  116215. * Create an effect to use with particle systems.
  116216. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  116217. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  116218. * @param uniformsNames defines a list of attribute names
  116219. * @param samplers defines an array of string used to represent textures
  116220. * @param defines defines the string containing the defines to use to compile the shaders
  116221. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  116222. * @param onCompiled defines a function to call when the effect creation is successful
  116223. * @param onError defines a function to call when the effect creation has failed
  116224. * @returns the new Effect
  116225. */
  116226. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  116227. }
  116228. interface Mesh {
  116229. /**
  116230. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  116231. * @returns an array of IParticleSystem
  116232. */
  116233. getEmittedParticleSystems(): IParticleSystem[];
  116234. /**
  116235. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  116236. * @returns an array of IParticleSystem
  116237. */
  116238. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  116239. }
  116240. /**
  116241. * @hidden
  116242. */
  116243. export var _IDoNeedToBeInTheBuild: number;
  116244. }
  116245. declare module BABYLON {
  116246. interface Scene {
  116247. /** @hidden (Backing field) */
  116248. _physicsEngine: Nullable<IPhysicsEngine>;
  116249. /**
  116250. * Gets the current physics engine
  116251. * @returns a IPhysicsEngine or null if none attached
  116252. */
  116253. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  116254. /**
  116255. * Enables physics to the current scene
  116256. * @param gravity defines the scene's gravity for the physics engine
  116257. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  116258. * @return a boolean indicating if the physics engine was initialized
  116259. */
  116260. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  116261. /**
  116262. * Disables and disposes the physics engine associated with the scene
  116263. */
  116264. disablePhysicsEngine(): void;
  116265. /**
  116266. * Gets a boolean indicating if there is an active physics engine
  116267. * @returns a boolean indicating if there is an active physics engine
  116268. */
  116269. isPhysicsEnabled(): boolean;
  116270. /**
  116271. * Deletes a physics compound impostor
  116272. * @param compound defines the compound to delete
  116273. */
  116274. deleteCompoundImpostor(compound: any): void;
  116275. /**
  116276. * An event triggered when physic simulation is about to be run
  116277. */
  116278. onBeforePhysicsObservable: Observable<Scene>;
  116279. /**
  116280. * An event triggered when physic simulation has been done
  116281. */
  116282. onAfterPhysicsObservable: Observable<Scene>;
  116283. }
  116284. interface AbstractMesh {
  116285. /** @hidden */
  116286. _physicsImpostor: Nullable<PhysicsImpostor>;
  116287. /**
  116288. * Gets or sets impostor used for physic simulation
  116289. * @see http://doc.babylonjs.com/features/physics_engine
  116290. */
  116291. physicsImpostor: Nullable<PhysicsImpostor>;
  116292. /**
  116293. * Gets the current physics impostor
  116294. * @see http://doc.babylonjs.com/features/physics_engine
  116295. * @returns a physics impostor or null
  116296. */
  116297. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  116298. /** Apply a physic impulse to the mesh
  116299. * @param force defines the force to apply
  116300. * @param contactPoint defines where to apply the force
  116301. * @returns the current mesh
  116302. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116303. */
  116304. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  116305. /**
  116306. * Creates a physic joint between two meshes
  116307. * @param otherMesh defines the other mesh to use
  116308. * @param pivot1 defines the pivot to use on this mesh
  116309. * @param pivot2 defines the pivot to use on the other mesh
  116310. * @param options defines additional options (can be plugin dependent)
  116311. * @returns the current mesh
  116312. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  116313. */
  116314. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  116315. /** @hidden */
  116316. _disposePhysicsObserver: Nullable<Observer<Node>>;
  116317. }
  116318. /**
  116319. * Defines the physics engine scene component responsible to manage a physics engine
  116320. */
  116321. export class PhysicsEngineSceneComponent implements ISceneComponent {
  116322. /**
  116323. * The component name helpful to identify the component in the list of scene components.
  116324. */
  116325. readonly name: string;
  116326. /**
  116327. * The scene the component belongs to.
  116328. */
  116329. scene: Scene;
  116330. /**
  116331. * Creates a new instance of the component for the given scene
  116332. * @param scene Defines the scene to register the component in
  116333. */
  116334. constructor(scene: Scene);
  116335. /**
  116336. * Registers the component in a given scene
  116337. */
  116338. register(): void;
  116339. /**
  116340. * Rebuilds the elements related to this component in case of
  116341. * context lost for instance.
  116342. */
  116343. rebuild(): void;
  116344. /**
  116345. * Disposes the component and the associated ressources
  116346. */
  116347. dispose(): void;
  116348. }
  116349. }
  116350. declare module BABYLON {
  116351. /**
  116352. * A helper for physics simulations
  116353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116354. */
  116355. export class PhysicsHelper {
  116356. private _scene;
  116357. private _physicsEngine;
  116358. /**
  116359. * Initializes the Physics helper
  116360. * @param scene Babylon.js scene
  116361. */
  116362. constructor(scene: Scene);
  116363. /**
  116364. * Applies a radial explosion impulse
  116365. * @param origin the origin of the explosion
  116366. * @param radiusOrEventOptions the radius or the options of radial explosion
  116367. * @param strength the explosion strength
  116368. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116369. * @returns A physics radial explosion event, or null
  116370. */
  116371. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  116372. /**
  116373. * Applies a radial explosion force
  116374. * @param origin the origin of the explosion
  116375. * @param radiusOrEventOptions the radius or the options of radial explosion
  116376. * @param strength the explosion strength
  116377. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116378. * @returns A physics radial explosion event, or null
  116379. */
  116380. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  116381. /**
  116382. * Creates a gravitational field
  116383. * @param origin the origin of the explosion
  116384. * @param radiusOrEventOptions the radius or the options of radial explosion
  116385. * @param strength the explosion strength
  116386. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116387. * @returns A physics gravitational field event, or null
  116388. */
  116389. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  116390. /**
  116391. * Creates a physics updraft event
  116392. * @param origin the origin of the updraft
  116393. * @param radiusOrEventOptions the radius or the options of the updraft
  116394. * @param strength the strength of the updraft
  116395. * @param height the height of the updraft
  116396. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  116397. * @returns A physics updraft event, or null
  116398. */
  116399. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  116400. /**
  116401. * Creates a physics vortex event
  116402. * @param origin the of the vortex
  116403. * @param radiusOrEventOptions the radius or the options of the vortex
  116404. * @param strength the strength of the vortex
  116405. * @param height the height of the vortex
  116406. * @returns a Physics vortex event, or null
  116407. * A physics vortex event or null
  116408. */
  116409. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  116410. }
  116411. /**
  116412. * Represents a physics radial explosion event
  116413. */
  116414. class PhysicsRadialExplosionEvent {
  116415. private _scene;
  116416. private _options;
  116417. private _sphere;
  116418. private _dataFetched;
  116419. /**
  116420. * Initializes a radial explosioin event
  116421. * @param _scene BabylonJS scene
  116422. * @param _options The options for the vortex event
  116423. */
  116424. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  116425. /**
  116426. * Returns the data related to the radial explosion event (sphere).
  116427. * @returns The radial explosion event data
  116428. */
  116429. getData(): PhysicsRadialExplosionEventData;
  116430. /**
  116431. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  116432. * @param impostor A physics imposter
  116433. * @param origin the origin of the explosion
  116434. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  116435. */
  116436. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  116437. /**
  116438. * Triggers affecterd impostors callbacks
  116439. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  116440. */
  116441. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  116442. /**
  116443. * Disposes the sphere.
  116444. * @param force Specifies if the sphere should be disposed by force
  116445. */
  116446. dispose(force?: boolean): void;
  116447. /*** Helpers ***/
  116448. private _prepareSphere;
  116449. private _intersectsWithSphere;
  116450. }
  116451. /**
  116452. * Represents a gravitational field event
  116453. */
  116454. class PhysicsGravitationalFieldEvent {
  116455. private _physicsHelper;
  116456. private _scene;
  116457. private _origin;
  116458. private _options;
  116459. private _tickCallback;
  116460. private _sphere;
  116461. private _dataFetched;
  116462. /**
  116463. * Initializes the physics gravitational field event
  116464. * @param _physicsHelper A physics helper
  116465. * @param _scene BabylonJS scene
  116466. * @param _origin The origin position of the gravitational field event
  116467. * @param _options The options for the vortex event
  116468. */
  116469. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  116470. /**
  116471. * Returns the data related to the gravitational field event (sphere).
  116472. * @returns A gravitational field event
  116473. */
  116474. getData(): PhysicsGravitationalFieldEventData;
  116475. /**
  116476. * Enables the gravitational field.
  116477. */
  116478. enable(): void;
  116479. /**
  116480. * Disables the gravitational field.
  116481. */
  116482. disable(): void;
  116483. /**
  116484. * Disposes the sphere.
  116485. * @param force The force to dispose from the gravitational field event
  116486. */
  116487. dispose(force?: boolean): void;
  116488. private _tick;
  116489. }
  116490. /**
  116491. * Represents a physics updraft event
  116492. */
  116493. class PhysicsUpdraftEvent {
  116494. private _scene;
  116495. private _origin;
  116496. private _options;
  116497. private _physicsEngine;
  116498. private _originTop;
  116499. private _originDirection;
  116500. private _tickCallback;
  116501. private _cylinder;
  116502. private _cylinderPosition;
  116503. private _dataFetched;
  116504. /**
  116505. * Initializes the physics updraft event
  116506. * @param _scene BabylonJS scene
  116507. * @param _origin The origin position of the updraft
  116508. * @param _options The options for the updraft event
  116509. */
  116510. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  116511. /**
  116512. * Returns the data related to the updraft event (cylinder).
  116513. * @returns A physics updraft event
  116514. */
  116515. getData(): PhysicsUpdraftEventData;
  116516. /**
  116517. * Enables the updraft.
  116518. */
  116519. enable(): void;
  116520. /**
  116521. * Disables the updraft.
  116522. */
  116523. disable(): void;
  116524. /**
  116525. * Disposes the cylinder.
  116526. * @param force Specifies if the updraft should be disposed by force
  116527. */
  116528. dispose(force?: boolean): void;
  116529. private getImpostorHitData;
  116530. private _tick;
  116531. /*** Helpers ***/
  116532. private _prepareCylinder;
  116533. private _intersectsWithCylinder;
  116534. }
  116535. /**
  116536. * Represents a physics vortex event
  116537. */
  116538. class PhysicsVortexEvent {
  116539. private _scene;
  116540. private _origin;
  116541. private _options;
  116542. private _physicsEngine;
  116543. private _originTop;
  116544. private _tickCallback;
  116545. private _cylinder;
  116546. private _cylinderPosition;
  116547. private _dataFetched;
  116548. /**
  116549. * Initializes the physics vortex event
  116550. * @param _scene The BabylonJS scene
  116551. * @param _origin The origin position of the vortex
  116552. * @param _options The options for the vortex event
  116553. */
  116554. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  116555. /**
  116556. * Returns the data related to the vortex event (cylinder).
  116557. * @returns The physics vortex event data
  116558. */
  116559. getData(): PhysicsVortexEventData;
  116560. /**
  116561. * Enables the vortex.
  116562. */
  116563. enable(): void;
  116564. /**
  116565. * Disables the cortex.
  116566. */
  116567. disable(): void;
  116568. /**
  116569. * Disposes the sphere.
  116570. * @param force
  116571. */
  116572. dispose(force?: boolean): void;
  116573. private getImpostorHitData;
  116574. private _tick;
  116575. /*** Helpers ***/
  116576. private _prepareCylinder;
  116577. private _intersectsWithCylinder;
  116578. }
  116579. /**
  116580. * Options fot the radial explosion event
  116581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116582. */
  116583. export class PhysicsRadialExplosionEventOptions {
  116584. /**
  116585. * The radius of the sphere for the radial explosion.
  116586. */
  116587. radius: number;
  116588. /**
  116589. * The strenth of the explosion.
  116590. */
  116591. strength: number;
  116592. /**
  116593. * The strenght of the force in correspondence to the distance of the affected object
  116594. */
  116595. falloff: PhysicsRadialImpulseFalloff;
  116596. /**
  116597. * Sphere options for the radial explosion.
  116598. */
  116599. sphere: {
  116600. segments: number;
  116601. diameter: number;
  116602. };
  116603. /**
  116604. * Sphere options for the radial explosion.
  116605. */
  116606. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  116607. }
  116608. /**
  116609. * Options fot the updraft event
  116610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116611. */
  116612. export class PhysicsUpdraftEventOptions {
  116613. /**
  116614. * The radius of the cylinder for the vortex
  116615. */
  116616. radius: number;
  116617. /**
  116618. * The strenth of the updraft.
  116619. */
  116620. strength: number;
  116621. /**
  116622. * The height of the cylinder for the updraft.
  116623. */
  116624. height: number;
  116625. /**
  116626. * The mode for the the updraft.
  116627. */
  116628. updraftMode: PhysicsUpdraftMode;
  116629. }
  116630. /**
  116631. * Options fot the vortex event
  116632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116633. */
  116634. export class PhysicsVortexEventOptions {
  116635. /**
  116636. * The radius of the cylinder for the vortex
  116637. */
  116638. radius: number;
  116639. /**
  116640. * The strenth of the vortex.
  116641. */
  116642. strength: number;
  116643. /**
  116644. * The height of the cylinder for the vortex.
  116645. */
  116646. height: number;
  116647. /**
  116648. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  116649. */
  116650. centripetalForceThreshold: number;
  116651. /**
  116652. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  116653. */
  116654. centripetalForceMultiplier: number;
  116655. /**
  116656. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  116657. */
  116658. centrifugalForceMultiplier: number;
  116659. /**
  116660. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  116661. */
  116662. updraftForceMultiplier: number;
  116663. }
  116664. /**
  116665. * The strenght of the force in correspondence to the distance of the affected object
  116666. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116667. */
  116668. export enum PhysicsRadialImpulseFalloff {
  116669. /** Defines that impulse is constant in strength across it's whole radius */
  116670. Constant = 0,
  116671. /** Defines that impulse gets weaker if it's further from the origin */
  116672. Linear = 1
  116673. }
  116674. /**
  116675. * The strength of the force in correspondence to the distance of the affected object
  116676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116677. */
  116678. export enum PhysicsUpdraftMode {
  116679. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  116680. Center = 0,
  116681. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  116682. Perpendicular = 1
  116683. }
  116684. /**
  116685. * Interface for a physics hit data
  116686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116687. */
  116688. export interface PhysicsHitData {
  116689. /**
  116690. * The force applied at the contact point
  116691. */
  116692. force: Vector3;
  116693. /**
  116694. * The contact point
  116695. */
  116696. contactPoint: Vector3;
  116697. /**
  116698. * The distance from the origin to the contact point
  116699. */
  116700. distanceFromOrigin: number;
  116701. }
  116702. /**
  116703. * Interface for radial explosion event data
  116704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116705. */
  116706. export interface PhysicsRadialExplosionEventData {
  116707. /**
  116708. * A sphere used for the radial explosion event
  116709. */
  116710. sphere: Mesh;
  116711. }
  116712. /**
  116713. * Interface for gravitational field event data
  116714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116715. */
  116716. export interface PhysicsGravitationalFieldEventData {
  116717. /**
  116718. * A sphere mesh used for the gravitational field event
  116719. */
  116720. sphere: Mesh;
  116721. }
  116722. /**
  116723. * Interface for updraft event data
  116724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116725. */
  116726. export interface PhysicsUpdraftEventData {
  116727. /**
  116728. * A cylinder used for the updraft event
  116729. */
  116730. cylinder: Mesh;
  116731. }
  116732. /**
  116733. * Interface for vortex event data
  116734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116735. */
  116736. export interface PhysicsVortexEventData {
  116737. /**
  116738. * A cylinder used for the vortex event
  116739. */
  116740. cylinder: Mesh;
  116741. }
  116742. /**
  116743. * Interface for an affected physics impostor
  116744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116745. */
  116746. export interface PhysicsAffectedImpostorWithData {
  116747. /**
  116748. * The impostor affected by the effect
  116749. */
  116750. impostor: PhysicsImpostor;
  116751. /**
  116752. * The data about the hit/horce from the explosion
  116753. */
  116754. hitData: PhysicsHitData;
  116755. }
  116756. }
  116757. declare module BABYLON {
  116758. /** @hidden */
  116759. export var blackAndWhitePixelShader: {
  116760. name: string;
  116761. shader: string;
  116762. };
  116763. }
  116764. declare module BABYLON {
  116765. /**
  116766. * Post process used to render in black and white
  116767. */
  116768. export class BlackAndWhitePostProcess extends PostProcess {
  116769. /**
  116770. * Linear about to convert he result to black and white (default: 1)
  116771. */
  116772. degree: number;
  116773. /**
  116774. * Creates a black and white post process
  116775. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  116776. * @param name The name of the effect.
  116777. * @param options The required width/height ratio to downsize to before computing the render pass.
  116778. * @param camera The camera to apply the render pass to.
  116779. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116780. * @param engine The engine which the post process will be applied. (default: current engine)
  116781. * @param reusable If the post process can be reused on the same frame. (default: false)
  116782. */
  116783. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116784. }
  116785. }
  116786. declare module BABYLON {
  116787. /**
  116788. * This represents a set of one or more post processes in Babylon.
  116789. * A post process can be used to apply a shader to a texture after it is rendered.
  116790. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  116791. */
  116792. export class PostProcessRenderEffect {
  116793. private _postProcesses;
  116794. private _getPostProcesses;
  116795. private _singleInstance;
  116796. private _cameras;
  116797. private _indicesForCamera;
  116798. /**
  116799. * Name of the effect
  116800. * @hidden
  116801. */
  116802. _name: string;
  116803. /**
  116804. * Instantiates a post process render effect.
  116805. * A post process can be used to apply a shader to a texture after it is rendered.
  116806. * @param engine The engine the effect is tied to
  116807. * @param name The name of the effect
  116808. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  116809. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  116810. */
  116811. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  116812. /**
  116813. * Checks if all the post processes in the effect are supported.
  116814. */
  116815. readonly isSupported: boolean;
  116816. /**
  116817. * Updates the current state of the effect
  116818. * @hidden
  116819. */
  116820. _update(): void;
  116821. /**
  116822. * Attaches the effect on cameras
  116823. * @param cameras The camera to attach to.
  116824. * @hidden
  116825. */
  116826. _attachCameras(cameras: Camera): void;
  116827. /**
  116828. * Attaches the effect on cameras
  116829. * @param cameras The camera to attach to.
  116830. * @hidden
  116831. */
  116832. _attachCameras(cameras: Camera[]): void;
  116833. /**
  116834. * Detaches the effect on cameras
  116835. * @param cameras The camera to detatch from.
  116836. * @hidden
  116837. */
  116838. _detachCameras(cameras: Camera): void;
  116839. /**
  116840. * Detatches the effect on cameras
  116841. * @param cameras The camera to detatch from.
  116842. * @hidden
  116843. */
  116844. _detachCameras(cameras: Camera[]): void;
  116845. /**
  116846. * Enables the effect on given cameras
  116847. * @param cameras The camera to enable.
  116848. * @hidden
  116849. */
  116850. _enable(cameras: Camera): void;
  116851. /**
  116852. * Enables the effect on given cameras
  116853. * @param cameras The camera to enable.
  116854. * @hidden
  116855. */
  116856. _enable(cameras: Nullable<Camera[]>): void;
  116857. /**
  116858. * Disables the effect on the given cameras
  116859. * @param cameras The camera to disable.
  116860. * @hidden
  116861. */
  116862. _disable(cameras: Camera): void;
  116863. /**
  116864. * Disables the effect on the given cameras
  116865. * @param cameras The camera to disable.
  116866. * @hidden
  116867. */
  116868. _disable(cameras: Nullable<Camera[]>): void;
  116869. /**
  116870. * Gets a list of the post processes contained in the effect.
  116871. * @param camera The camera to get the post processes on.
  116872. * @returns The list of the post processes in the effect.
  116873. */
  116874. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  116875. }
  116876. }
  116877. declare module BABYLON {
  116878. /** @hidden */
  116879. export var extractHighlightsPixelShader: {
  116880. name: string;
  116881. shader: string;
  116882. };
  116883. }
  116884. declare module BABYLON {
  116885. /**
  116886. * 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.
  116887. */
  116888. export class ExtractHighlightsPostProcess extends PostProcess {
  116889. /**
  116890. * The luminance threshold, pixels below this value will be set to black.
  116891. */
  116892. threshold: number;
  116893. /** @hidden */
  116894. _exposure: number;
  116895. /**
  116896. * Post process which has the input texture to be used when performing highlight extraction
  116897. * @hidden
  116898. */
  116899. _inputPostProcess: Nullable<PostProcess>;
  116900. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116901. }
  116902. }
  116903. declare module BABYLON {
  116904. /** @hidden */
  116905. export var bloomMergePixelShader: {
  116906. name: string;
  116907. shader: string;
  116908. };
  116909. }
  116910. declare module BABYLON {
  116911. /**
  116912. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  116913. */
  116914. export class BloomMergePostProcess extends PostProcess {
  116915. /** Weight of the bloom to be added to the original input. */
  116916. weight: number;
  116917. /**
  116918. * Creates a new instance of @see BloomMergePostProcess
  116919. * @param name The name of the effect.
  116920. * @param originalFromInput Post process which's input will be used for the merge.
  116921. * @param blurred Blurred highlights post process which's output will be used.
  116922. * @param weight Weight of the bloom to be added to the original input.
  116923. * @param options The required width/height ratio to downsize to before computing the render pass.
  116924. * @param camera The camera to apply the render pass to.
  116925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116926. * @param engine The engine which the post process will be applied. (default: current engine)
  116927. * @param reusable If the post process can be reused on the same frame. (default: false)
  116928. * @param textureType Type of textures used when performing the post process. (default: 0)
  116929. * @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)
  116930. */
  116931. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  116932. /** Weight of the bloom to be added to the original input. */
  116933. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116934. }
  116935. }
  116936. declare module BABYLON {
  116937. /**
  116938. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  116939. */
  116940. export class BloomEffect extends PostProcessRenderEffect {
  116941. private bloomScale;
  116942. /**
  116943. * @hidden Internal
  116944. */
  116945. _effects: Array<PostProcess>;
  116946. /**
  116947. * @hidden Internal
  116948. */
  116949. _downscale: ExtractHighlightsPostProcess;
  116950. private _blurX;
  116951. private _blurY;
  116952. private _merge;
  116953. /**
  116954. * The luminance threshold to find bright areas of the image to bloom.
  116955. */
  116956. threshold: number;
  116957. /**
  116958. * The strength of the bloom.
  116959. */
  116960. weight: number;
  116961. /**
  116962. * Specifies the size of the bloom blur kernel, relative to the final output size
  116963. */
  116964. kernel: number;
  116965. /**
  116966. * Creates a new instance of @see BloomEffect
  116967. * @param scene The scene the effect belongs to.
  116968. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  116969. * @param bloomKernel The size of the kernel to be used when applying the blur.
  116970. * @param bloomWeight The the strength of bloom.
  116971. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  116972. * @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)
  116973. */
  116974. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  116975. /**
  116976. * Disposes each of the internal effects for a given camera.
  116977. * @param camera The camera to dispose the effect on.
  116978. */
  116979. disposeEffects(camera: Camera): void;
  116980. /**
  116981. * @hidden Internal
  116982. */
  116983. _updateEffects(): void;
  116984. /**
  116985. * Internal
  116986. * @returns if all the contained post processes are ready.
  116987. * @hidden
  116988. */
  116989. _isReady(): boolean;
  116990. }
  116991. }
  116992. declare module BABYLON {
  116993. /** @hidden */
  116994. export var chromaticAberrationPixelShader: {
  116995. name: string;
  116996. shader: string;
  116997. };
  116998. }
  116999. declare module BABYLON {
  117000. /**
  117001. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  117002. */
  117003. export class ChromaticAberrationPostProcess extends PostProcess {
  117004. /**
  117005. * The amount of seperation of rgb channels (default: 30)
  117006. */
  117007. aberrationAmount: number;
  117008. /**
  117009. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  117010. */
  117011. radialIntensity: number;
  117012. /**
  117013. * 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))
  117014. */
  117015. direction: Vector2;
  117016. /**
  117017. * 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))
  117018. */
  117019. centerPosition: Vector2;
  117020. /**
  117021. * Creates a new instance ChromaticAberrationPostProcess
  117022. * @param name The name of the effect.
  117023. * @param screenWidth The width of the screen to apply the effect on.
  117024. * @param screenHeight The height of the screen to apply the effect on.
  117025. * @param options The required width/height ratio to downsize to before computing the render pass.
  117026. * @param camera The camera to apply the render pass to.
  117027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117028. * @param engine The engine which the post process will be applied. (default: current engine)
  117029. * @param reusable If the post process can be reused on the same frame. (default: false)
  117030. * @param textureType Type of textures used when performing the post process. (default: 0)
  117031. * @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)
  117032. */
  117033. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117034. }
  117035. }
  117036. declare module BABYLON {
  117037. /** @hidden */
  117038. export var circleOfConfusionPixelShader: {
  117039. name: string;
  117040. shader: string;
  117041. };
  117042. }
  117043. declare module BABYLON {
  117044. /**
  117045. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  117046. */
  117047. export class CircleOfConfusionPostProcess extends PostProcess {
  117048. /**
  117049. * 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.
  117050. */
  117051. lensSize: number;
  117052. /**
  117053. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117054. */
  117055. fStop: number;
  117056. /**
  117057. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117058. */
  117059. focusDistance: number;
  117060. /**
  117061. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  117062. */
  117063. focalLength: number;
  117064. private _depthTexture;
  117065. /**
  117066. * Creates a new instance CircleOfConfusionPostProcess
  117067. * @param name The name of the effect.
  117068. * @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.
  117069. * @param options The required width/height ratio to downsize to before computing the render pass.
  117070. * @param camera The camera to apply the render pass to.
  117071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117072. * @param engine The engine which the post process will be applied. (default: current engine)
  117073. * @param reusable If the post process can be reused on the same frame. (default: false)
  117074. * @param textureType Type of textures used when performing the post process. (default: 0)
  117075. * @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)
  117076. */
  117077. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117078. /**
  117079. * 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.
  117080. */
  117081. depthTexture: RenderTargetTexture;
  117082. }
  117083. }
  117084. declare module BABYLON {
  117085. /** @hidden */
  117086. export var colorCorrectionPixelShader: {
  117087. name: string;
  117088. shader: string;
  117089. };
  117090. }
  117091. declare module BABYLON {
  117092. /**
  117093. *
  117094. * This post-process allows the modification of rendered colors by using
  117095. * a 'look-up table' (LUT). This effect is also called Color Grading.
  117096. *
  117097. * The object needs to be provided an url to a texture containing the color
  117098. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  117099. * Use an image editing software to tweak the LUT to match your needs.
  117100. *
  117101. * For an example of a color LUT, see here:
  117102. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  117103. * For explanations on color grading, see here:
  117104. * @see http://udn.epicgames.com/Three/ColorGrading.html
  117105. *
  117106. */
  117107. export class ColorCorrectionPostProcess extends PostProcess {
  117108. private _colorTableTexture;
  117109. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117110. }
  117111. }
  117112. declare module BABYLON {
  117113. /** @hidden */
  117114. export var convolutionPixelShader: {
  117115. name: string;
  117116. shader: string;
  117117. };
  117118. }
  117119. declare module BABYLON {
  117120. /**
  117121. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  117122. * input texture to perform effects such as edge detection or sharpening
  117123. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  117124. */
  117125. export class ConvolutionPostProcess extends PostProcess {
  117126. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  117127. kernel: number[];
  117128. /**
  117129. * Creates a new instance ConvolutionPostProcess
  117130. * @param name The name of the effect.
  117131. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  117132. * @param options The required width/height ratio to downsize to before computing the render pass.
  117133. * @param camera The camera to apply the render pass to.
  117134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117135. * @param engine The engine which the post process will be applied. (default: current engine)
  117136. * @param reusable If the post process can be reused on the same frame. (default: false)
  117137. * @param textureType Type of textures used when performing the post process. (default: 0)
  117138. */
  117139. constructor(name: string,
  117140. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  117141. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117142. /**
  117143. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117144. */
  117145. static EdgeDetect0Kernel: number[];
  117146. /**
  117147. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117148. */
  117149. static EdgeDetect1Kernel: number[];
  117150. /**
  117151. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117152. */
  117153. static EdgeDetect2Kernel: number[];
  117154. /**
  117155. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117156. */
  117157. static SharpenKernel: number[];
  117158. /**
  117159. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117160. */
  117161. static EmbossKernel: number[];
  117162. /**
  117163. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117164. */
  117165. static GaussianKernel: number[];
  117166. }
  117167. }
  117168. declare module BABYLON {
  117169. /**
  117170. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  117171. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  117172. * based on samples that have a large difference in distance than the center pixel.
  117173. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  117174. */
  117175. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  117176. direction: Vector2;
  117177. /**
  117178. * Creates a new instance CircleOfConfusionPostProcess
  117179. * @param name The name of the effect.
  117180. * @param scene The scene the effect belongs to.
  117181. * @param direction The direction the blur should be applied.
  117182. * @param kernel The size of the kernel used to blur.
  117183. * @param options The required width/height ratio to downsize to before computing the render pass.
  117184. * @param camera The camera to apply the render pass to.
  117185. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  117186. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  117187. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117188. * @param engine The engine which the post process will be applied. (default: current engine)
  117189. * @param reusable If the post process can be reused on the same frame. (default: false)
  117190. * @param textureType Type of textures used when performing the post process. (default: 0)
  117191. * @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)
  117192. */
  117193. 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);
  117194. }
  117195. }
  117196. declare module BABYLON {
  117197. /** @hidden */
  117198. export var depthOfFieldMergePixelShader: {
  117199. name: string;
  117200. shader: string;
  117201. };
  117202. }
  117203. declare module BABYLON {
  117204. /**
  117205. * Options to be set when merging outputs from the default pipeline.
  117206. */
  117207. export class DepthOfFieldMergePostProcessOptions {
  117208. /**
  117209. * The original image to merge on top of
  117210. */
  117211. originalFromInput: PostProcess;
  117212. /**
  117213. * Parameters to perform the merge of the depth of field effect
  117214. */
  117215. depthOfField?: {
  117216. circleOfConfusion: PostProcess;
  117217. blurSteps: Array<PostProcess>;
  117218. };
  117219. /**
  117220. * Parameters to perform the merge of bloom effect
  117221. */
  117222. bloom?: {
  117223. blurred: PostProcess;
  117224. weight: number;
  117225. };
  117226. }
  117227. /**
  117228. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117229. */
  117230. export class DepthOfFieldMergePostProcess extends PostProcess {
  117231. private blurSteps;
  117232. /**
  117233. * Creates a new instance of DepthOfFieldMergePostProcess
  117234. * @param name The name of the effect.
  117235. * @param originalFromInput Post process which's input will be used for the merge.
  117236. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  117237. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  117238. * @param options The required width/height ratio to downsize to before computing the render pass.
  117239. * @param camera The camera to apply the render pass to.
  117240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117241. * @param engine The engine which the post process will be applied. (default: current engine)
  117242. * @param reusable If the post process can be reused on the same frame. (default: false)
  117243. * @param textureType Type of textures used when performing the post process. (default: 0)
  117244. * @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)
  117245. */
  117246. 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);
  117247. /**
  117248. * Updates the effect with the current post process compile time values and recompiles the shader.
  117249. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  117250. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  117251. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  117252. * @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
  117253. * @param onCompiled Called when the shader has been compiled.
  117254. * @param onError Called if there is an error when compiling a shader.
  117255. */
  117256. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  117257. }
  117258. }
  117259. declare module BABYLON {
  117260. /**
  117261. * Specifies the level of max blur that should be applied when using the depth of field effect
  117262. */
  117263. export enum DepthOfFieldEffectBlurLevel {
  117264. /**
  117265. * Subtle blur
  117266. */
  117267. Low = 0,
  117268. /**
  117269. * Medium blur
  117270. */
  117271. Medium = 1,
  117272. /**
  117273. * Large blur
  117274. */
  117275. High = 2
  117276. }
  117277. /**
  117278. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  117279. */
  117280. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  117281. private _circleOfConfusion;
  117282. /**
  117283. * @hidden Internal, blurs from high to low
  117284. */
  117285. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  117286. private _depthOfFieldBlurY;
  117287. private _dofMerge;
  117288. /**
  117289. * @hidden Internal post processes in depth of field effect
  117290. */
  117291. _effects: Array<PostProcess>;
  117292. /**
  117293. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  117294. */
  117295. focalLength: number;
  117296. /**
  117297. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117298. */
  117299. fStop: number;
  117300. /**
  117301. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117302. */
  117303. focusDistance: number;
  117304. /**
  117305. * 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.
  117306. */
  117307. lensSize: number;
  117308. /**
  117309. * Creates a new instance DepthOfFieldEffect
  117310. * @param scene The scene the effect belongs to.
  117311. * @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.
  117312. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117313. * @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)
  117314. */
  117315. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  117316. /**
  117317. * Get the current class name of the current effet
  117318. * @returns "DepthOfFieldEffect"
  117319. */
  117320. getClassName(): string;
  117321. /**
  117322. * 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.
  117323. */
  117324. depthTexture: RenderTargetTexture;
  117325. /**
  117326. * Disposes each of the internal effects for a given camera.
  117327. * @param camera The camera to dispose the effect on.
  117328. */
  117329. disposeEffects(camera: Camera): void;
  117330. /**
  117331. * @hidden Internal
  117332. */
  117333. _updateEffects(): void;
  117334. /**
  117335. * Internal
  117336. * @returns if all the contained post processes are ready.
  117337. * @hidden
  117338. */
  117339. _isReady(): boolean;
  117340. }
  117341. }
  117342. declare module BABYLON {
  117343. /** @hidden */
  117344. export var displayPassPixelShader: {
  117345. name: string;
  117346. shader: string;
  117347. };
  117348. }
  117349. declare module BABYLON {
  117350. /**
  117351. * DisplayPassPostProcess which produces an output the same as it's input
  117352. */
  117353. export class DisplayPassPostProcess extends PostProcess {
  117354. /**
  117355. * Creates the DisplayPassPostProcess
  117356. * @param name The name of the effect.
  117357. * @param options The required width/height ratio to downsize to before computing the render pass.
  117358. * @param camera The camera to apply the render pass to.
  117359. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117360. * @param engine The engine which the post process will be applied. (default: current engine)
  117361. * @param reusable If the post process can be reused on the same frame. (default: false)
  117362. */
  117363. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117364. }
  117365. }
  117366. declare module BABYLON {
  117367. /** @hidden */
  117368. export var filterPixelShader: {
  117369. name: string;
  117370. shader: string;
  117371. };
  117372. }
  117373. declare module BABYLON {
  117374. /**
  117375. * Applies a kernel filter to the image
  117376. */
  117377. export class FilterPostProcess extends PostProcess {
  117378. /** The matrix to be applied to the image */
  117379. kernelMatrix: Matrix;
  117380. /**
  117381. *
  117382. * @param name The name of the effect.
  117383. * @param kernelMatrix The matrix to be applied to the image
  117384. * @param options The required width/height ratio to downsize to before computing the render pass.
  117385. * @param camera The camera to apply the render pass to.
  117386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117387. * @param engine The engine which the post process will be applied. (default: current engine)
  117388. * @param reusable If the post process can be reused on the same frame. (default: false)
  117389. */
  117390. constructor(name: string,
  117391. /** The matrix to be applied to the image */
  117392. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117393. }
  117394. }
  117395. declare module BABYLON {
  117396. /** @hidden */
  117397. export var fxaaPixelShader: {
  117398. name: string;
  117399. shader: string;
  117400. };
  117401. }
  117402. declare module BABYLON {
  117403. /** @hidden */
  117404. export var fxaaVertexShader: {
  117405. name: string;
  117406. shader: string;
  117407. };
  117408. }
  117409. declare module BABYLON {
  117410. /**
  117411. * Fxaa post process
  117412. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  117413. */
  117414. export class FxaaPostProcess extends PostProcess {
  117415. /** @hidden */
  117416. texelWidth: number;
  117417. /** @hidden */
  117418. texelHeight: number;
  117419. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117420. private _getDefines;
  117421. }
  117422. }
  117423. declare module BABYLON {
  117424. /** @hidden */
  117425. export var grainPixelShader: {
  117426. name: string;
  117427. shader: string;
  117428. };
  117429. }
  117430. declare module BABYLON {
  117431. /**
  117432. * The GrainPostProcess adds noise to the image at mid luminance levels
  117433. */
  117434. export class GrainPostProcess extends PostProcess {
  117435. /**
  117436. * The intensity of the grain added (default: 30)
  117437. */
  117438. intensity: number;
  117439. /**
  117440. * If the grain should be randomized on every frame
  117441. */
  117442. animated: boolean;
  117443. /**
  117444. * Creates a new instance of @see GrainPostProcess
  117445. * @param name The name of the effect.
  117446. * @param options The required width/height ratio to downsize to before computing the render pass.
  117447. * @param camera The camera to apply the render pass to.
  117448. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117449. * @param engine The engine which the post process will be applied. (default: current engine)
  117450. * @param reusable If the post process can be reused on the same frame. (default: false)
  117451. * @param textureType Type of textures used when performing the post process. (default: 0)
  117452. * @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)
  117453. */
  117454. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117455. }
  117456. }
  117457. declare module BABYLON {
  117458. /** @hidden */
  117459. export var highlightsPixelShader: {
  117460. name: string;
  117461. shader: string;
  117462. };
  117463. }
  117464. declare module BABYLON {
  117465. /**
  117466. * Extracts highlights from the image
  117467. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117468. */
  117469. export class HighlightsPostProcess extends PostProcess {
  117470. /**
  117471. * Extracts highlights from the image
  117472. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117473. * @param name The name of the effect.
  117474. * @param options The required width/height ratio to downsize to before computing the render pass.
  117475. * @param camera The camera to apply the render pass to.
  117476. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117477. * @param engine The engine which the post process will be applied. (default: current engine)
  117478. * @param reusable If the post process can be reused on the same frame. (default: false)
  117479. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  117480. */
  117481. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117482. }
  117483. }
  117484. declare module BABYLON {
  117485. /** @hidden */
  117486. export var mrtFragmentDeclaration: {
  117487. name: string;
  117488. shader: string;
  117489. };
  117490. }
  117491. declare module BABYLON {
  117492. /** @hidden */
  117493. export var geometryPixelShader: {
  117494. name: string;
  117495. shader: string;
  117496. };
  117497. }
  117498. declare module BABYLON {
  117499. /** @hidden */
  117500. export var geometryVertexShader: {
  117501. name: string;
  117502. shader: string;
  117503. };
  117504. }
  117505. declare module BABYLON {
  117506. /** @hidden */
  117507. interface ISavedTransformationMatrix {
  117508. world: Matrix;
  117509. viewProjection: Matrix;
  117510. }
  117511. /**
  117512. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  117513. */
  117514. export class GeometryBufferRenderer {
  117515. /**
  117516. * Constant used to retrieve the position texture index in the G-Buffer textures array
  117517. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  117518. */
  117519. static readonly POSITION_TEXTURE_TYPE: number;
  117520. /**
  117521. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  117522. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  117523. */
  117524. static readonly VELOCITY_TEXTURE_TYPE: number;
  117525. /**
  117526. * Dictionary used to store the previous transformation matrices of each rendered mesh
  117527. * in order to compute objects velocities when enableVelocity is set to "true"
  117528. * @hidden
  117529. */
  117530. _previousTransformationMatrices: {
  117531. [index: number]: ISavedTransformationMatrix;
  117532. };
  117533. /**
  117534. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  117535. * in order to compute objects velocities when enableVelocity is set to "true"
  117536. * @hidden
  117537. */
  117538. _previousBonesTransformationMatrices: {
  117539. [index: number]: Float32Array;
  117540. };
  117541. /**
  117542. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  117543. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  117544. */
  117545. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  117546. private _scene;
  117547. private _multiRenderTarget;
  117548. private _ratio;
  117549. private _enablePosition;
  117550. private _enableVelocity;
  117551. private _positionIndex;
  117552. private _velocityIndex;
  117553. protected _effect: Effect;
  117554. protected _cachedDefines: string;
  117555. /**
  117556. * Set the render list (meshes to be rendered) used in the G buffer.
  117557. */
  117558. renderList: Mesh[];
  117559. /**
  117560. * Gets wether or not G buffer are supported by the running hardware.
  117561. * This requires draw buffer supports
  117562. */
  117563. readonly isSupported: boolean;
  117564. /**
  117565. * Returns the index of the given texture type in the G-Buffer textures array
  117566. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  117567. * @returns the index of the given texture type in the G-Buffer textures array
  117568. */
  117569. getTextureIndex(textureType: number): number;
  117570. /**
  117571. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  117572. */
  117573. /**
  117574. * Sets whether or not objects positions are enabled for the G buffer.
  117575. */
  117576. enablePosition: boolean;
  117577. /**
  117578. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  117579. */
  117580. /**
  117581. * Sets wether or not objects velocities are enabled for the G buffer.
  117582. */
  117583. enableVelocity: boolean;
  117584. /**
  117585. * Gets the scene associated with the buffer.
  117586. */
  117587. readonly scene: Scene;
  117588. /**
  117589. * Gets the ratio used by the buffer during its creation.
  117590. * How big is the buffer related to the main canvas.
  117591. */
  117592. readonly ratio: number;
  117593. /** @hidden */
  117594. static _SceneComponentInitialization: (scene: Scene) => void;
  117595. /**
  117596. * Creates a new G Buffer for the scene
  117597. * @param scene The scene the buffer belongs to
  117598. * @param ratio How big is the buffer related to the main canvas.
  117599. */
  117600. constructor(scene: Scene, ratio?: number);
  117601. /**
  117602. * Checks wether everything is ready to render a submesh to the G buffer.
  117603. * @param subMesh the submesh to check readiness for
  117604. * @param useInstances is the mesh drawn using instance or not
  117605. * @returns true if ready otherwise false
  117606. */
  117607. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117608. /**
  117609. * Gets the current underlying G Buffer.
  117610. * @returns the buffer
  117611. */
  117612. getGBuffer(): MultiRenderTarget;
  117613. /**
  117614. * Gets the number of samples used to render the buffer (anti aliasing).
  117615. */
  117616. /**
  117617. * Sets the number of samples used to render the buffer (anti aliasing).
  117618. */
  117619. samples: number;
  117620. /**
  117621. * Disposes the renderer and frees up associated resources.
  117622. */
  117623. dispose(): void;
  117624. protected _createRenderTargets(): void;
  117625. private _copyBonesTransformationMatrices;
  117626. }
  117627. }
  117628. declare module BABYLON {
  117629. interface Scene {
  117630. /** @hidden (Backing field) */
  117631. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  117632. /**
  117633. * Gets or Sets the current geometry buffer associated to the scene.
  117634. */
  117635. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  117636. /**
  117637. * Enables a GeometryBufferRender and associates it with the scene
  117638. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  117639. * @returns the GeometryBufferRenderer
  117640. */
  117641. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  117642. /**
  117643. * Disables the GeometryBufferRender associated with the scene
  117644. */
  117645. disableGeometryBufferRenderer(): void;
  117646. }
  117647. /**
  117648. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  117649. * in several rendering techniques.
  117650. */
  117651. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  117652. /**
  117653. * The component name helpful to identify the component in the list of scene components.
  117654. */
  117655. readonly name: string;
  117656. /**
  117657. * The scene the component belongs to.
  117658. */
  117659. scene: Scene;
  117660. /**
  117661. * Creates a new instance of the component for the given scene
  117662. * @param scene Defines the scene to register the component in
  117663. */
  117664. constructor(scene: Scene);
  117665. /**
  117666. * Registers the component in a given scene
  117667. */
  117668. register(): void;
  117669. /**
  117670. * Rebuilds the elements related to this component in case of
  117671. * context lost for instance.
  117672. */
  117673. rebuild(): void;
  117674. /**
  117675. * Disposes the component and the associated ressources
  117676. */
  117677. dispose(): void;
  117678. private _gatherRenderTargets;
  117679. }
  117680. }
  117681. declare module BABYLON {
  117682. /** @hidden */
  117683. export var motionBlurPixelShader: {
  117684. name: string;
  117685. shader: string;
  117686. };
  117687. }
  117688. declare module BABYLON {
  117689. /**
  117690. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  117691. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  117692. * As an example, all you have to do is to create the post-process:
  117693. * var mb = new BABYLON.MotionBlurPostProcess(
  117694. * 'mb', // The name of the effect.
  117695. * scene, // The scene containing the objects to blur according to their velocity.
  117696. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  117697. * camera // The camera to apply the render pass to.
  117698. * );
  117699. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  117700. */
  117701. export class MotionBlurPostProcess extends PostProcess {
  117702. /**
  117703. * Defines how much the image is blurred by the movement. Default value is equal to 1
  117704. */
  117705. motionStrength: number;
  117706. /**
  117707. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  117708. */
  117709. /**
  117710. * Sets the number of iterations to be used for motion blur quality
  117711. */
  117712. motionBlurSamples: number;
  117713. private _motionBlurSamples;
  117714. private _geometryBufferRenderer;
  117715. /**
  117716. * Creates a new instance MotionBlurPostProcess
  117717. * @param name The name of the effect.
  117718. * @param scene The scene containing the objects to blur according to their velocity.
  117719. * @param options The required width/height ratio to downsize to before computing the render pass.
  117720. * @param camera The camera to apply the render pass to.
  117721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117722. * @param engine The engine which the post process will be applied. (default: current engine)
  117723. * @param reusable If the post process can be reused on the same frame. (default: false)
  117724. * @param textureType Type of textures used when performing the post process. (default: 0)
  117725. * @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)
  117726. */
  117727. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117728. /**
  117729. * Excludes the given skinned mesh from computing bones velocities.
  117730. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  117731. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  117732. */
  117733. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  117734. /**
  117735. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  117736. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  117737. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  117738. */
  117739. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  117740. /**
  117741. * Disposes the post process.
  117742. * @param camera The camera to dispose the post process on.
  117743. */
  117744. dispose(camera?: Camera): void;
  117745. }
  117746. }
  117747. declare module BABYLON {
  117748. /** @hidden */
  117749. export var refractionPixelShader: {
  117750. name: string;
  117751. shader: string;
  117752. };
  117753. }
  117754. declare module BABYLON {
  117755. /**
  117756. * Post process which applies a refractin texture
  117757. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  117758. */
  117759. export class RefractionPostProcess extends PostProcess {
  117760. /** the base color of the refraction (used to taint the rendering) */
  117761. color: Color3;
  117762. /** simulated refraction depth */
  117763. depth: number;
  117764. /** the coefficient of the base color (0 to remove base color tainting) */
  117765. colorLevel: number;
  117766. private _refTexture;
  117767. private _ownRefractionTexture;
  117768. /**
  117769. * Gets or sets the refraction texture
  117770. * Please note that you are responsible for disposing the texture if you set it manually
  117771. */
  117772. refractionTexture: Texture;
  117773. /**
  117774. * Initializes the RefractionPostProcess
  117775. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  117776. * @param name The name of the effect.
  117777. * @param refractionTextureUrl Url of the refraction texture to use
  117778. * @param color the base color of the refraction (used to taint the rendering)
  117779. * @param depth simulated refraction depth
  117780. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  117781. * @param camera The camera to apply the render pass to.
  117782. * @param options The required width/height ratio to downsize to before computing the render pass.
  117783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117784. * @param engine The engine which the post process will be applied. (default: current engine)
  117785. * @param reusable If the post process can be reused on the same frame. (default: false)
  117786. */
  117787. constructor(name: string, refractionTextureUrl: string,
  117788. /** the base color of the refraction (used to taint the rendering) */
  117789. color: Color3,
  117790. /** simulated refraction depth */
  117791. depth: number,
  117792. /** the coefficient of the base color (0 to remove base color tainting) */
  117793. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117794. /**
  117795. * Disposes of the post process
  117796. * @param camera Camera to dispose post process on
  117797. */
  117798. dispose(camera: Camera): void;
  117799. }
  117800. }
  117801. declare module BABYLON {
  117802. /** @hidden */
  117803. export var sharpenPixelShader: {
  117804. name: string;
  117805. shader: string;
  117806. };
  117807. }
  117808. declare module BABYLON {
  117809. /**
  117810. * The SharpenPostProcess applies a sharpen kernel to every pixel
  117811. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  117812. */
  117813. export class SharpenPostProcess extends PostProcess {
  117814. /**
  117815. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  117816. */
  117817. colorAmount: number;
  117818. /**
  117819. * How much sharpness should be applied (default: 0.3)
  117820. */
  117821. edgeAmount: number;
  117822. /**
  117823. * Creates a new instance ConvolutionPostProcess
  117824. * @param name The name of the effect.
  117825. * @param options The required width/height ratio to downsize to before computing the render pass.
  117826. * @param camera The camera to apply the render pass to.
  117827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117828. * @param engine The engine which the post process will be applied. (default: current engine)
  117829. * @param reusable If the post process can be reused on the same frame. (default: false)
  117830. * @param textureType Type of textures used when performing the post process. (default: 0)
  117831. * @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)
  117832. */
  117833. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117834. }
  117835. }
  117836. declare module BABYLON {
  117837. /**
  117838. * PostProcessRenderPipeline
  117839. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117840. */
  117841. export class PostProcessRenderPipeline {
  117842. private engine;
  117843. private _renderEffects;
  117844. private _renderEffectsForIsolatedPass;
  117845. /**
  117846. * List of inspectable custom properties (used by the Inspector)
  117847. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  117848. */
  117849. inspectableCustomProperties: IInspectable[];
  117850. /**
  117851. * @hidden
  117852. */
  117853. protected _cameras: Camera[];
  117854. /** @hidden */
  117855. _name: string;
  117856. /**
  117857. * Gets pipeline name
  117858. */
  117859. readonly name: string;
  117860. /**
  117861. * Initializes a PostProcessRenderPipeline
  117862. * @param engine engine to add the pipeline to
  117863. * @param name name of the pipeline
  117864. */
  117865. constructor(engine: Engine, name: string);
  117866. /**
  117867. * Gets the class name
  117868. * @returns "PostProcessRenderPipeline"
  117869. */
  117870. getClassName(): string;
  117871. /**
  117872. * If all the render effects in the pipeline are supported
  117873. */
  117874. readonly isSupported: boolean;
  117875. /**
  117876. * Adds an effect to the pipeline
  117877. * @param renderEffect the effect to add
  117878. */
  117879. addEffect(renderEffect: PostProcessRenderEffect): void;
  117880. /** @hidden */
  117881. _rebuild(): void;
  117882. /** @hidden */
  117883. _enableEffect(renderEffectName: string, cameras: Camera): void;
  117884. /** @hidden */
  117885. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  117886. /** @hidden */
  117887. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  117888. /** @hidden */
  117889. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  117890. /** @hidden */
  117891. _attachCameras(cameras: Camera, unique: boolean): void;
  117892. /** @hidden */
  117893. _attachCameras(cameras: Camera[], unique: boolean): void;
  117894. /** @hidden */
  117895. _detachCameras(cameras: Camera): void;
  117896. /** @hidden */
  117897. _detachCameras(cameras: Nullable<Camera[]>): void;
  117898. /** @hidden */
  117899. _update(): void;
  117900. /** @hidden */
  117901. _reset(): void;
  117902. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  117903. /**
  117904. * Disposes of the pipeline
  117905. */
  117906. dispose(): void;
  117907. }
  117908. }
  117909. declare module BABYLON {
  117910. /**
  117911. * PostProcessRenderPipelineManager class
  117912. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117913. */
  117914. export class PostProcessRenderPipelineManager {
  117915. private _renderPipelines;
  117916. /**
  117917. * Initializes a PostProcessRenderPipelineManager
  117918. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117919. */
  117920. constructor();
  117921. /**
  117922. * Gets the list of supported render pipelines
  117923. */
  117924. readonly supportedPipelines: PostProcessRenderPipeline[];
  117925. /**
  117926. * Adds a pipeline to the manager
  117927. * @param renderPipeline The pipeline to add
  117928. */
  117929. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  117930. /**
  117931. * Attaches a camera to the pipeline
  117932. * @param renderPipelineName The name of the pipeline to attach to
  117933. * @param cameras the camera to attach
  117934. * @param unique if the camera can be attached multiple times to the pipeline
  117935. */
  117936. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  117937. /**
  117938. * Detaches a camera from the pipeline
  117939. * @param renderPipelineName The name of the pipeline to detach from
  117940. * @param cameras the camera to detach
  117941. */
  117942. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  117943. /**
  117944. * Enables an effect by name on a pipeline
  117945. * @param renderPipelineName the name of the pipeline to enable the effect in
  117946. * @param renderEffectName the name of the effect to enable
  117947. * @param cameras the cameras that the effect should be enabled on
  117948. */
  117949. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  117950. /**
  117951. * Disables an effect by name on a pipeline
  117952. * @param renderPipelineName the name of the pipeline to disable the effect in
  117953. * @param renderEffectName the name of the effect to disable
  117954. * @param cameras the cameras that the effect should be disabled on
  117955. */
  117956. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  117957. /**
  117958. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  117959. */
  117960. update(): void;
  117961. /** @hidden */
  117962. _rebuild(): void;
  117963. /**
  117964. * Disposes of the manager and pipelines
  117965. */
  117966. dispose(): void;
  117967. }
  117968. }
  117969. declare module BABYLON {
  117970. interface Scene {
  117971. /** @hidden (Backing field) */
  117972. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  117973. /**
  117974. * Gets the postprocess render pipeline manager
  117975. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117976. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  117977. */
  117978. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  117979. }
  117980. /**
  117981. * Defines the Render Pipeline scene component responsible to rendering pipelines
  117982. */
  117983. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  117984. /**
  117985. * The component name helpfull to identify the component in the list of scene components.
  117986. */
  117987. readonly name: string;
  117988. /**
  117989. * The scene the component belongs to.
  117990. */
  117991. scene: Scene;
  117992. /**
  117993. * Creates a new instance of the component for the given scene
  117994. * @param scene Defines the scene to register the component in
  117995. */
  117996. constructor(scene: Scene);
  117997. /**
  117998. * Registers the component in a given scene
  117999. */
  118000. register(): void;
  118001. /**
  118002. * Rebuilds the elements related to this component in case of
  118003. * context lost for instance.
  118004. */
  118005. rebuild(): void;
  118006. /**
  118007. * Disposes the component and the associated ressources
  118008. */
  118009. dispose(): void;
  118010. private _gatherRenderTargets;
  118011. }
  118012. }
  118013. declare module BABYLON {
  118014. /**
  118015. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  118016. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118017. */
  118018. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  118019. private _scene;
  118020. private _camerasToBeAttached;
  118021. /**
  118022. * ID of the sharpen post process,
  118023. */
  118024. private readonly SharpenPostProcessId;
  118025. /**
  118026. * @ignore
  118027. * ID of the image processing post process;
  118028. */
  118029. readonly ImageProcessingPostProcessId: string;
  118030. /**
  118031. * @ignore
  118032. * ID of the Fast Approximate Anti-Aliasing post process;
  118033. */
  118034. readonly FxaaPostProcessId: string;
  118035. /**
  118036. * ID of the chromatic aberration post process,
  118037. */
  118038. private readonly ChromaticAberrationPostProcessId;
  118039. /**
  118040. * ID of the grain post process
  118041. */
  118042. private readonly GrainPostProcessId;
  118043. /**
  118044. * Sharpen post process which will apply a sharpen convolution to enhance edges
  118045. */
  118046. sharpen: SharpenPostProcess;
  118047. private _sharpenEffect;
  118048. private bloom;
  118049. /**
  118050. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  118051. */
  118052. depthOfField: DepthOfFieldEffect;
  118053. /**
  118054. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  118055. */
  118056. fxaa: FxaaPostProcess;
  118057. /**
  118058. * Image post processing pass used to perform operations such as tone mapping or color grading.
  118059. */
  118060. imageProcessing: ImageProcessingPostProcess;
  118061. /**
  118062. * Chromatic aberration post process which will shift rgb colors in the image
  118063. */
  118064. chromaticAberration: ChromaticAberrationPostProcess;
  118065. private _chromaticAberrationEffect;
  118066. /**
  118067. * Grain post process which add noise to the image
  118068. */
  118069. grain: GrainPostProcess;
  118070. private _grainEffect;
  118071. /**
  118072. * Glow post process which adds a glow to emissive areas of the image
  118073. */
  118074. private _glowLayer;
  118075. /**
  118076. * Animations which can be used to tweak settings over a period of time
  118077. */
  118078. animations: Animation[];
  118079. private _imageProcessingConfigurationObserver;
  118080. private _sharpenEnabled;
  118081. private _bloomEnabled;
  118082. private _depthOfFieldEnabled;
  118083. private _depthOfFieldBlurLevel;
  118084. private _fxaaEnabled;
  118085. private _imageProcessingEnabled;
  118086. private _defaultPipelineTextureType;
  118087. private _bloomScale;
  118088. private _chromaticAberrationEnabled;
  118089. private _grainEnabled;
  118090. private _buildAllowed;
  118091. /**
  118092. * Gets active scene
  118093. */
  118094. readonly scene: Scene;
  118095. /**
  118096. * Enable or disable the sharpen process from the pipeline
  118097. */
  118098. sharpenEnabled: boolean;
  118099. private _resizeObserver;
  118100. private _hardwareScaleLevel;
  118101. private _bloomKernel;
  118102. /**
  118103. * Specifies the size of the bloom blur kernel, relative to the final output size
  118104. */
  118105. bloomKernel: number;
  118106. /**
  118107. * Specifies the weight of the bloom in the final rendering
  118108. */
  118109. private _bloomWeight;
  118110. /**
  118111. * Specifies the luma threshold for the area that will be blurred by the bloom
  118112. */
  118113. private _bloomThreshold;
  118114. private _hdr;
  118115. /**
  118116. * The strength of the bloom.
  118117. */
  118118. bloomWeight: number;
  118119. /**
  118120. * The strength of the bloom.
  118121. */
  118122. bloomThreshold: number;
  118123. /**
  118124. * The scale of the bloom, lower value will provide better performance.
  118125. */
  118126. bloomScale: number;
  118127. /**
  118128. * Enable or disable the bloom from the pipeline
  118129. */
  118130. bloomEnabled: boolean;
  118131. private _rebuildBloom;
  118132. /**
  118133. * If the depth of field is enabled.
  118134. */
  118135. depthOfFieldEnabled: boolean;
  118136. /**
  118137. * Blur level of the depth of field effect. (Higher blur will effect performance)
  118138. */
  118139. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  118140. /**
  118141. * If the anti aliasing is enabled.
  118142. */
  118143. fxaaEnabled: boolean;
  118144. private _samples;
  118145. /**
  118146. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  118147. */
  118148. samples: number;
  118149. /**
  118150. * If image processing is enabled.
  118151. */
  118152. imageProcessingEnabled: boolean;
  118153. /**
  118154. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  118155. */
  118156. glowLayerEnabled: boolean;
  118157. /**
  118158. * Gets the glow layer (or null if not defined)
  118159. */
  118160. readonly glowLayer: Nullable<GlowLayer>;
  118161. /**
  118162. * Enable or disable the chromaticAberration process from the pipeline
  118163. */
  118164. chromaticAberrationEnabled: boolean;
  118165. /**
  118166. * Enable or disable the grain process from the pipeline
  118167. */
  118168. grainEnabled: boolean;
  118169. /**
  118170. * @constructor
  118171. * @param name - The rendering pipeline name (default: "")
  118172. * @param hdr - If high dynamic range textures should be used (default: true)
  118173. * @param scene - The scene linked to this pipeline (default: the last created scene)
  118174. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  118175. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  118176. */
  118177. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  118178. /**
  118179. * Get the class name
  118180. * @returns "DefaultRenderingPipeline"
  118181. */
  118182. getClassName(): string;
  118183. /**
  118184. * Force the compilation of the entire pipeline.
  118185. */
  118186. prepare(): void;
  118187. private _hasCleared;
  118188. private _prevPostProcess;
  118189. private _prevPrevPostProcess;
  118190. private _setAutoClearAndTextureSharing;
  118191. private _depthOfFieldSceneObserver;
  118192. private _buildPipeline;
  118193. private _disposePostProcesses;
  118194. /**
  118195. * Adds a camera to the pipeline
  118196. * @param camera the camera to be added
  118197. */
  118198. addCamera(camera: Camera): void;
  118199. /**
  118200. * Removes a camera from the pipeline
  118201. * @param camera the camera to remove
  118202. */
  118203. removeCamera(camera: Camera): void;
  118204. /**
  118205. * Dispose of the pipeline and stop all post processes
  118206. */
  118207. dispose(): void;
  118208. /**
  118209. * Serialize the rendering pipeline (Used when exporting)
  118210. * @returns the serialized object
  118211. */
  118212. serialize(): any;
  118213. /**
  118214. * Parse the serialized pipeline
  118215. * @param source Source pipeline.
  118216. * @param scene The scene to load the pipeline to.
  118217. * @param rootUrl The URL of the serialized pipeline.
  118218. * @returns An instantiated pipeline from the serialized object.
  118219. */
  118220. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  118221. }
  118222. }
  118223. declare module BABYLON {
  118224. /** @hidden */
  118225. export var lensHighlightsPixelShader: {
  118226. name: string;
  118227. shader: string;
  118228. };
  118229. }
  118230. declare module BABYLON {
  118231. /** @hidden */
  118232. export var depthOfFieldPixelShader: {
  118233. name: string;
  118234. shader: string;
  118235. };
  118236. }
  118237. declare module BABYLON {
  118238. /**
  118239. * BABYLON.JS Chromatic Aberration GLSL Shader
  118240. * Author: Olivier Guyot
  118241. * Separates very slightly R, G and B colors on the edges of the screen
  118242. * Inspired by Francois Tarlier & Martins Upitis
  118243. */
  118244. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  118245. /**
  118246. * @ignore
  118247. * The chromatic aberration PostProcess id in the pipeline
  118248. */
  118249. LensChromaticAberrationEffect: string;
  118250. /**
  118251. * @ignore
  118252. * The highlights enhancing PostProcess id in the pipeline
  118253. */
  118254. HighlightsEnhancingEffect: string;
  118255. /**
  118256. * @ignore
  118257. * The depth-of-field PostProcess id in the pipeline
  118258. */
  118259. LensDepthOfFieldEffect: string;
  118260. private _scene;
  118261. private _depthTexture;
  118262. private _grainTexture;
  118263. private _chromaticAberrationPostProcess;
  118264. private _highlightsPostProcess;
  118265. private _depthOfFieldPostProcess;
  118266. private _edgeBlur;
  118267. private _grainAmount;
  118268. private _chromaticAberration;
  118269. private _distortion;
  118270. private _highlightsGain;
  118271. private _highlightsThreshold;
  118272. private _dofDistance;
  118273. private _dofAperture;
  118274. private _dofDarken;
  118275. private _dofPentagon;
  118276. private _blurNoise;
  118277. /**
  118278. * @constructor
  118279. *
  118280. * Effect parameters are as follow:
  118281. * {
  118282. * chromatic_aberration: number; // from 0 to x (1 for realism)
  118283. * edge_blur: number; // from 0 to x (1 for realism)
  118284. * distortion: number; // from 0 to x (1 for realism)
  118285. * grain_amount: number; // from 0 to 1
  118286. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  118287. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  118288. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  118289. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  118290. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  118291. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  118292. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  118293. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  118294. * }
  118295. * Note: if an effect parameter is unset, effect is disabled
  118296. *
  118297. * @param name The rendering pipeline name
  118298. * @param parameters - An object containing all parameters (see above)
  118299. * @param scene The scene linked to this pipeline
  118300. * @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)
  118301. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118302. */
  118303. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  118304. /**
  118305. * Get the class name
  118306. * @returns "LensRenderingPipeline"
  118307. */
  118308. getClassName(): string;
  118309. /**
  118310. * Gets associated scene
  118311. */
  118312. readonly scene: Scene;
  118313. /**
  118314. * Gets or sets the edge blur
  118315. */
  118316. edgeBlur: number;
  118317. /**
  118318. * Gets or sets the grain amount
  118319. */
  118320. grainAmount: number;
  118321. /**
  118322. * Gets or sets the chromatic aberration amount
  118323. */
  118324. chromaticAberration: number;
  118325. /**
  118326. * Gets or sets the depth of field aperture
  118327. */
  118328. dofAperture: number;
  118329. /**
  118330. * Gets or sets the edge distortion
  118331. */
  118332. edgeDistortion: number;
  118333. /**
  118334. * Gets or sets the depth of field distortion
  118335. */
  118336. dofDistortion: number;
  118337. /**
  118338. * Gets or sets the darken out of focus amount
  118339. */
  118340. darkenOutOfFocus: number;
  118341. /**
  118342. * Gets or sets a boolean indicating if blur noise is enabled
  118343. */
  118344. blurNoise: boolean;
  118345. /**
  118346. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  118347. */
  118348. pentagonBokeh: boolean;
  118349. /**
  118350. * Gets or sets the highlight grain amount
  118351. */
  118352. highlightsGain: number;
  118353. /**
  118354. * Gets or sets the highlight threshold
  118355. */
  118356. highlightsThreshold: number;
  118357. /**
  118358. * Sets the amount of blur at the edges
  118359. * @param amount blur amount
  118360. */
  118361. setEdgeBlur(amount: number): void;
  118362. /**
  118363. * Sets edge blur to 0
  118364. */
  118365. disableEdgeBlur(): void;
  118366. /**
  118367. * Sets the amout of grain
  118368. * @param amount Amount of grain
  118369. */
  118370. setGrainAmount(amount: number): void;
  118371. /**
  118372. * Set grain amount to 0
  118373. */
  118374. disableGrain(): void;
  118375. /**
  118376. * Sets the chromatic aberration amount
  118377. * @param amount amount of chromatic aberration
  118378. */
  118379. setChromaticAberration(amount: number): void;
  118380. /**
  118381. * Sets chromatic aberration amount to 0
  118382. */
  118383. disableChromaticAberration(): void;
  118384. /**
  118385. * Sets the EdgeDistortion amount
  118386. * @param amount amount of EdgeDistortion
  118387. */
  118388. setEdgeDistortion(amount: number): void;
  118389. /**
  118390. * Sets edge distortion to 0
  118391. */
  118392. disableEdgeDistortion(): void;
  118393. /**
  118394. * Sets the FocusDistance amount
  118395. * @param amount amount of FocusDistance
  118396. */
  118397. setFocusDistance(amount: number): void;
  118398. /**
  118399. * Disables depth of field
  118400. */
  118401. disableDepthOfField(): void;
  118402. /**
  118403. * Sets the Aperture amount
  118404. * @param amount amount of Aperture
  118405. */
  118406. setAperture(amount: number): void;
  118407. /**
  118408. * Sets the DarkenOutOfFocus amount
  118409. * @param amount amount of DarkenOutOfFocus
  118410. */
  118411. setDarkenOutOfFocus(amount: number): void;
  118412. private _pentagonBokehIsEnabled;
  118413. /**
  118414. * Creates a pentagon bokeh effect
  118415. */
  118416. enablePentagonBokeh(): void;
  118417. /**
  118418. * Disables the pentagon bokeh effect
  118419. */
  118420. disablePentagonBokeh(): void;
  118421. /**
  118422. * Enables noise blur
  118423. */
  118424. enableNoiseBlur(): void;
  118425. /**
  118426. * Disables noise blur
  118427. */
  118428. disableNoiseBlur(): void;
  118429. /**
  118430. * Sets the HighlightsGain amount
  118431. * @param amount amount of HighlightsGain
  118432. */
  118433. setHighlightsGain(amount: number): void;
  118434. /**
  118435. * Sets the HighlightsThreshold amount
  118436. * @param amount amount of HighlightsThreshold
  118437. */
  118438. setHighlightsThreshold(amount: number): void;
  118439. /**
  118440. * Disables highlights
  118441. */
  118442. disableHighlights(): void;
  118443. /**
  118444. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  118445. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  118446. */
  118447. dispose(disableDepthRender?: boolean): void;
  118448. private _createChromaticAberrationPostProcess;
  118449. private _createHighlightsPostProcess;
  118450. private _createDepthOfFieldPostProcess;
  118451. private _createGrainTexture;
  118452. }
  118453. }
  118454. declare module BABYLON {
  118455. /** @hidden */
  118456. export var ssao2PixelShader: {
  118457. name: string;
  118458. shader: string;
  118459. };
  118460. }
  118461. declare module BABYLON {
  118462. /** @hidden */
  118463. export var ssaoCombinePixelShader: {
  118464. name: string;
  118465. shader: string;
  118466. };
  118467. }
  118468. declare module BABYLON {
  118469. /**
  118470. * Render pipeline to produce ssao effect
  118471. */
  118472. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  118473. /**
  118474. * @ignore
  118475. * The PassPostProcess id in the pipeline that contains the original scene color
  118476. */
  118477. SSAOOriginalSceneColorEffect: string;
  118478. /**
  118479. * @ignore
  118480. * The SSAO PostProcess id in the pipeline
  118481. */
  118482. SSAORenderEffect: string;
  118483. /**
  118484. * @ignore
  118485. * The horizontal blur PostProcess id in the pipeline
  118486. */
  118487. SSAOBlurHRenderEffect: string;
  118488. /**
  118489. * @ignore
  118490. * The vertical blur PostProcess id in the pipeline
  118491. */
  118492. SSAOBlurVRenderEffect: string;
  118493. /**
  118494. * @ignore
  118495. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  118496. */
  118497. SSAOCombineRenderEffect: string;
  118498. /**
  118499. * The output strength of the SSAO post-process. Default value is 1.0.
  118500. */
  118501. totalStrength: number;
  118502. /**
  118503. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  118504. */
  118505. maxZ: number;
  118506. /**
  118507. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  118508. */
  118509. minZAspect: number;
  118510. private _samples;
  118511. /**
  118512. * Number of samples used for the SSAO calculations. Default value is 8
  118513. */
  118514. samples: number;
  118515. private _textureSamples;
  118516. /**
  118517. * Number of samples to use for antialiasing
  118518. */
  118519. textureSamples: number;
  118520. /**
  118521. * Ratio object used for SSAO ratio and blur ratio
  118522. */
  118523. private _ratio;
  118524. /**
  118525. * Dynamically generated sphere sampler.
  118526. */
  118527. private _sampleSphere;
  118528. /**
  118529. * Blur filter offsets
  118530. */
  118531. private _samplerOffsets;
  118532. private _expensiveBlur;
  118533. /**
  118534. * If bilateral blur should be used
  118535. */
  118536. expensiveBlur: boolean;
  118537. /**
  118538. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  118539. */
  118540. radius: number;
  118541. /**
  118542. * The base color of the SSAO post-process
  118543. * The final result is "base + ssao" between [0, 1]
  118544. */
  118545. base: number;
  118546. /**
  118547. * Support test.
  118548. */
  118549. static readonly IsSupported: boolean;
  118550. private _scene;
  118551. private _depthTexture;
  118552. private _normalTexture;
  118553. private _randomTexture;
  118554. private _originalColorPostProcess;
  118555. private _ssaoPostProcess;
  118556. private _blurHPostProcess;
  118557. private _blurVPostProcess;
  118558. private _ssaoCombinePostProcess;
  118559. private _firstUpdate;
  118560. /**
  118561. * Gets active scene
  118562. */
  118563. readonly scene: Scene;
  118564. /**
  118565. * @constructor
  118566. * @param name The rendering pipeline name
  118567. * @param scene The scene linked to this pipeline
  118568. * @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 }
  118569. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118570. */
  118571. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  118572. /**
  118573. * Get the class name
  118574. * @returns "SSAO2RenderingPipeline"
  118575. */
  118576. getClassName(): string;
  118577. /**
  118578. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  118579. */
  118580. dispose(disableGeometryBufferRenderer?: boolean): void;
  118581. private _createBlurPostProcess;
  118582. /** @hidden */
  118583. _rebuild(): void;
  118584. private _bits;
  118585. private _radicalInverse_VdC;
  118586. private _hammersley;
  118587. private _hemisphereSample_uniform;
  118588. private _generateHemisphere;
  118589. private _createSSAOPostProcess;
  118590. private _createSSAOCombinePostProcess;
  118591. private _createRandomTexture;
  118592. /**
  118593. * Serialize the rendering pipeline (Used when exporting)
  118594. * @returns the serialized object
  118595. */
  118596. serialize(): any;
  118597. /**
  118598. * Parse the serialized pipeline
  118599. * @param source Source pipeline.
  118600. * @param scene The scene to load the pipeline to.
  118601. * @param rootUrl The URL of the serialized pipeline.
  118602. * @returns An instantiated pipeline from the serialized object.
  118603. */
  118604. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  118605. }
  118606. }
  118607. declare module BABYLON {
  118608. /** @hidden */
  118609. export var ssaoPixelShader: {
  118610. name: string;
  118611. shader: string;
  118612. };
  118613. }
  118614. declare module BABYLON {
  118615. /**
  118616. * Render pipeline to produce ssao effect
  118617. */
  118618. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  118619. /**
  118620. * @ignore
  118621. * The PassPostProcess id in the pipeline that contains the original scene color
  118622. */
  118623. SSAOOriginalSceneColorEffect: string;
  118624. /**
  118625. * @ignore
  118626. * The SSAO PostProcess id in the pipeline
  118627. */
  118628. SSAORenderEffect: string;
  118629. /**
  118630. * @ignore
  118631. * The horizontal blur PostProcess id in the pipeline
  118632. */
  118633. SSAOBlurHRenderEffect: string;
  118634. /**
  118635. * @ignore
  118636. * The vertical blur PostProcess id in the pipeline
  118637. */
  118638. SSAOBlurVRenderEffect: string;
  118639. /**
  118640. * @ignore
  118641. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  118642. */
  118643. SSAOCombineRenderEffect: string;
  118644. /**
  118645. * The output strength of the SSAO post-process. Default value is 1.0.
  118646. */
  118647. totalStrength: number;
  118648. /**
  118649. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  118650. */
  118651. radius: number;
  118652. /**
  118653. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  118654. * Must not be equal to fallOff and superior to fallOff.
  118655. * Default value is 0.0075
  118656. */
  118657. area: number;
  118658. /**
  118659. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  118660. * Must not be equal to area and inferior to area.
  118661. * Default value is 0.000001
  118662. */
  118663. fallOff: number;
  118664. /**
  118665. * The base color of the SSAO post-process
  118666. * The final result is "base + ssao" between [0, 1]
  118667. */
  118668. base: number;
  118669. private _scene;
  118670. private _depthTexture;
  118671. private _randomTexture;
  118672. private _originalColorPostProcess;
  118673. private _ssaoPostProcess;
  118674. private _blurHPostProcess;
  118675. private _blurVPostProcess;
  118676. private _ssaoCombinePostProcess;
  118677. private _firstUpdate;
  118678. /**
  118679. * Gets active scene
  118680. */
  118681. readonly scene: Scene;
  118682. /**
  118683. * @constructor
  118684. * @param name - The rendering pipeline name
  118685. * @param scene - The scene linked to this pipeline
  118686. * @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 }
  118687. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  118688. */
  118689. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  118690. /**
  118691. * Get the class name
  118692. * @returns "SSAORenderingPipeline"
  118693. */
  118694. getClassName(): string;
  118695. /**
  118696. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  118697. */
  118698. dispose(disableDepthRender?: boolean): void;
  118699. private _createBlurPostProcess;
  118700. /** @hidden */
  118701. _rebuild(): void;
  118702. private _createSSAOPostProcess;
  118703. private _createSSAOCombinePostProcess;
  118704. private _createRandomTexture;
  118705. }
  118706. }
  118707. declare module BABYLON {
  118708. /** @hidden */
  118709. export var standardPixelShader: {
  118710. name: string;
  118711. shader: string;
  118712. };
  118713. }
  118714. declare module BABYLON {
  118715. /**
  118716. * Standard rendering pipeline
  118717. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  118718. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  118719. */
  118720. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  118721. /**
  118722. * Public members
  118723. */
  118724. /**
  118725. * Post-process which contains the original scene color before the pipeline applies all the effects
  118726. */
  118727. originalPostProcess: Nullable<PostProcess>;
  118728. /**
  118729. * Post-process used to down scale an image x4
  118730. */
  118731. downSampleX4PostProcess: Nullable<PostProcess>;
  118732. /**
  118733. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  118734. */
  118735. brightPassPostProcess: Nullable<PostProcess>;
  118736. /**
  118737. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  118738. */
  118739. blurHPostProcesses: PostProcess[];
  118740. /**
  118741. * Post-process array storing all the vertical blur post-processes used by the pipeline
  118742. */
  118743. blurVPostProcesses: PostProcess[];
  118744. /**
  118745. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  118746. */
  118747. textureAdderPostProcess: Nullable<PostProcess>;
  118748. /**
  118749. * Post-process used to create volumetric lighting effect
  118750. */
  118751. volumetricLightPostProcess: Nullable<PostProcess>;
  118752. /**
  118753. * Post-process used to smooth the previous volumetric light post-process on the X axis
  118754. */
  118755. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  118756. /**
  118757. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  118758. */
  118759. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  118760. /**
  118761. * Post-process used to merge the volumetric light effect and the real scene color
  118762. */
  118763. volumetricLightMergePostProces: Nullable<PostProcess>;
  118764. /**
  118765. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  118766. */
  118767. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  118768. /**
  118769. * Base post-process used to calculate the average luminance of the final image for HDR
  118770. */
  118771. luminancePostProcess: Nullable<PostProcess>;
  118772. /**
  118773. * Post-processes used to create down sample post-processes in order to get
  118774. * the average luminance of the final image for HDR
  118775. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  118776. */
  118777. luminanceDownSamplePostProcesses: PostProcess[];
  118778. /**
  118779. * Post-process used to create a HDR effect (light adaptation)
  118780. */
  118781. hdrPostProcess: Nullable<PostProcess>;
  118782. /**
  118783. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  118784. */
  118785. textureAdderFinalPostProcess: Nullable<PostProcess>;
  118786. /**
  118787. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  118788. */
  118789. lensFlareFinalPostProcess: Nullable<PostProcess>;
  118790. /**
  118791. * Post-process used to merge the final HDR post-process and the real scene color
  118792. */
  118793. hdrFinalPostProcess: Nullable<PostProcess>;
  118794. /**
  118795. * Post-process used to create a lens flare effect
  118796. */
  118797. lensFlarePostProcess: Nullable<PostProcess>;
  118798. /**
  118799. * Post-process that merges the result of the lens flare post-process and the real scene color
  118800. */
  118801. lensFlareComposePostProcess: Nullable<PostProcess>;
  118802. /**
  118803. * Post-process used to create a motion blur effect
  118804. */
  118805. motionBlurPostProcess: Nullable<PostProcess>;
  118806. /**
  118807. * Post-process used to create a depth of field effect
  118808. */
  118809. depthOfFieldPostProcess: Nullable<PostProcess>;
  118810. /**
  118811. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  118812. */
  118813. fxaaPostProcess: Nullable<FxaaPostProcess>;
  118814. /**
  118815. * Represents the brightness threshold in order to configure the illuminated surfaces
  118816. */
  118817. brightThreshold: number;
  118818. /**
  118819. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  118820. */
  118821. blurWidth: number;
  118822. /**
  118823. * Sets if the blur for highlighted surfaces must be only horizontal
  118824. */
  118825. horizontalBlur: boolean;
  118826. /**
  118827. * Gets the overall exposure used by the pipeline
  118828. */
  118829. /**
  118830. * Sets the overall exposure used by the pipeline
  118831. */
  118832. exposure: number;
  118833. /**
  118834. * Texture used typically to simulate "dirty" on camera lens
  118835. */
  118836. lensTexture: Nullable<Texture>;
  118837. /**
  118838. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  118839. */
  118840. volumetricLightCoefficient: number;
  118841. /**
  118842. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  118843. */
  118844. volumetricLightPower: number;
  118845. /**
  118846. * Used the set the blur intensity to smooth the volumetric lights
  118847. */
  118848. volumetricLightBlurScale: number;
  118849. /**
  118850. * Light (spot or directional) used to generate the volumetric lights rays
  118851. * The source light must have a shadow generate so the pipeline can get its
  118852. * depth map
  118853. */
  118854. sourceLight: Nullable<SpotLight | DirectionalLight>;
  118855. /**
  118856. * For eye adaptation, represents the minimum luminance the eye can see
  118857. */
  118858. hdrMinimumLuminance: number;
  118859. /**
  118860. * For eye adaptation, represents the decrease luminance speed
  118861. */
  118862. hdrDecreaseRate: number;
  118863. /**
  118864. * For eye adaptation, represents the increase luminance speed
  118865. */
  118866. hdrIncreaseRate: number;
  118867. /**
  118868. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  118869. */
  118870. /**
  118871. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  118872. */
  118873. hdrAutoExposure: boolean;
  118874. /**
  118875. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  118876. */
  118877. lensColorTexture: Nullable<Texture>;
  118878. /**
  118879. * The overall strengh for the lens flare effect
  118880. */
  118881. lensFlareStrength: number;
  118882. /**
  118883. * Dispersion coefficient for lens flare ghosts
  118884. */
  118885. lensFlareGhostDispersal: number;
  118886. /**
  118887. * Main lens flare halo width
  118888. */
  118889. lensFlareHaloWidth: number;
  118890. /**
  118891. * Based on the lens distortion effect, defines how much the lens flare result
  118892. * is distorted
  118893. */
  118894. lensFlareDistortionStrength: number;
  118895. /**
  118896. * Lens star texture must be used to simulate rays on the flares and is available
  118897. * in the documentation
  118898. */
  118899. lensStarTexture: Nullable<Texture>;
  118900. /**
  118901. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  118902. * flare effect by taking account of the dirt texture
  118903. */
  118904. lensFlareDirtTexture: Nullable<Texture>;
  118905. /**
  118906. * Represents the focal length for the depth of field effect
  118907. */
  118908. depthOfFieldDistance: number;
  118909. /**
  118910. * Represents the blur intensity for the blurred part of the depth of field effect
  118911. */
  118912. depthOfFieldBlurWidth: number;
  118913. /**
  118914. * Gets how much the image is blurred by the movement while using the motion blur post-process
  118915. */
  118916. /**
  118917. * Sets how much the image is blurred by the movement while using the motion blur post-process
  118918. */
  118919. motionStrength: number;
  118920. /**
  118921. * Gets wether or not the motion blur post-process is object based or screen based.
  118922. */
  118923. /**
  118924. * Sets wether or not the motion blur post-process should be object based or screen based
  118925. */
  118926. objectBasedMotionBlur: boolean;
  118927. /**
  118928. * List of animations for the pipeline (IAnimatable implementation)
  118929. */
  118930. animations: Animation[];
  118931. /**
  118932. * Private members
  118933. */
  118934. private _scene;
  118935. private _currentDepthOfFieldSource;
  118936. private _basePostProcess;
  118937. private _fixedExposure;
  118938. private _currentExposure;
  118939. private _hdrAutoExposure;
  118940. private _hdrCurrentLuminance;
  118941. private _motionStrength;
  118942. private _isObjectBasedMotionBlur;
  118943. private _floatTextureType;
  118944. private _ratio;
  118945. private _bloomEnabled;
  118946. private _depthOfFieldEnabled;
  118947. private _vlsEnabled;
  118948. private _lensFlareEnabled;
  118949. private _hdrEnabled;
  118950. private _motionBlurEnabled;
  118951. private _fxaaEnabled;
  118952. private _motionBlurSamples;
  118953. private _volumetricLightStepsCount;
  118954. private _samples;
  118955. /**
  118956. * @ignore
  118957. * Specifies if the bloom pipeline is enabled
  118958. */
  118959. BloomEnabled: boolean;
  118960. /**
  118961. * @ignore
  118962. * Specifies if the depth of field pipeline is enabed
  118963. */
  118964. DepthOfFieldEnabled: boolean;
  118965. /**
  118966. * @ignore
  118967. * Specifies if the lens flare pipeline is enabed
  118968. */
  118969. LensFlareEnabled: boolean;
  118970. /**
  118971. * @ignore
  118972. * Specifies if the HDR pipeline is enabled
  118973. */
  118974. HDREnabled: boolean;
  118975. /**
  118976. * @ignore
  118977. * Specifies if the volumetric lights scattering effect is enabled
  118978. */
  118979. VLSEnabled: boolean;
  118980. /**
  118981. * @ignore
  118982. * Specifies if the motion blur effect is enabled
  118983. */
  118984. MotionBlurEnabled: boolean;
  118985. /**
  118986. * Specifies if anti-aliasing is enabled
  118987. */
  118988. fxaaEnabled: boolean;
  118989. /**
  118990. * Specifies the number of steps used to calculate the volumetric lights
  118991. * Typically in interval [50, 200]
  118992. */
  118993. volumetricLightStepsCount: number;
  118994. /**
  118995. * Specifies the number of samples used for the motion blur effect
  118996. * Typically in interval [16, 64]
  118997. */
  118998. motionBlurSamples: number;
  118999. /**
  119000. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119001. */
  119002. samples: number;
  119003. /**
  119004. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119005. * @constructor
  119006. * @param name The rendering pipeline name
  119007. * @param scene The scene linked to this pipeline
  119008. * @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)
  119009. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  119010. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119011. */
  119012. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  119013. private _buildPipeline;
  119014. private _createDownSampleX4PostProcess;
  119015. private _createBrightPassPostProcess;
  119016. private _createBlurPostProcesses;
  119017. private _createTextureAdderPostProcess;
  119018. private _createVolumetricLightPostProcess;
  119019. private _createLuminancePostProcesses;
  119020. private _createHdrPostProcess;
  119021. private _createLensFlarePostProcess;
  119022. private _createDepthOfFieldPostProcess;
  119023. private _createMotionBlurPostProcess;
  119024. private _getDepthTexture;
  119025. private _disposePostProcesses;
  119026. /**
  119027. * Dispose of the pipeline and stop all post processes
  119028. */
  119029. dispose(): void;
  119030. /**
  119031. * Serialize the rendering pipeline (Used when exporting)
  119032. * @returns the serialized object
  119033. */
  119034. serialize(): any;
  119035. /**
  119036. * Parse the serialized pipeline
  119037. * @param source Source pipeline.
  119038. * @param scene The scene to load the pipeline to.
  119039. * @param rootUrl The URL of the serialized pipeline.
  119040. * @returns An instantiated pipeline from the serialized object.
  119041. */
  119042. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  119043. /**
  119044. * Luminance steps
  119045. */
  119046. static LuminanceSteps: number;
  119047. }
  119048. }
  119049. declare module BABYLON {
  119050. /** @hidden */
  119051. export var tonemapPixelShader: {
  119052. name: string;
  119053. shader: string;
  119054. };
  119055. }
  119056. declare module BABYLON {
  119057. /** Defines operator used for tonemapping */
  119058. export enum TonemappingOperator {
  119059. /** Hable */
  119060. Hable = 0,
  119061. /** Reinhard */
  119062. Reinhard = 1,
  119063. /** HejiDawson */
  119064. HejiDawson = 2,
  119065. /** Photographic */
  119066. Photographic = 3
  119067. }
  119068. /**
  119069. * Defines a post process to apply tone mapping
  119070. */
  119071. export class TonemapPostProcess extends PostProcess {
  119072. private _operator;
  119073. /** Defines the required exposure adjustement */
  119074. exposureAdjustment: number;
  119075. /**
  119076. * Creates a new TonemapPostProcess
  119077. * @param name defines the name of the postprocess
  119078. * @param _operator defines the operator to use
  119079. * @param exposureAdjustment defines the required exposure adjustement
  119080. * @param camera defines the camera to use (can be null)
  119081. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  119082. * @param engine defines the hosting engine (can be ignore if camera is set)
  119083. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119084. */
  119085. constructor(name: string, _operator: TonemappingOperator,
  119086. /** Defines the required exposure adjustement */
  119087. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  119088. }
  119089. }
  119090. declare module BABYLON {
  119091. /** @hidden */
  119092. export var depthVertexShader: {
  119093. name: string;
  119094. shader: string;
  119095. };
  119096. }
  119097. declare module BABYLON {
  119098. /** @hidden */
  119099. export var volumetricLightScatteringPixelShader: {
  119100. name: string;
  119101. shader: string;
  119102. };
  119103. }
  119104. declare module BABYLON {
  119105. /** @hidden */
  119106. export var volumetricLightScatteringPassPixelShader: {
  119107. name: string;
  119108. shader: string;
  119109. };
  119110. }
  119111. declare module BABYLON {
  119112. /**
  119113. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  119114. */
  119115. export class VolumetricLightScatteringPostProcess extends PostProcess {
  119116. private _volumetricLightScatteringPass;
  119117. private _volumetricLightScatteringRTT;
  119118. private _viewPort;
  119119. private _screenCoordinates;
  119120. private _cachedDefines;
  119121. /**
  119122. * If not undefined, the mesh position is computed from the attached node position
  119123. */
  119124. attachedNode: {
  119125. position: Vector3;
  119126. };
  119127. /**
  119128. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  119129. */
  119130. customMeshPosition: Vector3;
  119131. /**
  119132. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  119133. */
  119134. useCustomMeshPosition: boolean;
  119135. /**
  119136. * If the post-process should inverse the light scattering direction
  119137. */
  119138. invert: boolean;
  119139. /**
  119140. * The internal mesh used by the post-process
  119141. */
  119142. mesh: Mesh;
  119143. /**
  119144. * @hidden
  119145. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  119146. */
  119147. useDiffuseColor: boolean;
  119148. /**
  119149. * Array containing the excluded meshes not rendered in the internal pass
  119150. */
  119151. excludedMeshes: AbstractMesh[];
  119152. /**
  119153. * Controls the overall intensity of the post-process
  119154. */
  119155. exposure: number;
  119156. /**
  119157. * Dissipates each sample's contribution in range [0, 1]
  119158. */
  119159. decay: number;
  119160. /**
  119161. * Controls the overall intensity of each sample
  119162. */
  119163. weight: number;
  119164. /**
  119165. * Controls the density of each sample
  119166. */
  119167. density: number;
  119168. /**
  119169. * @constructor
  119170. * @param name The post-process name
  119171. * @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)
  119172. * @param camera The camera that the post-process will be attached to
  119173. * @param mesh The mesh used to create the light scattering
  119174. * @param samples The post-process quality, default 100
  119175. * @param samplingModeThe post-process filtering mode
  119176. * @param engine The babylon engine
  119177. * @param reusable If the post-process is reusable
  119178. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  119179. */
  119180. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  119181. /**
  119182. * Returns the string "VolumetricLightScatteringPostProcess"
  119183. * @returns "VolumetricLightScatteringPostProcess"
  119184. */
  119185. getClassName(): string;
  119186. private _isReady;
  119187. /**
  119188. * Sets the new light position for light scattering effect
  119189. * @param position The new custom light position
  119190. */
  119191. setCustomMeshPosition(position: Vector3): void;
  119192. /**
  119193. * Returns the light position for light scattering effect
  119194. * @return Vector3 The custom light position
  119195. */
  119196. getCustomMeshPosition(): Vector3;
  119197. /**
  119198. * Disposes the internal assets and detaches the post-process from the camera
  119199. */
  119200. dispose(camera: Camera): void;
  119201. /**
  119202. * Returns the render target texture used by the post-process
  119203. * @return the render target texture used by the post-process
  119204. */
  119205. getPass(): RenderTargetTexture;
  119206. private _meshExcluded;
  119207. private _createPass;
  119208. private _updateMeshScreenCoordinates;
  119209. /**
  119210. * Creates a default mesh for the Volumeric Light Scattering post-process
  119211. * @param name The mesh name
  119212. * @param scene The scene where to create the mesh
  119213. * @return the default mesh
  119214. */
  119215. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  119216. }
  119217. }
  119218. declare module BABYLON {
  119219. interface Scene {
  119220. /** @hidden (Backing field) */
  119221. _boundingBoxRenderer: BoundingBoxRenderer;
  119222. /** @hidden (Backing field) */
  119223. _forceShowBoundingBoxes: boolean;
  119224. /**
  119225. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  119226. */
  119227. forceShowBoundingBoxes: boolean;
  119228. /**
  119229. * Gets the bounding box renderer associated with the scene
  119230. * @returns a BoundingBoxRenderer
  119231. */
  119232. getBoundingBoxRenderer(): BoundingBoxRenderer;
  119233. }
  119234. interface AbstractMesh {
  119235. /** @hidden (Backing field) */
  119236. _showBoundingBox: boolean;
  119237. /**
  119238. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  119239. */
  119240. showBoundingBox: boolean;
  119241. }
  119242. /**
  119243. * Component responsible of rendering the bounding box of the meshes in a scene.
  119244. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  119245. */
  119246. export class BoundingBoxRenderer implements ISceneComponent {
  119247. /**
  119248. * The component name helpfull to identify the component in the list of scene components.
  119249. */
  119250. readonly name: string;
  119251. /**
  119252. * The scene the component belongs to.
  119253. */
  119254. scene: Scene;
  119255. /**
  119256. * Color of the bounding box lines placed in front of an object
  119257. */
  119258. frontColor: Color3;
  119259. /**
  119260. * Color of the bounding box lines placed behind an object
  119261. */
  119262. backColor: Color3;
  119263. /**
  119264. * Defines if the renderer should show the back lines or not
  119265. */
  119266. showBackLines: boolean;
  119267. /**
  119268. * @hidden
  119269. */
  119270. renderList: SmartArray<BoundingBox>;
  119271. private _colorShader;
  119272. private _vertexBuffers;
  119273. private _indexBuffer;
  119274. private _fillIndexBuffer;
  119275. private _fillIndexData;
  119276. /**
  119277. * Instantiates a new bounding box renderer in a scene.
  119278. * @param scene the scene the renderer renders in
  119279. */
  119280. constructor(scene: Scene);
  119281. /**
  119282. * Registers the component in a given scene
  119283. */
  119284. register(): void;
  119285. private _evaluateSubMesh;
  119286. private _activeMesh;
  119287. private _prepareRessources;
  119288. private _createIndexBuffer;
  119289. /**
  119290. * Rebuilds the elements related to this component in case of
  119291. * context lost for instance.
  119292. */
  119293. rebuild(): void;
  119294. /**
  119295. * @hidden
  119296. */
  119297. reset(): void;
  119298. /**
  119299. * Render the bounding boxes of a specific rendering group
  119300. * @param renderingGroupId defines the rendering group to render
  119301. */
  119302. render(renderingGroupId: number): void;
  119303. /**
  119304. * In case of occlusion queries, we can render the occlusion bounding box through this method
  119305. * @param mesh Define the mesh to render the occlusion bounding box for
  119306. */
  119307. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  119308. /**
  119309. * Dispose and release the resources attached to this renderer.
  119310. */
  119311. dispose(): void;
  119312. }
  119313. }
  119314. declare module BABYLON {
  119315. /** @hidden */
  119316. export var depthPixelShader: {
  119317. name: string;
  119318. shader: string;
  119319. };
  119320. }
  119321. declare module BABYLON {
  119322. /**
  119323. * This represents a depth renderer in Babylon.
  119324. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  119325. */
  119326. export class DepthRenderer {
  119327. private _scene;
  119328. private _depthMap;
  119329. private _effect;
  119330. private _cachedDefines;
  119331. private _camera;
  119332. /**
  119333. * Specifiess that the depth renderer will only be used within
  119334. * the camera it is created for.
  119335. * This can help forcing its rendering during the camera processing.
  119336. */
  119337. useOnlyInActiveCamera: boolean;
  119338. /** @hidden */
  119339. static _SceneComponentInitialization: (scene: Scene) => void;
  119340. /**
  119341. * Instantiates a depth renderer
  119342. * @param scene The scene the renderer belongs to
  119343. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  119344. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  119345. */
  119346. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  119347. /**
  119348. * Creates the depth rendering effect and checks if the effect is ready.
  119349. * @param subMesh The submesh to be used to render the depth map of
  119350. * @param useInstances If multiple world instances should be used
  119351. * @returns if the depth renderer is ready to render the depth map
  119352. */
  119353. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119354. /**
  119355. * Gets the texture which the depth map will be written to.
  119356. * @returns The depth map texture
  119357. */
  119358. getDepthMap(): RenderTargetTexture;
  119359. /**
  119360. * Disposes of the depth renderer.
  119361. */
  119362. dispose(): void;
  119363. }
  119364. }
  119365. declare module BABYLON {
  119366. interface Scene {
  119367. /** @hidden (Backing field) */
  119368. _depthRenderer: {
  119369. [id: string]: DepthRenderer;
  119370. };
  119371. /**
  119372. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  119373. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  119374. * @returns the created depth renderer
  119375. */
  119376. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  119377. /**
  119378. * Disables a depth renderer for a given camera
  119379. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  119380. */
  119381. disableDepthRenderer(camera?: Nullable<Camera>): void;
  119382. }
  119383. /**
  119384. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  119385. * in several rendering techniques.
  119386. */
  119387. export class DepthRendererSceneComponent implements ISceneComponent {
  119388. /**
  119389. * The component name helpfull to identify the component in the list of scene components.
  119390. */
  119391. readonly name: string;
  119392. /**
  119393. * The scene the component belongs to.
  119394. */
  119395. scene: Scene;
  119396. /**
  119397. * Creates a new instance of the component for the given scene
  119398. * @param scene Defines the scene to register the component in
  119399. */
  119400. constructor(scene: Scene);
  119401. /**
  119402. * Registers the component in a given scene
  119403. */
  119404. register(): void;
  119405. /**
  119406. * Rebuilds the elements related to this component in case of
  119407. * context lost for instance.
  119408. */
  119409. rebuild(): void;
  119410. /**
  119411. * Disposes the component and the associated ressources
  119412. */
  119413. dispose(): void;
  119414. private _gatherRenderTargets;
  119415. private _gatherActiveCameraRenderTargets;
  119416. }
  119417. }
  119418. declare module BABYLON {
  119419. /** @hidden */
  119420. export var outlinePixelShader: {
  119421. name: string;
  119422. shader: string;
  119423. };
  119424. }
  119425. declare module BABYLON {
  119426. /** @hidden */
  119427. export var outlineVertexShader: {
  119428. name: string;
  119429. shader: string;
  119430. };
  119431. }
  119432. declare module BABYLON {
  119433. interface Scene {
  119434. /** @hidden */
  119435. _outlineRenderer: OutlineRenderer;
  119436. /**
  119437. * Gets the outline renderer associated with the scene
  119438. * @returns a OutlineRenderer
  119439. */
  119440. getOutlineRenderer(): OutlineRenderer;
  119441. }
  119442. interface AbstractMesh {
  119443. /** @hidden (Backing field) */
  119444. _renderOutline: boolean;
  119445. /**
  119446. * Gets or sets a boolean indicating if the outline must be rendered as well
  119447. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  119448. */
  119449. renderOutline: boolean;
  119450. /** @hidden (Backing field) */
  119451. _renderOverlay: boolean;
  119452. /**
  119453. * Gets or sets a boolean indicating if the overlay must be rendered as well
  119454. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  119455. */
  119456. renderOverlay: boolean;
  119457. }
  119458. /**
  119459. * This class is responsible to draw bothe outline/overlay of meshes.
  119460. * It should not be used directly but through the available method on mesh.
  119461. */
  119462. export class OutlineRenderer implements ISceneComponent {
  119463. /**
  119464. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  119465. */
  119466. private static _StencilReference;
  119467. /**
  119468. * The name of the component. Each component must have a unique name.
  119469. */
  119470. name: string;
  119471. /**
  119472. * The scene the component belongs to.
  119473. */
  119474. scene: Scene;
  119475. /**
  119476. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  119477. */
  119478. zOffset: number;
  119479. private _engine;
  119480. private _effect;
  119481. private _cachedDefines;
  119482. private _savedDepthWrite;
  119483. /**
  119484. * Instantiates a new outline renderer. (There could be only one per scene).
  119485. * @param scene Defines the scene it belongs to
  119486. */
  119487. constructor(scene: Scene);
  119488. /**
  119489. * Register the component to one instance of a scene.
  119490. */
  119491. register(): void;
  119492. /**
  119493. * Rebuilds the elements related to this component in case of
  119494. * context lost for instance.
  119495. */
  119496. rebuild(): void;
  119497. /**
  119498. * Disposes the component and the associated ressources.
  119499. */
  119500. dispose(): void;
  119501. /**
  119502. * Renders the outline in the canvas.
  119503. * @param subMesh Defines the sumesh to render
  119504. * @param batch Defines the batch of meshes in case of instances
  119505. * @param useOverlay Defines if the rendering is for the overlay or the outline
  119506. */
  119507. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  119508. /**
  119509. * Returns whether or not the outline renderer is ready for a given submesh.
  119510. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  119511. * @param subMesh Defines the submesh to check readyness for
  119512. * @param useInstances Defines wheter wee are trying to render instances or not
  119513. * @returns true if ready otherwise false
  119514. */
  119515. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119516. private _beforeRenderingMesh;
  119517. private _afterRenderingMesh;
  119518. }
  119519. }
  119520. declare module BABYLON {
  119521. /**
  119522. * Defines the list of states available for a task inside a AssetsManager
  119523. */
  119524. export enum AssetTaskState {
  119525. /**
  119526. * Initialization
  119527. */
  119528. INIT = 0,
  119529. /**
  119530. * Running
  119531. */
  119532. RUNNING = 1,
  119533. /**
  119534. * Done
  119535. */
  119536. DONE = 2,
  119537. /**
  119538. * Error
  119539. */
  119540. ERROR = 3
  119541. }
  119542. /**
  119543. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  119544. */
  119545. export abstract class AbstractAssetTask {
  119546. /**
  119547. * Task name
  119548. */ name: string;
  119549. /**
  119550. * Callback called when the task is successful
  119551. */
  119552. onSuccess: (task: any) => void;
  119553. /**
  119554. * Callback called when the task is not successful
  119555. */
  119556. onError: (task: any, message?: string, exception?: any) => void;
  119557. /**
  119558. * Creates a new AssetsManager
  119559. * @param name defines the name of the task
  119560. */
  119561. constructor(
  119562. /**
  119563. * Task name
  119564. */ name: string);
  119565. private _isCompleted;
  119566. private _taskState;
  119567. private _errorObject;
  119568. /**
  119569. * Get if the task is completed
  119570. */
  119571. readonly isCompleted: boolean;
  119572. /**
  119573. * Gets the current state of the task
  119574. */
  119575. readonly taskState: AssetTaskState;
  119576. /**
  119577. * Gets the current error object (if task is in error)
  119578. */
  119579. readonly errorObject: {
  119580. message?: string;
  119581. exception?: any;
  119582. };
  119583. /**
  119584. * Internal only
  119585. * @hidden
  119586. */
  119587. _setErrorObject(message?: string, exception?: any): void;
  119588. /**
  119589. * Execute the current task
  119590. * @param scene defines the scene where you want your assets to be loaded
  119591. * @param onSuccess is a callback called when the task is successfully executed
  119592. * @param onError is a callback called if an error occurs
  119593. */
  119594. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119595. /**
  119596. * Execute the current task
  119597. * @param scene defines the scene where you want your assets to be loaded
  119598. * @param onSuccess is a callback called when the task is successfully executed
  119599. * @param onError is a callback called if an error occurs
  119600. */
  119601. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119602. /**
  119603. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  119604. * This can be used with failed tasks that have the reason for failure fixed.
  119605. */
  119606. reset(): void;
  119607. private onErrorCallback;
  119608. private onDoneCallback;
  119609. }
  119610. /**
  119611. * Define the interface used by progress events raised during assets loading
  119612. */
  119613. export interface IAssetsProgressEvent {
  119614. /**
  119615. * Defines the number of remaining tasks to process
  119616. */
  119617. remainingCount: number;
  119618. /**
  119619. * Defines the total number of tasks
  119620. */
  119621. totalCount: number;
  119622. /**
  119623. * Defines the task that was just processed
  119624. */
  119625. task: AbstractAssetTask;
  119626. }
  119627. /**
  119628. * Class used to share progress information about assets loading
  119629. */
  119630. export class AssetsProgressEvent implements IAssetsProgressEvent {
  119631. /**
  119632. * Defines the number of remaining tasks to process
  119633. */
  119634. remainingCount: number;
  119635. /**
  119636. * Defines the total number of tasks
  119637. */
  119638. totalCount: number;
  119639. /**
  119640. * Defines the task that was just processed
  119641. */
  119642. task: AbstractAssetTask;
  119643. /**
  119644. * Creates a AssetsProgressEvent
  119645. * @param remainingCount defines the number of remaining tasks to process
  119646. * @param totalCount defines the total number of tasks
  119647. * @param task defines the task that was just processed
  119648. */
  119649. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  119650. }
  119651. /**
  119652. * Define a task used by AssetsManager to load meshes
  119653. */
  119654. export class MeshAssetTask extends AbstractAssetTask {
  119655. /**
  119656. * Defines the name of the task
  119657. */
  119658. name: string;
  119659. /**
  119660. * Defines the list of mesh's names you want to load
  119661. */
  119662. meshesNames: any;
  119663. /**
  119664. * Defines the root url to use as a base to load your meshes and associated resources
  119665. */
  119666. rootUrl: string;
  119667. /**
  119668. * Defines the filename of the scene to load from
  119669. */
  119670. sceneFilename: string;
  119671. /**
  119672. * Gets the list of loaded meshes
  119673. */
  119674. loadedMeshes: Array<AbstractMesh>;
  119675. /**
  119676. * Gets the list of loaded particle systems
  119677. */
  119678. loadedParticleSystems: Array<IParticleSystem>;
  119679. /**
  119680. * Gets the list of loaded skeletons
  119681. */
  119682. loadedSkeletons: Array<Skeleton>;
  119683. /**
  119684. * Gets the list of loaded animation groups
  119685. */
  119686. loadedAnimationGroups: Array<AnimationGroup>;
  119687. /**
  119688. * Callback called when the task is successful
  119689. */
  119690. onSuccess: (task: MeshAssetTask) => void;
  119691. /**
  119692. * Callback called when the task is successful
  119693. */
  119694. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  119695. /**
  119696. * Creates a new MeshAssetTask
  119697. * @param name defines the name of the task
  119698. * @param meshesNames defines the list of mesh's names you want to load
  119699. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  119700. * @param sceneFilename defines the filename of the scene to load from
  119701. */
  119702. constructor(
  119703. /**
  119704. * Defines the name of the task
  119705. */
  119706. name: string,
  119707. /**
  119708. * Defines the list of mesh's names you want to load
  119709. */
  119710. meshesNames: any,
  119711. /**
  119712. * Defines the root url to use as a base to load your meshes and associated resources
  119713. */
  119714. rootUrl: string,
  119715. /**
  119716. * Defines the filename of the scene to load from
  119717. */
  119718. sceneFilename: string);
  119719. /**
  119720. * Execute the current task
  119721. * @param scene defines the scene where you want your assets to be loaded
  119722. * @param onSuccess is a callback called when the task is successfully executed
  119723. * @param onError is a callback called if an error occurs
  119724. */
  119725. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119726. }
  119727. /**
  119728. * Define a task used by AssetsManager to load text content
  119729. */
  119730. export class TextFileAssetTask extends AbstractAssetTask {
  119731. /**
  119732. * Defines the name of the task
  119733. */
  119734. name: string;
  119735. /**
  119736. * Defines the location of the file to load
  119737. */
  119738. url: string;
  119739. /**
  119740. * Gets the loaded text string
  119741. */
  119742. text: string;
  119743. /**
  119744. * Callback called when the task is successful
  119745. */
  119746. onSuccess: (task: TextFileAssetTask) => void;
  119747. /**
  119748. * Callback called when the task is successful
  119749. */
  119750. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  119751. /**
  119752. * Creates a new TextFileAssetTask object
  119753. * @param name defines the name of the task
  119754. * @param url defines the location of the file to load
  119755. */
  119756. constructor(
  119757. /**
  119758. * Defines the name of the task
  119759. */
  119760. name: string,
  119761. /**
  119762. * Defines the location of the file to load
  119763. */
  119764. url: string);
  119765. /**
  119766. * Execute the current task
  119767. * @param scene defines the scene where you want your assets to be loaded
  119768. * @param onSuccess is a callback called when the task is successfully executed
  119769. * @param onError is a callback called if an error occurs
  119770. */
  119771. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119772. }
  119773. /**
  119774. * Define a task used by AssetsManager to load binary data
  119775. */
  119776. export class BinaryFileAssetTask extends AbstractAssetTask {
  119777. /**
  119778. * Defines the name of the task
  119779. */
  119780. name: string;
  119781. /**
  119782. * Defines the location of the file to load
  119783. */
  119784. url: string;
  119785. /**
  119786. * Gets the lodaded data (as an array buffer)
  119787. */
  119788. data: ArrayBuffer;
  119789. /**
  119790. * Callback called when the task is successful
  119791. */
  119792. onSuccess: (task: BinaryFileAssetTask) => void;
  119793. /**
  119794. * Callback called when the task is successful
  119795. */
  119796. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  119797. /**
  119798. * Creates a new BinaryFileAssetTask object
  119799. * @param name defines the name of the new task
  119800. * @param url defines the location of the file to load
  119801. */
  119802. constructor(
  119803. /**
  119804. * Defines the name of the task
  119805. */
  119806. name: string,
  119807. /**
  119808. * Defines the location of the file to load
  119809. */
  119810. url: string);
  119811. /**
  119812. * Execute the current task
  119813. * @param scene defines the scene where you want your assets to be loaded
  119814. * @param onSuccess is a callback called when the task is successfully executed
  119815. * @param onError is a callback called if an error occurs
  119816. */
  119817. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119818. }
  119819. /**
  119820. * Define a task used by AssetsManager to load images
  119821. */
  119822. export class ImageAssetTask extends AbstractAssetTask {
  119823. /**
  119824. * Defines the name of the task
  119825. */
  119826. name: string;
  119827. /**
  119828. * Defines the location of the image to load
  119829. */
  119830. url: string;
  119831. /**
  119832. * Gets the loaded images
  119833. */
  119834. image: HTMLImageElement;
  119835. /**
  119836. * Callback called when the task is successful
  119837. */
  119838. onSuccess: (task: ImageAssetTask) => void;
  119839. /**
  119840. * Callback called when the task is successful
  119841. */
  119842. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  119843. /**
  119844. * Creates a new ImageAssetTask
  119845. * @param name defines the name of the task
  119846. * @param url defines the location of the image to load
  119847. */
  119848. constructor(
  119849. /**
  119850. * Defines the name of the task
  119851. */
  119852. name: string,
  119853. /**
  119854. * Defines the location of the image to load
  119855. */
  119856. url: string);
  119857. /**
  119858. * Execute the current task
  119859. * @param scene defines the scene where you want your assets to be loaded
  119860. * @param onSuccess is a callback called when the task is successfully executed
  119861. * @param onError is a callback called if an error occurs
  119862. */
  119863. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119864. }
  119865. /**
  119866. * Defines the interface used by texture loading tasks
  119867. */
  119868. export interface ITextureAssetTask<TEX extends BaseTexture> {
  119869. /**
  119870. * Gets the loaded texture
  119871. */
  119872. texture: TEX;
  119873. }
  119874. /**
  119875. * Define a task used by AssetsManager to load 2D textures
  119876. */
  119877. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  119878. /**
  119879. * Defines the name of the task
  119880. */
  119881. name: string;
  119882. /**
  119883. * Defines the location of the file to load
  119884. */
  119885. url: string;
  119886. /**
  119887. * Defines if mipmap should not be generated (default is false)
  119888. */
  119889. noMipmap?: boolean | undefined;
  119890. /**
  119891. * Defines if texture must be inverted on Y axis (default is false)
  119892. */
  119893. invertY?: boolean | undefined;
  119894. /**
  119895. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  119896. */
  119897. samplingMode: number;
  119898. /**
  119899. * Gets the loaded texture
  119900. */
  119901. texture: Texture;
  119902. /**
  119903. * Callback called when the task is successful
  119904. */
  119905. onSuccess: (task: TextureAssetTask) => void;
  119906. /**
  119907. * Callback called when the task is successful
  119908. */
  119909. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  119910. /**
  119911. * Creates a new TextureAssetTask object
  119912. * @param name defines the name of the task
  119913. * @param url defines the location of the file to load
  119914. * @param noMipmap defines if mipmap should not be generated (default is false)
  119915. * @param invertY defines if texture must be inverted on Y axis (default is false)
  119916. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  119917. */
  119918. constructor(
  119919. /**
  119920. * Defines the name of the task
  119921. */
  119922. name: string,
  119923. /**
  119924. * Defines the location of the file to load
  119925. */
  119926. url: string,
  119927. /**
  119928. * Defines if mipmap should not be generated (default is false)
  119929. */
  119930. noMipmap?: boolean | undefined,
  119931. /**
  119932. * Defines if texture must be inverted on Y axis (default is false)
  119933. */
  119934. invertY?: boolean | undefined,
  119935. /**
  119936. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  119937. */
  119938. samplingMode?: number);
  119939. /**
  119940. * Execute the current task
  119941. * @param scene defines the scene where you want your assets to be loaded
  119942. * @param onSuccess is a callback called when the task is successfully executed
  119943. * @param onError is a callback called if an error occurs
  119944. */
  119945. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119946. }
  119947. /**
  119948. * Define a task used by AssetsManager to load cube textures
  119949. */
  119950. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  119951. /**
  119952. * Defines the name of the task
  119953. */
  119954. name: string;
  119955. /**
  119956. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  119957. */
  119958. url: string;
  119959. /**
  119960. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  119961. */
  119962. extensions?: string[] | undefined;
  119963. /**
  119964. * Defines if mipmaps should not be generated (default is false)
  119965. */
  119966. noMipmap?: boolean | undefined;
  119967. /**
  119968. * Defines the explicit list of files (undefined by default)
  119969. */
  119970. files?: string[] | undefined;
  119971. /**
  119972. * Gets the loaded texture
  119973. */
  119974. texture: CubeTexture;
  119975. /**
  119976. * Callback called when the task is successful
  119977. */
  119978. onSuccess: (task: CubeTextureAssetTask) => void;
  119979. /**
  119980. * Callback called when the task is successful
  119981. */
  119982. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  119983. /**
  119984. * Creates a new CubeTextureAssetTask
  119985. * @param name defines the name of the task
  119986. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  119987. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  119988. * @param noMipmap defines if mipmaps should not be generated (default is false)
  119989. * @param files defines the explicit list of files (undefined by default)
  119990. */
  119991. constructor(
  119992. /**
  119993. * Defines the name of the task
  119994. */
  119995. name: string,
  119996. /**
  119997. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  119998. */
  119999. url: string,
  120000. /**
  120001. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120002. */
  120003. extensions?: string[] | undefined,
  120004. /**
  120005. * Defines if mipmaps should not be generated (default is false)
  120006. */
  120007. noMipmap?: boolean | undefined,
  120008. /**
  120009. * Defines the explicit list of files (undefined by default)
  120010. */
  120011. files?: string[] | undefined);
  120012. /**
  120013. * Execute the current task
  120014. * @param scene defines the scene where you want your assets to be loaded
  120015. * @param onSuccess is a callback called when the task is successfully executed
  120016. * @param onError is a callback called if an error occurs
  120017. */
  120018. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120019. }
  120020. /**
  120021. * Define a task used by AssetsManager to load HDR cube textures
  120022. */
  120023. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  120024. /**
  120025. * Defines the name of the task
  120026. */
  120027. name: string;
  120028. /**
  120029. * Defines the location of the file to load
  120030. */
  120031. url: string;
  120032. /**
  120033. * Defines the desired size (the more it increases the longer the generation will be)
  120034. */
  120035. size: number;
  120036. /**
  120037. * Defines if mipmaps should not be generated (default is false)
  120038. */
  120039. noMipmap: boolean;
  120040. /**
  120041. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120042. */
  120043. generateHarmonics: boolean;
  120044. /**
  120045. * 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)
  120046. */
  120047. gammaSpace: boolean;
  120048. /**
  120049. * Internal Use Only
  120050. */
  120051. reserved: boolean;
  120052. /**
  120053. * Gets the loaded texture
  120054. */
  120055. texture: HDRCubeTexture;
  120056. /**
  120057. * Callback called when the task is successful
  120058. */
  120059. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  120060. /**
  120061. * Callback called when the task is successful
  120062. */
  120063. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  120064. /**
  120065. * Creates a new HDRCubeTextureAssetTask object
  120066. * @param name defines the name of the task
  120067. * @param url defines the location of the file to load
  120068. * @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.
  120069. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120070. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120071. * @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)
  120072. * @param reserved Internal use only
  120073. */
  120074. constructor(
  120075. /**
  120076. * Defines the name of the task
  120077. */
  120078. name: string,
  120079. /**
  120080. * Defines the location of the file to load
  120081. */
  120082. url: string,
  120083. /**
  120084. * Defines the desired size (the more it increases the longer the generation will be)
  120085. */
  120086. size: number,
  120087. /**
  120088. * Defines if mipmaps should not be generated (default is false)
  120089. */
  120090. noMipmap?: boolean,
  120091. /**
  120092. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120093. */
  120094. generateHarmonics?: boolean,
  120095. /**
  120096. * 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)
  120097. */
  120098. gammaSpace?: boolean,
  120099. /**
  120100. * Internal Use Only
  120101. */
  120102. reserved?: boolean);
  120103. /**
  120104. * Execute the current task
  120105. * @param scene defines the scene where you want your assets to be loaded
  120106. * @param onSuccess is a callback called when the task is successfully executed
  120107. * @param onError is a callback called if an error occurs
  120108. */
  120109. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120110. }
  120111. /**
  120112. * Define a task used by AssetsManager to load Equirectangular cube textures
  120113. */
  120114. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  120115. /**
  120116. * Defines the name of the task
  120117. */
  120118. name: string;
  120119. /**
  120120. * Defines the location of the file to load
  120121. */
  120122. url: string;
  120123. /**
  120124. * Defines the desired size (the more it increases the longer the generation will be)
  120125. */
  120126. size: number;
  120127. /**
  120128. * Defines if mipmaps should not be generated (default is false)
  120129. */
  120130. noMipmap: boolean;
  120131. /**
  120132. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  120133. * but the standard material would require them in Gamma space) (default is true)
  120134. */
  120135. gammaSpace: boolean;
  120136. /**
  120137. * Gets the loaded texture
  120138. */
  120139. texture: EquiRectangularCubeTexture;
  120140. /**
  120141. * Callback called when the task is successful
  120142. */
  120143. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  120144. /**
  120145. * Callback called when the task is successful
  120146. */
  120147. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  120148. /**
  120149. * Creates a new EquiRectangularCubeTextureAssetTask object
  120150. * @param name defines the name of the task
  120151. * @param url defines the location of the file to load
  120152. * @param size defines the desired size (the more it increases the longer the generation will be)
  120153. * If the size is omitted this implies you are using a preprocessed cubemap.
  120154. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120155. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  120156. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  120157. * (default is true)
  120158. */
  120159. constructor(
  120160. /**
  120161. * Defines the name of the task
  120162. */
  120163. name: string,
  120164. /**
  120165. * Defines the location of the file to load
  120166. */
  120167. url: string,
  120168. /**
  120169. * Defines the desired size (the more it increases the longer the generation will be)
  120170. */
  120171. size: number,
  120172. /**
  120173. * Defines if mipmaps should not be generated (default is false)
  120174. */
  120175. noMipmap?: boolean,
  120176. /**
  120177. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  120178. * but the standard material would require them in Gamma space) (default is true)
  120179. */
  120180. gammaSpace?: boolean);
  120181. /**
  120182. * Execute the current task
  120183. * @param scene defines the scene where you want your assets to be loaded
  120184. * @param onSuccess is a callback called when the task is successfully executed
  120185. * @param onError is a callback called if an error occurs
  120186. */
  120187. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120188. }
  120189. /**
  120190. * This class can be used to easily import assets into a scene
  120191. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  120192. */
  120193. export class AssetsManager {
  120194. private _scene;
  120195. private _isLoading;
  120196. protected _tasks: AbstractAssetTask[];
  120197. protected _waitingTasksCount: number;
  120198. protected _totalTasksCount: number;
  120199. /**
  120200. * Callback called when all tasks are processed
  120201. */
  120202. onFinish: (tasks: AbstractAssetTask[]) => void;
  120203. /**
  120204. * Callback called when a task is successful
  120205. */
  120206. onTaskSuccess: (task: AbstractAssetTask) => void;
  120207. /**
  120208. * Callback called when a task had an error
  120209. */
  120210. onTaskError: (task: AbstractAssetTask) => void;
  120211. /**
  120212. * Callback called when a task is done (whatever the result is)
  120213. */
  120214. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  120215. /**
  120216. * Observable called when all tasks are processed
  120217. */
  120218. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  120219. /**
  120220. * Observable called when a task had an error
  120221. */
  120222. onTaskErrorObservable: Observable<AbstractAssetTask>;
  120223. /**
  120224. * Observable called when all tasks were executed
  120225. */
  120226. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  120227. /**
  120228. * Observable called when a task is done (whatever the result is)
  120229. */
  120230. onProgressObservable: Observable<IAssetsProgressEvent>;
  120231. /**
  120232. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  120233. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120234. */
  120235. useDefaultLoadingScreen: boolean;
  120236. /**
  120237. * Creates a new AssetsManager
  120238. * @param scene defines the scene to work on
  120239. */
  120240. constructor(scene: Scene);
  120241. /**
  120242. * Add a MeshAssetTask to the list of active tasks
  120243. * @param taskName defines the name of the new task
  120244. * @param meshesNames defines the name of meshes to load
  120245. * @param rootUrl defines the root url to use to locate files
  120246. * @param sceneFilename defines the filename of the scene file
  120247. * @returns a new MeshAssetTask object
  120248. */
  120249. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  120250. /**
  120251. * Add a TextFileAssetTask to the list of active tasks
  120252. * @param taskName defines the name of the new task
  120253. * @param url defines the url of the file to load
  120254. * @returns a new TextFileAssetTask object
  120255. */
  120256. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  120257. /**
  120258. * Add a BinaryFileAssetTask to the list of active tasks
  120259. * @param taskName defines the name of the new task
  120260. * @param url defines the url of the file to load
  120261. * @returns a new BinaryFileAssetTask object
  120262. */
  120263. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  120264. /**
  120265. * Add a ImageAssetTask to the list of active tasks
  120266. * @param taskName defines the name of the new task
  120267. * @param url defines the url of the file to load
  120268. * @returns a new ImageAssetTask object
  120269. */
  120270. addImageTask(taskName: string, url: string): ImageAssetTask;
  120271. /**
  120272. * Add a TextureAssetTask to the list of active tasks
  120273. * @param taskName defines the name of the new task
  120274. * @param url defines the url of the file to load
  120275. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120276. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  120277. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  120278. * @returns a new TextureAssetTask object
  120279. */
  120280. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  120281. /**
  120282. * Add a CubeTextureAssetTask to the list of active tasks
  120283. * @param taskName defines the name of the new task
  120284. * @param url defines the url of the file to load
  120285. * @param extensions defines the extension to use to load the cube map (can be null)
  120286. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120287. * @param files defines the list of files to load (can be null)
  120288. * @returns a new CubeTextureAssetTask object
  120289. */
  120290. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  120291. /**
  120292. *
  120293. * Add a HDRCubeTextureAssetTask to the list of active tasks
  120294. * @param taskName defines the name of the new task
  120295. * @param url defines the url of the file to load
  120296. * @param size defines the size you want for the cubemap (can be null)
  120297. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120298. * @param generateHarmonics defines if you want to automatically generate (true by default)
  120299. * @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)
  120300. * @param reserved Internal use only
  120301. * @returns a new HDRCubeTextureAssetTask object
  120302. */
  120303. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  120304. /**
  120305. *
  120306. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  120307. * @param taskName defines the name of the new task
  120308. * @param url defines the url of the file to load
  120309. * @param size defines the size you want for the cubemap (can be null)
  120310. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120311. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  120312. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  120313. * @returns a new EquiRectangularCubeTextureAssetTask object
  120314. */
  120315. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  120316. /**
  120317. * Remove a task from the assets manager.
  120318. * @param task the task to remove
  120319. */
  120320. removeTask(task: AbstractAssetTask): void;
  120321. private _decreaseWaitingTasksCount;
  120322. private _runTask;
  120323. /**
  120324. * Reset the AssetsManager and remove all tasks
  120325. * @return the current instance of the AssetsManager
  120326. */
  120327. reset(): AssetsManager;
  120328. /**
  120329. * Start the loading process
  120330. * @return the current instance of the AssetsManager
  120331. */
  120332. load(): AssetsManager;
  120333. /**
  120334. * Start the loading process as an async operation
  120335. * @return a promise returning the list of failed tasks
  120336. */
  120337. loadAsync(): Promise<void>;
  120338. }
  120339. }
  120340. declare module BABYLON {
  120341. /**
  120342. * Wrapper class for promise with external resolve and reject.
  120343. */
  120344. export class Deferred<T> {
  120345. /**
  120346. * The promise associated with this deferred object.
  120347. */
  120348. readonly promise: Promise<T>;
  120349. private _resolve;
  120350. private _reject;
  120351. /**
  120352. * The resolve method of the promise associated with this deferred object.
  120353. */
  120354. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  120355. /**
  120356. * The reject method of the promise associated with this deferred object.
  120357. */
  120358. readonly reject: (reason?: any) => void;
  120359. /**
  120360. * Constructor for this deferred object.
  120361. */
  120362. constructor();
  120363. }
  120364. }
  120365. declare module BABYLON {
  120366. /**
  120367. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  120368. */
  120369. export class MeshExploder {
  120370. private _centerMesh;
  120371. private _meshes;
  120372. private _meshesOrigins;
  120373. private _toCenterVectors;
  120374. private _scaledDirection;
  120375. private _newPosition;
  120376. private _centerPosition;
  120377. /**
  120378. * Explodes meshes from a center mesh.
  120379. * @param meshes The meshes to explode.
  120380. * @param centerMesh The mesh to be center of explosion.
  120381. */
  120382. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  120383. private _setCenterMesh;
  120384. /**
  120385. * Get class name
  120386. * @returns "MeshExploder"
  120387. */
  120388. getClassName(): string;
  120389. /**
  120390. * "Exploded meshes"
  120391. * @returns Array of meshes with the centerMesh at index 0.
  120392. */
  120393. getMeshes(): Array<Mesh>;
  120394. /**
  120395. * Explodes meshes giving a specific direction
  120396. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  120397. */
  120398. explode(direction?: number): void;
  120399. }
  120400. }
  120401. declare module BABYLON {
  120402. /**
  120403. * Class used to help managing file picking and drag'n'drop
  120404. */
  120405. export class FilesInput {
  120406. /**
  120407. * List of files ready to be loaded
  120408. */
  120409. static readonly FilesToLoad: {
  120410. [key: string]: File;
  120411. };
  120412. /**
  120413. * Callback called when a file is processed
  120414. */
  120415. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  120416. private _engine;
  120417. private _currentScene;
  120418. private _sceneLoadedCallback;
  120419. private _progressCallback;
  120420. private _additionalRenderLoopLogicCallback;
  120421. private _textureLoadingCallback;
  120422. private _startingProcessingFilesCallback;
  120423. private _onReloadCallback;
  120424. private _errorCallback;
  120425. private _elementToMonitor;
  120426. private _sceneFileToLoad;
  120427. private _filesToLoad;
  120428. /**
  120429. * Creates a new FilesInput
  120430. * @param engine defines the rendering engine
  120431. * @param scene defines the hosting scene
  120432. * @param sceneLoadedCallback callback called when scene is loaded
  120433. * @param progressCallback callback called to track progress
  120434. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  120435. * @param textureLoadingCallback callback called when a texture is loading
  120436. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  120437. * @param onReloadCallback callback called when a reload is requested
  120438. * @param errorCallback callback call if an error occurs
  120439. */
  120440. 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);
  120441. private _dragEnterHandler;
  120442. private _dragOverHandler;
  120443. private _dropHandler;
  120444. /**
  120445. * Calls this function to listen to drag'n'drop events on a specific DOM element
  120446. * @param elementToMonitor defines the DOM element to track
  120447. */
  120448. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  120449. /**
  120450. * Release all associated resources
  120451. */
  120452. dispose(): void;
  120453. private renderFunction;
  120454. private drag;
  120455. private drop;
  120456. private _traverseFolder;
  120457. private _processFiles;
  120458. /**
  120459. * Load files from a drop event
  120460. * @param event defines the drop event to use as source
  120461. */
  120462. loadFiles(event: any): void;
  120463. private _processReload;
  120464. /**
  120465. * Reload the current scene from the loaded files
  120466. */
  120467. reload(): void;
  120468. }
  120469. }
  120470. declare module BABYLON {
  120471. /**
  120472. * Defines the root class used to create scene optimization to use with SceneOptimizer
  120473. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120474. */
  120475. export class SceneOptimization {
  120476. /**
  120477. * Defines the priority of this optimization (0 by default which means first in the list)
  120478. */
  120479. priority: number;
  120480. /**
  120481. * Gets a string describing the action executed by the current optimization
  120482. * @returns description string
  120483. */
  120484. getDescription(): string;
  120485. /**
  120486. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120487. * @param scene defines the current scene where to apply this optimization
  120488. * @param optimizer defines the current optimizer
  120489. * @returns true if everything that can be done was applied
  120490. */
  120491. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120492. /**
  120493. * Creates the SceneOptimization object
  120494. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120495. * @param desc defines the description associated with the optimization
  120496. */
  120497. constructor(
  120498. /**
  120499. * Defines the priority of this optimization (0 by default which means first in the list)
  120500. */
  120501. priority?: number);
  120502. }
  120503. /**
  120504. * Defines an optimization used to reduce the size of render target textures
  120505. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120506. */
  120507. export class TextureOptimization extends SceneOptimization {
  120508. /**
  120509. * Defines the priority of this optimization (0 by default which means first in the list)
  120510. */
  120511. priority: number;
  120512. /**
  120513. * 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
  120514. */
  120515. maximumSize: number;
  120516. /**
  120517. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  120518. */
  120519. step: number;
  120520. /**
  120521. * Gets a string describing the action executed by the current optimization
  120522. * @returns description string
  120523. */
  120524. getDescription(): string;
  120525. /**
  120526. * Creates the TextureOptimization object
  120527. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120528. * @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
  120529. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  120530. */
  120531. constructor(
  120532. /**
  120533. * Defines the priority of this optimization (0 by default which means first in the list)
  120534. */
  120535. priority?: number,
  120536. /**
  120537. * 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
  120538. */
  120539. maximumSize?: number,
  120540. /**
  120541. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  120542. */
  120543. step?: number);
  120544. /**
  120545. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120546. * @param scene defines the current scene where to apply this optimization
  120547. * @param optimizer defines the current optimizer
  120548. * @returns true if everything that can be done was applied
  120549. */
  120550. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120551. }
  120552. /**
  120553. * Defines an optimization used to increase or decrease the rendering resolution
  120554. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120555. */
  120556. export class HardwareScalingOptimization extends SceneOptimization {
  120557. /**
  120558. * Defines the priority of this optimization (0 by default which means first in the list)
  120559. */
  120560. priority: number;
  120561. /**
  120562. * Defines the maximum scale to use (2 by default)
  120563. */
  120564. maximumScale: number;
  120565. /**
  120566. * Defines the step to use between two passes (0.5 by default)
  120567. */
  120568. step: number;
  120569. private _currentScale;
  120570. private _directionOffset;
  120571. /**
  120572. * Gets a string describing the action executed by the current optimization
  120573. * @return description string
  120574. */
  120575. getDescription(): string;
  120576. /**
  120577. * Creates the HardwareScalingOptimization object
  120578. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120579. * @param maximumScale defines the maximum scale to use (2 by default)
  120580. * @param step defines the step to use between two passes (0.5 by default)
  120581. */
  120582. constructor(
  120583. /**
  120584. * Defines the priority of this optimization (0 by default which means first in the list)
  120585. */
  120586. priority?: number,
  120587. /**
  120588. * Defines the maximum scale to use (2 by default)
  120589. */
  120590. maximumScale?: number,
  120591. /**
  120592. * Defines the step to use between two passes (0.5 by default)
  120593. */
  120594. step?: number);
  120595. /**
  120596. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120597. * @param scene defines the current scene where to apply this optimization
  120598. * @param optimizer defines the current optimizer
  120599. * @returns true if everything that can be done was applied
  120600. */
  120601. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120602. }
  120603. /**
  120604. * Defines an optimization used to remove shadows
  120605. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120606. */
  120607. export class ShadowsOptimization extends SceneOptimization {
  120608. /**
  120609. * Gets a string describing the action executed by the current optimization
  120610. * @return description string
  120611. */
  120612. getDescription(): string;
  120613. /**
  120614. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120615. * @param scene defines the current scene where to apply this optimization
  120616. * @param optimizer defines the current optimizer
  120617. * @returns true if everything that can be done was applied
  120618. */
  120619. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120620. }
  120621. /**
  120622. * Defines an optimization used to turn post-processes off
  120623. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120624. */
  120625. export class PostProcessesOptimization extends SceneOptimization {
  120626. /**
  120627. * Gets a string describing the action executed by the current optimization
  120628. * @return description string
  120629. */
  120630. getDescription(): string;
  120631. /**
  120632. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120633. * @param scene defines the current scene where to apply this optimization
  120634. * @param optimizer defines the current optimizer
  120635. * @returns true if everything that can be done was applied
  120636. */
  120637. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120638. }
  120639. /**
  120640. * Defines an optimization used to turn lens flares off
  120641. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120642. */
  120643. export class LensFlaresOptimization extends SceneOptimization {
  120644. /**
  120645. * Gets a string describing the action executed by the current optimization
  120646. * @return description string
  120647. */
  120648. getDescription(): string;
  120649. /**
  120650. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120651. * @param scene defines the current scene where to apply this optimization
  120652. * @param optimizer defines the current optimizer
  120653. * @returns true if everything that can be done was applied
  120654. */
  120655. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120656. }
  120657. /**
  120658. * Defines an optimization based on user defined callback.
  120659. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120660. */
  120661. export class CustomOptimization extends SceneOptimization {
  120662. /**
  120663. * Callback called to apply the custom optimization.
  120664. */
  120665. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  120666. /**
  120667. * Callback called to get custom description
  120668. */
  120669. onGetDescription: () => string;
  120670. /**
  120671. * Gets a string describing the action executed by the current optimization
  120672. * @returns description string
  120673. */
  120674. getDescription(): string;
  120675. /**
  120676. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120677. * @param scene defines the current scene where to apply this optimization
  120678. * @param optimizer defines the current optimizer
  120679. * @returns true if everything that can be done was applied
  120680. */
  120681. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120682. }
  120683. /**
  120684. * Defines an optimization used to turn particles off
  120685. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120686. */
  120687. export class ParticlesOptimization extends SceneOptimization {
  120688. /**
  120689. * Gets a string describing the action executed by the current optimization
  120690. * @return description string
  120691. */
  120692. getDescription(): string;
  120693. /**
  120694. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120695. * @param scene defines the current scene where to apply this optimization
  120696. * @param optimizer defines the current optimizer
  120697. * @returns true if everything that can be done was applied
  120698. */
  120699. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120700. }
  120701. /**
  120702. * Defines an optimization used to turn render targets off
  120703. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120704. */
  120705. export class RenderTargetsOptimization extends SceneOptimization {
  120706. /**
  120707. * Gets a string describing the action executed by the current optimization
  120708. * @return description string
  120709. */
  120710. getDescription(): string;
  120711. /**
  120712. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120713. * @param scene defines the current scene where to apply this optimization
  120714. * @param optimizer defines the current optimizer
  120715. * @returns true if everything that can be done was applied
  120716. */
  120717. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120718. }
  120719. /**
  120720. * Defines an optimization used to merge meshes with compatible materials
  120721. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120722. */
  120723. export class MergeMeshesOptimization extends SceneOptimization {
  120724. private static _UpdateSelectionTree;
  120725. /**
  120726. * Gets or sets a boolean which defines if optimization octree has to be updated
  120727. */
  120728. /**
  120729. * Gets or sets a boolean which defines if optimization octree has to be updated
  120730. */
  120731. static UpdateSelectionTree: boolean;
  120732. /**
  120733. * Gets a string describing the action executed by the current optimization
  120734. * @return description string
  120735. */
  120736. getDescription(): string;
  120737. private _canBeMerged;
  120738. /**
  120739. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120740. * @param scene defines the current scene where to apply this optimization
  120741. * @param optimizer defines the current optimizer
  120742. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  120743. * @returns true if everything that can be done was applied
  120744. */
  120745. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  120746. }
  120747. /**
  120748. * Defines a list of options used by SceneOptimizer
  120749. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120750. */
  120751. export class SceneOptimizerOptions {
  120752. /**
  120753. * Defines the target frame rate to reach (60 by default)
  120754. */
  120755. targetFrameRate: number;
  120756. /**
  120757. * Defines the interval between two checkes (2000ms by default)
  120758. */
  120759. trackerDuration: number;
  120760. /**
  120761. * Gets the list of optimizations to apply
  120762. */
  120763. optimizations: SceneOptimization[];
  120764. /**
  120765. * Creates a new list of options used by SceneOptimizer
  120766. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  120767. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  120768. */
  120769. constructor(
  120770. /**
  120771. * Defines the target frame rate to reach (60 by default)
  120772. */
  120773. targetFrameRate?: number,
  120774. /**
  120775. * Defines the interval between two checkes (2000ms by default)
  120776. */
  120777. trackerDuration?: number);
  120778. /**
  120779. * Add a new optimization
  120780. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  120781. * @returns the current SceneOptimizerOptions
  120782. */
  120783. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  120784. /**
  120785. * Add a new custom optimization
  120786. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  120787. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  120788. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120789. * @returns the current SceneOptimizerOptions
  120790. */
  120791. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  120792. /**
  120793. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  120794. * @param targetFrameRate defines the target frame rate (60 by default)
  120795. * @returns a SceneOptimizerOptions object
  120796. */
  120797. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  120798. /**
  120799. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  120800. * @param targetFrameRate defines the target frame rate (60 by default)
  120801. * @returns a SceneOptimizerOptions object
  120802. */
  120803. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  120804. /**
  120805. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  120806. * @param targetFrameRate defines the target frame rate (60 by default)
  120807. * @returns a SceneOptimizerOptions object
  120808. */
  120809. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  120810. }
  120811. /**
  120812. * Class used to run optimizations in order to reach a target frame rate
  120813. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120814. */
  120815. export class SceneOptimizer implements IDisposable {
  120816. private _isRunning;
  120817. private _options;
  120818. private _scene;
  120819. private _currentPriorityLevel;
  120820. private _targetFrameRate;
  120821. private _trackerDuration;
  120822. private _currentFrameRate;
  120823. private _sceneDisposeObserver;
  120824. private _improvementMode;
  120825. /**
  120826. * Defines an observable called when the optimizer reaches the target frame rate
  120827. */
  120828. onSuccessObservable: Observable<SceneOptimizer>;
  120829. /**
  120830. * Defines an observable called when the optimizer enables an optimization
  120831. */
  120832. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  120833. /**
  120834. * Defines an observable called when the optimizer is not able to reach the target frame rate
  120835. */
  120836. onFailureObservable: Observable<SceneOptimizer>;
  120837. /**
  120838. * Gets a boolean indicating if the optimizer is in improvement mode
  120839. */
  120840. readonly isInImprovementMode: boolean;
  120841. /**
  120842. * Gets the current priority level (0 at start)
  120843. */
  120844. readonly currentPriorityLevel: number;
  120845. /**
  120846. * Gets the current frame rate checked by the SceneOptimizer
  120847. */
  120848. readonly currentFrameRate: number;
  120849. /**
  120850. * Gets or sets the current target frame rate (60 by default)
  120851. */
  120852. /**
  120853. * Gets or sets the current target frame rate (60 by default)
  120854. */
  120855. targetFrameRate: number;
  120856. /**
  120857. * Gets or sets the current interval between two checks (every 2000ms by default)
  120858. */
  120859. /**
  120860. * Gets or sets the current interval between two checks (every 2000ms by default)
  120861. */
  120862. trackerDuration: number;
  120863. /**
  120864. * Gets the list of active optimizations
  120865. */
  120866. readonly optimizations: SceneOptimization[];
  120867. /**
  120868. * Creates a new SceneOptimizer
  120869. * @param scene defines the scene to work on
  120870. * @param options defines the options to use with the SceneOptimizer
  120871. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  120872. * @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)
  120873. */
  120874. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  120875. /**
  120876. * Stops the current optimizer
  120877. */
  120878. stop(): void;
  120879. /**
  120880. * Reset the optimizer to initial step (current priority level = 0)
  120881. */
  120882. reset(): void;
  120883. /**
  120884. * Start the optimizer. By default it will try to reach a specific framerate
  120885. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  120886. */
  120887. start(): void;
  120888. private _checkCurrentState;
  120889. /**
  120890. * Release all resources
  120891. */
  120892. dispose(): void;
  120893. /**
  120894. * Helper function to create a SceneOptimizer with one single line of code
  120895. * @param scene defines the scene to work on
  120896. * @param options defines the options to use with the SceneOptimizer
  120897. * @param onSuccess defines a callback to call on success
  120898. * @param onFailure defines a callback to call on failure
  120899. * @returns the new SceneOptimizer object
  120900. */
  120901. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  120902. }
  120903. }
  120904. declare module BABYLON {
  120905. /**
  120906. * Class used to serialize a scene into a string
  120907. */
  120908. export class SceneSerializer {
  120909. /**
  120910. * Clear cache used by a previous serialization
  120911. */
  120912. static ClearCache(): void;
  120913. /**
  120914. * Serialize a scene into a JSON compatible object
  120915. * @param scene defines the scene to serialize
  120916. * @returns a JSON compatible object
  120917. */
  120918. static Serialize(scene: Scene): any;
  120919. /**
  120920. * Serialize a mesh into a JSON compatible object
  120921. * @param toSerialize defines the mesh to serialize
  120922. * @param withParents defines if parents must be serialized as well
  120923. * @param withChildren defines if children must be serialized as well
  120924. * @returns a JSON compatible object
  120925. */
  120926. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  120927. }
  120928. }
  120929. declare module BABYLON {
  120930. /**
  120931. * Class used to host texture specific utilities
  120932. */
  120933. export class TextureTools {
  120934. /**
  120935. * Uses the GPU to create a copy texture rescaled at a given size
  120936. * @param texture Texture to copy from
  120937. * @param width defines the desired width
  120938. * @param height defines the desired height
  120939. * @param useBilinearMode defines if bilinear mode has to be used
  120940. * @return the generated texture
  120941. */
  120942. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  120943. }
  120944. }
  120945. declare module BABYLON {
  120946. /**
  120947. * This represents the different options avilable for the video capture.
  120948. */
  120949. export interface VideoRecorderOptions {
  120950. /** Defines the mime type of the video */
  120951. mimeType: string;
  120952. /** Defines the video the video should be recorded at */
  120953. fps: number;
  120954. /** Defines the chunk size for the recording data */
  120955. recordChunckSize: number;
  120956. /** The audio tracks to attach to the record */
  120957. audioTracks?: MediaStreamTrack[];
  120958. }
  120959. /**
  120960. * This can helps recording videos from BabylonJS.
  120961. * This is based on the available WebRTC functionalities of the browser.
  120962. *
  120963. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  120964. */
  120965. export class VideoRecorder {
  120966. private static readonly _defaultOptions;
  120967. /**
  120968. * Returns wehther or not the VideoRecorder is available in your browser.
  120969. * @param engine Defines the Babylon Engine to check the support for
  120970. * @returns true if supported otherwise false
  120971. */
  120972. static IsSupported(engine: Engine): boolean;
  120973. private readonly _options;
  120974. private _canvas;
  120975. private _mediaRecorder;
  120976. private _recordedChunks;
  120977. private _fileName;
  120978. private _resolve;
  120979. private _reject;
  120980. /**
  120981. * True wether a recording is already in progress.
  120982. */
  120983. readonly isRecording: boolean;
  120984. /**
  120985. * Create a new VideoCapture object which can help converting what you see in Babylon to
  120986. * a video file.
  120987. * @param engine Defines the BabylonJS Engine you wish to record
  120988. * @param options Defines options that can be used to customized the capture
  120989. */
  120990. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  120991. /**
  120992. * Stops the current recording before the default capture timeout passed in the startRecording
  120993. * functions.
  120994. */
  120995. stopRecording(): void;
  120996. /**
  120997. * Starts recording the canvas for a max duration specified in parameters.
  120998. * @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.
  120999. * @param maxDuration Defines the maximum recording time in seconds.
  121000. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  121001. * @return a promise callback at the end of the recording with the video data in Blob.
  121002. */
  121003. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  121004. /**
  121005. * Releases internal resources used during the recording.
  121006. */
  121007. dispose(): void;
  121008. private _handleDataAvailable;
  121009. private _handleError;
  121010. private _handleStop;
  121011. }
  121012. }
  121013. declare module BABYLON {
  121014. /**
  121015. * Class containing a set of static utilities functions for screenshots
  121016. */
  121017. export class ScreenshotTools {
  121018. /**
  121019. * Captures a screenshot of the current rendering
  121020. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  121021. * @param engine defines the rendering engine
  121022. * @param camera defines the source camera
  121023. * @param size This parameter can be set to a single number or to an object with the
  121024. * following (optional) properties: precision, width, height. If a single number is passed,
  121025. * it will be used for both width and height. If an object is passed, the screenshot size
  121026. * will be derived from the parameters. The precision property is a multiplier allowing
  121027. * rendering at a higher or lower resolution
  121028. * @param successCallback defines the callback receives a single parameter which contains the
  121029. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  121030. * src parameter of an <img> to display it
  121031. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  121032. * Check your browser for supported MIME types
  121033. */
  121034. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  121035. /**
  121036. * Generates an image screenshot from the specified camera.
  121037. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  121038. * @param engine The engine to use for rendering
  121039. * @param camera The camera to use for rendering
  121040. * @param size This parameter can be set to a single number or to an object with the
  121041. * following (optional) properties: precision, width, height. If a single number is passed,
  121042. * it will be used for both width and height. If an object is passed, the screenshot size
  121043. * will be derived from the parameters. The precision property is a multiplier allowing
  121044. * rendering at a higher or lower resolution
  121045. * @param successCallback The callback receives a single parameter which contains the
  121046. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  121047. * src parameter of an <img> to display it
  121048. * @param mimeType The MIME type of the screenshot image (default: image/png).
  121049. * Check your browser for supported MIME types
  121050. * @param samples Texture samples (default: 1)
  121051. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  121052. * @param fileName A name for for the downloaded file.
  121053. */
  121054. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  121055. }
  121056. }
  121057. declare module BABYLON {
  121058. /**
  121059. * A cursor which tracks a point on a path
  121060. */
  121061. export class PathCursor {
  121062. private path;
  121063. /**
  121064. * Stores path cursor callbacks for when an onchange event is triggered
  121065. */
  121066. private _onchange;
  121067. /**
  121068. * The value of the path cursor
  121069. */
  121070. value: number;
  121071. /**
  121072. * The animation array of the path cursor
  121073. */
  121074. animations: Animation[];
  121075. /**
  121076. * Initializes the path cursor
  121077. * @param path The path to track
  121078. */
  121079. constructor(path: Path2);
  121080. /**
  121081. * Gets the cursor point on the path
  121082. * @returns A point on the path cursor at the cursor location
  121083. */
  121084. getPoint(): Vector3;
  121085. /**
  121086. * Moves the cursor ahead by the step amount
  121087. * @param step The amount to move the cursor forward
  121088. * @returns This path cursor
  121089. */
  121090. moveAhead(step?: number): PathCursor;
  121091. /**
  121092. * Moves the cursor behind by the step amount
  121093. * @param step The amount to move the cursor back
  121094. * @returns This path cursor
  121095. */
  121096. moveBack(step?: number): PathCursor;
  121097. /**
  121098. * Moves the cursor by the step amount
  121099. * If the step amount is greater than one, an exception is thrown
  121100. * @param step The amount to move the cursor
  121101. * @returns This path cursor
  121102. */
  121103. move(step: number): PathCursor;
  121104. /**
  121105. * Ensures that the value is limited between zero and one
  121106. * @returns This path cursor
  121107. */
  121108. private ensureLimits;
  121109. /**
  121110. * Runs onchange callbacks on change (used by the animation engine)
  121111. * @returns This path cursor
  121112. */
  121113. private raiseOnChange;
  121114. /**
  121115. * Executes a function on change
  121116. * @param f A path cursor onchange callback
  121117. * @returns This path cursor
  121118. */
  121119. onchange(f: (cursor: PathCursor) => void): PathCursor;
  121120. }
  121121. }
  121122. declare module BABYLON {
  121123. /** @hidden */
  121124. export var blurPixelShader: {
  121125. name: string;
  121126. shader: string;
  121127. };
  121128. }
  121129. declare module BABYLON {
  121130. /** @hidden */
  121131. export var bones300Declaration: {
  121132. name: string;
  121133. shader: string;
  121134. };
  121135. }
  121136. declare module BABYLON {
  121137. /** @hidden */
  121138. export var instances300Declaration: {
  121139. name: string;
  121140. shader: string;
  121141. };
  121142. }
  121143. declare module BABYLON {
  121144. /** @hidden */
  121145. export var pointCloudVertexDeclaration: {
  121146. name: string;
  121147. shader: string;
  121148. };
  121149. }
  121150. // Mixins
  121151. interface Window {
  121152. mozIndexedDB: IDBFactory;
  121153. webkitIndexedDB: IDBFactory;
  121154. msIndexedDB: IDBFactory;
  121155. webkitURL: typeof URL;
  121156. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  121157. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  121158. WebGLRenderingContext: WebGLRenderingContext;
  121159. MSGesture: MSGesture;
  121160. CANNON: any;
  121161. AudioContext: AudioContext;
  121162. webkitAudioContext: AudioContext;
  121163. PointerEvent: any;
  121164. Math: Math;
  121165. Uint8Array: Uint8ArrayConstructor;
  121166. Float32Array: Float32ArrayConstructor;
  121167. mozURL: typeof URL;
  121168. msURL: typeof URL;
  121169. VRFrameData: any; // WebVR, from specs 1.1
  121170. DracoDecoderModule: any;
  121171. setImmediate(handler: (...args: any[]) => void): number;
  121172. }
  121173. interface HTMLCanvasElement {
  121174. requestPointerLock(): void;
  121175. msRequestPointerLock?(): void;
  121176. mozRequestPointerLock?(): void;
  121177. webkitRequestPointerLock?(): void;
  121178. /** Track wether a record is in progress */
  121179. isRecording: boolean;
  121180. /** Capture Stream method defined by some browsers */
  121181. captureStream(fps?: number): MediaStream;
  121182. }
  121183. interface CanvasRenderingContext2D {
  121184. msImageSmoothingEnabled: boolean;
  121185. }
  121186. interface MouseEvent {
  121187. mozMovementX: number;
  121188. mozMovementY: number;
  121189. webkitMovementX: number;
  121190. webkitMovementY: number;
  121191. msMovementX: number;
  121192. msMovementY: number;
  121193. }
  121194. interface Navigator {
  121195. mozGetVRDevices: (any: any) => any;
  121196. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121197. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121198. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121199. webkitGetGamepads(): Gamepad[];
  121200. msGetGamepads(): Gamepad[];
  121201. webkitGamepads(): Gamepad[];
  121202. }
  121203. interface HTMLVideoElement {
  121204. mozSrcObject: any;
  121205. }
  121206. interface Math {
  121207. fround(x: number): number;
  121208. imul(a: number, b: number): number;
  121209. }
  121210. interface WebGLRenderingContext {
  121211. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  121212. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  121213. vertexAttribDivisor(index: number, divisor: number): void;
  121214. createVertexArray(): any;
  121215. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  121216. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  121217. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  121218. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  121219. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  121220. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  121221. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  121222. // Queries
  121223. createQuery(): WebGLQuery;
  121224. deleteQuery(query: WebGLQuery): void;
  121225. beginQuery(target: number, query: WebGLQuery): void;
  121226. endQuery(target: number): void;
  121227. getQueryParameter(query: WebGLQuery, pname: number): any;
  121228. getQuery(target: number, pname: number): any;
  121229. MAX_SAMPLES: number;
  121230. RGBA8: number;
  121231. READ_FRAMEBUFFER: number;
  121232. DRAW_FRAMEBUFFER: number;
  121233. UNIFORM_BUFFER: number;
  121234. HALF_FLOAT_OES: number;
  121235. RGBA16F: number;
  121236. RGBA32F: number;
  121237. R32F: number;
  121238. RG32F: number;
  121239. RGB32F: number;
  121240. R16F: number;
  121241. RG16F: number;
  121242. RGB16F: number;
  121243. RED: number;
  121244. RG: number;
  121245. R8: number;
  121246. RG8: number;
  121247. UNSIGNED_INT_24_8: number;
  121248. DEPTH24_STENCIL8: number;
  121249. /* Multiple Render Targets */
  121250. drawBuffers(buffers: number[]): void;
  121251. readBuffer(src: number): void;
  121252. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  121253. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  121254. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  121255. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  121256. // Occlusion Query
  121257. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  121258. ANY_SAMPLES_PASSED: number;
  121259. QUERY_RESULT_AVAILABLE: number;
  121260. QUERY_RESULT: number;
  121261. }
  121262. interface WebGLProgram {
  121263. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  121264. }
  121265. interface EXT_disjoint_timer_query {
  121266. QUERY_COUNTER_BITS_EXT: number;
  121267. TIME_ELAPSED_EXT: number;
  121268. TIMESTAMP_EXT: number;
  121269. GPU_DISJOINT_EXT: number;
  121270. QUERY_RESULT_EXT: number;
  121271. QUERY_RESULT_AVAILABLE_EXT: number;
  121272. queryCounterEXT(query: WebGLQuery, target: number): void;
  121273. createQueryEXT(): WebGLQuery;
  121274. beginQueryEXT(target: number, query: WebGLQuery): void;
  121275. endQueryEXT(target: number): void;
  121276. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  121277. deleteQueryEXT(query: WebGLQuery): void;
  121278. }
  121279. interface WebGLUniformLocation {
  121280. _currentState: any;
  121281. }
  121282. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  121283. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  121284. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  121285. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  121286. interface WebGLRenderingContext {
  121287. readonly RASTERIZER_DISCARD: number;
  121288. readonly DEPTH_COMPONENT24: number;
  121289. readonly TEXTURE_3D: number;
  121290. readonly TEXTURE_2D_ARRAY: number;
  121291. readonly TEXTURE_COMPARE_FUNC: number;
  121292. readonly TEXTURE_COMPARE_MODE: number;
  121293. readonly COMPARE_REF_TO_TEXTURE: number;
  121294. readonly TEXTURE_WRAP_R: number;
  121295. readonly HALF_FLOAT: number;
  121296. readonly RGB8: number;
  121297. readonly RED_INTEGER: number;
  121298. readonly RG_INTEGER: number;
  121299. readonly RGB_INTEGER: number;
  121300. readonly RGBA_INTEGER: number;
  121301. readonly R8_SNORM: number;
  121302. readonly RG8_SNORM: number;
  121303. readonly RGB8_SNORM: number;
  121304. readonly RGBA8_SNORM: number;
  121305. readonly R8I: number;
  121306. readonly RG8I: number;
  121307. readonly RGB8I: number;
  121308. readonly RGBA8I: number;
  121309. readonly R8UI: number;
  121310. readonly RG8UI: number;
  121311. readonly RGB8UI: number;
  121312. readonly RGBA8UI: number;
  121313. readonly R16I: number;
  121314. readonly RG16I: number;
  121315. readonly RGB16I: number;
  121316. readonly RGBA16I: number;
  121317. readonly R16UI: number;
  121318. readonly RG16UI: number;
  121319. readonly RGB16UI: number;
  121320. readonly RGBA16UI: number;
  121321. readonly R32I: number;
  121322. readonly RG32I: number;
  121323. readonly RGB32I: number;
  121324. readonly RGBA32I: number;
  121325. readonly R32UI: number;
  121326. readonly RG32UI: number;
  121327. readonly RGB32UI: number;
  121328. readonly RGBA32UI: number;
  121329. readonly RGB10_A2UI: number;
  121330. readonly R11F_G11F_B10F: number;
  121331. readonly RGB9_E5: number;
  121332. readonly RGB10_A2: number;
  121333. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  121334. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  121335. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  121336. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121337. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  121338. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  121339. 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;
  121340. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  121341. readonly TRANSFORM_FEEDBACK: number;
  121342. readonly INTERLEAVED_ATTRIBS: number;
  121343. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  121344. createTransformFeedback(): WebGLTransformFeedback;
  121345. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  121346. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  121347. beginTransformFeedback(primitiveMode: number): void;
  121348. endTransformFeedback(): void;
  121349. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  121350. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121351. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121352. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121353. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  121354. }
  121355. interface ImageBitmap {
  121356. readonly width: number;
  121357. readonly height: number;
  121358. close(): void;
  121359. }
  121360. interface WebGLQuery extends WebGLObject {
  121361. }
  121362. declare var WebGLQuery: {
  121363. prototype: WebGLQuery;
  121364. new(): WebGLQuery;
  121365. };
  121366. interface WebGLSampler extends WebGLObject {
  121367. }
  121368. declare var WebGLSampler: {
  121369. prototype: WebGLSampler;
  121370. new(): WebGLSampler;
  121371. };
  121372. interface WebGLSync extends WebGLObject {
  121373. }
  121374. declare var WebGLSync: {
  121375. prototype: WebGLSync;
  121376. new(): WebGLSync;
  121377. };
  121378. interface WebGLTransformFeedback extends WebGLObject {
  121379. }
  121380. declare var WebGLTransformFeedback: {
  121381. prototype: WebGLTransformFeedback;
  121382. new(): WebGLTransformFeedback;
  121383. };
  121384. interface WebGLVertexArrayObject extends WebGLObject {
  121385. }
  121386. declare var WebGLVertexArrayObject: {
  121387. prototype: WebGLVertexArrayObject;
  121388. new(): WebGLVertexArrayObject;
  121389. };
  121390. // Type definitions for WebVR API
  121391. // Project: https://w3c.github.io/webvr/
  121392. // Definitions by: six a <https://github.com/lostfictions>
  121393. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  121394. interface VRDisplay extends EventTarget {
  121395. /**
  121396. * Dictionary of capabilities describing the VRDisplay.
  121397. */
  121398. readonly capabilities: VRDisplayCapabilities;
  121399. /**
  121400. * z-depth defining the far plane of the eye view frustum
  121401. * enables mapping of values in the render target depth
  121402. * attachment to scene coordinates. Initially set to 10000.0.
  121403. */
  121404. depthFar: number;
  121405. /**
  121406. * z-depth defining the near plane of the eye view frustum
  121407. * enables mapping of values in the render target depth
  121408. * attachment to scene coordinates. Initially set to 0.01.
  121409. */
  121410. depthNear: number;
  121411. /**
  121412. * An identifier for this distinct VRDisplay. Used as an
  121413. * association point in the Gamepad API.
  121414. */
  121415. readonly displayId: number;
  121416. /**
  121417. * A display name, a user-readable name identifying it.
  121418. */
  121419. readonly displayName: string;
  121420. readonly isConnected: boolean;
  121421. readonly isPresenting: boolean;
  121422. /**
  121423. * If this VRDisplay supports room-scale experiences, the optional
  121424. * stage attribute contains details on the room-scale parameters.
  121425. */
  121426. readonly stageParameters: VRStageParameters | null;
  121427. /**
  121428. * Passing the value returned by `requestAnimationFrame` to
  121429. * `cancelAnimationFrame` will unregister the callback.
  121430. * @param handle Define the hanle of the request to cancel
  121431. */
  121432. cancelAnimationFrame(handle: number): void;
  121433. /**
  121434. * Stops presenting to the VRDisplay.
  121435. * @returns a promise to know when it stopped
  121436. */
  121437. exitPresent(): Promise<void>;
  121438. /**
  121439. * Return the current VREyeParameters for the given eye.
  121440. * @param whichEye Define the eye we want the parameter for
  121441. * @returns the eye parameters
  121442. */
  121443. getEyeParameters(whichEye: string): VREyeParameters;
  121444. /**
  121445. * Populates the passed VRFrameData with the information required to render
  121446. * the current frame.
  121447. * @param frameData Define the data structure to populate
  121448. * @returns true if ok otherwise false
  121449. */
  121450. getFrameData(frameData: VRFrameData): boolean;
  121451. /**
  121452. * Get the layers currently being presented.
  121453. * @returns the list of VR layers
  121454. */
  121455. getLayers(): VRLayer[];
  121456. /**
  121457. * Return a VRPose containing the future predicted pose of the VRDisplay
  121458. * when the current frame will be presented. The value returned will not
  121459. * change until JavaScript has returned control to the browser.
  121460. *
  121461. * The VRPose will contain the position, orientation, velocity,
  121462. * and acceleration of each of these properties.
  121463. * @returns the pose object
  121464. */
  121465. getPose(): VRPose;
  121466. /**
  121467. * Return the current instantaneous pose of the VRDisplay, with no
  121468. * prediction applied.
  121469. * @returns the current instantaneous pose
  121470. */
  121471. getImmediatePose(): VRPose;
  121472. /**
  121473. * The callback passed to `requestAnimationFrame` will be called
  121474. * any time a new frame should be rendered. When the VRDisplay is
  121475. * presenting the callback will be called at the native refresh
  121476. * rate of the HMD. When not presenting this function acts
  121477. * identically to how window.requestAnimationFrame acts. Content should
  121478. * make no assumptions of frame rate or vsync behavior as the HMD runs
  121479. * asynchronously from other displays and at differing refresh rates.
  121480. * @param callback Define the eaction to run next frame
  121481. * @returns the request handle it
  121482. */
  121483. requestAnimationFrame(callback: FrameRequestCallback): number;
  121484. /**
  121485. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  121486. * Repeat calls while already presenting will update the VRLayers being displayed.
  121487. * @param layers Define the list of layer to present
  121488. * @returns a promise to know when the request has been fulfilled
  121489. */
  121490. requestPresent(layers: VRLayer[]): Promise<void>;
  121491. /**
  121492. * Reset the pose for this display, treating its current position and
  121493. * orientation as the "origin/zero" values. VRPose.position,
  121494. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  121495. * updated when calling resetPose(). This should be called in only
  121496. * sitting-space experiences.
  121497. */
  121498. resetPose(): void;
  121499. /**
  121500. * The VRLayer provided to the VRDisplay will be captured and presented
  121501. * in the HMD. Calling this function has the same effect on the source
  121502. * canvas as any other operation that uses its source image, and canvases
  121503. * created without preserveDrawingBuffer set to true will be cleared.
  121504. * @param pose Define the pose to submit
  121505. */
  121506. submitFrame(pose?: VRPose): void;
  121507. }
  121508. declare var VRDisplay: {
  121509. prototype: VRDisplay;
  121510. new(): VRDisplay;
  121511. };
  121512. interface VRLayer {
  121513. leftBounds?: number[] | Float32Array | null;
  121514. rightBounds?: number[] | Float32Array | null;
  121515. source?: HTMLCanvasElement | null;
  121516. }
  121517. interface VRDisplayCapabilities {
  121518. readonly canPresent: boolean;
  121519. readonly hasExternalDisplay: boolean;
  121520. readonly hasOrientation: boolean;
  121521. readonly hasPosition: boolean;
  121522. readonly maxLayers: number;
  121523. }
  121524. interface VREyeParameters {
  121525. /** @deprecated */
  121526. readonly fieldOfView: VRFieldOfView;
  121527. readonly offset: Float32Array;
  121528. readonly renderHeight: number;
  121529. readonly renderWidth: number;
  121530. }
  121531. interface VRFieldOfView {
  121532. readonly downDegrees: number;
  121533. readonly leftDegrees: number;
  121534. readonly rightDegrees: number;
  121535. readonly upDegrees: number;
  121536. }
  121537. interface VRFrameData {
  121538. readonly leftProjectionMatrix: Float32Array;
  121539. readonly leftViewMatrix: Float32Array;
  121540. readonly pose: VRPose;
  121541. readonly rightProjectionMatrix: Float32Array;
  121542. readonly rightViewMatrix: Float32Array;
  121543. readonly timestamp: number;
  121544. }
  121545. interface VRPose {
  121546. readonly angularAcceleration: Float32Array | null;
  121547. readonly angularVelocity: Float32Array | null;
  121548. readonly linearAcceleration: Float32Array | null;
  121549. readonly linearVelocity: Float32Array | null;
  121550. readonly orientation: Float32Array | null;
  121551. readonly position: Float32Array | null;
  121552. readonly timestamp: number;
  121553. }
  121554. interface VRStageParameters {
  121555. sittingToStandingTransform?: Float32Array;
  121556. sizeX?: number;
  121557. sizeY?: number;
  121558. }
  121559. interface Navigator {
  121560. getVRDisplays(): Promise<VRDisplay[]>;
  121561. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  121562. }
  121563. interface Window {
  121564. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  121565. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  121566. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  121567. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  121568. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  121569. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  121570. }
  121571. interface Gamepad {
  121572. readonly displayId: number;
  121573. }
  121574. interface XRDevice {
  121575. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  121576. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  121577. }
  121578. interface XRSession {
  121579. getInputSources(): Array<any>;
  121580. baseLayer: XRWebGLLayer;
  121581. requestFrameOfReference(type: string): Promise<void>;
  121582. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  121583. end(): Promise<void>;
  121584. requestAnimationFrame: Function;
  121585. addEventListener: Function;
  121586. }
  121587. interface XRSessionCreationOptions {
  121588. outputContext?: WebGLRenderingContext | null;
  121589. immersive?: boolean;
  121590. environmentIntegration?: boolean;
  121591. }
  121592. interface XRLayer {
  121593. getViewport: Function;
  121594. framebufferWidth: number;
  121595. framebufferHeight: number;
  121596. }
  121597. interface XRView {
  121598. projectionMatrix: Float32Array;
  121599. }
  121600. interface XRFrame {
  121601. getDevicePose: Function;
  121602. getInputPose: Function;
  121603. views: Array<XRView>;
  121604. baseLayer: XRLayer;
  121605. }
  121606. interface XRFrameOfReference {
  121607. }
  121608. interface XRWebGLLayer extends XRLayer {
  121609. framebuffer: WebGLFramebuffer;
  121610. }
  121611. declare var XRWebGLLayer: {
  121612. prototype: XRWebGLLayer;
  121613. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  121614. };